CommandButton.Builder
class CommandButton.Builder
A builder for CommandButton.
Summary
Public constructors |
|---|
This function is deprecated. |
Builder(@CommandButton.Icon icon: Int)Creates a builder. |
Public functions |
|
|---|---|
CommandButton! |
build()Builds a |
CommandButton.Builder! |
Sets the fallback resource ID of an icon. |
CommandButton.Builder! |
@CanIgnoreReturnValueSets a display name of this button. |
CommandButton.Builder! |
@CanIgnoreReturnValueSets whether the button is enabled. |
CommandButton.Builder! |
@CanIgnoreReturnValueSets an extra |
CommandButton.Builder! |
@CanIgnoreReturnValueThis function is deprecated. The icon should be defined with the constructor |
CommandButton.Builder! |
@CanIgnoreReturnValueSets a fallback |
CommandButton.Builder! |
@CanIgnoreReturnValueSets the |
CommandButton.Builder! |
@UnstableApiSets the |
CommandButton.Builder! |
@CanIgnoreReturnValueSets the |
CommandButton.Builder! |
@CanIgnoreReturnValueSets the |
CommandButton.Builder! |
Sets the allowed |
Public constructors
Builder
Builder(@CommandButton.Icon icon: Int)
Creates a builder.
| Parameters | |
|---|---|
@CommandButton.Icon icon: Int |
The |
Public functions
setCustomIconResId
@CanIgnoreReturnValue
fun setCustomIconResId(resId: @DrawableRes Int): CommandButton.Builder!
Sets the fallback resource ID of an icon.
This is used when either the predefined icon is not available, or it's set to ICON_UNDEFINED.
| Parameters | |
|---|---|
resId: @DrawableRes Int |
The resource id of a custom icon. |
| Returns | |
|---|---|
CommandButton.Builder! |
This builder for chaining. |
setDisplayName
@CanIgnoreReturnValue
fun setDisplayName(displayName: CharSequence!): CommandButton.Builder!
Sets a display name of this button.
| Parameters | |
|---|---|
displayName: CharSequence! |
The display name. |
| Returns | |
|---|---|
CommandButton.Builder! |
This builder for chaining. |
setEnabled
@CanIgnoreReturnValue
fun setEnabled(enabled: Boolean): CommandButton.Builder!
Sets whether the button is enabled.
Note that this value will be set to false for MediaController instances if the corresponding command is not available to this controller (see setPlayerCommand and setSessionCommand).
The default value is true.
| Parameters | |
|---|---|
enabled: Boolean |
Whether the button is enabled. |
| Returns | |
|---|---|
CommandButton.Builder! |
This builder for chaining. |
setExtras
@CanIgnoreReturnValue
fun setExtras(extras: Bundle!): CommandButton.Builder!
Sets an extra Bundle of this button.
| Returns | |
|---|---|
CommandButton.Builder! |
This builder for chaining. |
setIconUri
@CanIgnoreReturnValue
fun setIconUri(uri: Uri!): CommandButton.Builder!
Sets a fallback content or resourceUri for the icon of this button.
Note that this Uri may be used when either the predefined icon is not available, or it's set to ICON_UNDEFINED. It can be used in addition to setCustomIconResId for consumers that are capable of loading the content or resource Uri.
| Parameters | |
|---|---|
uri: Uri! |
The uri to an icon. |
| Returns | |
|---|---|
CommandButton.Builder! |
This builder for chaining. |
setPlayerCommand
@CanIgnoreReturnValue
fun setPlayerCommand(@Player.Command playerCommand: Int): CommandButton.Builder!
Sets the Player.Command that is required to be available when the button is clicked.
Cannot set this if a session command is already set via setSessionCommand.
The controller can execute the action associated with this command. See executeAction for a list of supported actions. If the action requires an additional parameter, use setPlayerCommand instead.
| Parameters | |
|---|---|
@Player.Command playerCommand: Int |
The |
| Returns | |
|---|---|
CommandButton.Builder! |
This builder for chaining. |
setPlayerCommand
@UnstableApi
@CanIgnoreReturnValue
fun setPlayerCommand(@Player.Command playerCommand: Int, parameter: Any?): CommandButton.Builder!
Sets the Player.Command that is required to be available when the button is clicked.
Cannot set this if a session command is already set via setSessionCommand.
The controller can execute the action associated with this command. See executeAction for a list of supported actions. If the action requires no additional parameter, use setPlayerCommand instead.
| Parameters | |
|---|---|
@Player.Command playerCommand: Int |
The |
parameter: Any? |
The parameter required to execute the action associated with this command. See |
| Returns | |
|---|---|
CommandButton.Builder! |
This builder for chaining. |
setSessionCommand
@CanIgnoreReturnValue
fun setSessionCommand(sessionCommand: SessionCommand!): CommandButton.Builder!
Sets the SessionCommand that is required to be available when the button is clicked.
Cannot set this if a player command is already set via setPlayerCommand.
The controller can execute the action associated with this command. See executeAction for a list of supported actions. If the action requires an additional parameter, use setSessionCommand instead.
| Parameters | |
|---|---|
sessionCommand: SessionCommand! |
The |
| Returns | |
|---|---|
CommandButton.Builder! |
This builder for chaining. |
setSessionCommand
@CanIgnoreReturnValue
@UnstableApi
fun setSessionCommand(sessionCommand: SessionCommand!, parameter: Any?): CommandButton.Builder!
Sets the SessionCommand that is required to be available when the button is clicked.
Cannot set this if a player command is already set via setPlayerCommand.
The controller can execute the action associated with this command. See executeAction for a list of supported actions. If the action requires no additional parameter, use setSessionCommand instead.
| Parameters | |
|---|---|
sessionCommand: SessionCommand! |
The |
parameter: Any? |
The parameter required to execute the action associated with this command. See |
| Returns | |
|---|---|
CommandButton.Builder! |
This builder for chaining. |
setSlots
@UnstableApi
@CanIgnoreReturnValue
fun setSlots(@CommandButton.Slot slots: IntArray!): CommandButton.Builder!
Sets the allowed Slot positions for this button.
The button is only allowed in the defined slots. If none of the slots can display the button, either because the slots do not exist, are already occupied or the UI surface does not allow the specific type of button in these slots, the button will not be displayed at all.
When multiple slots are provided, they define a preference order. The button will be placed in the first slot in the list that exists, isn't already occupied and that allows this type of button.
When not specified, the default value depends on the associated player command and the Icon set in the constructor:
COMMAND_PLAY_PAUSEand/orICON_PLAY,ICON_PAUSE:SLOT_CENTRALCOMMAND_SEEK_TO_PREVIOUS,COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM,COMMAND_SEEK_BACKand/orICON_PREVIOUS,ICON_SKIP_BACK,ICON_REWIND:SLOT_BACKCOMMAND_SEEK_TO_NEXT,COMMAND_SEEK_TO_NEXT_MEDIA_ITEM,COMMAND_SEEK_FORWARDand/orICON_NEXT,ICON_SKIP_FORWARD,ICON_FAST_FORWARD:SLOT_FORWARD- Anything else:
SLOT_OVERFLOW
| Parameters | |
|---|---|
@CommandButton.Slot slots: IntArray! |
The list of allowed |
| Returns | |
|---|---|
CommandButton.Builder! |
This builder for chaining. |