# VideoPlaybackPictureInPicture

Artifact: [androidx.core:core-pip](https://developer.android.com/jetpack/androidx/releases/core) [View Source](https://cs.android.com/search?q=file:androidx/core/pip/PictureInPictureImpl.kt+class:androidx.core.pip.VideoPlaybackPictureInPicture) Added in [1.0.0-alpha04](https://developer.android.com/jetpack/androidx/releases/core#1.0.0-alpha04)

*** ** * ** ***


```
public final class VideoPlaybackPictureInPicture extends BasicPictureInPicture implements AutoCloseable
```

<br />

|---|---|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object.html) ||||
| ↳ | [androidx.core.pip.PictureInPictureDelegate](https://developer.android.com/reference/androidx/core/pip/PictureInPictureDelegate) |||
|   | ↳ | [androidx.core.pip.BasicPictureInPicture](https://developer.android.com/reference/androidx/core/pip/BasicPictureInPicture) ||
|   |   | ↳ | [androidx.core.pip.VideoPlaybackPictureInPicture](https://developer.android.com/reference/androidx/core/pip/VideoPlaybackPictureInPicture) |

*** ** * ** ***

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

Enables seamless resize and allows tracking a View to automatically update the source rectangle hint for smooth animations using the package's ViewBoundsTracker.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/core/pip/VideoPlaybackPictureInPicture#VideoPlaybackPictureInPicture(androidx.core.app.PictureInPictureProvider,java.util.concurrent.Executor)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/core/app/PictureInPictureProvider provider, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/concurrent/Executor.html executor )` |

| ### Public methods |
|---|---|
| `void` | `https://developer.android.com/reference/androidx/core/pip/VideoPlaybackPictureInPicture#close()()` Releases resources used by this implementation, such as the ViewBoundsTracker. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/core/pip/VideoPlaybackPictureInPicture` | `https://developer.android.com/reference/androidx/core/pip/VideoPlaybackPictureInPicture#setPlayerView(android.view.View)(https://developer.android.com/reference/android/view/View.html view)` Sets the View to be tracked for updating the source rectangle hint. |

### Inherited methods

From [androidx.core.pip.BasicPictureInPicture](https://developer.android.com/reference/androidx/core/pip/BasicPictureInPicture) `final void` `https://developer.android.com/reference/androidx/core/pip/BasicPictureInPicture#commit()()`

Commits the changes made through the setter methods and applies them to the current Picture-in-Picture session.
`final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/core/app/PictureInPictureParamsCompat.Builder` `https://developer.android.com/reference/androidx/core/pip/BasicPictureInPicture#getPictureInPictureParamsBuilder()()` `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/core/pip/BasicPictureInPicture` `https://developer.android.com/reference/androidx/core/pip/BasicPictureInPicture#setActions(kotlin.collections.List)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/app/RemoteAction.html> actions)`

Sets the custom actions to be available in the Picture-in-Picture menu.
`final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/core/pip/BasicPictureInPicture` `https://developer.android.com/reference/androidx/core/pip/BasicPictureInPicture#setAspectRatio(android.util.Rational)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/Rational.html aspectRatio)`

Sets the desired aspect ratio for the Picture-in-Picture window.
`final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/core/pip/BasicPictureInPicture` `https://developer.android.com/reference/androidx/core/pip/BasicPictureInPicture#setEnabled(kotlin.Boolean)(boolean enabled)`

Sets whether the activity should automatically enter Picture-in-Picture mode when eligible (e.g., when swiping to home).
From [androidx.core.pip.PictureInPictureDelegate](https://developer.android.com/reference/androidx/core/pip/PictureInPictureDelegate) `final void` `https://developer.android.com/reference/androidx/core/pip/PictureInPictureDelegate#addOnPictureInPictureEventListener(java.util.concurrent.Executor,androidx.core.pip.PictureInPictureDelegate.OnPictureInPictureEventListener)(
@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/concurrent/Executor.html executor,
@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/core/pip/PictureInPictureDelegate.OnPictureInPictureEventListener listener
)`

Adds `https://developer.android.com/reference/androidx/core/pip/PictureInPictureDelegate.OnPictureInPictureEventListener` for events sent from system.
`final void` `https://developer.android.com/reference/androidx/core/pip/PictureInPictureDelegate#removeOnPictureInPictureEventListener(androidx.core.pip.PictureInPictureDelegate.OnPictureInPictureEventListener)(
@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/core/pip/PictureInPictureDelegate.OnPictureInPictureEventListener listener
)`

Removes `https://developer.android.com/reference/androidx/core/pip/PictureInPictureDelegate.OnPictureInPictureEventListener` for events sent from system.
`final void` `https://developer.android.com/reference/androidx/core/pip/PictureInPictureDelegate#setPictureInPictureParams(androidx.core.app.PictureInPictureParamsCompat)(
@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/core/app/PictureInPictureParamsCompat pictureInPictureParamsCompat
)`

Sets the `https://developer.android.com/reference/androidx/core/app/PictureInPictureParamsCompat` instance for PiP.

## Public constructors

### VideoPlaybackPictureInPicture

Added in [1.0.0-alpha04](https://developer.android.com/jetpack/androidx/releases/core#1.0.0-alpha04)

```
public VideoPlaybackPictureInPicture(
    @NonNull PictureInPictureProvider provider,
    @NonNull Executor executor
)
```

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/core/app/PictureInPictureProvider provider` | `https://developer.android.com/reference/androidx/core/app/PictureInPictureProvider` instance that this delegate will call into for actual Picture-in-Picture functionalities. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/concurrent/Executor.html 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

### close

Added in [1.0.0-alpha04](https://developer.android.com/jetpack/androidx/releases/core#1.0.0-alpha04)

```
public void close()
```

Releases resources used by this implementation, such as the ViewBoundsTracker. Call this when the implementation is no longer needed (e.g., in Activity.onDestroy).

### setPlayerView

Added in [1.0.0-alpha04](https://developer.android.com/jetpack/androidx/releases/core#1.0.0-alpha04)

```
public final @NonNull VideoPlaybackPictureInPicture setPlayerView(View view)
```

Sets the View to be tracked for updating the source rectangle hint. The bounds of this View (e.g., the player view) will be used to ensure smooth entry/exit animations into/out of Picture-in-Picture.

Callers must invoke `https://developer.android.com/reference/androidx/core/pip/BasicPictureInPicture#commit()` to apply the changes.

| Parameters |
|---|---|
| `https://developer.android.com/reference/android/view/View.html view` | The View to track, or null to stop tracking and clear the hint. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/core/pip/VideoPlaybackPictureInPicture` | This implementation instance for chaining. |