Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detecting iTunes playlist folders on a device

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?

like image 437
BigSprocket Avatar asked Dec 26 '22 22:12

BigSprocket


1 Answers

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.

like image 156
John Muir Avatar answered Jan 15 '23 05:01

John Muir