# ProgressStateWithTickInterval

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


```
@UnstableApi
class ProgressStateWithTickInterval
```

<br />

*** ** * ** ***

State that holds playback progress information of a `https://developer.android.com/reference/kotlin/androidx/media3/common/Player`. This includes playback position, buffered position and duration.

This class is optimised for state changes according to the media clock. A composable UI element that makes use of such `https://developer.android.com/reference/kotlin/androidx/compose/runtime/MutableState` elements will recompose at the frequency of those updates, leading to a more efficient performance.

For example, for a textual-based UI, the current position usually requires "ticking" on the second, on the minute or some other step definition according to the media clock rather than elapsed real time. The coarseness of the interval can be carefully chosen as the granularity of the displayed string.

In most cases, this will be created via `https://developer.android.com/reference/kotlin/androidx/media3/ui/compose/state/rememberProgressStateWithTickInterval.composable#rememberProgressStateWithTickInterval(androidx.media3.common.Player,kotlin.Long,kotlinx.coroutines.CoroutineScope)`.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/ui/compose/state/ProgressStateWithTickInterval#ProgressStateWithTickInterval(androidx.media3.common.Player,kotlin.Long,kotlinx.coroutines.CoroutineScope)( player: https://developer.android.com/reference/kotlin/androidx/media3/common/Player?, tickIntervalMs: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, scope: https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-scope/index.html )` |

| ### Public functions |
|---|---|
| `suspend https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-nothing/index.html?` | `https://developer.android.com/reference/kotlin/androidx/media3/ui/compose/state/ProgressStateWithTickInterval#observe()()` Subscribes to updates from `https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Events` to track changes of progress-related information in an asynchronous way. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/ui/compose/state/ProgressStateWithTickInterval#seekToDefaultPosition()()` Seeks to the default position associated with the current media item. |

| ### Public properties |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/ui/compose/state/ProgressStateWithTickInterval#bufferedPositionMs()` An estimate of the position in the current content or ad up to which data is buffered, in milliseconds. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/ui/compose/state/ProgressStateWithTickInterval#currentPositionMs()` The playback position in the current content or ad, in milliseconds, matches `https://developer.android.com/reference/kotlin/androidx/media3/common/Player#getCurrentPosition()` that is rounded to a multiple of `https://developer.android.com/reference/kotlin/androidx/media3/ui/compose/state/ProgressStateWithTickInterval#tickIntervalMs()`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/ui/compose/state/ProgressStateWithTickInterval#durationMs()` The duration of the current content or ad in milliseconds, matches `https://developer.android.com/reference/kotlin/androidx/media3/common/Player#getDuration()`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/ui/compose/state/ProgressStateWithTickInterval#isLive()` Whether the currently playing item is a live stream. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/ui/compose/state/ProgressStateWithTickInterval#liveOffsetMs()` The offset of the current playback position from the live edge in milliseconds, or `https://developer.android.com/reference/kotlin/androidx/media3/common/C#TIME_UNSET()` if the current media item isn't live or the offset is unknown. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/ui/compose/state/ProgressStateWithTickInterval#originalDurationMs()` The duration of the current media item in milliseconds before any clipping of its start or end. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/ui/compose/state/ProgressStateWithTickInterval#seekToDefaultPositionEnabled()` Whether seeking to the default position is enabled, i.e., `https://developer.android.com/reference/kotlin/androidx/media3/common/Player#COMMAND_SEEK_TO_DEFAULT_POSITION()` is available. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/ui/compose/state/ProgressStateWithTickInterval#targetLiveOffsetMs()` The target live offset in milliseconds if configured. |

## Public constructors

### ProgressStateWithTickInterval

```
ProgressStateWithTickInterval(
    player: Player?,
    tickIntervalMs: @IntRange(from = 0) Long = 0,
    scope: CoroutineScope
)
```

