ActivityPipHandler
Ready-made PipHandler for the common case: drives the activity's picture-in-picture parameters from the player state OGPlayerView feeds it, auto-enters PiP when the user leaves the app (see OGPlayerView's autoEnterPipOnBackground), and exposes one play/pause remote action on the PiP window.
Host requirements:
The player's activity must declare
android:supportsPictureInPicture="true"(and the usualandroid:configChangesfor PiP's size/orientation changes) in the manifest. A missing flag is caught: the handler logs the fix once and disables itself instead of crashing.activity must be an androidx
ComponentActivity(any AppCompat / Compose activity qualifies) — PiP mode and user-leave observation come from its androidx.core listener registries.
On API 31+ auto-enter uses the platform's seamless setAutoEnterEnabled; on API 26–30 it is approximated via the user-leave hint. The play/pause remote action's broadcast receiver is registered only while in PiP.
Properties
Functions
Called by OGPlayerView whenever the video state relevant to PiP changes — implementations use it to keep the system's PiP parameters (aspect ratio, source bounds, auto-enter) current. Not host-app API.
Detaches the handler from the activity and player and clears the activity's auto-enter arming. A handler is one player screen's companion, not the activity's: call this when that screen closes while the activity lives on (single-activity/navigation apps) — otherwise the activity stays armed and leaving the app from an unrelated screen still drops it into a PiP window. Terminal and idempotent; runs automatically when the activity is destroyed.