I want to play music from iPod library using AudioFileOpenURL
or ExtAudioFileOpenURL
.
CFURLRef fileURL = [mediaItem valueForProperty:MPMediaItemPropertyAssetURL];
AudioFileOpenURL(fileURL,a,b,&id);
//or ExtAudioFileOpenURL
But it doesn't work! How can I deal with it?Thank you!
This isn't going to work because MPMediaItem asset URLs are only valid within AV Foundation. You can use that asset URL to open an AVURLAsset, get an AVAssetReader, etc., but you can't open it using any CoreAudio interfaces.
Check out the AV Foundation programming guide for more info - in particular, you'll want to check out AVPlayer and friends:
来源:https://stackoverflow.com/questions/5487568/audiofileopenurl-ipod-library