Register now for Android Dev Summit 2019!

SessionCommand

public final class SessionCommand
extends Object implements VersionedParcelable

java.lang.Object
   ↳ androidx.media2.session.SessionCommand


Define a command that a MediaController can send to a MediaSession.

If getCommandCode() isn't COMMAND_CODE_CUSTOM), it's predefined command. If getCommandCode() is COMMAND_CODE_CUSTOM), it's custom command and getCustomAction() 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 SessionCommand.

int COMMAND_CODE_LIBRARY_GET_CHILDREN

Command code for MediaBrowser.getChildren(String, int, int, LibraryParams).

int COMMAND_CODE_LIBRARY_GET_ITEM

Command code for MediaBrowser.getItem(String).

int COMMAND_CODE_LIBRARY_GET_LIBRARY_ROOT

Command code for MediaBrowser.getLibraryRoot(LibraryParams).

int COMMAND_CODE_LIBRARY_GET_SEARCH_RESULT

Command code for MediaBrowser.getSearchResult(String, int, int, LibraryParams).

int COMMAND_CODE_LIBRARY_SEARCH

Command code for MediaBrowser.search(String, LibraryParams).

int COMMAND_CODE_LIBRARY_SUBSCRIBE

Command code for MediaBrowser.subscribe(String, LibraryParams).

int COMMAND_CODE_LIBRARY_UNSUBSCRIBE

Command code for MediaBrowser.unsubscribe(String).

int COMMAND_CODE_PLAYER_ADD_PLAYLIST_ITEM

Command code for MediaController.addPlaylistItem(int, String).

int COMMAND_CODE_PLAYER_GET_CURRENT_MEDIA_ITEM

Command code for MediaController.getCurrentMediaItem().

int COMMAND_CODE_PLAYER_GET_PLAYLIST

Command code for MediaController.getPlaylist().

int COMMAND_CODE_PLAYER_GET_PLAYLIST_METADATA

Command code for MediaController.getPlaylistMetadata().

int COMMAND_CODE_PLAYER_PAUSE

Command code for MediaController.pause().

int COMMAND_CODE_PLAYER_PLAY

Command code for MediaController.play().

int COMMAND_CODE_PLAYER_PREPARE

Command code for MediaController.prepare().

int COMMAND_CODE_PLAYER_REMOVE_PLAYLIST_ITEM

Command code for MediaController.removePlaylistItem(int).

int COMMAND_CODE_PLAYER_REPLACE_PLAYLIST_ITEM

Command code for MediaController.replacePlaylistItem(int, String).

int COMMAND_CODE_PLAYER_SEEK_TO

Command code for MediaController.seekTo(long).

int COMMAND_CODE_PLAYER_SET_MEDIA_ITEM

Command code for MediaController.setMediaItem(String).

int COMMAND_CODE_PLAYER_SET_PLAYLIST

Command code for MediaController.setPlaylist(List, MediaMetadata).

int COMMAND_CODE_PLAYER_SET_REPEAT_MODE

Command code for MediaController.setRepeatMode(int).

int COMMAND_CODE_PLAYER_SET_SHUFFLE_MODE

Command code for MediaController.setShuffleMode(int).

int COMMAND_CODE_PLAYER_SET_SPEED

Command code for MediaController.setPlaybackSpeed(float)}.

int COMMAND_CODE_PLAYER_SKIP_TO_NEXT_PLAYLIST_ITEM

Command code for MediaController.skipToNextPlaylistItem().

int COMMAND_CODE_PLAYER_SKIP_TO_PLAYLIST_ITEM

Command code for MediaController.skipToPlaylistItem(int).

int COMMAND_CODE_PLAYER_SKIP_TO_PREVIOUS_PLAYLIST_ITEM

Command code for MediaController.skipToPreviousPlaylistItem().

int COMMAND_CODE_PLAYER_UPDATE_LIST_METADATA

