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

PlayPauseButtonState(player: Player?, displayMode: @DisplayMode Int)

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
Boolean

true if player is null or shouldShowPlayButton is true.

Boolean

true if the replay indicator should be shown based on the displayMode.

Boolean

true if the retry indicator should be shown based on the displayMode.

Public constructors

PlayPauseButtonState

PlayPauseButtonState(
    player: Player?,
    displayMode: @DisplayMode Int = SHOW_BUFFERING_ALWAYS or SHOW_REPLAY_ON_ENDED or SHOW_RETRY_ON_ERROR
)
Parameters
displayMode: @DisplayMode Int = SHOW_BUFFERING_ALWAYS or SHOW_REPLAY_ON_ENDED or SHOW_RETRY_ON_ERROR

The @DisplayMode specifying when to show buffering, replay, or retry.

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 isEnabled: Boolean

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.

showBuffering

val showBuffering: Boolean

showPlay

val showPlay: Boolean

true if player is null or shouldShowPlayButton is true. Note that showReplay and showRetry are further specifications of this state, meaning if either is true, showPlay will also be true. Callers may prefer to prioritize showing retry and replay indicators over a generic play indicator.

showReplay

val showReplay: Boolean

true if the replay indicator should be shown based on the displayMode.

showRetry

val showRetry: Boolean

true if the retry indicator should be shown based on the displayMode.