---
title: "prepareToPlay(completionHandler:)"
framework: mediaplayer
role: symbol
role_heading: Instance Method
path: "mediaplayer/mpmusicplayercontroller/preparetoplay(completionhandler:)"
---

# prepareToPlay(completionHandler:)

Prepares a music player for playback.

## Declaration

```swift
func prepareToPlay(completionHandler: @escaping @Sendable ((any Error)?) -> Void)
```

```swift
func prepareToPlay() async throws
```

## Parameters

- `completionHandler`: A block that the system call after it buffers the first item in the queue and it’s ready to play.

## Discussion

Discussion Call this function to ensure that the system buffers the first item in the queue and it’s ready to play. The system executes the code in the completion handler after it buffers the first item in the queue.
