Contents

prepareToPlay()

Prepares the player for audio playback.

Declaration

func prepareToPlay() -> Bool

Return Value

true if the system successfully prepares the player; otherwise, false.

Discussion

Calling this method preloads audio buffers and acquires the audio hardware necessary for playback. This method activates the audio session, so pass false to setActive:error: if immediate playback isn’t necessary. For example, when using the category option duckOthers, this method lowers the audio outside of the app.

The system calls this method when using the method play(), but calling it in advance minimizes the delay between calling play() and the start of sound output.

Calling stop(), or allowing a sound to finish playing, undoes this setup.

See Also

Controlling playback