# 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)

*** ** * ** ***


```
class VideoPlaybackPictureInPicture : BasicPictureInPicture, AutoCloseable
```

<br />

|---|---|---|---|
| [kotlin.Any](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html) ||||
| ↳ | [androidx.core.pip.PictureInPictureDelegate](https://developer.android.com/reference/kotlin/androidx/core/pip/PictureInPictureDelegate) |||
|   | ↳ | [androidx.core.pip.BasicPictureInPicture](https://developer.android.com/reference/kotlin/androidx/core/pip/BasicPictureInPicture) ||
|   |   | ↳ | [androidx.core.pip.VideoPlaybackPictureInPicture](https://developer.android.com/reference/kotlin/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/kotlin/androidx/core/pip/VideoPlaybackPictureInPicture#VideoPlaybackPictureInPicture(androidx.core.app.PictureInPictureProvider,java.util.concurrent.Executor)( provider: https://developer.android.com/reference/kotlin/androidx/core/app/PictureInPictureProvider, executor: https://developer.android.com/reference/java/util/concurrent/Executor.html )` |

| ### Public functions |
|---|---|
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/core/pip/VideoPlaybackPictureInPicture#close()()` Releases resources used by this implementation, such as the ViewBoundsTracker. |
| `https://developer.android.com/reference/kotlin/androidx/core/pip/VideoPlaybackPictureInPicture` | `https://developer.android.com/reference/kotlin/androidx/core/pip/VideoPlaybackPictureInPicture#setPlayerView(android.view.View)(view: https://developer.android.com/reference/android/view/View.html?)` Sets the View to be tracked for updating the source rectangle hint. |

### Inherited functions

From [androidx.core.pip.BasicPictureInPicture](https://developer.android.com/reference/kotlin/androidx/core/pip/BasicPictureInPicture) `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/core/pip/BasicPictureInPicture#commit()()`

Commits the changes made through the setter methods and applies them to the current Picture-in-Picture session.
`https://developer.android.com/reference/kotlin/androidx/core/pip/BasicPictureInPicture` `https://developer.android.com/reference/kotlin/androidx/core/pip/BasicPictureInPicture#setActions(kotlin.collections.List)(actions: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/android/app/RemoteAction.html>)`

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

Sets the desired aspect ratio for the Picture-in-Picture window.
`https://developer.android.com/reference/kotlin/androidx/core/pip/BasicPictureInPicture` `https://developer.android.com/reference/kotlin/androidx/core/pip/BasicPictureInPicture#setEnabled(kotlin.Boolean)(enabled: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)`

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/kotlin/androidx/core/pip/PictureInPictureDelegate) `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/core/pip/PictureInPictureDelegate#addOnPictureInPictureEventListener(java.util.concurrent.Executor,androidx.core.pip.PictureInPictureDelegate.OnPictureInPictureEventListener)(
executor: https://developer.android.com/reference/java/util/concurrent/Executor.html,
listener: https://developer.android.com/reference/kotlin/androidx/core/pip/PictureInPictureDelegate.OnPictureInPictureEventListener
)`

Adds `https://developer.android.com/reference/kotlin/androidx/core/pip/PictureInPictureDelegate.OnPictureInPictureEventListener` for events sent from system.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/core/pip/PictureInPictureDelegate#removeOnPictureInPictureEventListener(androidx.core.pip.PictureInPictureDelegate.OnPictureInPictureEventListener)(
listener: https://developer.android.com/reference/kotlin/androidx/core/pip/PictureInPictureDelegate.OnPictureInPictureEventListener
)`

Removes `https://developer.android.com/reference/kotlin/androidx/core/pip/PictureInPictureDelegate.OnPictureInPictureEventListener` for events sent from system.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/core/pip/PictureInPictureDelegate#setPictureInPictureParams(androidx.core.app.PictureInPictureParamsCompat)(
pictureInPictureParamsCompat: https://developer.android.com/reference/kotlin/androidx/core/app/PictureInPictureParamsCompat
)`

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

### Inherited properties

From [androidx.core.pip.BasicPictureInPicture](https://developer.android.com/reference/kotlin/androidx/core/pip/BasicPictureInPicture) `https://developer.android.com/reference/kotlin/androidx/core/app/PictureInPictureParamsCompat.Builder` `https://developer.android.com/reference/kotlin/androidx/core/pip/BasicPictureInPicture#pictureInPictureParamsBuilder()`

## Public constructors

### VideoPlaybackPictureInPicture

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

```
VideoPlaybackPictureInPicture(
    provider: PictureInPictureProvider,
    executor: Executor
)
```

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

### close

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

```
open fun close(): Unit
```

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)

```
fun setPlayerView(view: View?): VideoPlaybackPictureInPicture
```

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/kotlin/androidx/core/pip/BasicPictureInPicture#commit()` to apply the changes.

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

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