SessionCommand2

public final class SessionCommand2
extends Object implements VersionedParcelable

java.lang.Object
   ↳ androidx.media2.SessionCommand2


Define a command that a MediaController2 can send to a MediaSession2.

If getCommandCode() isn't COMMAND_CODE_CUSTOM), it's predefined command. If getCommandCode() is COMMAND_CODE_CUSTOM), it's custom command and getCustomCommand() shouldn't be null.

Summary

Constants

int COMMAND_CODE_CUSTOM

Command code for the custom command which can be defined by string action in the SessionCommand2.

int COMMAND_CODE_LIBRARY_GET_CHILDREN

Command code for MediaBrowser2.getChildren(String, int, int, Bundle).

int COMMAND_CODE_LIBRARY_GET_ITEM

Command code for MediaBrowser2.getItem(String).

int COMMAND_CODE_LIBRARY_GET_LIBRARY_ROOT

Command code for MediaBrowser2.getLibraryRoot(Bundle).

int COMMAND_CODE_LIBRARY_GET_SEARCH_RESULT

Command code for MediaBrowser2.getSearchResult(String, int, int, Bundle).

int COMMAND_CODE_LIBRARY_SEARCH

Command code for MediaBrowser2.search(String, Bundle).

int COMMAND_CODE_LIBRARY_SUBSCRIBE

Command code for MediaBrowser2.subscribe(String, Bundle).

int COMMAND_CODE_LIBRARY_UNSUBSCRIBE

Command code for MediaBrowser2.unsubscribe(String).

int COMMAND_CODE_PLAYBACK_PAUSE

Command code for MediaController2.pause().

int COMMAND_CODE_PLAYBACK_PLAY

Command code for MediaController2.play().

int COMMAND_CODE_PLAYBACK_PREPARE

Command code for MediaController2.prepare().

int COMMAND_CODE_PLAYBACK_RESET

Command code for MediaController2.reset().

int COMMAND_CODE_PLAYBACK_SEEK_TO

Command code for MediaController2.seekTo(long).

int COMMAND_CODE_PLAYBACK_SET_SPEED

Command code for MediaController2.setPlaybackSpeed(float)}.

int COMMAND_CODE_PLAYLIST_ADD_ITEM

Command code for MediaController2.addPlaylistItem(int, MediaItem2).

int COMMAND_CODE_PLAYLIST_GET_CURRENT_MEDIA_ITEM

Command code for MediaController2.getCurrentMediaItem().

int COMMAND_CODE_PLAYLIST_GET_LIST

Command code for MediaController2.getPlaylist().

int COMMAND_CODE_PLAYLIST_GET_LIST_METADATA

Command code for MediaController2.getPlaylistMetadata().

int COMMAND_CODE_PLAYLIST_REMOVE_ITEM

Command code for MediaController2.addPlaylistItem(int, MediaItem2).

int COMMAND_CODE_PLAYLIST_REPLACE_ITEM

Command code for MediaController2.replacePlaylistItem(int, MediaItem2).

int COMMAND_CODE_PLAYLIST_SET_LIST

Command code for MediaController2.setPlaylist(List, MediaMetadata2).

int COMMAND_CODE_PLAYLIST_SET_LIST_METADATA

Command code for MediaController2.updatePlaylistMetadata(MediaMetadata2).

int COMMAND_CODE_PLAYLIST_SET_REPEAT_MODE

Command code for MediaController2.setRepeatMode(int).

int COMMAND_CODE_PLAYLIST_SET_SHUFFLE_MODE

Command code for MediaController2.setShuffleMode(int).

int COMMAND_CODE_PLAYLIST_SKIP_TO_NEXT_ITEM

Command code for MediaController2.skipToNextItem().

int COMMAND_CODE_PLAYLIST_SKIP_TO_PLAYLIST_ITEM

Command code for MediaController2.skipToPlaylistItem(MediaItem2).

int COMMAND_CODE_PLAYLIST_SKIP_TO_PREV_ITEM

Command code for MediaController2.skipToPreviousItem().

int COMMAND_CODE_SESSION_FAST_FORWARD

Command code for MediaController2.fastForward().

int COMMAND_CODE_SESSION_PLAY_FROM_MEDIA_ID