| Parameters |
|---|---|
| `player: https://developer.android.com/reference/kotlin/androidx/media3/common/Player?` | The player whose progress to observe. |
| `tickIntervalMs: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html = 0` | Delta of the media time that constitutes a progress step/tick, in milliseconds. A value of 0 indicates continuous updates, coming at the rate of Compose runtime requesting new frames. The `https://developer.android.com/reference/kotlin/androidx/media3/ui/compose/state/ProgressStateWithTickInterval#currentPositionMs()` will aim to be updated at the `https://developer.android.com/reference/kotlin/androidx/media3/ui/compose/state/ProgressStateWithTickInterval#tickIntervalMs()` interval. The updates might sometimes be more frequent, or less frequent for small values of `https://developer.android.com/reference/kotlin/androidx/media3/ui/compose/state/ProgressStateWithTickInterval#tickIntervalMs()` (where the screen is refreshing less frequently). |
| `scope: https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-scope/index.html` | Coroutine scope whose context is used to launch the progress update job. When scoped to some UI element, the scope of the Composable will ensure the job is cancelled when the element is disposed. |

## Public functions

### observe

```
suspend fun observe(): Nothing?
```

Subscribes to updates from `https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Events` to track changes of progress-related information in an asynchronous way.

### seekToDefaultPosition

```
fun seekToDefaultPosition(): Unit
```

Seeks to the default position associated with the current media item. For live streams, this will typically be the live edge.

This method does nothing if `https://developer.android.com/reference/kotlin/androidx/media3/common/Player#COMMAND_SEEK_TO_DEFAULT_POSITION()` is not available.

## Public properties

### bufferedPositionMs

```
val bufferedPositionMs: Long
```

An estimate of the position in the current content or ad up to which data is buffered, in milliseconds. Smoothed for live streams in the same way as `https://developer.android.com/reference/kotlin/androidx/media3/ui/compose/state/ProgressStateWithTickInterval#currentPositionMs()`.

### currentPositionMs

```
val currentPositionMs: Long
```

The playback position in the current content or ad, in milliseconds, matches `https://developer.android.com/reference/kotlin/androidx/media3/common/Player#getCurrentPosition()` that is rounded to a multiple of `https://developer.android.com/reference/kotlin/androidx/media3/ui/compose/state/ProgressStateWithTickInterval#tickIntervalMs()`. For live streams with a sliding window, the position is relative to a smoothly advancing window start, so that it does not jump whenever the live window is updated.

### durationMs

```
val durationMs: Long
```

The duration of the current content or ad in milliseconds, matches `https://developer.android.com/reference/kotlin/androidx/media3/common/Player#getDuration()`.

### isLive

```
val isLive: Boolean
```

Whether the currently playing item is a live stream. Always `false` while an ad is playing.

### liveOffsetMs

```
val liveOffsetMs: Long
```

The offset of the current playback position from the live edge in milliseconds, or `https://developer.android.com/reference/kotlin/androidx/media3/common/C#TIME_UNSET()` if the current media item isn't live or the offset is unknown.

### originalDurationMs

```
val originalDurationMs: Long
```

The duration of the current media item in milliseconds before any clipping of its start or end. Equal to `https://developer.android.com/reference/kotlin/androidx/media3/ui/compose/state/ProgressStateWithTickInterval#durationMs()` if the media item isn't clipped, its original duration isn't known, it has multiple periods, or an ad is playing.

### seekToDefaultPositionEnabled

```
val seekToDefaultPositionEnabled: Boolean
```

Whether seeking to the default position is enabled, i.e., `https://developer.android.com/reference/kotlin/androidx/media3/common/Player#COMMAND_SEEK_TO_DEFAULT_POSITION()` is available.

### targetLiveOffsetMs

```
val targetLiveOffsetMs: Long
```

The target live offset in milliseconds if configured. Otherwise, the offset of the default position, measured in the same way as `https://developer.android.com/reference/kotlin/androidx/media3/ui/compose/state/ProgressStateWithTickInterval#liveOffsetMs()` if the window start time is known, or from the end of the window if not. `https://developer.android.com/reference/kotlin/androidx/media3/common/C#TIME_UNSET()` if unknown or not a live stream.