SessionCommand

class SessionCommand : VersionedParcelable
kotlin.Any
   ↳ 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

static Int

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

static Int

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

static Int

Command code for MediaBrowser#getItem(String).

static Int

Command code for MediaBrowser#getLibraryRoot(LibraryParams).

static Int

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

static Int

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

static Int

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

static Int

Command code for MediaBrowser#unsubscribe(String).

static Int

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

static Int

Command code for MediaController#getCurrentMediaItem().

static Int

Command code for MediaController#getPlaylist().

static Int

Command code for MediaController#getPlaylistMetadata().

static Int

Command code for MediaController#pause().

static Int

Command code for MediaController#play().

static Int

Command code for MediaController#prepare().

static Int

Command code for MediaController#removePlaylistItem(int).

static Int

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

static Int

Command code for MediaController#seekTo(long).

static Int

Command code for MediaController#setMediaItem(String).

static Int

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

static Int

Command code for MediaController#setRepeatMode(int).

static Int

Command code for MediaController#setShuffleMode(int).

static Int

Command code for MediaController#setPlaybackSpeed(float)}.

static Int

Command code for MediaController#skipToNextPlaylistItem().

static Int

Command code for MediaController#skipToPlaylistItem(int).

static Int

Command code for MediaController#skipToPreviousPlaylistItem().

static Int

Command code for MediaController#updatePlaylistMetadata(MediaMetadata).

static Int

Command code for MediaController#fastForward().

static Int

Command code for MediaController#rewind().

static Int

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

static Int

Command code for MediaController#skipBackward().

static Int

Command code for MediaController#skipForward().

static Int

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

static Int

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

static Int

The first version of session commands.

Public constructors

<init>(commandCode: Int)

Constructor for creating a predefined command.

<init>(@NonNull action: String, @Nullable extras: Bundle?)

Constructor for creating a custom command.

Public methods

Boolean
equals(other: Any?)

Int

Gets the command code of a predefined command.

String?

Gets the action of a custom command.

Bundle?

Gets the extra bundle of a custom command.

Int

Constants

COMMAND_CODE_CUSTOM

static val COMMAND_CODE_CUSTOM: Int

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

Value: 0

COMMAND_CODE_LIBRARY_GET_CHILDREN

static val COMMAND_CODE_LIBRARY_GET_CHILDREN: Int

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

Code version is COMMAND_VERSION_1.

Value: 50003

COMMAND_CODE_LIBRARY_GET_ITEM

static val COMMAND_CODE_LIBRARY_GET_ITEM: Int

Command code for MediaBrowser#getItem(String).

Code version is COMMAND_VERSION_1.

Value: 50004

COMMAND_CODE_LIBRARY_GET_LIBRARY_ROOT

static val COMMAND_CODE_LIBRARY_GET_LIBRARY_ROOT: Int

Command code for MediaBrowser#getLibraryRoot(LibraryParams).

Code version is COMMAND_VERSION_1.

Value: 50000

COMMAND_CODE_LIBRARY_GET_SEARCH_RESULT

static val COMMAND_CODE_LIBRARY_GET_SEARCH_RESULT: Int

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

Code version is COMMAND_VERSION_1.

Value: 50006

COMMAND_CODE_LIBRARY_SEARCH

static val COMMAND_CODE_LIBRARY_SEARCH: Int

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

Code version is COMMAND_VERSION_1.

Value: 50005

COMMAND_CODE_LIBRARY_SUBSCRIBE

static val COMMAND_CODE_LIBRARY_SUBSCRIBE: Int

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

Code version is COMMAND_VERSION_1.

Value: 50001

COMMAND_CODE_LIBRARY_UNSUBSCRIBE

static val COMMAND_CODE_LIBRARY_UNSUBSCRIBE: Int

Command code for MediaBrowser#unsubscribe(String).

Code version is COMMAND_VERSION_1.

Value: 50002

