PipHandler

interface PipHandler

Implemented by the host app to put the activity into picture-in-picture. Passing a handler to OGPlayerView IS the enable switch: with one set, the player feeds it live video state (aspect ratio, on-screen bounds, auto-enter eligibility) and reacts to PiP transitions — there is no PiP button in the player chrome, entering is the handler's (i.e. the developer's) decision.

ActivityPipHandler is the ready-made implementation covering the common case; implement this interface directly only for custom presentations.

Inheritors

Properties

Link copied to clipboard
abstract val isInPip: Boolean

True while the activity is in picture-in-picture mode.

Functions

Link copied to clipboard
abstract fun addPipListener(listener: PipListener)
Link copied to clipboard
abstract fun enterPip(): Boolean

Enters picture-in-picture now (e.g. from a custom action or a host button). Returns false when the device/host cannot enter PiP.

Link copied to clipboard

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.

Link copied to clipboard
open fun release()

Called by the handler's OWNER (the host) when the player screen closes while the activity lives on — implementations undo whatever they registered on the activity so it cannot keep reacting (e.g. auto-entering PiP) for screens without a player. OGPlayerView additionally pushes a final non-eligible PipVideoState on dispose, which covers the PiP parameters but not an implementation's own listeners. Default: no-op.

Link copied to clipboard
abstract fun removePipListener(listener: PipListener)