Created
October 4, 2016 09:16
-
-
Save bendodson/d842769c2d6f29280e55231e3c0cc5f8 to your computer and use it in GitHub Desktop.
Example of playlist media query
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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