COMMAND_CODE_PLAYER_ADD_PLAYLIST_ITEM

static val COMMAND_CODE_PLAYER_ADD_PLAYLIST_ITEM: Int

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 SessionCallback#onCommandRequest(MediaSession, ControllerInfo, SessionCommand).

Code version is COMMAND_VERSION_1.

Value: 10013

COMMAND_CODE_PLAYER_GET_CURRENT_MEDIA_ITEM

static val COMMAND_CODE_PLAYER_GET_CURRENT_MEDIA_ITEM: Int

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

Code version is COMMAND_VERSION_1.

Value: 10016

COMMAND_CODE_PLAYER_GET_PLAYLIST

static val COMMAND_CODE_PLAYER_GET_PLAYLIST: Int

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

Code version is COMMAND_VERSION_1.

Value: 10005

COMMAND_CODE_PLAYER_GET_PLAYLIST_METADATA

static val COMMAND_CODE_PLAYER_GET_PLAYLIST_METADATA: Int

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

Code version is COMMAND_VERSION_1.

Value: 10012

COMMAND_CODE_PLAYER_PAUSE

static val COMMAND_CODE_PLAYER_PAUSE: Int

Command code for MediaController#pause().

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

Code version is COMMAND_VERSION_1.

Value: 10001

COMMAND_CODE_PLAYER_PLAY

static val COMMAND_CODE_PLAYER_PLAY: Int

Command code for MediaController#play().

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

Code version is COMMAND_VERSION_1.

Value: 10000

COMMAND_CODE_PLAYER_PREPARE

static val COMMAND_CODE_PLAYER_PREPARE: Int

Command code for MediaController#prepare().

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

Code version is COMMAND_VERSION_1.

Value: 10002

COMMAND_CODE_PLAYER_REMOVE_PLAYLIST_ITEM

static val COMMAND_CODE_PLAYER_REMOVE_PLAYLIST_ITEM: Int

Command code for MediaController#removePlaylistItem(int).

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

Code version is COMMAND_VERSION_1.

Value: 10014

COMMAND_CODE_PLAYER_REPLACE_PLAYLIST_ITEM

static val COMMAND_CODE_PLAYER_REPLACE_PLAYLIST_ITEM: Int

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 SessionCallback#onCommandRequest(MediaSession, ControllerInfo, SessionCommand).

Code version is COMMAND_VERSION_1.

Value: 10015

COMMAND_CODE_PLAYER_SEEK_TO

static val COMMAND_CODE_PLAYER_SEEK_TO: Int

Command code for MediaController#seekTo(long).

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

Code version is COMMAND_VERSION_1.

Value: 10003

COMMAND_CODE_PLAYER_SET_MEDIA_ITEM

static val COMMAND_CODE_PLAYER_SET_MEDIA_ITEM: Int

Command code for MediaController#setMediaItem(String).

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

Code version is COMMAND_VERSION_1.

Value: 10018

COMMAND_CODE_PLAYER_SET_PLAYLIST

static val COMMAND_CODE_PLAYER_SET_PLAYLIST: Int

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 SessionCallback#onCommandRequest(MediaSession, ControllerInfo, SessionCommand).

Code version is COMMAND_VERSION_1.

Value: 10006

COMMAND_CODE_PLAYER_SET_REPEAT_MODE

static val COMMAND_CODE_PLAYER_SET_REPEAT_MODE: Int

Command code for MediaController#setRepeatMode(int).

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

Code version is COMMAND_VERSION_1.

Value: 10011

COMMAND_CODE_PLAYER_SET_SHUFFLE_MODE

static val COMMAND_CODE_PLAYER_SET_SHUFFLE_MODE: Int

Command code for MediaController#setShuffleMode(int).

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

Code version is COMMAND_VERSION_1.

Value: 10010

COMMAND_CODE_PLAYER_SET_SPEED

