How can you play music from the iPod app while still receiving remote control events in your app?

后端 未结 4 1460
一生所求
一生所求 2020-12-05 12:09

Ok, I\'m trying to let a user choose songs from their iPod library to listen to, but I still want to receive remote control notifications (headphones, lock screen osd, etc.)

4条回答
  •  长情又很酷
    2020-12-05 13:00

    One think I noticed about MPMediaItemPropertyAssetURL is that, although the object returned is in NSURL but the absoluteString is something like this:

    ipod-library://item/item.mp3?id=580807975475997900

    Which is not what AVAudioPlayer want. What AVAudioPlayer want is NSURL object that is created from a file with a valid file path.

    And I have no idea how to get file path from MPMediaItem. So I guess maybe AVPlayer is the way to go if you want to play iPod track without using MPMusicPlayer.

提交回复
热议问题