Protocol

AVAudioPlayerDelegate

A protocol that allows a delegate to respond to audio interruptions and audio decoding errors, and to the completion of a sound’s playback.

Declaration

@protocol AVAudioPlayerDelegate

Overview

The delegate of an AVAudioPlayer object must adopt the AVAudioPlayerDelegate protocol. All of the methods in this protocol are optional.

Topics

Responding to Sound Playback Completion

audioPlayerDidFinishPlaying:successfully:

Called when a sound has finished playing.

Responding to an Audio Decoding Error

audioPlayerDecodeErrorDidOccur:error:

Called when an audio player encounters a decoding error during playback.

Handling Audio Interruptions

audioPlayerBeginInterruption:

Called when an audio player is interrupted, such as by an incoming phone call.

Deprecated
audioPlayerEndInterruption:withOptions:

Called after your audio session interruption ends, with options indicating the state of the audio session.

Deprecated
audioPlayerEndInterruption:

Called after your audio session interruption ends.

Deprecated
audioPlayerEndInterruption:withFlags:

Called after your audio session interruption ends, with flags indicating the state of the audio session.

Deprecated

Relationships

Inherits From

See Also

Configuring and Controlling Playback

play

Plays a sound asynchronously.

playAtTime:

Plays a sound asynchronously, starting at a specified point in the audio output device’s timeline.

pause

Pauses playback; sound remains ready to resume playback from where it left off.

stop

Stops playback and undoes the setup needed for playback.

prepareToPlay

Prepares the audio player for playback by preloading its buffers.

setVolume:fadeDuration:

Fades to a new volume over a specific duration.

playing

A Boolean value that indicates whether the audio player is playing (YES) or not (NO).

volume

The playback volume for the audio player, ranging from 0.0 through 1.0 on a linear scale.

pan

The audio player’s stereo pan position.

rate

The audio player’s playback rate.

enableRate

A Boolean value that specifies whether playback rate adjustment is enabled for an audio player.

numberOfLoops

The number of times a sound will return to the beginning, upon reaching the end, to repeat playback.

delegate

The delegate object for the audio player.

settings

The audio player’s settings dictionary, containing information about the sound associated with the player.