public final class

MediaSession.CommandButton.Builder

extends java.lang.Object

 java.lang.Object

↳androidx.media2.session.MediaSession.CommandButton.Builder

Overview

Builder for MediaSession.CommandButton.

Summary

Constructors
publicBuilder()

Methods
public MediaSession.CommandButtonbuild()

Builds the MediaSession.CommandButton.

public MediaSession.CommandButton.BuildersetCommand(SessionCommand command)

Sets the SessionCommand that would be sent to the session when the button is clicked.

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

Sets the display name of the button.

public MediaSession.CommandButton.BuildersetEnabled(boolean enabled)

Sets whether the button is enabled.

public MediaSession.CommandButton.BuildersetExtras(Bundle extras)

Sets the extras of the button.

public MediaSession.CommandButton.BuildersetIconResId(int resId)

Sets the bitmap-type (e.g.

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

Constructors

public Builder()

Methods

Sets the SessionCommand that would be sent to the session when the button is clicked.

Parameters:

command: session command

public MediaSession.CommandButton.Builder setIconResId(int resId)

Sets the bitmap-type (e.g. PNG) icon resource id of the button.

None bitmap type (e.g. VectorDrawabale) may cause unexpected behavior when it's sent to MediaController app, so please avoid using it especially for the older platform (API < 21).

Parameters:

resId: resource id of the button

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

Sets the display name of the button.

Parameters:

displayName: display name of the button

public MediaSession.CommandButton.Builder setEnabled(boolean enabled)

Sets whether the button is enabled. Can be false to indicate that the button should be shown but isn't clickable.

Parameters:

enabled: true if the button is enabled and ready. false otherwise.

public MediaSession.CommandButton.Builder setExtras(Bundle extras)

Sets the extras of the button.

Parameters:

extras: extras information of the button

Builds the MediaSession.CommandButton.

Returns:

a new MediaSession.CommandButton