<!--
{
  "availability" : [
    "iOS: 3.0.0 -",
    "iPadOS: 3.0.0 -",
    "macCatalyst: 13.1.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "MediaPlayer",
  "identifier" : "/documentation/MediaPlayer/MPMediaQuery/playlists()",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "Media Player"
    ],
    "preciseIdentifier" : "c:objc(cs)MPMediaQuery(cm)playlistsQuery"
  },
  "title" : "playlists()"
}
-->

# playlists()

Creates a media query that matches the entire library and that groups and sorts collections by playlist name.

```
class func playlists() -> MPMediaQuery
```

## Return Value

A media query that matches all media items and that has a grouping type of [`MPMediaGrouping.playlist`](/documentation/MediaPlayer/MPMediaGrouping/playlist).

---

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)