Android 12 Developer Preview is here! Try it out, and give us your feedback!

SessionCallback

abstract class SessionCallback
kotlin.Any
   ↳ 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

Callback to be called for all incoming commands from MediaControllers.

Public methods
open Int
onCommandRequest(@NonNull session: MediaSession, @NonNull controller: MediaSession.ControllerInfo, @NonNull command: SessionCommand)

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

open SessionCommandGroup?
onConnect(@NonNull session: MediaSession, @NonNull controller: MediaSession.ControllerInfo)

Called when a controller is created for this session.

open MediaItem?
onCreateMediaItem(@NonNull session: MediaSession, @NonNull controller: MediaSession.ControllerInfo, @NonNull mediaId: String)

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

open SessionResult
onCustomCommand(@NonNull session: MediaSession, @NonNull controller: MediaSession.ControllerInfo, @NonNull customCommand: SessionCommand, @Nullable args: Bundle?)

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

open Unit
onDisconnected(@NonNull session: MediaSession, @NonNull controller: MediaSession.ControllerInfo)

Called when a controller is disconnected.

open Int
onFastForward(@NonNull session: MediaSession, @NonNull controller: MediaSession.ControllerInfo)

Called when a controller called MediaController#fastForward().

open Unit
onPostConnect(@NonNull session: MediaSession, @NonNull controller: MediaSession.ControllerInfo)

Called immediately after a controller is connected.

open Int
onRewind(@NonNull session: MediaSession, @NonNull controller: MediaSession.ControllerInfo)

Called when a controller called MediaController#rewind().

open Int
onSetMediaUri(@NonNull session: MediaSession, @NonNull controller: MediaSession.ControllerInfo, @NonNull uri: Uri, @Nullable extras: Bundle?)

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

open Int
onSetRating(@NonNull session: MediaSession, @NonNull controller: MediaSession.ControllerInfo, @NonNull mediaId: String, @NonNull rating: Rating)

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

open Int
onSkipBackward(@NonNull session: MediaSession, @NonNull controller: MediaSession.ControllerInfo)

Called when a controller called MediaController#skipBackward().

open</