PreviousButton

Functions summary

Unit
@UnstableApi
@Composable
PreviousButton(
    player: Player?,
    modifier: Modifier,
    imageVector: @Composable PreviousButtonState.() -> ImageVector,
    iconSize: Dp,
    contentDescription: @Composable PreviousButtonState.() -> String,
    shape: Shape,
    colors: IconButtonColors,
    tint: Color,
    interactionSource: MutableInteractionSource?,
    onClick: PreviousButtonState.() -> Unit
)

A Material3 IconButton that seeks to the previous media item.

Unit
@UnstableApi
@Composable
PreviousButton(
    player: Player?,
    modifier: Modifier,
    painter: @Composable PreviousButtonState.() -> Painter,
    iconSize: Dp,
    contentDescription: @Composable PreviousButtonState.() -> String,
    shape: Shape,
    colors: IconButtonColors,
    tint: Color,
    interactionSource: MutableInteractionSource?,
    onClick: PreviousButtonState.() -> Unit
)

A Material3 IconButton that seeks to the previous media item.

Functions

@UnstableApi
@Composable
fun PreviousButton(
    player: Player?,
    modifier: Modifier = Modifier,
    imageVector: @Composable PreviousButtonState.() -> ImageVector,
    iconSize: Dp = PlayerTokens.MediumIconSize,
    contentDescription: @Composable PreviousButtonState.() -> String = { stringResource(R.string.previous_button) },
    shape: Shape = IconButtonDefaults.standardShape,
    colors: IconButtonColors = IconButtonDefaults.iconButtonColors(),
    tint: Color = Color.Unspecified,
    interactionSource: MutableInteractionSource? = null,
    onClick: PreviousButtonState.() -> Unit = PreviousButtonState::onClick
): Unit

A Material3 IconButton that seeks to the previous media item.

When clicked, it attempts to advance the player to the previous media item in its current playlist. The button's state (e.g., whether it's enabled) is managed by a PreviousButtonState instance derived from the provided player.

Parameters
player: Player?

The Player to control.

modifier: Modifier = Modifier

The Modifier to be applied to the button.

imageVector: @Composable PreviousButtonState.() -> ImageVector

The supplier for ImageVector used for the icon displayed on the button.

iconSize: Dp = PlayerTokens.MediumIconSize

The size of the icon.

contentDescription: @Composable PreviousButtonState.() -> String = { stringResource(R.string.previous_button) }

The content description for accessibility purposes. Defaults to R.string.previous_button.

shape: Shape = IconButtonDefaults.standardShape

Defines the shape of this icon button's container. See IconButtonDefaults.standardShape.

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.

interactionSource: MutableInteractionSource? = null

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

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

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

  • To add custom logic while still performing the default previous 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 seeking is not possible.

@UnstableApi
@Composable
fun PreviousButton(
    player: Player?,
    modifier: Modifier = Modifier,
    painter: @Composable PreviousButtonState.() -> Painter = { painterResource(R.drawable.media3_icon_previous) },
    iconSize: Dp = PlayerTokens.MediumIconSize,
    contentDescription: @Composable PreviousButtonState.() -> String = { stringResource(R.string.previous_button) },
    shape: Shape = IconButtonDefaults.standardShape,
    colors: IconButtonColors = IconButtonDefaults.iconButtonColors(),
    tint: Color = Color.Unspecified,
    interactionSource: MutableInteractionSource? = null,
    onClick: PreviousButtonState.() -> Unit = PreviousButtonState::onClick
): Unit

A Material3 IconButton that seeks to the previous media item.

PreviousButton
image

When clicked, it attempts to advance the player to the previous media item in its current playlist. The button's state (e.g., whether it's enabled) is managed by a PreviousButtonState instance derived from the provided player.

Parameters
player: Player?

The Player to control.

modifier: Modifier = Modifier

The Modifier to be applied to the button.

painter: @Composable PreviousButtonState.() -> Painter = { painterResource(R.drawable.media3_icon_previous) }

The supplier for Painter used for the icon displayed on the button. Defaults to R.drawable.media3_icon_previous.

iconSize: Dp = PlayerTokens.MediumIconSize

The size of the icon.

contentDescription: @Composable PreviousButtonState.() -> String = { stringResource(R.string.previous_button) }

The content description for accessibility purposes. Defaults to R.string.previous_button.

shape: Shape = IconButtonDefaults.standardShape

Defines the shape of this icon button's container. See IconButtonDefaults.standardShape.

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.

interactionSource: MutableInteractionSource? = null

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

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

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

  • To add custom logic while still performing the default previous 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 seeking is not possible.