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 Uri 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.

Public constructors

Builder

Builder()

[will be deprecated] Use Builder instead to define the Icon for this button. A separate resource id via setIconResId or setIconUri 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 Uri 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 or instead of setCustomIconResId for consumers that are capable of loading the 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.