Get list of albums from ipod library in swift

1.4k views Asked by At

I want to make a simple media player in Swift. I want to make a table with all Albums on the iphone and after selecting the album i want to play the songs of it. But i can not get the album titles (and artwork).

I tried:

    var query = MPMediaQuery.albumsQuery()
    let mediaCollection = MPMediaItemCollection(items: query.items)
    println(mediaCollection.items)


    let player = MPMusicPlayerController.systemMusicPlayer()
    player.setQueueWithItemCollection(mediaCollection)

    player.play()
1

There are 1 answers

0
kelin On BEST ANSWER

MPMediaItem has valueForProperty() function. The properties which you need are MPMediaItemPropertyAlbumTitle and MPMediaItemPropertyArtwork.