RepeatButtonState

@UnstableApi
class RepeatButtonState


State that holds all interactions to correctly deal with a UI component representing a Repeat On/All/Off button.

Summary

Public constructors

RepeatButtonState(
    player: Player,
    toggleModeSequence: List<@Player.RepeatMode Int>
)

Public functions

suspend Nothing

Subscribes to updates from Player.Events and listens to

Unit

Cycles to the next repeat mode in the toggleModeSequence.

Public properties

Boolean

determined by isCommandAvailable(Player.COMMAND_SET_REPEAT_MODE)

Int

determined by Player's repeatMode.

Public constructors

RepeatButtonState

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

Player object that operates as a state provider and can be control via clicking

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

An ordered list of Player.RepeatModes to cycle through when the button is clicked. Defaults to Player.REPEAT_MODE_OFF, Player.REPEAT_MODE_ONE, Player.REPEAT_MODE_ALL.

Public functions

observe

suspend fun observe(): Nothing

Subscribes to updates from Player.Events and listens to

onClick

fun onClick(): Unit

Cycles to the next repeat mode in the toggleModeSequence. If the current repeat mode from the Player is not among the modes in the provided toggleModeSequence, pick the first one.

Public properties

isEnabled

val isEnabledBoolean

determined by isCommandAvailable(Player.COMMAND_SET_REPEAT_MODE)

repeatModeState

val repeatModeStateInt

determined by Player's repeatMode. Note that there is no guarantee for this state to be one from toggleModeSequence. A button click in such case will toggle the mode into the first one of toggleModeSequence.