ContentPip

Added in 1.0.0-alpha04

public final class ContentPip


Summary

Public methods

static final void
disablePipOnAppSwitch(
    @NonNull ComponentActivity receiver,
    @NonNull ContentPipToken contentPipToken
)

Disables entering PiP on app switch for this Activity with Content PiP.

static final @NonNull ContentPipToken

Enables entering PiP on app switch for this Activity with Content PiP.

Public methods

disablePipOnAppSwitch

public static final void disablePipOnAppSwitch(
    @NonNull ComponentActivity receiver,
    @NonNull ContentPipToken contentPipToken
)

Disables entering PiP on app switch for this Activity with Content PiP.

This method unregisters the listeners and observers that were added by enablePipOnAppSwitch. It restores the original window callback and stops monitoring lifecycle and exit hints.

Threading: This method must be called on the main thread of your application.

Parameters
@NonNull ContentPipToken contentPipToken

The token returned by enablePipOnAppSwitch.

enablePipOnAppSwitch

public static final @NonNull ContentPipToken enablePipOnAppSwitch(
    @NonNull ComponentActivity receiver,
    @NonNull ContentPipCallback callback
)

Enables entering PiP on app switch for this Activity with Content PiP.

This API hooks into standard Activity exit hints to trigger a fallback PiP pipeline when native Auto-Enter is suppressed by the OS (e.g. on Quick Switch).

It also automatically monitors the Activity lifecycle and user interactions to "pull back" the player and terminate the fallback task when the user returns to the app.

It is recommended to call this method from ComponentActivity.onCreate, if it is called multiple times, only the last ContentPipCallback is effective.

Threading: This callback is strictly tied to the UI toolkit and will always be executed synchronously on the main thread of your application.

Parameters
@NonNull ContentPipCallback callback

The callback to manage handoff between tasks.

Returns
@NonNull ContentPipToken

ContentPipToken that caller can pass to disablePipOnAppSwitch.