An ActionMediaControl that cycles between multiple states.

Similar to SingleActionMediaControl, but when clicked it always launches the current action.

When launching the currentAction, the expectation is that the source will replace it with another one from the MediaControlContext.actions list in context. When the currentAction changes, both the performed action and the drawable should in principle change to reflect the new action.

For example: a media source with a "change playback speed" feature, made of two states, reflected by Actions with ID 'speed_1x' and 'speed_2x'; in the application, a MultipleActionMediaControl has those two action IDs in its actions list.

The example shows that the behavior of the specific feature from the media source must be known in advance, to correctly reflect its state in the MultipleActionMediaControl.

This class makes no assumption about the exposed drawable; subclasses must implement their own behavior, for example changing it according to which currentAction is set.


Link copied to clipboard
constructor(context: MediaControlContext)


Link copied to clipboard

Supported action currently present in the context. null if none of the actions are currently available.

Link copied to clipboard
open override val isAvailable: LiveData<Boolean>

The media control is available when any of the actions present in the context are.

Inherited properties

Link copied to clipboard
open val actionType: TtButton.ActionType

The type of the control, which is used by TtButton to apply one of the predefined styles. May be overridden in subclasses in order to apply a specialized style. TtButton.ActionType.TERTIARY is used by default as the most neutral option.

Link copied to clipboard
abstract val drawable: LiveData<DrawableResolver?>

The icon of the control, which is used to represent the control to the user.

Link copied to clipboard

Whether the control is visible. This can be used to show the control as disabled. Defaults to isAvailable.

Link copied to clipboard
open val tag: Int?

Int resource ID to tag this MediaControl with. The tag can be used in tests to refer to one or more controls with the same tag.

Link copied to clipboard
open val text: LiveData<StringResolver>

Textual description of the control.


Link copied to clipboard
open override fun toAction(): Action

Return the current action to launch.

Inherited functions

Link copied to clipboard
open fun asIconTtButtonViewModel(): LiveData<TtButtonViewModel>

Creates a TtButtonViewModel representation of this MediaControl as an icon button. This implies only the drawable is included.

Link copied to clipboard
open override fun launch(): Boolean

Launch this action using the current action context. The Action, determined by toAction, is performed using the current context. If the action is not currently available, the operation will fail.