CommandButton.Builder
public final class CommandButton.Builder
A builder for CommandButton.
Summary
Public constructors |
|---|
This method is deprecated. |
Builder(@CommandButton.Icon int icon)Creates a builder. |
Public constructors
Builder
public Builder(@CommandButton.Icon int icon)
Creates a builder.
| Parameters | |
|---|---|
@CommandButton.Icon int icon |
The |
Public methods
setCustomIconResId
@CanIgnoreReturnValue
public CommandButton.Builder setCustomIconResId(@DrawableRes int resId)
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 | |
|---|---|
@DrawableRes int resId |
The resource id of a custom icon. |
| Returns | |
|---|---|
CommandButton.Builder |
This builder for chaining. |
setDisplayName
@CanIgnoreReturnValue
public CommandButton.Builder setDisplayName(CharSequence displayName)
Sets a display name of this button.
| Parameters | |
|---|---|
CharSequence displayName |
The display name. |
| Returns | |
|---|---|
CommandButton.Builder |
This builder for chaining. |
setEnabled
@CanIgnoreReturnValue
public CommandButton.Builder setEnabled(boolean enabled)
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 | |
|---|---|
boolean enabled |
Whether the button is enabled. |
| Returns | |
|---|---|
CommandButton.Builder |
This builder for chaining. |
setExtras
@CanIgnoreReturnValue
public CommandButton.Builder setExtras(Bundle extras)
Sets an extra Bundle of this button.
| Returns | |
|---|---|
CommandButton.Builder |
This builder for chaining. |
setIconUri
@CanIgnoreReturnValue
public CommandButton.Builder setIconUri(Uri uri)
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
public CommandButton.Builder setPlayerCommand(@Player.Command int playerCommand)
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 int playerCommand |
The |
| Returns | |
|---|---|
CommandButton.Builder |
This builder for chaining. |
setPlayerCommand
@UnstableApi
@CanIgnoreReturnValue
public CommandButton.Builder setPlayerCommand(
@Player.Command int playerCommand,
@Nullable Object parameter
)
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 int playerCommand |
The |
@Nullable Object parameter |
The parameter required to execute the action associated with this command. See |
| Returns | |
|---|---|
CommandButton.Builder |
This builder for chaining. |
setSessionCommand
@CanIgnoreReturnValue
public CommandButton.Builder setSessionCommand(SessionCommand sessionCommand)
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
public CommandButton.Builder setSessionCommand(
SessionCommand sessionCommand,
@Nullable Object parameter
)
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 |
@Nullable Object parameter |
The parameter required to execute the action associated with this command. See |
| Returns | |
|---|---|
CommandButton.Builder |
This builder for chaining. |
setSlots
@UnstableApi
@CanIgnoreReturnValue
public CommandButton.Builder setSlots(@CommandButton.Slot int[] slots)
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 int[] slots |
The list of allowed |
| Returns | |
|---|---|
CommandButton.Builder |
This builder for chaining. |