Command code for MediaController.updatePlaylistMetadata(MediaMetadata).

int COMMAND_CODE_SESSION_FAST_FORWARD

Command code for MediaController.fastForward().

int COMMAND_CODE_SESSION_REWIND

Command code for MediaController.rewind().

int COMMAND_CODE_SESSION_SET_RATING

Command code for MediaController.setRating(String, Rating).

int COMMAND_CODE_SESSION_SKIP_BACKWARD

Command code for MediaController.skipBackward().

int COMMAND_CODE_SESSION_SKIP_FORWARD

Command code for MediaController.skipForward().

int COMMAND_CODE_VOLUME_ADJUST_VOLUME

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

int COMMAND_CODE_VOLUME_SET_VOLUME

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

int COMMAND_VERSION_1

The first version of session commands.

Public constructors

SessionCommand(int commandCode)

Constructor for creating a predefined command.

SessionCommand(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 getCustomAction()

Gets the action of a custom command.

Bundle getCustomExtras()

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

Constant Value: 0 (0x00000000)

COMMAND_CODE_LIBRARY_GET_CHILDREN

public static final int COMMAND_CODE_LIBRARY_GET_CHILDREN

Command code for MediaBrowser.getChildren(String, int, int, LibraryParams).

Code version is COMMAND_VERSION_1.

Constant Value: 50003 (0x0000c353)

COMMAND_CODE_LIBRARY_GET_ITEM

public static final int COMMAND_CODE_LIBRARY_GET_ITEM

Command code for MediaBrowser.getItem(String).

Code version is COMMAND_VERSION_1.

Constant Value: 50004 (0x0000c354)

COMMAND_CODE_LIBRARY_GET_LIBRARY_ROOT

public static final int COMMAND_CODE_LIBRARY_GET_LIBRARY_ROOT

Command code for MediaBrowser.getLibraryRoot(LibraryParams).

Code version is COMMAND_VERSION_1.

Constant Value: 50000 (0x0000c350)

COMMAND_CODE_LIBRARY_GET_SEARCH_RESULT

public static final int COMMAND_CODE_LIBRARY_GET_SEARCH_RESULT

Command code for MediaBrowser.getSearchResult(String, int, int, LibraryParams).

Code version is COMMAND_VERSION_1.

Constant Value: 50006 (0x0000c356)

public static final int COMMAND_CODE_LIBRARY_SEARCH

Command code for MediaBrowser.search(String, LibraryParams).

Code version is COMMAND_VERSION_1.

Constant Value: 50005 (0x0000c355)

COMMAND_CODE_LIBRARY_SUBSCRIBE

public static final int COMMAND_CODE_LIBRARY_SUBSCRIBE

Command code for MediaBrowser.subscribe(String, LibraryParams).

Code version is COMMAND_VERSION_1.

Constant Value: 50001 (0x0000c351)

COMMAND_CODE_LIBRARY_UNSUBSCRIBE

public static final int COMMAND_CODE_LIBRARY_UNSUBSCRIBE

Command code for MediaBrowser.unsubscribe(String).

Code version is COMMAND_VERSION_1.

Constant Value: 50002 (0x0000c352)

COMMAND_CODE_PLAYER_ADD_PLAYLIST_ITEM

public static final int COMMAND_CODE_PLAYER_ADD_PLAYLIST_ITEM

Command code for MediaController.addPlaylistItem(int, String).

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

Code version is COMMAND_VERSION_1.

Constant Value: 10013 (0x0000271d)

COMMAND_CODE_PLAYER_GET_CURRENT_MEDIA_ITEM

public static final int COMMAND_CODE_PLAYER_GET_CURRENT_MEDIA_ITEM

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

Code version is COMMAND_VERSION_1.

Constant Value: 10016 (0x00002720)

COMMAND_CODE_PLAYER_GET_PLAYLIST

public static final int COMMAND_CODE_PLAYER_GET_PLAYLIST

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

Code version is COMMAND_VERSION_1.

Constant Value: 10005 (0x00002715)

COMMAND_CODE_PLAYER_GET_PLAYLIST_METADATA

public static final int COMMAND_CODE_PLAYER_GET_PLAYLIST_METADATA

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

Code version is COMMAND_VERSION_1.

Constant Value: 10012 (0x0000271c)

COMMAND_CODE_PLAYER_PAUSE

public static final int COMMAND_CODE_PLAYER_PAUSE

Command code for MediaController.pause().

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

Code version is COMMAND_VERSION_1.

Constant Value: 10001 (0x00002711)

COMMAND_CODE_PLAYER_PLAY

public static final int COMMAND_CODE_PLAYER_PLAY

Command code for MediaController.play().

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

Code version is COMMAND_VERSION_1.

Constant Value: 10000 (0x00002710)

COMMAND_CODE_PLAYER_PREPARE

public static final int COMMAND_CODE_PLAYER_PREPARE

Command code for MediaController.prepare().

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

Code version is COMMAND_VERSION_1.

Constant Value: 10002 (0x00002712)

COMMAND_CODE_PLAYER_REMOVE_PLAYLIST_ITEM

public static final int COMMAND_CODE_PLAYER_REMOVE_PLAYLIST_ITEM

Command code for MediaController.removePlaylistItem(int).

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

Code version is COMMAND_VERSION_1.

Constant Value: 10014 (0x0000271e)

COMMAND_CODE_PLAYER_REPLACE_PLAYLIST_ITEM

public static final int COMMAND_CODE_PLAYER_REPLACE_PLAYLIST_ITEM

Command code for MediaController.replacePlaylistItem(int, String).

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

Code version is COMMAND_VERSION_1.

Constant Value: 10015 (0x0000271f)

COMMAND_CODE_PLAYER_SEEK_TO

public static final int COMMAND_CODE_PLAYER_SEEK_TO

Command code for MediaController.seekTo(long).

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

Code version is COMMAND_VERSION_1.

Constant Value: 10003 (0x00002713)

COMMAND_CODE_PLAYER_SET_MEDIA_ITEM

public static final int COMMAND_CODE_PLAYER_SET_MEDIA_ITEM

Command code for MediaController.setMediaItem(String).

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

Code version is COMMAND_VERSION_1.

Constant Value: 10018 (0x00002722)

COMMAND_CODE_PLAYER_SET_PLAYLIST

public static final int COMMAND_CODE_PLAYER_SET_PLAYLIST

Command code for MediaController.setPlaylist(List, MediaMetadata).

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

Code version is COMMAND_VERSION_1.

Constant Value: 10006 (0x00002716)

COMMAND_CODE_PLAYER_SET_REPEAT_MODE

public static final int COMMAND_CODE_PLAYER_SET_REPEAT_MODE

Command code for MediaController.setRepeatMode(int).

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

Code version is COMMAND_VERSION_1.

Constant Value: 10011 (0x0000271b)

COMMAND_CODE_PLAYER_SET_SHUFFLE_MODE

public static final int COMMAND_CODE_PLAYER_SET_SHUFFLE_MODE

Command code for MediaController.setShuffleMode(int).

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

Code version is COMMAND_VERSION_1.

Constant Value: 10010 (0x0000271a)

COMMAND_CODE_PLAYER_SET_SPEED

public static final int COMMAND_CODE_PLAYER_SET_SPEED

Command code for MediaController.setPlaybackSpeed(float)}.

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

