RepeatButton

Functions summary

Unit
@UnstableApi
@Composable
RepeatButton(
    player: Player?,
    modifier: Modifier,
    toggleModeSequence: List<@Player.RepeatMode Int>,
    imageVector: RepeatButtonState.() -> ImageVector,
    contentDescription: @Composable RepeatButtonState.() -> String,
    colors: IconButtonColors,
    tint: Color,
    onClick: RepeatButtonState.() -> Unit
)

A Material3 IconButton that toggles the repeat mode of the player.

Unit
@UnstableApi
@Composable
RepeatButton(
    player: Player?,
    modifier: Modifier,
    toggleModeSequence: List<@Player.RepeatMode Int>,
    painter: @Composable RepeatButtonState.() -> Painter,
    contentDescription: @Composable RepeatButtonState.() -> String,
    colors: IconButtonColors,
    tint: Color,
    onClick: RepeatButtonState.() -> Unit
)

A Material3 IconButton that toggles the repeat mode of the player.

Functions

@UnstableApi
@Composable
fun RepeatButton(
    player: Player?,
    modifier: Modifier = Modifier,
    toggleModeSequence: List<@Player.RepeatMode Int> = listOf(Player.REPEAT_MODE_OFF, Player.REPEAT_MODE_ONE, Player.REPEAT_MODE_ALL),
    imageVector: RepeatButtonState.() -> ImageVector,
    contentDescription: @Composable RepeatButtonState.() -> String = defaultRepeatModeContentDescription,
    colors: IconButtonColors = IconButtonDefaults.iconButtonColors(),
    tint: Color = Color.Unspecified,
    onClick: RepeatButtonState.() -> Unit = RepeatButtonState::onClick
): Unit

A Material3 IconButton that toggles the repeat mode of the player.

When clicked, it cycles through the available repeat modes in the order defined by toggleModeSequence. The button's state (e.g., whether it's enabled and the current repeat mode icon) is managed by a RepeatButtonState instance derived from the provided player.

Parameters
player: Player?

The Player to control.

modifier: Modifier = Modifier

The Modifier to be applied to the button.

toggleModeSequence: List<@Player.RepeatMode Int> = listOf(Player.REPEAT_MODE_OFF, Player.REPEAT_MODE_ONE, Player.REPEAT_MODE_ALL)

The sequence of repeat modes to cycle through when the button is clicked.

imageVector: RepeatButtonState.() -> ImageVector

The supplier for ImageVector used for the icon displayed on the button. This is a composable lambda with RepeatButtonState as its receiver, allowing the icon to be updated based on the button's current state (e.g. RepeatButtonState.repeatModeState).

contentDescription: @Composable RepeatButtonState.() -> String = defaultRepeatModeContentDescription

The content description for accessibility purposes.

colors: IconButtonColors = IconButtonDefaults.iconButtonColors()

IconButtonColors that will be used to resolve the colors used for this icon button in different states. See IconButtonDefaults.iconButtonColors.

tint: Color = Color.Unspecified

Tint to be applied to imageVector. If Color.Unspecified is provided, then no tint is applied.

onClick: RepeatButtonState.() -> Unit = RepeatButtonState::onClick

The action to be performed when the button is clicked. This lambda has RepeatButtonState as its receiver, providing access to the button's current state (e.g., RepeatButtonState.isEnabled). The default behavior is to call RepeatButtonState.onClick, which updates the player's repeat mode. Consumers can customize this behavior:

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

  • To completely override the default behavior, implement your custom logic without calling this.onClick(). Note that in this case, the button might still be enabled based on the player state, so ensure your custom logic handles cases where modifying the repeat mode is not possible.

@UnstableApi
@Composable
fun RepeatButton(
    player: Player?,
    modifier: Modifier = Modifier,
    toggleModeSequence: List<@Player.RepeatMode Int> = listOf(Player.REPEAT_MODE_OFF, Player.REPEAT_MODE_ONE, Player.REPEAT_MODE_ALL),
    painter: @Composable RepeatButtonState.() -> Painter = defaultRepeatModePainterIcon,
    contentDescription: @Composable RepeatButtonState.() -> String = defaultRepeatModeContentDescription,
    colors: IconButtonColors = IconButtonDefaults.iconButtonColors(),
    tint: Color = Color.Unspecified,
    onClick: RepeatButtonState.() -> Unit = RepeatButtonState::onClick
): Unit

A Material3 IconButton that toggles the repeat mode of the player.

When clicked, it cycles through the available repeat modes in the order defined by toggleModeSequence. The button's state (e.g., whether it's enabled and the current repeat mode icon) is managed by a RepeatButtonState instance derived from the provided player.

Parameters
player: Player?

The Player to control.

modifier: Modifier = Modifier

The Modifier to be applied to the button.

toggleModeSequence: List<@Player.RepeatMode Int> = listOf(Player.REPEAT_MODE_OFF, Player.REPEAT_MODE_ONE, Player.REPEAT_MODE_ALL)

The sequence of repeat modes to cycle through when the button is clicked.

painter: @Composable RepeatButtonState.() -> Painter = defaultRepeatModePainterIcon

The supplier for Painter used for the icon displayed on the button. This is a composable lambda with RepeatButtonState as its receiver, allowing the icon to be updated based on the button's current state (e.g. RepeatButtonState.repeatModeState).

contentDescription: @Composable RepeatButtonState.() -> String = defaultRepeatModeContentDescription

The content description for accessibility purposes.

colors: IconButtonColors = IconButtonDefaults.iconButtonColors()

IconButtonColors that will be used to resolve the colors used for this icon button in different states. See IconButtonDefaults.iconButtonColors.

tint: Color = Color.Unspecified

Tint to be applied to painter. If Color.Unspecified is provided, then no tint is applied.

onClick: RepeatButtonState.() -> Unit = RepeatButtonState::onClick

The action to be performed when the button is clicked. This lambda has RepeatButtonState as its receiver, providing access to the button's current state (e.g., RepeatButtonState.isEnabled). The default behavior is to call RepeatButtonState.onClick, which updates the player's repeat mode. Consumers can customize this behavior:

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

  • To completely override the default behavior, implement your custom logic without calling this.onClick(). Note that in this case, the button might still be enabled based on the player state, so ensure your custom logic handles cases where modifying the repeat mode is not possible.