| Conforms to | |
| Framework | /System/Library/Frameworks/AVFoundation.framework |
| Availability | Available in iPhone OS 2.2 and later. |
| Declared in | AVAudioPlayer.h |
| Related sample code |
The delegate of an AVAudioPlayer object must adopt the AVAudioPlayerDelegate protocol. All of the methods in this protocol are optional. They allow a delegate to respond to audio interruptions and audio decoding errors, and to the completion of a sound’s playback.
Called when an audio player is interrupted, such as by an incoming phone call.
- (void)audioPlayerBeginInterruption:(AVAudioPlayer *)player
The audio player that has been interrupted.
Upon interruption, your application’s audio session is deactivated and the audio player pauses. You cannot use the audio player again until you receive a notification that the interruption has ended.
AVAudioPlayer.hCalled when an audio player encounters a decoding error during playback.
- (void)audioPlayerDecodeErrorDidOccur:(AVAudioPlayer *)player error:(NSError *)error
The audio player that encountered the decoding error.
The decoding error.
AVAudioPlayer.hCalled when a sound has finished playing.
- (void)audioPlayerDidFinishPlaying:(AVAudioPlayer *)player successfully:(BOOL)flag
The audio player that finished playing.
YES on successful completion of playback; NO if playback stopped because the system could not decode the audio data.
This method is not called upon an audio interruption. Rather, an audio player is paused upon interruption—the sound has not finished playing.
AVAudioPlayer.hCalled when an interruption ends, such as by a user ignoring an incoming phone call.
- (void)audioPlayerEndInterruption:(AVAudioPlayer *)player
The audio player whose interruption has ended.
When an interruption ends, the audio session for your application is automatically reactivated, allowing you to interact with the audio player. To resume playback, call the play method.
AVAudioPlayer.hLast updated: 2009-11-17