Instance Method


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


- (BOOL)playAtTime:(NSTimeInterval)time;



The absolute audio output device time to begin playback. The value that you provide to the time parameter must be greater than the device’s current time. You can delay the start of playback by using code like this:

NSTimeInterval playbackDelay = 3.0;              // must be ≥ 0
[myAudioPlayer playAtTime: myAudioPlayer.deviceCurrentTime + playbackDelay];

Return Value

YES on success, or NO on failure.


Use this method to precisely synchronize the playback of two or more AVAudioPlayer objects. This code snippet shows the recommended way to do this:

// Before calling this method, instantiate two AVAudioPlayer objects and
// assign each of them a sound.
- (void) startSynchronizedPlayback {
    NSTimeInterval shortStartDelay = 0.01;            // seconds
    NSTimeInterval now = player.deviceCurrentTime;
    [player       playAtTime: now + shortStartDelay];
    [secondPlayer playAtTime: now + shortStartDelay];
    // Here, update state and user interface for each player, as appropriate

To learn about the virtual audio output device’s timeline, read the description for the deviceCurrentTime property.

Calling this method implicitly calls the prepareToPlay method if the audio player is not already prepared to play.

See Also

Configuring and Controlling Playback

- play

Plays a sound asynchronously.

- 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.


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


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


The audio player’s stereo pan position.


The audio player’s playback rate.


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


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


The delegate object for the audio player.


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


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