MPMediaItem and iTunes Match MPMediaItem and iTunes Match objective-c objective-c

MPMediaItem and iTunes Match


I have found something, but it isn't great. If you select the song to be played through the iPod player then that will trigger a download. You can access the iPod player with an MPMusicPlayerController.

MPMusicPlayerController *mDRMAudioPlayer;mDRMAudioPlayer = [MPMusicPlayerController iPodMusicPlayer];MPMediaQuery *assetQuery = [[MPMediaQuery alloc] init];NSNumber *persistentID = [mediaItem valueForProperty: MPMediaItemPropertyPersistentID];MPMediaPropertyPredicate *predicate = [MPMediaPropertyPredicate predicateWithValue: persistentID                                                                        forProperty: MPMediaItemPropertyPersistentID];[assetQuery addFilterPredicate: predicate];[mDRMAudioPlayer setQueueWithQuery: assetQuery];[mDRMAudioPlayer play];

No feedback on if this really started a download or not, or progress on the download but the item will start downloading and if your connection is good it will play the first time (otherwise you can spam play and it will get around to starting).


I just heard back from Apple regarding this issue (I used one of my Technical Support Incidents).

According to Apple, the iOS SDK does not currently provide any APIs for initiating a download from iCloud. I was instructed to file an enhancement request for this feature via Apple's bug reporter tool. I would encourage others to do the same.

Apple really should provide programmatic support for downloading audio assets from iCloud considering that iCloud is one of the defining features of iOS 5.


MPMediaItem | iCloud or DRM Protected

The link above shows how you can use a property introduced in iOS 6 to see if an MPMediaItem is in the cloud.

MPMediaItemPropertyIsCloudItem

BOOL isCloud = FALSE;if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"6.0")) {    NSNumber *isCloudNumber = [mediaItem valueForProperty:MPMediaItemPropertyIsCloudItem];    isCloud = [isCloudNumber boolValue];}if (isCloud) {    DebugLog(@"Cloud Asset URL: %@", assetURL);}

That is using a macro to ensure only iOS 6 uses that code which was added with iOS 6. Below is that macro.

#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v)  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)

Still you cannot initiate a download as far as I can tell.