Command code for MediaController2.playFromMediaId(String, Bundle).

int COMMAND_CODE_SESSION_PLAY_FROM_SEARCH

Command code for MediaController2.playFromSearch(String, Bundle).

int COMMAND_CODE_SESSION_PLAY_FROM_URI

Command code for MediaController2.playFromUri(Uri, Bundle).

int COMMAND_CODE_SESSION_PREPARE_FROM_MEDIA_ID

Command code for MediaController2.prepareFromMediaId(String, Bundle).

int COMMAND_CODE_SESSION_PREPARE_FROM_SEARCH

Command code for MediaController2.prepareFromSearch(String, Bundle).

int COMMAND_CODE_SESSION_PREPARE_FROM_URI

Command code for MediaController2.prepareFromUri(Uri, Bundle).

int COMMAND_CODE_SESSION_REWIND

Command code for MediaController2.rewind().

int COMMAND_CODE_SESSION_SELECT_ROUTE

Command code for MediaController2.selectRoute(Bundle)}

int COMMAND_CODE_SESSION_SET_RATING

Command code for MediaController2.setRating(String, Rating2).

int COMMAND_CODE_SESSION_SUBSCRIBE_ROUTES_INFO

Command code for MediaController2.subscribeRoutesInfo()

int COMMAND_CODE_SESSION_UNSUBSCRIBE_ROUTES_INFO

Command code for MediaController2.unsubscribeRoutesInfo()

int COMMAND_CODE_VOLUME_ADJUST_VOLUME

Command code for MediaController2.adjustVolume(int, int).

int COMMAND_CODE_VOLUME_SET_VOLUME

Command code for MediaController2.setVolumeTo(int, int).

Public constructors

SessionCommand2(int commandCode)

Constructor for creating a predefined command.

SessionCommand2(String action, Bundle extras)

Constructor for creating a custom command.

Public methods

boolean equals(Object obj)
int getCommandCode()

Gets the command code of a predefined command.

String getCustomCommand()

Gets the action of a custom command.

Bundle getExtras()

Gets the extra bundle of a custom command.

int hashCode()

Inherited methods

Constants

COMMAND_CODE_CUSTOM

public static final int COMMAND_CODE_CUSTOM

Command code for the custom command which can be defined by string action in the SessionCommand2.

Constant Value: 0 (0x00000000)

COMMAND_CODE_LIBRARY_GET_CHILDREN

public static final int COMMAND_CODE_LIBRARY_GET_CHILDREN

Command code for MediaBrowser2.getChildren(String, int, int, Bundle).

Constant Value: 29 (0x0000001d)

COMMAND_CODE_LIBRARY_GET_ITEM

public static final int COMMAND_CODE_LIBRARY_GET_ITEM

Command code for MediaBrowser2.getItem(String).

Constant Value: 30 (0x0000001e)

COMMAND_CODE_LIBRARY_GET_LIBRARY_ROOT

public static final int COMMAND_CODE_LIBRARY_GET_LIBRARY_ROOT

Command code for MediaBrowser2.getLibraryRoot(Bundle).

Constant Value: 31 (0x0000001f)

COMMAND_CODE_LIBRARY_GET_SEARCH_RESULT

public static final int COMMAND_CODE_LIBRARY_GET_SEARCH_RESULT

Command code for MediaBrowser2.getSearchResult(String, int, int, Bundle).

Constant Value: 32 (0x00000020)

public static final int COMMAND_CODE_LIBRARY_SEARCH

Command code for MediaBrowser2.search(String, Bundle).

Constant Value: 33 (0x00000021)

COMMAND_CODE_LIBRARY_SUBSCRIBE

public static final int COMMAND_CODE_LIBRARY_SUBSCRIBE

Command code for MediaBrowser2.subscribe(String, Bundle).

Constant Value: 34 (0x00000022)

COMMAND_CODE_LIBRARY_UNSUBSCRIBE

public static final int COMMAND_CODE_LIBRARY_UNSUBSCRIBE

Command code for MediaBrowser2.unsubscribe(String).

Constant Value: 35 (0x00000023)

COMMAND_CODE_PLAYBACK_PAUSE

public static final int COMMAND_CODE_PLAYBACK_PAUSE

