<!--
{
  "availability" : [
    "iOS: 3.0.0 -",
    "iPadOS: 3.0.0 -",
    "macCatalyst: 13.1.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "MediaPlayer",
  "identifier" : "/documentation/MediaPlayer/MPMusicPlayerController/setQueue(with:)-5rii3",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Media Player"
    ],
    "preciseIdentifier" : "c:objc(cs)MPMusicPlayerController(im)setQueueWithQuery:"
  },
  "title" : "setQueue(with:)"
}
-->

# setQueue(with:)

Sets a music player’s playback queue based on a media query.

```
func setQueue(with query: MPMediaQuery)
```

## Parameters

`query`

A media query that specifies the collection of media items that you want as the playback queue. See [`MPMediaQuery`](/documentation/MediaPlayer/MPMediaQuery) for a description of query types and how to create them.

## Discussion

To begin playback after establishing a playback queue, call [`prepareToPlay()`](/documentation/MediaPlayer/MPMediaPlayback/prepareToPlay()).

---

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)