MPMediaItem | iCloud or DRM Protected
Asked Answered
D

2

6

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

Darin answered 19/7, 2012 at 13:38 Comment(0)
R
7

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

Rattlepate answered 1/10, 2012 at 22:32 Comment(0)
S
0

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
}
Somaliland answered 19/7, 2012 at 19:33 Comment(3)
It wouldn't work since MPMediaItemPropertyAssetURL is nil for DRM protected media as well, so I wouldn't know if the media item is DRM protected or represents something that is in cloudDarin
Are you certain about that? In my app, DRM protected content does have MPMediaItemPropertyAssetURL set. The way to check if it's DRM protected is to check the AVAsset's hasProtectedContent methodSomaliland
To get an AVAsset you need the URL for it from MPMediaItem and the URL is not set if it is either DRM protected, downloaded as an cloud resource or somehow not ready. So you cannot even get to the hasProtectedContent property.Sletten

© 2022 - 2024 — McMap. All rights reserved.