Code version is COMMAND_VERSION_1.

Constant Value: 10004 (0x00002714)

COMMAND_CODE_PLAYER_SKIP_TO_NEXT_PLAYLIST_ITEM

public static final int COMMAND_CODE_PLAYER_SKIP_TO_NEXT_PLAYLIST_ITEM

Command code for MediaController.skipToNextPlaylistItem().

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

Code version is COMMAND_VERSION_1.

Constant Value: 10009 (0x00002719)

COMMAND_CODE_PLAYER_SKIP_TO_PLAYLIST_ITEM

public static final int COMMAND_CODE_PLAYER_SKIP_TO_PLAYLIST_ITEM

Command code for MediaController.skipToPlaylistItem(int).

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

Code version is COMMAND_VERSION_1.

Constant Value: 10007 (0x00002717)

COMMAND_CODE_PLAYER_SKIP_TO_PREVIOUS_PLAYLIST_ITEM

public static final int COMMAND_CODE_PLAYER_SKIP_TO_PREVIOUS_PLAYLIST_ITEM

Command code for MediaController.skipToPreviousPlaylistItem().

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

Code version is COMMAND_VERSION_1.

Constant Value: 10008 (0x00002718)

COMMAND_CODE_PLAYER_UPDATE_LIST_METADATA

