MPNowPlayingInfoCenter nowPlayingInfo ignored for AVPlayer audio via AirPlay

后端 未结 2 510
被撕碎了的回忆
被撕碎了的回忆 2021-02-13 20:32

I have implemented audio playback using AVPlayer, playing a remote mp3 url.

I want to display the information about the currently playing audio using the MPNowPlay

相关标签:
2条回答
  • 2021-02-13 20:59

    Ok - I dug through the apple dev forums and found a hint.

    If you are using AVPlayer for audio only, and want it to work in the background while doing airplay, you need to disable the allowsAirPlayVideo setting.

    Apparently AVPlayer on iOS 5+ assumes that it is playing back video via AirPlay, and so does not allow backgrounding, unless you explicitly disable video AirPlay.

    Once you disable this (i.e. self.player.allowsAirPlayVideo = NO;) then your audio will still play via AirPlay, but now it will now show the audio/ipod like interface correctly.

    0 讨论(0)
  • 2021-02-13 21:22

    If you're on iOS7 you've got to disable external playback :

    self.player.allowsExternalPlayback = NO;

    0 讨论(0)
提交回复
热议问题