SessionCommand

Added in 1.0.0
Deprecated in 1.3.0

public final class SessionCommand implements VersionedParcelable


Defines 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

static final int

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

static final int

Command code for getChildren.

static final int

Command code for getItem.

static final int

Command code for getLibraryRoot.

static final int

Command code for getSearchResult.

static final int

Command code for search.

static final int

Command code for subscribe.

static final int

Command code for unsubscribe.

static final int

Command code for addPlaylistItem.

static final int

Command code for deselectTrack.

static final int

Command code for getCurrentMediaItem.

static final int

Command code for getPlaylist.

static final int

Command code for getPlaylistMetadata.

static final int

Command code for replacePlaylistItem.

static final int

Command code for pause.

static final int

Command code for play.

static final int

Command code for prepare.

static final int

Command code for removePlaylistItem.

static final int

Command code for replacePlaylistItem.

static final int

Command code for seekTo.

static final int

Command code for selectTrack.

static final int

Command code for setMediaItem.

static final int

Command code for setPlaylist.

static final int

Command code for setRepeatMode.

static final int

Command code for setShuffleMode.

static final int

Command code for setPlaybackSpeed}.

static final int

Command code for setSurface.

static final int

Command code for skipToNextPlaylistItem.

static final int

Command code for skipToPlaylistItem.

static final int

Command code for skipToPreviousPlaylistItem.

static final int

Command code for updatePlaylistMetadata.

static final int

Command code for fastForward.

static final int

Command code for rewind.

static final int

Command code for setMediaUri.

static final int

Command code for setRating.

static final int

Command code for skipBackward.

static final int

Command code for skipForward.

static final int

Command code for adjustVolume.

static final int

Command code for setVolumeTo.

static final int

The first version of session commands.

static final int

The 2nd version of session commands.

Public constructors

SessionCommand(int commandCode)

Constructor for creating a predefined command.

Constructor for creating a custom command.

Public methods

boolean
int

Gets the command code of a predefined command.

@Nullable String

Gets the action of a custom command.

@Nullable Bundle

Gets the extra bundle of a custom command.

int

Constants

COMMAND_CODE_CUSTOM

Added in 1.0.0
Deprecated in 1.3.0
public static final int COMMAND_CODE_CUSTOM = 0

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

COMMAND_CODE_LIBRARY_GET_CHILDREN

Added in 1.0.0
Deprecated in 1.3.0
public static final int COMMAND_CODE_LIBRARY_GET_CHILDREN = 50003

Command code for getChildren.

Code version is COMMAND_VERSION_1.

COMMAND_CODE_LIBRARY_GET_ITEM

Added in 1.0.0
Deprecated in 1.3.0
public static final int COMMAND_CODE_LIBRARY_GET_ITEM = 50004

Command code for getItem.

Code version is COMMAND_VERSION_1.

COMMAND_CODE_LIBRARY_GET_LIBRARY_ROOT

Added in 1.0.0
Deprecated in 1.3.0
public static final int COMMAND_CODE_LIBRARY_GET_LIBRARY_ROOT = 50000

Command code for getLibraryRoot.

Code version is COMMAND_VERSION_1.

COMMAND_CODE_LIBRARY_GET_SEARCH_RESULT

Added in 1.0.0
Deprecated in 1.3.0
public static final int COMMAND_CODE_LIBRARY_GET_SEARCH_RESULT = 50006

Command code for getSearchResult.

Code version is COMMAND_VERSION_1.

COMMAND_CODE_LIBRARY_SEARCH

Added in 1.0.0
Deprecated in 1.3.0
public static final int COMMAND_CODE_LIBRARY_SEARCH = 50005

Command code for search.

Code version is COMMAND_VERSION_1.

COMMAND_CODE_LIBRARY_SUBSCRIBE

Added in 1.0.0
Deprecated in 1.3.0
public static final int COMMAND_CODE_LIBRARY_SUBSCRIBE = 50001

Command code for subscribe.

Code version is COMMAND_VERSION_1.

COMMAND_CODE_LIBRARY_UNSUBSCRIBE

Added in 1.0.0
Deprecated in 1.3.0
public static final int COMMAND_CODE_LIBRARY_UNSUBSCRIBE = 50002

Command code for unsubscribe.

