CommandButton.Builder


public final 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 methods

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

public 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
public Builder(@CommandButton.Icon int icon)

Creates a builder.

Parameters
@CommandButton.Icon int icon

The Icon that should be shown for this button.

Public methods

build

public CommandButton build()

Builds a CommandButton.

setCustomIconResId

@UnstableApi
@CanIgnoreReturnValue
public CommandButton.Builder setCustomIconResId(@DrawableRes int resId)

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

Parameters
Bundle extras

The extra Bundle.

Returns
CommandButton.Builder

This builder for chaining.

setIconResId

@CanIgnoreReturnValue
public CommandButton.Builder setIconResId(@DrawableRes int resId)

[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
public CommandButton.Builder setIconUri(Uri uri)

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

Parameters
@Player.Command int playerCommand

The Player.Command.

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.

Parameters
SessionCommand sessionCommand

The SessionCommand.

Returns
CommandButton.Builder

This builder for chaining.