BasicPictureInPicture


public class BasicPictureInPicture extends PictureInPictureDelegate

Known direct subclasses
VideoPlaybackPictureInPicture

Picture-in-Picture implementation optimized for Video Playback applications.


Basic Picture-in-Picture implementation.

Configures PiP with a specific aspect ratio, custom actions, and controls enter behavior. Seamless resize is disabled and no sourceRectHint is used.

Summary

Public constructors

BasicPictureInPicture(
    @NonNull PictureInPictureProvider pictureInPictureProvider,
    @NonNull Executor executor
)

Public methods

final void

Commits the changes made through the setter methods and applies them to the current Picture-in-Picture session.

final @NonNull BasicPictureInPicture

Sets the custom actions to be available in the Picture-in-Picture menu.

final @NonNull BasicPictureInPicture

Sets the desired aspect ratio for the Picture-in-Picture window.

final @NonNull BasicPictureInPicture
setEnabled(boolean enabled)

Sets whether the activity should automatically enter Picture-in-Picture mode when eligible (e.g., when swiping to home).

Public constructors

BasicPictureInPicture

Added in 1.0.0-alpha03
public BasicPictureInPicture(
    @NonNull PictureInPictureProvider pictureInPictureProvider,
    @NonNull Executor executor
)
Parameters
@NonNull PictureInPictureProvider pictureInPictureProvider

PictureInPictureProvider instance that this delegate will call into for actual Picture-in-Picture functionalities.

@NonNull Executor executor

The executor to use for applying the Picture-in-Picture parameters. It is recommended to use a background executor to offload these framework calls from the main thread.

Public methods

commit

Added in 1.0.0-alpha03
public final void commit()

Commits the changes made through the setter methods and applies them to the current Picture-in-Picture session.

This method builds the PictureInPictureParamsCompat and schedules an update using the executor provided at construction.

setActions

Added in 1.0.0-alpha03
public final @NonNull BasicPictureInPicture setActions(@NonNull List<@NonNull RemoteAction> actions)

Sets the custom actions to be available in the Picture-in-Picture menu.

Callers must invoke commit to apply the changes.

Parameters
@NonNull List<@NonNull RemoteAction> actions

A list of RemoteActions.

Returns
@NonNull BasicPictureInPicture

This implementation instance for chaining.

setAspectRatio

Added in 1.0.0-alpha03
public final @NonNull BasicPictureInPicture setAspectRatio(@NonNull Rational aspectRatio)

Sets the desired aspect ratio for the Picture-in-Picture window.

Callers must invoke commit to apply the changes.

Parameters
@NonNull Rational aspectRatio

The desired width/height ratio.

Returns
@NonNull BasicPictureInPicture

This implementation instance for chaining.

setEnabled

Added in 1.0.0-alpha03
public final @NonNull BasicPictureInPicture setEnabled(boolean enabled)

Sets whether the activity should automatically enter Picture-in-Picture mode when eligible (e.g., when swiping to home). This indicates the "willingness to enter PiP".

Callers must invoke commit to apply the changes.

Parameters
boolean enabled

True if the Activity is PiP-able, false otherwise.

Returns
@NonNull BasicPictureInPicture

This implementation instance for chaining.

Protected methods

getPictureInPictureParamsBuilder

Added in 1.0.0-alpha03
protected final @NonNull PictureInPictureParamsCompat.Builder getPictureInPictureParamsBuilder()