MediaSession.SessionCallback

public static abstract class MediaSession.SessionCallback
extends Object

java.lang.Object
   ↳ androidx.media2.session.MediaSession.SessionCallback


Callback to be called for all incoming commands from MediaControllers.

If it's not set, the session will accept all controllers and all incoming commands by default.

Summary

Public constructors

SessionCallback()

Public methods

int onCommandRequest(MediaSession session, MediaSession.ControllerInfo controller, SessionCommand command)

Called when a controller sent a command which will be sent directly to one of the following:

Return SessionResult.RESULT_SUCCESS to proceed the command.

SessionCommandGroup onConnect(MediaSession session, MediaSession.ControllerInfo controller)

Called when a controller is created for this session.

MediaItem onCreateMediaItem(MediaSession session, MediaSession.ControllerInfo controller, String mediaId)

Called when a controller has sent a command with a MediaItem to add a new media item to this session.

SessionResult onCustomCommand(MediaSession session, MediaSession.ControllerInfo controller, SessionCommand customCommand, Bundle args)

Called when a controller sent a custom command through MediaController.sendCustomCommand(SessionCommand, Bundle).

void onDisconnected(MediaSession session, MediaSession.ControllerInfo controller)

Called when a controller is disconnected.

int onFastForward(MediaSession session, MediaSession.ControllerInfo controller)

Called when a controller called MediaController.fastForward().

void onPostConnect(MediaSession session, MediaSession.ControllerInfo controller)

Called immediately after a controller is connected.

int onRewind(MediaSession session, MediaSession.ControllerInfo controller)

Called when a controller called MediaController.rewind().

int onSetMediaUri(MediaSession session, MediaSession.ControllerInfo controller, Uri uri, Bundle extras)

Called when a controller requested to set the specific media item(s) represented by a URI through MediaController.setMediaUri(Uri, Bundle).

int onSetRating(MediaSession session, MediaSession.ControllerInfo controller, String mediaId, Rating rating)

Called when a controller set rating of a media item through MediaController.setRating(String, Rating).

int onSkipBackward(MediaSession session, MediaSession.ControllerInfo controller)

Called when a controller called MediaController.skipBackward().

int onSkipForward(MediaSession session, MediaSession.ControllerInfo controller)

Called when a controller called MediaController.skipForward().

Inherited methods

Public constructors

SessionCallback

public SessionCallback ()

Public methods

onCommandRequest

public int onCommandRequest (MediaSession session, 
                MediaSession.ControllerInfo controller,