Skip to content

Instantly share code, notes, and snippets.

@bendodson
Created October 4, 2016 09:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bendodson/d842769c2d6f29280e55231e3c0cc5f8 to your computer and use it in GitHub Desktop.
Save bendodson/d842769c2d6f29280e55231e3c0cc5f8 to your computer and use it in GitHub Desktop.
Example of playlist media query
func runMediaLibraryQuery() {
let query = MPMediaQuery.playlists()
if let playlists = query.collections {
for playlist in playlists {
if let playlistName = playlist.value(forKey: MPMediaPlaylistPropertyName) {
NSLog("Playlist: \(playlistName)")
if let item = playlist.items.first, let title = item.title {
NSLog("First track: \(title)")
}
}
NSLog("\n\n")
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment