0

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 Answers1

0

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

kelin
  • 11,323
  • 6
  • 67
  • 104