Pergunta

Is there any way I can check if a mediaItem fetched from iPhone's music library represents a iCloud Item?

I know MPMediaItemPropertyAssetURL property of a media Item is nil for both DRM Protected media as well as for iCloud item, but I have no idea how to determine if the item is DRM protected or it is available on cloud.

Thanks in advance

Foi útil?

Solução

Starting in iOS 6, you can check if the item is in iCloud with the following property MPMediaItemPropertyIsCloudItem

https://developer.apple.com/documentation/mediaplayer/mpmediaitempropertyisclouditem?language=objc

Since iOS 9.2, you can check MPMediaItemPropertyHasProtectedAsset for DRM. https://developer.apple.com/documentation/mediaplayer/mpmediaitempropertyhasprotectedasset?language=objc

Outras dicas

I can't say with absolute certainty that this is the best way to do it, but in my app I just test the MPMediaItem's MPMediaItemPropertyAssetURL property to see if it's nil:

if ([(MPMediaItem*)item valueForProperty:MPMediaItemPropertyAssetURL] == nil) {
  // it's in the cloud
}
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top