SRGSSR / srgmediaplayer-apple

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

Issues with advanced player restoration from picture in picture #77

Closed defagos closed 4 years ago

defagos commented 4 years ago

When returning from picture in picture, restoration occurs erratically. Sometimes it works, sometimes it interrupts playback, sometimes the animation is ugly.

Issue type

Incorrect behavior

Environment information

Reproducibility

Always reproducible

Steps to reproduce

  1. Open the demo application on an iPad with PiP support.
  2. Open the advanced player demo.
  3. Switch to PiP.
  4. Tap on the restore button and observe the transition. Repeat several times (resume playback in between if it was paused).
defagos commented 4 years ago

I had a rough time understanding why this was not working, while it was working in other projects based on SRG Media Player perfectly fine (e.g. Letterbox or Play). The fact that AVPlayerViewController-based examples were working fine in the SRG Media Player demo was also proof it was not an OS or device issue.

The implementation of PiP in the demo is in fact perfectly fine. What is not is the that the modal presentation is made using standard iOS presentation animations, internally implemented using UIPercentDrivenInteractiveTransition. Such transitions mess with timeOffset, thus altering the time of the player, even pausing it sometimes.

AVPlayerViewController works fine because it uses its own private transitioning delegate (AVTransitionController).

I therefore updated the advanced player example to use the modal transition we had on the segment player example. I removed it from this less interesting example.

I also updated SRGMediaPlayerController header picture in picture documentation to mention this fact.

defagos commented 4 years ago

I updated the advanced player demo with a very basic control center implementation. This provides an example to start from, as well as a valuable tool to test picture in picture vs. AirPlay interactions.