ProgressStateWithTickCount

@UnstableApi
class ProgressStateWithTickCount


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

Summary

Public constructors

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

Public functions

suspend Nothing

Subscribes to updates from Player.Events to track changes of progress-related information in an asynchronous way.

Unit
updateTotalTickCount(newTotalTickCount: Int)

Dynamically set totalTickCount to another value with the change taking effect immediately, leading to a change of position progress polling interval.

Public properties

Float

An estimate of the progress in the current content or ad up to which data is buffered as represented by Player.getBufferedPosition.

Float

The progress of the current content of the Player as represented by Player.getCurrentPosition.

Public constructors

ProgressStateWithTickCount

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

scope: CoroutineScope

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 Player.Events to track changes of progress-related information in an asynchronous way.

updateTotalTickCount

fun updateTotalTickCount(newTotalTickCount: Int): Unit

Dynamically set totalTickCount to another value with the change taking effect immediately, leading to a change of position progress polling interval.

Public properties

bufferedPositionProgress

val bufferedPositionProgressFloat

An estimate of the progress in the current content or ad up to which data is buffered as represented by Player.getBufferedPosition. The values range from 0.0 (represents no progress) and 1.0 (represents full progress and reaching Player.getDuration). Values outside of this range are coerced into the range. Values are rounded to the nearest multiple of 1/totalTickCount.

currentPositionProgress

val currentPositionProgressFloat

The progress of the current content of the Player as represented by Player.getCurrentPosition. The values range from 0.0 (represents no progress) and 1.0 (represents full progress and reaching Player.getDuration). Values outside of this range are coerced into the range. Values are rounded to the nearest multiple of 1/totalTickCount.