MultipleActionMediaControl
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 media source starts by exposing the 'speed_1x' action in MediaControlContext.actions, and currentAction shows that one.
Clicking the control will launch the 'speed_1x' action from currentAction, and the source will increase its speed and starts exposing `speed_2x' in MediaControlContext.actions.
Clicking the control again will launch 'speed_2x' and the source then exposes again 'speed_1x'.
If none of the actions of the feature are available in MediaControlContext.actions, the control will have isAvailable set to
false
.
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.
Inherited properties
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.
Whether the control is visible. This can be used to show the control as disabled. Defaults to isAvailable.
Functions
Inherited functions
Creates a TtButtonViewModel representation of this MediaControl as an icon button. This implies only the drawable is included.