Save the date! Android Dev Summit is coming to Sunnyvale, CA on Oct 23-24, 2019.

SessionCommand2

class SessionCommand2 : VersionedParcelable
kotlin.Any
   ↳ 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
static Int

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

static Int

Command code for MediaController2#play().

static Int

Command code for MediaController2#pause().

static Int

Command code for MediaController2#reset().

static Int

Command code for MediaController2#skipToNextItem().

static Int

Command code for MediaController2#skipToPreviousItem().

static Int

Command code for MediaController2#prepare().

static Int

Command code for MediaController2#fastForward().

static Int

Command code for MediaController2#rewind().

static Int

Command code for MediaController2#seekTo(long).

static Int

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

static Int

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

static Int

Command code for MediaController2#skipToPlaylistItem(MediaItem2).

static Int

Command code for MediaController2#setShuffleMode(int).

static Int

Command code for MediaController2#setRepeatMode(int).

static Int

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

static Int

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

static Int

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

static Int

Command code for MediaController2#getPlaylist().

static Int

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

static Int

Command code for MediaController2#getPlaylistMetadata().

static Int

Command code for MediaController2#updatePlaylistMetadata(MediaMetadata2).

static Int

Command code for MediaController2#getCurrentMediaItem().

static Int

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

static Int

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

static Int

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

static Int

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

static Int

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

static Int

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

static Int

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

static Int

Command code for MediaController2#subscribeRoutesInfo()

static Int

Command code for MediaController2#unsubscribeRoutesInfo()

static Int

Command code for MediaController2#selectRoute(Bundle)}

static Int

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

static Int

Command code for MediaBrowser2#getItem(String).

static Int

Command code for MediaBrowser2#getLibraryRoot(Bundle).

static Int

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

static Int

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

static Int

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

static Int

Command code for MediaBrowser2#unsubscribe(String).

static Int

Command code for MediaController2#setPlaybackSpeed(float)}.

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
Int

Gets the command code of a predefined command.

Int

String?

Gets the action of a custom command.

Boolean
equals(other: Any?)

Bundle?

Gets the extra bundle of a custom command.

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

Value: 0

COMMAND_CODE_PLAYBACK_PLAY

static val COMMAND_CODE_PLAYBACK_PLAY: Int

Command code for MediaController2#play().

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

Value: 1

COMMAND_CODE_PLAYBACK_PAUSE

static val COMMAND_CODE_PLAYBACK_PAUSE: Int

Command code for MediaController2#pause().

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

Value: 2

COMMAND_CODE_PLAYBACK_RESET

static val COMMAND_CODE_PLAYBACK_RESET: Int

Command code for MediaController2#reset().

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

Value: 3

COMMAND_CODE_PLAYLIST_SKIP_TO_NEXT_ITEM

static val COMMAND_CODE_PLAYLIST_SKIP_TO_NEXT_ITEM: Int

Command code for MediaController2#skipToNextItem().

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

Value: 4

COMMAND_CODE_PLAYLIST_SKIP_TO_PREV_ITEM

static val COMMAND_CODE_PLAYLIST_SKIP_TO_PREV_ITEM: Int

Command code for MediaController2#skipToPreviousItem().

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

Value: 5

COMMAND_CODE_PLAYBACK_PREPARE

static val COMMAND_CODE_PLAYBACK_PREPARE: Int

Command code for MediaController2#prepare().

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

Value: 6

COMMAND_CODE_SESSION_FAST_FORWARD

static val COMMAND_CODE_SESSION_FAST_FORWARD: Int

Command code for MediaController2#fastForward().

Value: 7

COMMAND_CODE_SESSION_REWIND

static val COMMAND_CODE_SESSION_REWIND: Int

Command code for MediaController2#rewind().

Value: 8

COMMAND_CODE_PLAYBACK_SEEK_TO

static val COMMAND_CODE_PLAYBACK_SEEK_TO: Int

Command code for MediaController2#seekTo(long).

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

Value: 9

COMMAND_CODE_VOLUME_SET_VOLUME

static val COMMAND_CODE_VOLUME_SET_VOLUME: Int

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

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

Value: 10

COMMAND_CODE_VOLUME_ADJUST_VOLUME

static val COMMAND_CODE_VOLUME_ADJUST_VOLUME: Int

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

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

Value: 11

COMMAND_CODE_PLAYLIST_SKIP_TO_PLAYLIST_ITEM

static val COMMAND_CODE_PLAYLIST_SKIP_TO_PLAYLIST_ITEM: Int

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

Value: 12

COMMAND_CODE_PLAYLIST_SET_SHUFFLE_MODE

static val COMMAND_CODE_PLAYLIST_SET_SHUFFLE_MODE: Int

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

Value: 13

COMMAND_CODE_PLAYLIST_SET_REPEAT_MODE

static val COMMAND_CODE_PLAYLIST_SET_REPEAT_MODE: Int

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

Value: 14

COMMAND_CODE_PLAYLIST_ADD_ITEM

static val COMMAND_CODE_PLAYLIST_ADD_ITEM: Int

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

Value: 15

COMMAND_CODE_PLAYLIST_REMOVE_ITEM

static val COMMAND_CODE_PLAYLIST_REMOVE_ITEM: Int

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