Command code for MediaController2.pause().

Command would be sent directly to the player if the session doesn't reject the request through the MediaSession2.SessionCallback.onCommandRequest(MediaSession2, ControllerInfo, SessionCommand2).

Constant Value: 2 (0x00000002)

COMMAND_CODE_PLAYBACK_PLAY

public static final int COMMAND_CODE_PLAYBACK_PLAY

Command code for MediaController2.play().

Command would be sent directly to the player if the session doesn't reject the request through the MediaSession2.SessionCallback.onCommandRequest(MediaSession2, ControllerInfo, SessionCommand2).

Constant Value: 1 (0x00000001)

COMMAND_CODE_PLAYBACK_PREPARE

public static final int COMMAND_CODE_PLAYBACK_PREPARE

Command code for MediaController2.prepare().

Command would be sent directly to the player if the session doesn't reject the request through the MediaSession2.SessionCallback.onCommandRequest(MediaSession2, ControllerInfo, SessionCommand2).

Constant Value: 6 (0x00000006)

COMMAND_CODE_PLAYBACK_RESET

public static final int COMMAND_CODE_PLAYBACK_RESET

Command code for MediaController2.reset().

Command would be sent directly to the player if the session doesn't reject the request through the MediaSession2.SessionCallback.onCommandRequest(MediaSession2, ControllerInfo, SessionCommand2).

Constant Value: 3 (0x00000003)

COMMAND_CODE_PLAYBACK_SEEK_TO

public static final int COMMAND_CODE_PLAYBACK_SEEK_TO

Command code for MediaController2.seekTo(long).

Command would be sent directly to the player if the session doesn't reject the request through the MediaSession2.SessionCallback.onCommandRequest(MediaSession2, ControllerInfo, SessionCommand2).

Constant Value: 9 (0x00000009)

COMMAND_CODE_PLAYBACK_SET_SPEED

public static final int COMMAND_CODE_PLAYBACK_SET_SPEED

Command code for MediaController2.setPlaybackSpeed(float)}.

Command would be sent directly to the player if the session doesn't reject the request through the MediaSession2.SessionCallback.onCommandRequest(MediaSession2, ControllerInfo, SessionCommand2).

Constant Value: 39 (0x00000027)

COMMAND_CODE_PLAYLIST_ADD_ITEM

public static final int COMMAND_CODE_PLAYLIST_ADD_ITEM

Command code for MediaController2.addPlaylistItem(int, MediaItem2).

Command would be sent directly to the playlist agent if the session doesn't reject the request through the MediaSession2.SessionCallback.onCommandRequest(MediaSession2, ControllerInfo, SessionCommand2).

Constant Value: 15 (0x0000000f)

COMMAND_CODE_PLAYLIST_GET_CURRENT_MEDIA_ITEM

public static final int COMMAND_CODE_PLAYLIST_GET_CURRENT_MEDIA_ITEM

Command code for MediaController2.getCurrentMediaItem(). This will expose metadata information to the controller.

Constant Value: 20 (0x00000014)

COMMAND_CODE_PLAYLIST_GET_LIST

public static final int COMMAND_CODE_PLAYLIST_GET_LIST

Command code for MediaController2.getPlaylist(). This will expose metadata information to the controller.

Constant Value: 18 (0x00000012)

COMMAND_CODE_PLAYLIST_GET_LIST_METADATA

public static final int COMMAND_CODE_PLAYLIST_GET_LIST_METADATA

Command code for MediaController2.getPlaylistMetadata(). This will expose metadata information to the controller.

Constant Value: 20 (0x00000014)

COMMAND_CODE_PLAYLIST_REMOVE_ITEM

public static final int COMMAND_CODE_PLAYLIST_REMOVE_ITEM

Command code for MediaController2.addPlaylistItem(int, MediaItem2).

Command would be sent directly to the playlist agent if the session doesn't reject the request through the MediaSession2.SessionCallback.onCommandRequest(MediaSession2, ControllerInfo, SessionCommand2).

Constant Value: 16 (0x00000010)

COMMAND_CODE_PLAYLIST_REPLACE_ITEM

public static final int COMMAND_CODE_PLAYLIST_REPLACE_ITEM

