# CurrentMediaItemState

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/CurrentMediaItemState.kt+class:androidx.media3.ui.compose.state.CurrentMediaItemState)


```
@UnstableApi
class CurrentMediaItemState
```

<br />

*** ** * ** ***

A state holder that observes a `https://developer.android.com/reference/kotlin/androidx/media3/common/Player` and provides reactive updates for properties of the currently playing media item.

This state includes both static configuration from the `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem` and dynamic information obtained from the player's `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline` and `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaMetadata`.

Use `https://developer.android.com/reference/kotlin/androidx/media3/ui/compose/state/rememberCurrentMediaItemState.composable#rememberCurrentMediaItemState(androidx.media3.common.Player)` to create and manage the lifecycle of this state within a Composable.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/ui/compose/state/CurrentMediaItemState#CurrentMediaItemState(androidx.media3.common.Player)(player: https://developer.android.com/reference/kotlin/androidx/media3/common/Player?)` |

| ### 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/CurrentMediaItemState#observe()()` |

| ### Public properties |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/ui/compose/state/CurrentMediaItemState#durationMs()` The duration of the currently playing item (content or ad) in milliseconds, or `https://developer.android.com/reference/kotlin/androidx/media3/common/C#TIME_UNSET()` if the duration is unknown or the command is not available. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/ui/compose/state/CurrentMediaItemState#isAd()` Whether the player is currently playing an ad. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/ui/compose/state/CurrentMediaItemState#isLive()` Whether the currently playing item is a live stream. |
| `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem?` | `https://developer.android.com/reference/kotlin/androidx/media3/ui/compose/state/CurrentMediaItemState#mediaItem()` The currently playing `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem`, or `null` if no item is being played or the `https://developer.android.com/reference/kotlin/androidx/media3/common/Player#COMMAND_GET_CURRENT_MEDIA_ITEM()` is not available. |
| `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaMetadata` | `https://developer.android.com/reference/kotlin/androidx/media3/ui/compose/state/CurrentMediaItemState#mediaMetadata()` The combined `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaMetadata` for the current item, including both static metadata from the `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem` and dynamic updates from the stream. |

## Public constructors

### CurrentMediaItemState

```
CurrentMediaItemState(player: Player?)
```

## Public functions

### observe

```
suspend fun observe(): Unit
```

## Public properties

### durationMs

```
val durationMs: Long
```

The duration of the currently playing item (content or ad) in milliseconds, or `https://developer.android.com/reference/kotlin/androidx/media3/common/C#TIME_UNSET()` if the duration is unknown or the command is not available.

### isAd

```
val isAd: Boolean
```

Whether the player is currently playing an ad. When `true`, properties like `https://developer.android.com/reference/kotlin/androidx/media3/ui/compose/state/CurrentMediaItemState#durationMs()` will reflect the duration of the current ad rather than the main content.

### isLive

```
val isLive: Boolean
```

Whether the currently playing item is a live stream.

### mediaItem

```
val mediaItem: MediaItem?
```

The currently playing `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem`, or `null` if no item is being played or the `https://developer.android.com/reference/kotlin/androidx/media3/common/Player#COMMAND_GET_CURRENT_MEDIA_ITEM()` is not available.

### mediaMetadata

```
val mediaMetadata: MediaMetadata
```

The combined `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaMetadata` for the current item, including both static metadata from the `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem` and dynamic updates from the stream. Returns `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaMetadata#EMPTY()` if metadata is not available.