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

Moves the player to a position represented by progress which is a value between 0..1, effectively updating currentPositionProgress.

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.

Boolean

Whether the user is allowed to change the progress of the player, for example by dragging or tapping a slider ob the UI side or programmatically calling updateCurrentPositionProgress.

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.

updateCurrentPositionProgress

fun updateCurrentPositionProgress(progress: Float): Unit

Moves the player to a position represented by progress which is a value between 0..1, effectively updating currentPositionProgress.

This method must only be called if changing of progress is enabled on the state. Throws an IllegalStateException otherwise.

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.

changingProgressEnabled

val changingProgressEnabledBoolean

Whether the user is allowed to change the progress of the player, for example by dragging or tapping a slider ob the UI side or programmatically calling updateCurrentPositionProgress.

This value is derived from the underlying Player state. It will be true only if Player.COMMAND_SEEK_IN_CURRENT_MEDIA_ITEM is available and the duration of the current media item is known (i.e., not C.TIME_UNSET).

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.