public final class

CommandButton.Builder

extends java.lang.Object

 java.lang.Object

↳androidx.media3.session.CommandButton.Builder

Overview

A builder for CommandButton.

Summary

Constructors
publicBuilder()

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

publicBuilder(int icon)

Creates a builder.

Methods
public CommandButtonbuild()

Builds a CommandButton.

public CommandButton.BuildersetCustomIconResId(int resId)

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

public CommandButton.BuildersetDisplayName(java.lang.CharSequence displayName)

Sets a display name of this button.

public CommandButton.BuildersetEnabled(boolean enabled)

Sets whether the button is enabled.

public CommandButton.BuildersetExtras(Bundle extras)

Sets an extra of this button.

public CommandButton.BuildersetIconResId(int resId)

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

public CommandButton.BuildersetIconUri(Uri uri)

Sets a for the icon of this button.

public CommandButton.BuildersetPlayerCommand(int playerCommand)

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

public CommandButton.BuildersetSessionCommand(SessionCommand sessionCommand)

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

from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructors

public Builder()

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

public Builder(int icon)

Creates a builder.

Parameters:

icon: The CommandButton.Icon that should be shown for this button.

Methods

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 CommandButton.Builder.setPlayerCommand(int).

Parameters:

sessionCommand: The SessionCommand.

Returns:

This builder for chaining.

public CommandButton.Builder setPlayerCommand(int playerCommand)

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

Cannot set this if a session command is already set via CommandButton.Builder.setSessionCommand(SessionCommand).

Parameters:

playerCommand: The .

Returns:

This builder for chaining.

public CommandButton.Builder setIconResId(int resId)

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

public CommandButton.Builder setCustomIconResId(int resId)

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

Parameters:

resId: The resource id of a custom icon.

Returns:

This builder for chaining.

public CommandButton.Builder setIconUri(Uri uri)

Sets a for the icon of this button.

Note that this may be used when the predefined CommandButton.Icon is not available or set to CommandButton.ICON_UNDEFINED. It can be used in addition or instead of CommandButton.Builder.setCustomIconResId(int) for consumers that are capable of loading the .

Parameters:

uri: The uri to an icon.

Returns:

This builder for chaining.

public CommandButton.Builder setDisplayName(java.lang.CharSequence displayName)

Sets a display name of this button.

Parameters:

displayName: The display name.

Returns:

This builder for chaining.

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 CommandButton.Builder.setPlayerCommand(int) and CommandButton.Builder.setSessionCommand(SessionCommand)).

The default value is true.

Parameters:

enabled: Whether the button is enabled.

Returns:

This builder for chaining.

public CommandButton.Builder setExtras(Bundle extras)

Sets an extra of this button.

Parameters:

extras: The extra .

Returns:

This builder for chaining.

public CommandButton build()

Builds a CommandButton.