# ProgressStateWithTickCount

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


```
@UnstableApi
class ProgressStateWithTickCount
```

<br />

*** ** * ** ***

State that aims to hold accurate progress information (position, bufferedPosition, duration) that is required for a UI component representing a non-textual progress indicator, e.g. circular or linear. Such components are limited in how much progress they can show by their screen representation, such as the number of pixels. In this case, it is more important to track progress that can correspond to a visual jump rather than a particular media clock frequency.

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

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/ui/compose/state/ProgressStateWithTickCount#ProgressStateWithTickCount(androidx.media3.common.Player,kotlin.Int,kotlinx.coroutines.CoroutineScope)( player: https://developer.android.com/reference/kotlin/androidx/media3/common/Player?, totalTickCount: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/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/ProgressStateWithTickCount#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/-long/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/ui/compose/state/ProgressStateWithTickCount#progressToPosition(kotlin.Float)(progress: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)` Converts a progress value (0.0 to 1.0) to a position in the current media in milliseconds. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/ui/compose/state/ProgressStateWithTickCount#seekToDefaultPosition()()` Seeks to the default position associated with the current media item. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/ui/compose/state/ProgressStateWithTickCount#updateCurrentPositionProgress(kotlin.Float)(progress: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)` Moves the player to a position represented by `https://developer.android.com/reference/kotlin/androidx/media3/ui/compose/state/ProgressStateWithTickCount#updateCurrentPositionProgress(kotlin.Float)` which is a value between 0..1, effectively updating `https://developer.android.com/reference/kotlin/androidx/media3/ui/compose/state/ProgressStateWithTickCount#currentPositionProgress()`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/ui/compose/state/ProgressStateWithTickCount#updateTotalTickCount(kotlin.Int)(newTotalTickCount: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Dynamically set `https://developer.android.com/reference/kotlin/androidx/media3/ui/compose/state/ProgressStateWithTickCount#totalTickCount()` to another value with the change taking effect immediately, leading to a change of position progress polling interval. |

| ### Public properties |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/ui/compose/state/ProgressStateWithTickCount#bufferedPositionProgress()` An estimate of the progress in the current content or ad up to which data is buffered as represented by `https://developer.android.com/reference/kotlin/androidx/media3/common/Player#getBufferedPosition()`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/ui/compose/state/ProgressStateWithTickCount#changingProgressEnabled()` Whether the user is allowed to change the progress of the player, for example by dragging or tapping a slider on the UI side or programmatically calling `https://developer.android.com/reference/kotlin/androidx/media3/ui/compose/state/ProgressStateWithTickCount#updateCurrentPositionProgress(kotlin.Float)`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/ui/compose/state/ProgressStateWithTickCount#currentPositionProgress()` The progress of the current content of the Player as represented by `https://developer.android.com/reference/kotlin/androidx/media3/common/Player#getCurrentPosition()`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/ui/compose/state/ProgressStateWithTickCount#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/ProgressStateWithTickCount#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/ProgressStateWithTickCount#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/ProgressStateWithTickCount#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/ProgressStateWithTickCount#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/ProgressStateWithTickCount#targetLiveOffsetMs()` The target live offset in milliseconds if configured. |

## Public constructors

### ProgressStateWithTickCount

```
ProgressStateWithTickCount(
    player: Player?,
    totalTickCount: @IntRange(from = 0) Int = 0,
    scope: CoroutineScope
)
```

| Parameters |
|---|---|
| `player: https://developer.android.com/reference/kotlin/androidx/media3/common/Player?` | The player whose progress to observe. |
| `totalTickCount: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html = 0` | If strictly greater than 0, specifies the amounts of discrete values, evenly distributed across the whole duration of the current media item. If 0, `https://developer.android.com/reference/kotlin/androidx/media3/ui/compose/state/ProgressStateWithTickCount#currentPositionProgress()` and `https://developer.android.com/reference/kotlin/androidx/media3/ui/compose/state/ProgressStateWithTickCount#bufferedPositionProgress()` will remain 0 until this value becomes positive. Must not be negative. |
| `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.

### progressToPosition

```
fun progressToPosition(progress: Float): Long
```

Converts a progress value (0.0 to 1.0) to a position in the current media in milliseconds.

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

### updateCurrentPositionProgress

```
fun updateCurrentPositionProgress(progress: Float): Unit
```

Moves the player to a position represented by `https://developer.android.com/reference/kotlin/androidx/media3/ui/compose/state/ProgressStateWithTickCount#updateCurrentPositionProgress(kotlin.Float)` which is a value between 0..1, effectively updating `https://developer.android.com/reference/kotlin/androidx/media3/ui/compose/state/ProgressStateWithTickCount#currentPositionProgress()`.

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

### updateTotalTickCount

```
fun updateTotalTickCount(newTotalTickCount: Int): Unit
```

Dynamically set `https://developer.android.com/reference/kotlin/androidx/media3/ui/compose/state/ProgressStateWithTickCount#totalTickCount()` to another value with the change taking effect immediately, leading to a change of position progress polling interval.

## Public properties

### bufferedPositionProgress

```
val bufferedPositionProgress: Float
```

An estimate of the progress in the current content or ad up to which data is buffered as represented by `https://developer.android.com/reference/kotlin/androidx/media3/common/Player#getBufferedPosition()`. The values range from 0.0 (represents no progress) and 1.0 (represents full progress and reaching `https://developer.android.com/reference/kotlin/androidx/media3/common/Player#getDuration()`). Values outside of this range are coerced into the range. Values are rounded to the nearest multiple of 1/totalTickCount. Smoothed for live streams in the same way as `https://developer.android.com/reference/kotlin/androidx/media3/ui/compose/state/ProgressStateWithTickCount#currentPositionProgress()`.

### changingProgressEnabled

```
val changingProgressEnabled: Boolean
```

Whether the user is allowed to change the progress of the player, for example by dragging or tapping a slider on the UI side or programmatically calling `https://developer.android.com/reference/kotlin/androidx/media3/ui/compose/state/ProgressStateWithTickCount#updateCurrentPositionProgress(kotlin.Float)`.

This value is derived from the underlying `https://developer.android.com/reference/kotlin/androidx/media3/common/Player` state. It will be `true` only if `https://developer.android.com/reference/kotlin/androidx/media3/common/Player#COMMAND_SEEK_IN_CURRENT_MEDIA_ITEM()` is available and the duration of the current media item is known and strictly positive.

### currentPositionProgress

```
val currentPositionProgress: Float
```

The progress of the current content of the Player as represented by `https://developer.android.com/reference/kotlin/androidx/media3/common/Player#getCurrentPosition()`. The values range from 0.0 (represents no progress) and 1.0 (represents full progress and reaching `https://developer.android.com/reference/kotlin/androidx/media3/common/Player#getDuration()`). Values outside of this range are coerced into the range. Values are rounded to the nearest multiple of 1/totalTickCount. 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/ProgressStateWithTickCount#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/ProgressStateWithTickCount#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.