4

Through iTunes, you can create playlist folders that are nested arbitrarily deep. When you copy those playlist folders to your iOS device, iTunes is able to detect that they're folders, and allows you to drill down to the point where you ultimately get songs. Any idea how they do that?? I've been trying to figure this out for days.

When I query for a specific persistentID of a known folder, the only things I can see about it that are different from a playlist that contains songs are:

  • playlist.mediaTypes = 4359 (this is Music|Podcast|Audiobook|Movie|VideoiTunes) whereas a normal playlist will not mix audio types and video types
  • value for property MPMediaPlaylistPropertyPlaylistAttributes contains 2 (MPMediaPlaylistAttributeSmart), whereas a normal playlist contains 0
  • the item count will be equal to the total number of items on the device

But, that's it! I don't see any way to get at the sub-folders. Or, when interrogating a playlist or subfolder that's contained within a folder, I don't see any way to tie it to the parent.

Apple does it in iTunes, so there must be a way. Are they using some private API?

BigSprocket
  • 166
  • 7

1 Answers1

10

There are the following undocumented properties that can get you what you are looking for using MPMediaPlaylist's valueForProperty method: @"isFolder", and @"parentPersistentID".

Note, these are not documented and do not appear in any header files, so use of them might be considered use of a 'private API' according to Apple's application submission rules.

I've opened a bug report to Apple asking that those be made available in header files, and also asking to clarify whether they are considered to be part of a private API.

Pop
  • 12,135
  • 5
  • 55
  • 68
John Muir
  • 101
  • 1
  • 4
  • 1
    On iOS 8 GM, I've noticed that playlist folders simply no longer turn up from a query. I've tried creating a predicate requesting the exact playlist persistent ID, still no luck. Any ideas on how to retrieve playlist folders on iOS 8? – beebcon Sep 10 '14 at 01:41
  • Almost 9 years past, seems the `parentPersistentID` is still not publiced till now... sign. Btw, any reply for your bug report? – Kjuly Mar 15 '21 at 13:47