LiveButton

Functions summary

Unit
@UnstableApi
@Composable
LiveButton(
    player: Player?,
    modifier: Modifier,
    liveEdgeThresholdMs: Long,
    shape: Shape,
    colors: ButtonColors,
    elevation: ButtonElevation?,
    border: BorderStroke?,
    contentPadding: PaddingValues,
    interactionSource: MutableInteractionSource?,
    scope: CoroutineScope,
    onClick: ProgressStateWithTickInterval.() -> Unit,
    content: @Composable ProgressStateWithTickInterval.() -> Unit
)

A Material3 TextButton that is only visible during live streams when seeking to the default position is available.

Functions

@UnstableApi
@Composable
fun LiveButton(
    player: Player?,
    modifier: Modifier = Modifier,
    liveEdgeThresholdMs: Long = DEFAULT_LIVE_EDGE_THRESHOLD_MS,
    shape: Shape = ButtonDefaults.textShape,
    colors: ButtonColors = LiveButtonDefaults.textButtonColors(),
    elevation: ButtonElevation? = null,
    border: BorderStroke? = null,
    contentPadding: PaddingValues = PaddingValues(0.dp),
    interactionSource: MutableInteractionSource? = null,
    scope: CoroutineScope = rememberCoroutineScope(),
    onClick: ProgressStateWithTickInterval.() -> Unit = ProgressStateWithTickInterval::seekToDefaultPosition,
    content: @Composable ProgressStateWithTickInterval.() -> Unit = { Text(stringResource(R.string.live_button_text)) }
): Unit

A Material3 TextButton that is only visible during live streams when seeking to the default position is available. It indicates whether the playback is at the live edge and seeks to the default position (typically the live edge) when clicked while behind the live edge.

LiveButton
image

Parameters
player: Player?

The Player to control.

modifier: Modifier = Modifier

The Modifier to be applied to the button.

liveEdgeThresholdMs: Long = DEFAULT_LIVE_EDGE_THRESHOLD_MS

How far behind the target live offset, in milliseconds, playback can be while still being considered at the live edge. Without playback speed control the player typically settles a segment duration or more behind the target, so this should be larger than the expected segment duration. Defaults to 5000ms.

shape: Shape = ButtonDefaults.textShape

Defines the shape of this button's container, border (when border is not null), and shadow (when using elevation). See ButtonDefaults.textShape.

colors: ButtonColors = LiveButtonDefaults.textButtonColors()

ButtonColors that will be used to resolve the colors for this button in different states. Defaults to LiveButtonDefaults.textButtonColors.

elevation: ButtonElevation? = null

ButtonElevation used to resolve the elevation for this button in different states. A TextButton typically has no elevation. See ButtonDefaults.buttonElevation.

border: BorderStroke? = null

The border to draw around the container of this button.

contentPadding: PaddingValues = PaddingValues(0.dp)

The spacing values to apply internally between the container and the content. Defaults to PaddingValues(0.dp).

interactionSource: MutableInteractionSource? = null

An optional hoisted MutableInteractionSource for observing and emitting Interactions for this button. You can use this to change the button's appearance or preview the button in different states. Note that if null is provided, interactions will still happen internally.

scope: CoroutineScope = rememberCoroutineScope()

The CoroutineScope to use for listening to player progress updates.

onClick: ProgressStateWithTickInterval.() -> Unit = ProgressStateWithTickInterval::seekToDefaultPosition

The action to be performed when the button is clicked. This lambda has ProgressStateWithTickInterval as its receiver, providing access to the button's current state. The default behavior is to call ProgressStateWithTickInterval.seekToDefaultPosition. Consumers can customize this behavior:

  • To add custom logic while still performing the default action, call this.seekToDefaultPosition() within your lambda.

  • To completely override the default behavior, implement your custom logic without calling this.seekToDefaultPosition().

content: @Composable ProgressStateWithTickInterval.() -> Unit = { Text(stringResource(R.string.live_button_text)) }

A composable lambda with ProgressStateWithTickInterval as its receiver, allowing the content of the button to be customized.