SRGSSR / pillarbox-apple

A next-generation reactive media playback ecosystem for Apple platforms.
https://testflight.apple.com/join/TS6ngLqf
MIT License
60 stars 9 forks source link

Improve Picture in Picture behavior when several video views are involved #1013

Closed defagos closed 2 months ago

defagos commented 2 months ago

Description

This PR improves Picture in Picture (PiP) behavior when several VideoViews are involved. This fixes issues such as:

Implementation considerations

The work required to make PiP more reliable in the above scenarios was not trivial and involved several smaller steps:

  1. Ensure that a VideoView supporting PiP is reassigned a video layer when stolen by another view enabled for PiP.
  2. Consider player identity to find the best match when restoring a video view from a PiP-enabled video layer.
  3. Store the list of video layers supporting PiP so that PiP can fallback onto a formerly enabled view.
  4. Since the player identity is considered when finding a best match (previously the 1st video view was always winning), two additional use cases have to be considered when PiP ends:
    • No PiP-enabled view is visible, in which case PiP-resources must be cleaned up.
    • PiP-enabled views are visible, but for other players. In this case the most recently PiP-enabled player must be used as fallback.

Changes made

Checklist