<!--
{
  "availability" : [
    "iOS: 10.1.0 -",
    "iPadOS: 10.1.0 -",
    "macCatalyst: 13.1.0 -",
    "tvOS: 14.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "MediaPlayer",
  "identifier" : "/documentation/MediaPlayer/MPMusicPlayerController/prepareToPlay(completionHandler:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Media Player"
    ],
    "preciseIdentifier" : "c:objc(cs)MPMusicPlayerController(im)prepareToPlayWithCompletionHandler:"
  },
  "title" : "prepareToPlay(completionHandler:)"
}
-->

# prepareToPlay(completionHandler:)

Prepares a music player for playback.

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

## Parameters

`completionHandler`

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

- error: If an error occurred, this parameter holds the error object that explains the error. Otherwise, the value of this parameter is <doc://com.apple.documentation/documentation/ObjectiveC/nil-227m0>.

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

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)