MPMediaPickerController returns a MPMediaItem
If a local url is returned it is possible to play the sound.
If the music has not been downloaded locally, the assetURL is null.
How to download the MPMediaItem music locally ?
MPMediaPickerController returns a MPMediaItem
If a local url is returned it is possible to play the sound.
If the music has not been downloaded locally, the assetURL is null.
How to download the MPMediaItem music locally ?
Apple does not provide API to trigger MPMediaItem download. However you can trigger downloading by playing it.
// init a system music player
MPMusicPlayerController *MPPlayer = [MPMusicPlayerController systemMusicPlayer];
// set play queue with the MPMediaItem you got
[MPPlayer setQueueWithItemCollection:[MPMediaItemCollection collectionWithItems:@[theMPMediaItemYouGot]]];
// prepare to play it
[MPPlayer prepareToPlayWithCompletionHandler:^(NSError *error){
if ( error ){
...
}
// success playing
}];
© 2022 - 2024 — McMap. All rights reserved.