Code version is COMMAND_VERSION_1.

COMMAND_CODE_PLAYER_ADD_PLAYLIST_ITEM

Added in 1.0.0
Deprecated in 1.3.0
public static final int COMMAND_CODE_PLAYER_ADD_PLAYLIST_ITEM = 10013

Command code for addPlaylistItem.

Command would be sent directly to the player if the session doesn't reject the request through the onCommandRequest.

Code version is COMMAND_VERSION_1.

COMMAND_CODE_PLAYER_DESELECT_TRACK

Added in 1.1.0
Deprecated in 1.3.0
public static final int COMMAND_CODE_PLAYER_DESELECT_TRACK = 11002

Command code for deselectTrack.

Command would be sent directly to the player if the session doesn't reject the request through the onCommandRequest.

Code version is COMMAND_VERSION_1.

COMMAND_CODE_PLAYER_GET_CURRENT_MEDIA_ITEM

Added in 1.0.0
Deprecated in 1.3.0
public static final int COMMAND_CODE_PLAYER_GET_CURRENT_MEDIA_ITEM = 10016

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

Code version is COMMAND_VERSION_1.

COMMAND_CODE_PLAYER_GET_PLAYLIST

Added in 1.0.0
Deprecated in 1.3.0
public static final int COMMAND_CODE_PLAYER_GET_PLAYLIST = 10005

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

Code version is COMMAND_VERSION_1.

COMMAND_CODE_PLAYER_GET_PLAYLIST_METADATA

Added in 1.0.0
Deprecated in 1.3.0
public static final int COMMAND_CODE_PLAYER_GET_PLAYLIST_METADATA = 10012

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

Code version is COMMAND_VERSION_1.

COMMAND_CODE_PLAYER_MOVE_PLAYLIST_ITEM

Added in 1.1.0
Deprecated in 1.3.0
public static final int COMMAND_CODE_PLAYER_MOVE_PLAYLIST_ITEM = 10019

Command code for replacePlaylistItem.

Command would be sent directly to the player if the session doesn't reject the request through the onCommandRequest.

Code version is COMMAND_VERSION_2.

COMMAND_CODE_PLAYER_PAUSE

Added in 1.0.0
Deprecated in 1.3.0
public static final int COMMAND_CODE_PLAYER_PAUSE = 10001

Command code for pause.

Command would be sent directly to the player if the session doesn't reject the request through the onCommandRequest.

Code version is COMMAND_VERSION_1.

COMMAND_CODE_PLAYER_PLAY

Added in 1.0.0
Deprecated in 1.3.0
public static final int COMMAND_CODE_PLAYER_PLAY = 10000

Command code for play.

Command would be sent directly to the player if the session doesn't reject the request through the onCommandRequest.

Code version is COMMAND_VERSION_1.

COMMAND_CODE_PLAYER_PREPARE

Added in 1.0.0
Deprecated in 1.3.0
public static final int COMMAND_CODE_PLAYER_PREPARE = 10002

Command code for prepare.

Command would be sent directly to the player if the session doesn't reject the request through the onCommandRequest.

Code version is COMMAND_VERSION_1.

COMMAND_CODE_PLAYER_REMOVE_PLAYLIST_ITEM

Added in 1.0.0
Deprecated in 1.3.0
public static final int COMMAND_CODE_PLAYER_REMOVE_PLAYLIST_ITEM = 10014

Command code for removePlaylistItem.

Command would be sent directly to the player if the session doesn't reject the request through the onCommandRequest.

Code version is COMMAND_VERSION_1.

COMMAND_CODE_PLAYER_REPLACE_PLAYLIST_ITEM

Added in 1.0.0
Deprecated in 1.3.0
public static final int COMMAND_CODE_PLAYER_REPLACE_PLAYLIST_ITEM = 10015

Command code for replacePlaylistItem.

Command would be sent directly to the player if the session doesn't reject the request through the onCommandRequest.

Code version is COMMAND_VERSION_1.

COMMAND_CODE_PLAYER_SEEK_TO

Added in 1.0.0
Deprecated in 1.3.0
public static final int COMMAND_CODE_PLAYER_SEEK_TO = 10003

Command code for seekTo.

Command would be sent directly to the player if the session doesn't reject the request through the onCommandRequest.

