I have an AVAudioPlayer playing some audio (duh!)
The audio is initiated when the user presses a button. When they release it I want the audio to fade out.
I
In Objective-C try this:
NSURL *trackURL = [[NSURL alloc]initFileURLWithPath:@"path to audio track"];
// fade duration in seconds
NSTimeInterval fadeDuration = 0.3;
// duration of the audio track in seconds
NSTimeInterval audioTrackDuration = 5.0;
AVAudioPlayer *audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:trackURL error:nil];
[audioPlayer play];
// first we set the volume to 1 - highest
[audioPlayer setVolume:1.0];
// then to 0 - lowest
[musicAudioPlayer setVolume:0 fadeDuration:audioTrackDuration - fadeDuration];