rememberProgressStateWithTickCount

Functions summary

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

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

Functions

rememberProgressStateWithTickCount

@UnstableApi
@Composable
fun rememberProgressStateWithTickCount(
    player: Player?,
    totalTickCount: @IntRange(from = 0) Int = 0,
    scope: CoroutineScope = rememberCoroutineScope()
): ProgressStateWithTickCount

Remember the value of ProgressStateWithTickCount 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.

ProgressStateWithTickCount is a state holder optimised for updates according to the discrete number of ticks that make up the full progress. Non-textual UI 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 in ticks/steps that correspond to a visible "jump" rather than a particular real time or media time frequency. Make sure to tune the totalTickCount value for the shape of the composable that is consuming this state. This will help you keep the recomposition count low, since the updates will be triggered at the frequency that matches the needs of the UI.

Parameters
player: Player?

The player whose progress to observe.

totalTickCount: @IntRange(from = 0) Int = 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, ProgressStateWithTickCount.currentPositionProgress and ProgressStateWithTickCount.bufferedPositionProgress will remain 0 until this value becomes positive. Must not be negative.

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.

Returns
ProgressStateWithTickCount

The remembered ProgressStateWithTickCount instance.