Code version is COMMAND_VERSION_1.

COMMAND_CODE_PLAYER_SELECT_TRACK

Added in 1.1.0
Deprecated in 1.3.0
public static final int COMMAND_CODE_PLAYER_SELECT_TRACK = 11001

Command code for selectTrack.

Command would be sent directly to the player if the session doesn't reject the request through the onCommandRequest.

Code version is COMMAND_VERSION_1.

COMMAND_CODE_PLAYER_SET_MEDIA_ITEM

Added in 1.0.0
Deprecated in 1.3.0
public static final int COMMAND_CODE_PLAYER_SET_MEDIA_ITEM = 10018

Command code for setMediaItem.

Command would be sent directly to the player if the session doesn't reject the request through the onCommandRequest.

Code version is COMMAND_VERSION_1.

COMMAND_CODE_PLAYER_SET_PLAYLIST

Added in 1.0.0
Deprecated in 1.3.0
public static final int COMMAND_CODE_PLAYER_SET_PLAYLIST = 10006

Command code for setPlaylist.

Command would be sent directly to the player if the session doesn't reject the request through the onCommandRequest.

Code version is COMMAND_VERSION_1.

COMMAND_CODE_PLAYER_SET_REPEAT_MODE

Added in 1.0.0
Deprecated in 1.3.0
public static final int COMMAND_CODE_PLAYER_SET_REPEAT_MODE = 10011

Command code for setRepeatMode.

Command would be sent directly to the player if the session doesn't reject the request through the onCommandRequest.

Code version is COMMAND_VERSION_1.

COMMAND_CODE_PLAYER_SET_SHUFFLE_MODE

Added in 1.0.0
Deprecated in 1.3.0
public static final int COMMAND_CODE_PLAYER_SET_SHUFFLE_MODE = 10010

Command code for setShuffleMode.

Command would be sent directly to the player if the session doesn't reject the request through the onCommandRequest.

Code version is COMMAND_VERSION_1.

COMMAND_CODE_PLAYER_SET_SPEED

Added in 1.0.0
Deprecated in 1.3.0
public static final int COMMAND_CODE_PLAYER_SET_SPEED = 10004

Command code for setPlaybackSpeed}.

Command would be sent directly to the player if the session doesn't reject the request through the onCommandRequest.

Code version is COMMAND_VERSION_1.

COMMAND_CODE_PLAYER_SET_SURFACE

Added in 1.1.0
Deprecated in 1.3.0
public static final int COMMAND_CODE_PLAYER_SET_SURFACE = 11000

Command code for setSurface.

Command would be sent directly to the player if the session doesn't reject the request through the onCommandRequest.

Code version is COMMAND_VERSION_1.

COMMAND_CODE_PLAYER_SKIP_TO_NEXT_PLAYLIST_ITEM

Added in 1.0.0
Deprecated in 1.3.0
public static final int COMMAND_CODE_PLAYER_SKIP_TO_NEXT_PLAYLIST_ITEM = 10009

Command code for skipToNextPlaylistItem.

Command would be sent directly to the player if the session doesn't reject the request through the onCommandRequest.

Code version is COMMAND_VERSION_1.

COMMAND_CODE_PLAYER_SKIP_TO_PLAYLIST_ITEM

Added in 1.0.0
Deprecated in 1.3.0
public static final int COMMAND_CODE_PLAYER_SKIP_TO_PLAYLIST_ITEM = 10007

Command code for skipToPlaylistItem.

Command would be sent directly to the player if the session doesn't reject the request through the onCommandRequest.

Code version is COMMAND_VERSION_1.

COMMAND_CODE_PLAYER_SKIP_TO_PREVIOUS_PLAYLIST_ITEM

Added in 1.0.0
Deprecated in 1.3.0
public static final int COMMAND_CODE_PLAYER_SKIP_TO_PREVIOUS_PLAYLIST_ITEM = 10008

Command code for skipToPreviousPlaylistItem.

Command would be sent directly to the player if the session doesn't reject the request through the onCommandRequest.

Code version is COMMAND_VERSION_1.

COMMAND_CODE_PLAYER_UPDATE_LIST_METADATA

