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.

It will have no effect if no suitable player method is available to handle the play request.

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. See shouldEnablePlayPauseButton for more details.

showPlay

val showPlayBoolean

true if player is null or shouldShowPlayButton is true.