VideoPictureInPictureController
Added in Scripting 3.2.2. This global class lets JavaScript request system video Picture in Picture (PiP) from a layer-backed AVPlayerView. Use it directly, without importing it from "scripting". It is separate from the custom UI PiP view modifiers.
API
Binding and lifetime
Pass the handle as pictureInPictureController with explicit renderingMode="layer". Omitting the mode or using "controller" with this handle throws, even inside a context-menu preview whose default mode is layer. One handle can bind to only one source view at a time.
Keep the handle stable across renders, and keep the source view mounted and the AVPlayer alive during PiP. Removing the source view stops and unbinds PiP; this API does not keep PiP running after dismissing the page or exiting the script. Configure SharedAudioSession for playback explicitly; the SDK does not change the global audio session for you. Layer mode provides no playback controls, automatic PiP, full-screen transitions or Now Playing management. pipStatus is still required and receives lifecycle updates when a handle is attached; start failures are reported through onStateChanged.
When leaving the page, dispose the PiP handle before stopping/disposing your player. Keep temporary media files until the player is released. Do not delete a user-selected source file.
Complete example
Choose a local video, wait for readiness, then tap Start PiP. Keep the page open. This example loads one video per run; reopen it to choose another video. In your own app, stop PiP and wait for didStop before replacing the video. Actual PiP availability depends on the device and playback state.