static val COMMAND_CODE_PLAYER_SET_SPEED: Int

Command code for MediaController#setPlaybackSpeed(float)}.

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

Code version is COMMAND_VERSION_1.

Value: 10004

COMMAND_CODE_PLAYER_SKIP_TO_NEXT_PLAYLIST_ITEM

static val COMMAND_CODE_PLAYER_SKIP_TO_NEXT_PLAYLIST_ITEM: Int

Command code for MediaController#skipToNextPlaylistItem().

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

Code version is COMMAND_VERSION_1.

Value: 10009

COMMAND_CODE_PLAYER_SKIP_TO_PLAYLIST_ITEM

static val COMMAND_CODE_PLAYER_SKIP_TO_PLAYLIST_ITEM: Int

Command code for MediaController#skipToPlaylistItem(int).

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

Code version is COMMAND_VERSION_1.

Value: 10007

COMMAND_CODE_PLAYER_SKIP_TO_PREVIOUS_PLAYLIST_ITEM

static val COMMAND_CODE_PLAYER_SKIP_TO_PREVIOUS_PLAYLIST_ITEM: Int

Command code for MediaController#skipToPreviousPlaylistItem().

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

Code version is COMMAND_VERSION_1.

Value: 10008

COMMAND_CODE_PLAYER_UPDATE_LIST_METADATA

static val COMMAND_CODE_PLAYER_UPDATE_LIST_METADATA: Int

Command code for MediaController#updatePlaylistMetadata(MediaMetadata).

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

Code version is COMMAND_VERSION_1.

Value: 10017

COMMAND_CODE_SESSION_FAST_FORWARD

static val COMMAND_CODE_SESSION_FAST_FORWARD: Int

Command code for MediaController#fastForward().

Code version is COMMAND_VERSION_1.

Value: 40000

COMMAND_CODE_SESSION_REWIND

static val COMMAND_CODE_SESSION_REWIND: Int

Command code for MediaController#rewind().

Code version is COMMAND_VERSION_1.

Value: 40001

COMMAND_CODE_SESSION_SET_RATING

static val COMMAND_CODE_SESSION_SET_RATING: Int

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

Code version is COMMAND_VERSION_1.

Value: 40010

COMMAND_CODE_SESSION_SKIP_BACKWARD

static val COMMAND_CODE_SESSION_SKIP_BACKWARD: Int

Command code for MediaController#skipBackward().

Code version is COMMAND_VERSION_1.

Value: 40003

COMMAND_CODE_SESSION_SKIP_FORWARD

static val COMMAND_CODE_SESSION_SKIP_FORWARD: Int

Command code for MediaController#skipForward().

Code version is COMMAND_VERSION_1.

Value: 40002

COMMAND_CODE_VOLUME_ADJUST_VOLUME

static val COMMAND_CODE_VOLUME_ADJUST_VOLUME: Int

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

If the session doesn't reject the request through the 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.

Value: 30001

COMMAND_CODE_VOLUME_SET_VOLUME

static val COMMAND_CODE_VOLUME_SET_VOLUME: Int

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

If the session doesn't reject the request through the 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.

Value: 30000

COMMAND_VERSION_1

static val COMMAND_VERSION_1: Int

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)

Value: 1

Public constructors

<init>

SessionCommand(commandCode: Int)

Constructor for creating a predefined command.

Parameters
commandCode Int: A command code for predefined command.

<init>

SessionCommand(@NonNull action: String, @Nullable extras: Bundle?)

Constructor for creating a custom command.

Parameters
action String: The action of this custom command.
extras String: An extra bundle for this custom command.

Public methods

equals

fun equals(other: Any?): Boolean

getCommandCode

fun getCommandCode(): Int

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

getCustomAction

@Nullable fun getCustomAction(): String?

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

getCustomExtras

@Nullable fun getCustomExtras(): Bundle?

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

hashCode

fun hashCode(): Int