質問

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

役に立ちましたか?

解決

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

他のヒント

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
}
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top