0

I want to get Playlist Name, but it gives value of Mpconcreteitem.

let myQuery2 : MPMediaQuery = MPMediaQuery.playlists()
let playlist = myQuery2.collections
print(playlist!)


for album in playlist!{
    print("---------------")
    print("playlist \(String(describing: album.items)))")
    if album.items.count == 0 {

    } else {
          print(album.items[0].value(forProperty: "MPMediaPlaylistPropertyName") )
    }

}
Eric Aya
  • 69,473
  • 35
  • 181
  • 253

1 Answers1

0

I do not believe that an MPMediaItem will have a reference to the playlists it is in.

I also think playlists only store songs (could be mistaken)

In any case to get a playlist name you want:

 let mediaQuery:MPMediaQuery = MPMediaQuery.playlists()

        for playlist in mediaQuery.collections! {
            print(playlist.value(forProperty: MPMediaPlaylistPropertyName) as Any)

        }
solenoid
  • 954
  • 1
  • 9
  • 20