Developers and Picture-in-Picture
For the standard player view controller, Apple does a lot of the heavy lifting for PiP, but the button won't appear automagically.
- To enable PiP, developers need to enable Audio, AirPlay, and Picture-in-Picture in background modes, and to set the audio category by adding AVFoundation and some code to the app delegate. Once that's done, the PiP button will show up.
- Developers also need to add some code to the player view controller that lets people leave PiP, return to the proper place in the app to restore video playback to the standard layer.
- PiP can also be disabled for apps that don't want to support it.
- Developers first need to check if the device the video is running on can support PiP. If so, they can create a PiP controller.
- A PiP button needs to be added to the custom player controls, so viewers can choose to enter the mode.
- The in-app video player will need to be disabled while PiP video is playing, but without killing the PiP video.
- If a developer wants to support automatic PiP on exit, they need to make sure their player is in full-window.
- If the viewer taps the full-screen button, they need to be taken back to the right place in the app, and the in-app video player needs to restore playback from that point on.
- If the device supports PiP but using it isn't possible at the moment, the developer needs to disable the button and, ideally, show the viewer that the feature is currently unavailable.