Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.