I have an app that uses the iPod Library API to access the song database in iOS. With the release of iTunes Match, any song which is not on the device will fail to load. Is there a way I an request that the song be downloaded? Perhaps using the new iCloud API?
To be clear I am not asking how to download songs with iTunes Match using the iPhone. The iOS SDK allows access to the iPod Library via the MPMediaQuery/MPMediaItems. On a iOS device with iTunes Match enabled songs which are in your iTunes Match library but not local on the device are returned via a MPMediaQuery however the MPMediaItems have their 'exportable' flag set to false. When I access these songs in the Music app they are automatically downloaded. I would like to trigger the same automatic download via the MPMediaItem.
I have seen items in iTunes Match refereed to as part of iCloud and there is a new iCloud section of the iOS 5 SDK. However as I understand it I can only get data my app as uploaded. I was hoping there was a way via the MPMediaItem or using the URL via iCloud to trigger an iTunes Match download.
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).