Value: 16

COMMAND_CODE_PLAYLIST_REPLACE_ITEM

static val COMMAND_CODE_PLAYLIST_REPLACE_ITEM: Int

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

Value: 17

COMMAND_CODE_PLAYLIST_GET_LIST

static val COMMAND_CODE_PLAYLIST_GET_LIST: Int

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

Value: 18

COMMAND_CODE_PLAYLIST_SET_LIST

static val COMMAND_CODE_PLAYLIST_SET_LIST: Int

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

Value: 19

COMMAND_CODE_PLAYLIST_GET_LIST_METADATA

static val COMMAND_CODE_PLAYLIST_GET_LIST_METADATA: Int

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

Value: 20

COMMAND_CODE_PLAYLIST_SET_LIST_METADATA

static val COMMAND_CODE_PLAYLIST_SET_LIST_METADATA: Int

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

Value: 21

COMMAND_CODE_PLAYLIST_GET_CURRENT_MEDIA_ITEM

static val COMMAND_CODE_PLAYLIST_GET_CURRENT_MEDIA_ITEM: Int

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

Value: 20

COMMAND_CODE_SESSION_PLAY_FROM_MEDIA_ID

static val COMMAND_CODE_SESSION_PLAY_FROM_MEDIA_ID: Int

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

Value: 22

COMMAND_CODE_SESSION_PLAY_FROM_URI

static val COMMAND_CODE_SESSION_PLAY_FROM_URI: Int

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

Value: 23

COMMAND_CODE_SESSION_PLAY_FROM_SEARCH

static val COMMAND_CODE_SESSION_PLAY_FROM_SEARCH: Int

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

Value: 24

COMMAND_CODE_SESSION_PREPARE_FROM_MEDIA_ID

static val COMMAND_CODE_SESSION_PREPARE_FROM_MEDIA_ID: Int

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

Value: 25

COMMAND_CODE_SESSION_PREPARE_FROM_URI

static val COMMAND_CODE_SESSION_PREPARE_FROM_URI: Int

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

Value: 26

COMMAND_CODE_SESSION_PREPARE_FROM_SEARCH

static val COMMAND_CODE_SESSION_PREPARE_FROM_SEARCH: Int

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

Value: 27

COMMAND_CODE_SESSION_SET_RATING

static val COMMAND_CODE_SESSION_SET_RATING: Int

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

Value: 28

COMMAND_CODE_SESSION_SUBSCRIBE_ROUTES_INFO

static val COMMAND_CODE_SESSION_SUBSCRIBE_ROUTES_INFO: Int

Command code for MediaController2#subscribeRoutesInfo()

Value: 36

COMMAND_CODE_SESSION_UNSUBSCRIBE_ROUTES_INFO

static val COMMAND_CODE_SESSION_UNSUBSCRIBE_ROUTES_INFO: Int

Command code for MediaController2#unsubscribeRoutesInfo()

Value: 37

COMMAND_CODE_SESSION_SELECT_ROUTE

static val COMMAND_CODE_SESSION_SELECT_ROUTE: Int

Command code for MediaController2#selectRoute(Bundle)}

Value: 38

COMMAND_CODE_LIBRARY_GET_CHILDREN

static val COMMAND_CODE_LIBRARY_GET_CHILDREN: Int

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

Value: 29

COMMAND_CODE_LIBRARY_GET_ITEM

static val COMMAND_CODE_LIBRARY_GET_ITEM: Int

Command code for MediaBrowser2#getItem(String).

Value: 30

COMMAND_CODE_LIBRARY_GET_LIBRARY_ROOT

static val COMMAND_CODE_LIBRARY_GET_LIBRARY_ROOT: Int

Command code for MediaBrowser2#getLibraryRoot(Bundle).

Value: 31

COMMAND_CODE_LIBRARY_GET_SEARCH_RESULT

static val COMMAND_CODE_LIBRARY_GET_SEARCH_RESULT: Int

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

Value: 32

COMMAND_CODE_LIBRARY_SEARCH

static val COMMAND_CODE_LIBRARY_SEARCH: Int

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

Value: 33

COMMAND_CODE_LIBRARY_SUBSCRIBE

static val COMMAND_CODE_LIBRARY_SUBSCRIBE: Int

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

Value: 34

COMMAND_CODE_LIBRARY_UNSUBSCRIBE

static val COMMAND_CODE_LIBRARY_UNSUBSCRIBE: Int

Command code for MediaBrowser2#unsubscribe(String).

Value: 35

COMMAND_CODE_PLAYBACK_SET_SPEED

static val COMMAND_CODE_PLAYBACK_SET_SPEED: Int

Command code for MediaController2#setPlaybackSpeed(float)}.

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

Value: 39

Public constructors

<init>

SessionCommand2(commandCode: Int)

Constructor for creating a predefined command.

Parameters
commandCode Int: A command code for predefined command.

<init>

SessionCommand2(@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

getCommandCode

fun getCommandCode(): Int

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

hashCode

fun hashCode(): Int

getCustomCommand

@Nullable fun getCustomCommand(): String?

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

equals

fun equals(other: Any?): Boolean

getExtras

@Nullable fun getExtras(): Bundle?

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