# PresentationState

Artifact: [androidx.media3:media3-ui-compose](https://developer.android.com/jetpack/androidx/releases/media3) [View Source](https://cs.android.com/search?q=file:androidx/media3/ui/compose/state/PresentationState.kt+class:androidx.media3.ui.compose.state.PresentationState)


```
@UnstableApi
class PresentationState
```

<br />

*** ** * ** ***

State that holds information to correctly deal with UI components related to the rendering of frames to a surface.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/ui/compose/state/PresentationState#PresentationState(kotlin.Boolean)(keepContentOnReset: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` |

| ### Public functions |
|---|---|
| `suspend https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/ui/compose/state/PresentationState#observe(androidx.media3.common.Player)(player: https://developer.android.com/reference/kotlin/androidx/media3/common/Player?)` Subscribes to updates from `https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Events` and listens to |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/VisibleForTesting(otherwise = 2) https://developer.android.com/reference/kotlin/androidx/media3/ui/compose/state/PresentationState#updateForCurrentTrackSelections(androidx.media3.common.Player)(player: https://developer.android.com/reference/kotlin/androidx/media3/common/Player?)` |

| ### Public properties |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/ui/compose/state/PresentationState#coverSurface()` set to false when the Player emits `https://developer.android.com/reference/kotlin/androidx/media3/common/Player#EVENT_RENDERED_FIRST_FRAME()` and reset back to true on `https://developer.android.com/reference/kotlin/androidx/media3/common/Player#EVENT_TRACKS_CHANGED()` depending on the number and type of tracks. |
| `https://developer.android.com/reference/kotlin/androidx/media3/common/Player?` | `@https://developer.android.com/reference/kotlin/androidx/annotation/VisibleForTesting(otherwise = 2) https://developer.android.com/reference/kotlin/androidx/media3/ui/compose/state/PresentationState#player()` |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/ui/compose/state/PresentationState#showArtwork()` set to true when artwork should be displayed. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html?` | `https://developer.android.com/reference/kotlin/androidx/media3/ui/compose/state/PresentationState#videoAspectRatio()` the aspect ratio of the video (width / height), adjusted for `https://developer.android.com/reference/kotlin/androidx/media3/common/VideoSize#pixelWidthHeightRatio()`. |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size?` | `https://developer.android.com/reference/kotlin/androidx/media3/ui/compose/state/PresentationState#videoSizeDp()` **This property is deprecated.** Use videoAspectRatio instead. |

## Public constructors

### PresentationState

```
PresentationState(keepContentOnReset: Boolean = false)
```

| Parameters |
|---|---|
| `keepContentOnReset: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html = false` | whether the currently displayed video frame or media artwork is kept visible when tracks change or player changes. Defaults to false. |

## Public functions

### observe

```
suspend fun observe(player: Player?): Unit
```

Subscribes to updates from `https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Events` and listens to

- `https://developer.android.com/reference/kotlin/androidx/media3/common/Player#EVENT_VIDEO_SIZE_CHANGED()` to determine pixelWidthHeightRatio-adjusted video size

- `https://developer.android.com/reference/kotlin/androidx/media3/common/Player#EVENT_RENDERED_FIRST_FRAME()`, `https://developer.android.com/reference/kotlin/androidx/media3/common/Player#EVENT_TRACKS_CHANGED()`, and `https://developer.android.com/reference/kotlin/androidx/media3/common/Player#EVENT_TRACK_SELECTION_PARAMETERS_CHANGED()` to determine whether the surface is ready to be shown

### updateForCurrentTrackSelections

```
@VisibleForTesting(otherwise = 2)
fun updateForCurrentTrackSelections(player: Player?): Unit
```

## Public properties

### coverSurface

```
val coverSurface: Boolean
```

set to false when the Player emits `https://developer.android.com/reference/kotlin/androidx/media3/common/Player#EVENT_RENDERED_FIRST_FRAME()` and reset back to true on `https://developer.android.com/reference/kotlin/androidx/media3/common/Player#EVENT_TRACKS_CHANGED()` depending on the number and type of tracks.

### player

```
@VisibleForTesting(otherwise = 2)
var player: Player?
```

### showArtwork

```
val showArtwork: Boolean
```

set to true when artwork should be displayed. It does not guarantee that the current media item actually contains artwork data; the caller is responsible for validating the presence of artwork before rendering.

### videoAspectRatio

```
val videoAspectRatio: Float?
```

the aspect ratio of the video (width / height), adjusted for `https://developer.android.com/reference/kotlin/androidx/media3/common/VideoSize#pixelWidthHeightRatio()`. Becomes `null` when either height or width of the video is zero, or `https://developer.android.com/reference/kotlin/androidx/media3/ui/compose/state/PresentationState#player()` is null.

### videoSizeDp

```
val videoSizeDp: Size?
```

> [!CAUTION]
> **This property is deprecated.**   
> Use videoAspectRatio instead.

Wraps the video size in Compose's `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size`.

Use `https://developer.android.com/reference/kotlin/androidx/media3/ui/compose/state/PresentationState#videoAspectRatio()` instead.