Added in 1.0.0
Deprecated in 1.3.0
public static final int COMMAND_CODE_PLAYER_UPDATE_LIST_METADATA = 10017

Command code for updatePlaylistMetadata.

Command would be sent directly to the player if the session doesn't reject the request through the onCommandRequest.

Code version is COMMAND_VERSION_1.

COMMAND_CODE_SESSION_FAST_FORWARD

Added in 1.0.0
Deprecated in 1.3.0
public static final int COMMAND_CODE_SESSION_FAST_FORWARD = 40000

Command code for fastForward.

Code version is COMMAND_VERSION_1.

COMMAND_CODE_SESSION_REWIND

Added in 1.0.0
Deprecated in 1.3.0
public static final int COMMAND_CODE_SESSION_REWIND = 40001

Command code for rewind.

Code version is COMMAND_VERSION_1.

COMMAND_CODE_SESSION_SET_MEDIA_URI

Added in 1.1.0
Deprecated in 1.3.0
public static final int COMMAND_CODE_SESSION_SET_MEDIA_URI = 40011

Command code for setMediaUri.

Code version is COMMAND_VERSION_2.

COMMAND_CODE_SESSION_SET_RATING

Added in 1.0.0
Deprecated in 1.3.0
public static final int COMMAND_CODE_SESSION_SET_RATING = 40010

Command code for setRating.

Code version is COMMAND_VERSION_1.

COMMAND_CODE_SESSION_SKIP_BACKWARD

Added in 1.0.0
Deprecated in 1.3.0
public static final int COMMAND_CODE_SESSION_SKIP_BACKWARD = 40003

Command code for skipBackward.

Code version is COMMAND_VERSION_1.

COMMAND_CODE_SESSION_SKIP_FORWARD

Added in 1.0.0
Deprecated in 1.3.0
public static final int COMMAND_CODE_SESSION_SKIP_FORWARD = 40002

Command code for skipForward.

Code version is COMMAND_VERSION_1.

COMMAND_CODE_VOLUME_ADJUST_VOLUME

Added in 1.0.0
Deprecated in 1.3.0
public static final int COMMAND_CODE_VOLUME_ADJUST_VOLUME = 30001

Command code for adjustVolume.

If the session doesn't reject the request through the onCommandRequest, command would adjust the device volume. It would send to the player directly only if it's a RemoteSessionPlayer.

Code version is COMMAND_VERSION_1.

COMMAND_CODE_VOLUME_SET_VOLUME

Added in 1.0.0
Deprecated in 1.3.0
public static final int COMMAND_CODE_VOLUME_SET_VOLUME = 30000

Command code for setVolumeTo.

If the session doesn't reject the request through the onCommandRequest, command would adjust the device volume. It would send to the player directly only if it's a RemoteSessionPlayer.

Code version is COMMAND_VERSION_1.

COMMAND_VERSION_1

Added in 1.0.0
Deprecated in 1.3.0
public static final int COMMAND_VERSION_1 = 1

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

This would be used to specify which commands should be added by addAllPredefinedCommands

COMMAND_VERSION_2

Added in 1.1.0
Deprecated in 1.3.0
public static final int COMMAND_VERSION_2 = 2

The 2nd version of session commands. This version is for commands introduced in AndroidX media2-session 1.1.0.

This would be used to specify which commands should be added by addAllPredefinedCommands

Public constructors

SessionCommand

Added in 1.0.0
Deprecated in 1.3.0
public SessionCommand(int commandCode)

Constructor for creating a predefined command.

Parameters
int commandCode

A command code for predefined command.

SessionCommand

Added in 1.0.0
Deprecated in 1.3.0
public SessionCommand(@NonNull String action, @Nullable Bundle extras)

Constructor for creating a custom command.

Parameters
@NonNull String action

The action of this custom command.

@Nullable Bundle extras

An extra bundle for this custom command.

Public methods

equals

public boolean equals(Object obj)

getCommandCode

Added in 1.0.0
Deprecated in 1.3.0
public int getCommandCode()

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

getCustomAction

Added in 1.0.0
Deprecated in 1.3.0
public @Nullable String getCustomAction()

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

getCustomExtras

Added in 1.0.0
Deprecated in 1.3.0
public @Nullable Bundle getCustomExtras()

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

hashCode

public int hashCode()