My app plays streaming audio via AVPlayer
, and uses MPNowPlayingInfoCenter
to display info about the stream on the device lock screen.
This works fine when audio is actually playing, but if the stream stalls due to network slowdowns (i.e. I receive AVPlayerItemPlaybackStalledNotification
) the information disappears from the lock screen. But then if the stream resumes playing, it reappears.
This is confusing because when the now-playing info disappears from the lock screen it gives the appearance that the app has stopped playback. But then it resumes playback, when the lock screen UI seems to indicate that this won't happen.
Is there something I can do to make sure the now playing info remains visible whenever the stream should be playing but currently is not due to network speed issues? It seems like the only way to keep a consistent lock screen UI is to actually kill the network connection when it stalls, which is kind of stupid but at least not confusing.
In case more detail would help:
- When the app gets that notification, the only thing it does is update the UI.
- The app never clears
MPNowPlayingInfoCenter
when there's a current program, so as long as the stream is supposed to be playing, there's non-empty data that should be getting displayed.
addPeriodicTimeObserverForInterval:
– PhotometryAVPlayerItemPlaybackStalledNotification
? What happens when you not listening? And what is about caching your data-streams? – ErnieMPNowPlayingInfoCenter
declaresnowPlayingInfo
to be acopy
ivar, that shouldn't matter. Regardless it works normally except when an audio stall occurs. – Squander