rememberProgressStateWithTickInterval

Functions summary

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

Remember the value of ProgressStateWithTickInterval created based on the passed Player and launch a coroutine to listen to Player's changes.

Functions

rememberProgressStateWithTickInterval

@UnstableApi
@Composable
fun rememberProgressStateWithTickInterval(
    player: Player?,
    tickIntervalMs: @IntRange(from = 0) Long = 0,
    scope: CoroutineScope = rememberCoroutineScope()
): ProgressStateWithTickInterval

Remember the value of ProgressStateWithTickInterval created based on the passed Player and launch a coroutine to listen to Player's changes. If the Player instance changes between compositions, produce and remember a new value.

ProgressStateWithTickInterval is a state holder optimised for updates according to the media clock at the provided tickIntervalMs interval. Make sure to tune the interval value for the shape of the composable that is consuming this state.

Parameters
player: Player?

The player whose progress to observe.

tickIntervalMs: @IntRange(from = 0) Long = 0

Delta of the media time that constitutes a progress step, in milliseconds. A value of 0 indicates continuous updates, coming at the rate of Compose runtime requesting new frames. The ProgressStateWithTickInterval.currentPositionMs will aim to be updated at the tickIntervalMs interval. The updates might sometimes be more frequent, or less frequent for small values of tickIntervalMs (where the screen is refreshing less frequently).

scope: CoroutineScope = rememberCoroutineScope()

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.