I want to show all folders and playlists in my app just like iTunes does. I do get playlists from MPMediaQuery
, but I cannot bifurcate if its playlist or a folder.
Below is my code:
let playlistQuery = MPMediaQuery.playlistsQuery()
if let arrPlaylists = playlistQuery.collections{
for playlist in arrPlaylists {
if let mediaPlaylist = playlist as? MPMediaPlaylist{
//got the playlist and all folders as playlists
}
}
}
I found here about some private api to bifurcate, but as of iOS 9.3, those properties are not available either.
*** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<MPConcreteMediaPlaylist 0x15594c40> valueForUndefinedKey:]: this class is not key value coding-compliant for the key isFolder.'
I do get folders information as if they are playlist, all hierarchical folders are displayed in root. Like I have directory structure like:
D1
--D11
----D111
------SomePlaylist
Then it shows like I have playlists
like below:
D1 (Containing items in SomePlaylist)
D11 (Containing items in SomePlaylist)
D111 (Containing items in SomePlaylist)
Is there any way I can bifurcate folders from playlist and show them in its original hierarchy?
Note: iTunes app shows this very well as it should.