This PR improves Picture in Picture (PiP) behavior when several VideoViews are involved. This fixes issues such as:
VideoViews being stolen when PiP is enabled for other views.
PiP being unexpectedly terminated.
Implementation considerations
The work required to make PiP more reliable in the above scenarios was not trivial and involved several smaller steps:
Ensure that a VideoView supporting PiP is reassigned a video layer when stolen by another view enabled for PiP.
Consider player identity to find the best match when restoring a video view from a PiP-enabled video layer.
Store the list of video layers supporting PiP so that PiP can fallback onto a formerly enabled view.
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
Update PiP controller using content sources (works well and avoids recreating controllers and using KVO).
Increase restoration animation delay to mitigate improve restoration animations in some scenarios.
Add demos to help test PiP behavior in the following cases (including toggling on / off PiP for a view at any time):
Twins view (same player whose content is displayed in two sibling views).
Multi view (two players with two associated views).
Transition view (one player whose content is displayed by a view, from which a modal displaying the same content can be opened).
Update demo close button to make interaction with it more reliable.
Checklist
[x] APIs have been properly documented (if relevant).
[x] The documentation has been updated (if relevant).
[x] New unit tests have been written (if relevant).
Description
This PR improves Picture in Picture (PiP) behavior when several
VideoView
s are involved. This fixes issues such as:VideoView
s being stolen when PiP is enabled for other views.Implementation considerations
The work required to make PiP more reliable in the above scenarios was not trivial and involved several smaller steps:
VideoView
supporting PiP is reassigned a video layer when stolen by another view enabled for PiP.Changes made
Checklist