Command code for MediaController2.replacePlaylistItem(int, MediaItem2).

Command would be sent directly to the playlist agent if the session doesn't reject the request through the MediaSession2.SessionCallback.onCommandRequest(MediaSession2, ControllerInfo, SessionCommand2).

Constant Value: 17 (0x00000011)

COMMAND_CODE_PLAYLIST_SET_LIST

public static final int COMMAND_CODE_PLAYLIST_SET_LIST

Command code for MediaController2.setPlaylist(List, MediaMetadata2).

Command would be sent directly to the playlist agent if the session doesn't reject the request through the MediaSession2.SessionCallback.onCommandRequest(MediaSession2, ControllerInfo, SessionCommand2).

Constant Value: 19 (0x00000013)

COMMAND_CODE_PLAYLIST_SET_LIST_METADATA

public static final int COMMAND_CODE_PLAYLIST_SET_LIST_METADATA

Command code for MediaController2.updatePlaylistMetadata(MediaMetadata2).

Command would be sent directly to the playlist agent if the session doesn't reject the request through the MediaSession2.SessionCallback.onCommandRequest(MediaSession2, ControllerInfo, SessionCommand2).

Constant Value: 21 (0x00000015)

COMMAND_CODE_PLAYLIST_SET_REPEAT_MODE

public static final int COMMAND_CODE_PLAYLIST_SET_REPEAT_MODE

Command code for MediaController2.setRepeatMode(int).

Command would be sent directly to the playlist agent if the session doesn't reject the request through the MediaSession2.SessionCallback.onCommandRequest(MediaSession2, ControllerInfo, SessionCommand2).

Constant Value: 14 (0x0000000e)

COMMAND_CODE_PLAYLIST_SET_SHUFFLE_MODE

public static final int COMMAND_CODE_PLAYLIST_SET_SHUFFLE_MODE

Command code for MediaController2.setShuffleMode(int).

Command would be sent directly to the playlist agent if the session doesn't reject the request through the MediaSession2.SessionCallback.onCommandRequest(MediaSession2, ControllerInfo, SessionCommand2).

Constant Value: 13 (0x0000000d)

COMMAND_CODE_PLAYLIST_SKIP_TO_NEXT_ITEM

public static final int COMMAND_CODE_PLAYLIST_SKIP_TO_NEXT_ITEM

Command code for MediaController2.skipToNextItem().

Command would be sent directly to the playlist agent if the session doesn't reject the request through the MediaSession2.SessionCallback.onCommandRequest(MediaSession2, ControllerInfo, SessionCommand2).

Constant Value: 4 (0x00000004)

COMMAND_CODE_PLAYLIST_SKIP_TO_PLAYLIST_ITEM

public static final int COMMAND_CODE_PLAYLIST_SKIP_TO_PLAYLIST_ITEM

Command code for MediaController2.skipToPlaylistItem(MediaItem2).

Command would be sent directly to the playlist agent if the session doesn't reject the request through the MediaSession2.SessionCallback.onCommandRequest(MediaSession2, ControllerInfo, SessionCommand2).

Constant Value: 12 (0x0000000c)

COMMAND_CODE_PLAYLIST_SKIP_TO_PREV_ITEM

public static final int COMMAND_CODE_PLAYLIST_SKIP_TO_PREV_ITEM

Command code for MediaController2.skipToPreviousItem().

Command would be sent directly to the playlist agent if the session doesn't reject the request through the MediaSession2.SessionCallback.onCommandRequest(MediaSession2, ControllerInfo, SessionCommand2).

Constant Value: 5 (0x00000005)

COMMAND_CODE_SESSION_FAST_FORWARD

public static final int COMMAND_CODE_SESSION_FAST_FORWARD

Command code for MediaController2.fastForward().

Constant Value: 7 (0x00000007)

COMMAND_CODE_SESSION_PLAY_FROM_MEDIA_ID

public static final int COMMAND_CODE_SESSION_PLAY_FROM_MEDIA_ID

Command code for MediaController2.playFromMediaId(String, Bundle).

Constant Value: 22 (0x00000016)

public static final int COMMAND_CODE_SESSION_PLAY_FROM_SEARCH

Command code for MediaController2.playFromSearch(String, Bundle).

Constant Value: 24 (0x00000018)

