SRGSSR / srgmediaplayer-apple

An advanced media player library, simple and reliable
MIT License
158 stars 33 forks source link

Background video playback is incorrectly paused #113

Closed defagos closed 2 years ago

defagos commented 2 years ago

As of version 6.1.5 background video playback does not work correctly anymore. This is not related to the iOS version, as I first incorrectly assumed. This regression is likely connected to the fixes made for PiP in 6.1.5.

Issue type

Incorrect behavior

Environment information

Reproducibility

Always reproducible

Steps to reproduce

  1. Open the demo.
  2. Play some video with the inline player.
  3. Detach the video layer and enabled detached background view behavior.
  4. Send the app to the background. Playback incorrectly pauses.
defagos commented 2 years ago

The behavior is fixed if we remove the check for installation of the player view into a hierarchy.

I looked into the past to have a better understanding how this code ended up in the implementation. The final result was implemented between versions 4.0.0 and 5.0.0, mostly in response to issue #84, check commit 23e71041a60fa02479caa8599b8b45a8a0fa4dca and neighbouring ones from the merged feature/background-behavior-fixes branch.

Since everything is related to PiP I'll test PiP playback again (as the implementation changed completely for version 6.1.5 anyway), and all background modes as well. If everything works correctly I assume that the code was kept for safety reasons but was indeed not compatible with the new background detection approach introduced for version 6.1.5.

defagos commented 2 years ago

I could check PiP and background playback on iOS 14.8 and iOS 15.2, the fix works as expected with no noticeable negative consequence.