---
title: prepareToPlay()
framework: avfaudio
role: symbol
role_heading: Instance Method
path: avfaudio/avaudioplayer/preparetoplay()
---

# prepareToPlay()

Prepares the player for audio playback.

## Declaration

```swift
func prepareToPlay() -> Bool
```

## Return Value

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

## Discussion

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

- [play()](avfaudio/avaudioplayer/play().md)
- [play(atTime:)](avfaudio/avaudioplayer/play(attime:).md)
- [pause()](avfaudio/avaudioplayer/pause().md)
- [stop()](avfaudio/avaudioplayer/stop().md)
- [isPlaying](avfaudio/avaudioplayer/isplaying.md)
