Detecting iTunes playlist folders on a device

老子叫甜甜 提交于 2019-12-06 07:21:35

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/11303745/detecting-itunes-playlist-folders-on-a-device

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!