MPMediaItem and iTunes Match

前端 未结 4 1490
故里飘歌
故里飘歌 2020-12-23 11:47

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. I

4条回答
  •  -上瘾入骨i
    2020-12-23 12:28

    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).

提交回复
热议问题