SRGSSR / srgmediaplayer-apple

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

PiP must be an opt-in #111

Closed defagos closed 2 years ago

defagos commented 3 years ago

Not sure when (and if) this behavior changed with iOS 14 and the introduction of PiP for iPhone, but PiP should now be an opt-in. If we namely play a video with SRGMediaPlayerController and an SRGMediaPlayerView, playback will automatically switch to PiP when sending the app to the background, whether or not a PiP delegate was actually implemented by the application.

This is of course due to the fact that we currently always instantiate a PiP controller when we can. This process itself should be an opt-in, so that PiP only occurs where the app decides it has to.

Issue type

Incorrect behavior

Environment information

Reproducibility

Always reproducible

Steps to reproduce

  1. Run the demo and play a stream with the Simple custom player.
  2. Send the app to the background. The PiP overlay appears.
defagos commented 3 years ago

The opt-in setting has been implemented on the feature/pip-opt-in branch. The flag can be toggled at any time and the behavior will be adjusted automatically (e.g. an SRGPictureInPictureButton will automatically appear or disappear).

I applied the new opt-in to the advanced demo, which is the only custom player with PiP support in our demo project. I also updated the code to deal with the special case of using SRGMediaPlayerViewControler, as well as the associated documentation.