CommandButton.Builder


class CommandButton.Builder


A builder for CommandButton.

Summary

Public constructors

[will be deprecated] Use Builder instead to define the Icon for this button.

Creates a builder.

Public functions

CommandButton!

Builds a CommandButton.

CommandButton.Builder!

Sets the resource id of an icon that is used when the predefined Icon is not available or set to ICON_UNDEFINED.

CommandButton.Builder!

Sets a display name of this button.

CommandButton.Builder!

Sets whether the button is enabled.

CommandButton.Builder!

Sets an extra Bundle of this button.

CommandButton.Builder!

[will be deprecated] The icon should be defined with the constructor Icon parameter in Builder instead.

CommandButton.Builder!

Sets a content or resourceUri for the icon of this button.

CommandButton.Builder!

Sets the Player.Command that is required to be available when the button is clicked.

CommandButton.Builder!

Sets the SessionCommand that is required to be available when the button is clicked.

CommandButton.Builder!

Sets the allowed Slot positions for this button.

Public constructors

Builder

Builder()

[will be deprecated] Use Builder instead to define the Icon for this button. A separate resource id via setIconResId is no longer required unless for ICON_UNDEFINED.

Builder

@UnstableApi
Builder(@CommandButton.Icon icon: Int)

Creates a builder.

Parameters
@CommandButton.Icon icon: Int

The Icon that should be shown for this button.

Public functions

build

fun build(): CommandButton!

Builds a CommandButton.

setCustomIconResId

@UnstableApi
@CanIgnoreReturnValue
fun setCustomIconResId(resId: @DrawableRes Int): CommandButton.Builder!

Sets the resource id of an icon that is used when the predefined Icon is not available or 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.

Parameters
extras: Bundle!

The extra Bundle.

Returns
CommandButton.Builder!

This builder for chaining.

setIconResId

@CanIgnoreReturnValue
fun setIconResId(resId: @DrawableRes Int): CommandButton.Builder!

[will be deprecated] The icon should be defined with the constructor Icon parameter in Builder instead. Only in case the existing list of icons is not sufficient, use ICON_UNDEFINED and set a separate resource id with setCustomIconResId.

setIconUri

@UnstableApi
@CanIgnoreReturnValue
fun setIconUri(uri: Uri!): CommandButton.Builder!

Sets a content or resourceUri for the icon of this button.

Note that this Uri may be used when the predefined Icon is not available or 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.

Parameters
@Player.Command playerCommand: Int

The Player.Command.

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.

Parameters
sessionCommand: SessionCommand!

The SessionCommand.

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:

Parameters
@CommandButton.Slot slots: IntArray!

The list of allowed Slot positions. Must not be empty.

Returns
CommandButton.Builder!

This builder for chaining.