COMMAND_CODE_SESSION_PLAY_FROM_URI

public static final int COMMAND_CODE_SESSION_PLAY_FROM_URI

Command code for MediaController2.playFromUri(Uri, Bundle).

Constant Value: 23 (0x00000017)

COMMAND_CODE_SESSION_PREPARE_FROM_MEDIA_ID

public static final int COMMAND_CODE_SESSION_PREPARE_FROM_MEDIA_ID

Command code for MediaController2.prepareFromMediaId(String, Bundle).

Constant Value: 25 (0x00000019)

public static final int COMMAND_CODE_SESSION_PREPARE_FROM_SEARCH

Command code for MediaController2.prepareFromSearch(String, Bundle).

Constant Value: 27 (0x0000001b)

COMMAND_CODE_SESSION_PREPARE_FROM_URI

public static final int COMMAND_CODE_SESSION_PREPARE_FROM_URI

Command code for MediaController2.prepareFromUri(Uri, Bundle).

Constant Value: 26 (0x0000001a)

COMMAND_CODE_SESSION_REWIND

public static final int COMMAND_CODE_SESSION_REWIND

Command code for MediaController2.rewind().

Constant Value: 8 (0x00000008)

COMMAND_CODE_SESSION_SELECT_ROUTE

public static final int COMMAND_CODE_SESSION_SELECT_ROUTE

Command code for MediaController2.selectRoute(Bundle)}

Constant Value: 38 (0x00000026)

COMMAND_CODE_SESSION_SET_RATING

public static final int COMMAND_CODE_SESSION_SET_RATING

Command code for MediaController2.setRating(String, Rating2).

Constant Value: 28 (0x0000001c)

COMMAND_CODE_SESSION_SUBSCRIBE_ROUTES_INFO

public static final int COMMAND_CODE_SESSION_SUBSCRIBE_ROUTES_INFO

Command code for MediaController2.subscribeRoutesInfo()

Constant Value: 36 (0x00000024)

COMMAND_CODE_SESSION_UNSUBSCRIBE_ROUTES_INFO

public static final int COMMAND_CODE_SESSION_UNSUBSCRIBE_ROUTES_INFO

Command code for MediaController2.unsubscribeRoutesInfo()

Constant Value: 37 (0x00000025)

COMMAND_CODE_VOLUME_ADJUST_VOLUME

public static final int COMMAND_CODE_VOLUME_ADJUST_VOLUME

Command code for MediaController2.adjustVolume(int, int).

If the session doesn't reject the request through the MediaSession2.SessionCallback.onCommandRequest(MediaSession2, ControllerInfo, SessionCommand2), command would adjust the device volume. It would send to the player directly only if it's remote player. See RouteMediaPlayer for a remote player.

Constant Value: 11 (0x0000000b)

COMMAND_CODE_VOLUME_SET_VOLUME

public static final int COMMAND_CODE_VOLUME_SET_VOLUME

Command code for MediaController2.setVolumeTo(int, int).

If the session doesn't reject the request through the MediaSession2.SessionCallback.onCommandRequest(MediaSession2, ControllerInfo, SessionCommand2), command would adjust the device volume. It would send to the player directly only if it's remote player. See RouteMediaPlayer for a remote player.

Constant Value: 10 (0x0000000a)

Public constructors

SessionCommand2

public SessionCommand2 (int commandCode)

Constructor for creating a predefined command.

Parameters
commandCode int: A command code for predefined command.

SessionCommand2

public SessionCommand2 (String action, 
                Bundle extras)

Constructor for creating a custom command.

Parameters
action String: The action of this custom command.

extras Bundle: An extra bundle for this custom command.

Public methods

equals

public boolean equals (Object obj)

Parameters
obj Object

Returns
boolean

getCommandCode

public int getCommandCode ()

Gets the command code of a predefined command. This will return COMMAND_CODE_CUSTOM for a custom command.

Returns
int

getCustomCommand

public String getCustomCommand ()

Gets the action of a custom command. This will return null for a predefined command.

Returns
String

getExtras

public Bundle getExtras ()

Gets the extra bundle of a custom command. This will return null for a predefined command.

Returns
Bundle

hashCode

public int hashCode ()

Returns
int