androidx.media3.ui.compose.indicators

Top-level functions summary

Unit
@UnstableApi
@Composable
TimeText(
    player: Player,
    tickIntervalMs: @IntRange(from = 0) Int,
    scope: CoroutineScope,
    content: @Composable ProgressStateWithTickInterval.() -> Unit
)

A Composable that provides player progress information to a content lambda, allowing for the creation of custom progress indicators.

Top-level functions

@UnstableApi
@Composable
fun TimeText(
    player: Player,
    tickIntervalMs: @IntRange(from = 0) Int = 1000,
    scope: CoroutineScope = rememberCoroutineScope(),
    content: @Composable ProgressStateWithTickInterval.() -> Unit
): Unit

A Composable that provides player progress information to a content lambda, allowing for the creation of custom progress indicators.

This function does not render any UI itself. Instead, it manages the state of the player's progress and exposes a ProgressStateWithTickInterval object to its content lambda. This allows for complete control over the layout and appearance of the progress display.

Note that the reliance on ProgressStateWithTickInterval implies that the UI responsiveness and precision is optimised with the media-clock in mind. That makes it most suitable for displaying time-based text progress (rather than pixel-based slider/bar), hence the name of this Composable.

It serves as a state provider, decoupling the logic of listening to player progress from the UI presentation, which is a flexible pattern recommended for building reusable Composables.

Example usage:

TimeText(player) {
// `this` is a `ProgressStateWithTickInterval`
val currentPosition = Util.getStringForTime(this.currentPositionMs)
val duration = Util.getStringForTime(this.durationMs)
Text("$currentPosition / $duration")
}
Parameters
player: Player

The Player to get the progress from.

tickIntervalMs: @IntRange(from = 0) Int = 1000

The granularity of the progress updates in milliseconds. A smaller value means more frequent updates, which may cause more recompositions.

scope: CoroutineScope = rememberCoroutineScope()

The CoroutineScope to use for listening to player progress updates.

content: @Composable ProgressStateWithTickInterval.() -> Unit

A content lambda that receives a ProgressStateWithTickInterval as its receiver scope, which can be used to build a custom UI.