public static final int COMMAND_CODE_PLAYER_UPDATE_LIST_METADATA

Command code for MediaController.updatePlaylistMetadata(MediaMetadata).

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

Code version is COMMAND_VERSION_1.

Constant Value: 10017 (0x00002721)

COMMAND_CODE_SESSION_FAST_FORWARD

public static final int COMMAND_CODE_SESSION_FAST_FORWARD

Command code for MediaController.fastForward().

Code version is COMMAND_VERSION_1.

Constant Value: 40000 (0x00009c40)

COMMAND_CODE_SESSION_REWIND

public static final int COMMAND_CODE_SESSION_REWIND

Command code for MediaController.rewind().

Code version is COMMAND_VERSION_1.

Constant Value: 40001 (0x00009c41)

COMMAND_CODE_SESSION_SET_RATING

public static final int COMMAND_CODE_SESSION_SET_RATING

Command code for MediaController.setRating(String, Rating).

Code version is COMMAND_VERSION_1.

Constant Value: 40010 (0x00009c4a)

COMMAND_CODE_SESSION_SKIP_BACKWARD

public static final int COMMAND_CODE_SESSION_SKIP_BACKWARD

Command code for MediaController.skipBackward().

Code version is COMMAND_VERSION_1.

Constant Value: 40003 (0x00009c43)

COMMAND_CODE_SESSION_SKIP_FORWARD

public static final int COMMAND_CODE_SESSION_SKIP_FORWARD

Command code for MediaController.skipForward().

Code version is COMMAND_VERSION_1.

Constant Value: 40002 (0x00009c42)

COMMAND_CODE_VOLUME_ADJUST_VOLUME

public static final int COMMAND_CODE_VOLUME_ADJUST_VOLUME

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

If the session doesn't reject the request through the MediaSession.SessionCallback.onCommandRequest(MediaSession, ControllerInfo, SessionCommand), 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.

Code version is COMMAND_VERSION_1.

Constant Value: 30001 (0x00007531)

COMMAND_CODE_VOLUME_SET_VOLUME

public static final int COMMAND_CODE_VOLUME_SET_VOLUME

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

If the session doesn't reject the request through the MediaSession.SessionCallback.onCommandRequest(MediaSession, ControllerInfo, SessionCommand), 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.

Code version is COMMAND_VERSION_1.

Constant Value: 30000 (0x00007530)

COMMAND_VERSION_1

public static final int COMMAND_VERSION_1

The first version of session commands. This version is for commands introduced in AndroidX 1.0.0.

This would be used to specify which commands should be added by SessionCommandGroup.Builder.addAllPredefinedCommands(int)

Constant Value: 1 (0x00000001)

Public constructors

SessionCommand

public SessionCommand (int commandCode)

Constructor for creating a predefined command.

Parameters
commandCode int: A command code for predefined command.

SessionCommand

public SessionCommand (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

getCustomAction

public String getCustomAction ()

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

Returns
String

getCustomExtras

public Bundle getCustomExtras ()

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

Returns
Bundle

hashCode

public int hashCode ()

Returns
int