PlayPauseButtonState

@UnstableApi
class PlayPauseButtonState


State that converts the necessary information from the Player to correctly deal with a UI component representing a PlayPause button.

Summary

Public constructors

Public functions

suspend Unit

Subscribes to updates from Player.Events and listens to

Unit

Handles the interaction with the PlayPause button according to the current state of the Player.

Public properties

Boolean

true if player is not null, Player.COMMAND_PLAY_PAUSE is available and we have something in the Timeline to play.

Boolean

true if player is null or shouldShowPlayButton is true.

Public constructors

PlayPauseButtonState

PlayPauseButtonState(player: Player?)

Public functions

observe

suspend fun observe(): Unit

Subscribes to updates from Player.Events and listens to

onClick

fun onClick(): Unit

Handles the interaction with the PlayPause button according to the current state of the Player.

The Player update that follows can take a form of Player.play, Player.pause, Player.prepare or Player.seekToDefaultPosition.

This method must only be programmatically called if the state is enabled. However, it can be freely provided into containers that take care of skipping the onClick if a particular UI node is not enabled (see Compose Clickable Modifier).

Public properties

isEnabled

val isEnabledBoolean

true if player is not null, Player.COMMAND_PLAY_PAUSE is available and we have something in the Timeline to play.

showPlay

val showPlayBoolean

true if player is null or shouldShowPlayButton is true.