MPNowPlayingInfoCenter nowPlayingInfo ignored for AVPlayer audio via AirPlay

后端 未结 2 499
被撕碎了的回忆
被撕碎了的回忆 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.

提交回复
热议问题