AVPlayer incorrectly stopping playback with the reason AVPlayerRateDidChangeReasonAppBackgrounded

Since iOS 15 we've had quite a few reports from users having issues with live stream playback.

After some digging, it seems the following is happening.

  • A user plays a live stream
  • They put the app in the background
  • They return at some point later and play the stream again, at this point the stream plays correctly.
  • User rotates their phone to landscape, this triggers logic to remove the view that holds an AVPlayerLayer from its current view hierarchy, into a new one to display in fullscreen.
  • At this point, the AVPlayer playback rate is set to 0 and stops streaming, a rateDidChange notification is fired with the reason AVPlayerRateDidChangeReasonAppBackgrounded

Has anyone else experienced this issue or have any guidance on why this might be happening? It seems like an AVFoundation bug as the rate change reason is fundamentally incorrect as the app is not in fact backgrounded.

I agree that it sounds like unexpected behavior. Please file a report using the feedback assistant.

Something similar is still happening in iOS16.3

  • A user is playing a live stream.
  • The user puts the app to background resulting in Picture-In-Picture being activated.
  • The application is brought to foreground resulting in player UI to be restored and PiP to be stopped.

Later:

  • A VC is presented over player VC. (modalPresentationStyle = .currentContext)

At this time playback is automatically paused with the rateDidChange reason as AVPlayerRateDidChangeReasonAppBackgrounded.

AVPlayer incorrectly stopping playback with the reason AVPlayerRateDidChangeReasonAppBackgrounded
 
 
Q