The Android Developer Challenge is back! Submit your idea before December 2.

Callback

abstract class Callback
kotlin.Any
   ↳ android.support.v4.media.session.MediaSessionCompat.Callback

Receives transport controls, media buttons, and commands from controllers and the system. The callback may be set using setCallback.

Summary

Public constructors

Public methods

open Unit

Called when a MediaControllerCompat wants to add a QueueItem with the given description at the end of the play queue.

open Unit
onAddQueueItem(description: MediaDescriptionCompat!, index: Int)

Called when a MediaControllerCompat wants to add a QueueItem with the given description at the specified position in the play queue.

open Unit
onCommand(command: String!, extras: Bundle!, cb: ResultReceiver!)

Called when a controller has sent a custom command to this session.

open Unit
onCustomAction(action: String!, extras: Bundle!)

Called when a MediaControllerCompat wants a PlaybackStateCompat.CustomAction to be performed.

open Unit

Override to handle requests to fast forward.

open Boolean
onMediaButtonEvent(mediaButtonEvent: Intent!)

Override to handle media button events.

open Unit

Override to handle requests to pause playback.

open Unit

Override to handle requests to begin playback.

open Unit
onPlayFromMediaId(mediaId: String!, extras: Bundle!)

Override to handle requests to play a specific mediaId that was provided by your app.

open Unit
onPlayFromSearch(query: String!, extras: Bundle!)

Override to handle requests to begin playback from a search query.

open Unit
onPlayFromUri(uri: Uri!, extras: Bundle!)

Override to handle requests to play a specific media item represented by a URI.

open Unit

Override to handle requests to prepare playback.

open Unit
onPrepareFromMediaId(mediaId: String!, extras: Bundle!)

Override to handle requests to prepare for playing a specific mediaId that was provided by your app.

open Unit
onPrepareFromSearch(query: String!, extras: Bundle!)

Override to handle requests to prepare playback from a search query.

open Unit
onPrepareFromUri(uri: Uri!, extras: Bundle!)

Override to handle requests to prepare a specific media item represented by a URI.

open Unit

Called when a MediaControllerCompat wants to remove the first occurrence of the specified QueueItem with the given description in the play queue.

open Unit

Called when a MediaControllerCompat wants to remove a QueueItem at the specified position in the play queue.

open Unit

Override to handle requests to rewind.

open Unit
onSeekTo(pos: Long)

Override to handle requests to seek to a specific position in ms.

open Unit

Override to handle requests to enable/disable captioning.

open Unit

Override to handle the item being rated.

open Unit
onSetRating(rating: RatingCompat!, extras: Bundle!)

Override to handle the item being rated.

open Unit
onSetRepeatMode(repeatMode: Int)

Override to handle the setting of the repeat mode.

open Unit
onSetShuffleMode(shuffleMode: Int)

Override to handle the setting of the shuffle mode.

open Unit

Override to handle requests to skip to the next media item.

open Unit

Override to handle requests to skip to the previous media item.

open Unit

Override to handle requests to play an item with a given id from the play queue.

open Unit

Override to handle requests to stop playback.

Public constructors

<init>

Callback()

Public methods

onAddQueueItem

open fun onAddQueueItem(description: MediaDescriptionCompat!): Unit

Called when a MediaControllerCompat wants to add a QueueItem with the given description at the end of the play queue.

Parameters
description MediaDescriptionCompat!: The MediaDescriptionCompat for creating the QueueItem to be inserted.

onAddQueueItem

open fun onAddQueueItem(description: MediaDescriptionCompat!, index: Int): Unit

Called when a MediaControllerCompat wants to add a QueueItem with the given description at the specified position in the play queue.

Parameters
description MediaDescriptionCompat!: The MediaDescriptionCompat for creating the QueueItem to be inserted.
index MediaDescriptionCompat!: The index at which the created QueueItem is to be inserted.

onCommand

open fun onCommand(command: String!, extras: Bundle!, cb: ResultReceiver!): Unit

Called when a controller has sent a custom command to this session. The owner of the session may handle custom commands but is not required to.

Parameters
command String!: The command name.
extras String!: Optional parameters for the command, may be null.
cb String!: A result receiver to which a result may be sent by the command, may be null.

onCustomAction

open fun onCustomAction(action: String!, extras: Bundle!): Unit

Called when a MediaControllerCompat wants a PlaybackStateCompat.CustomAction to be performed.

Parameters
action String!: The action that was originally sent in the PlaybackStateCompat.CustomAction.
extras String!: Optional extras specified by the MediaControllerCompat.

onFastForward

open fun onFastForward(): Unit

Override to handle requests to fast forward.

onMediaButtonEvent

open fun onMediaButtonEvent(mediaButtonEvent: Intent!): Boolean

Override to handle media button events.

The double tap of KeyEvent#KEYCODE_MEDIA_PLAY_PAUSE or will call the onSkipToNext by default. If the current SDK level is 27 or higher, the default double tap handling is done by framework so this method would do nothing for it.

Parameters
mediaButtonEvent Intent!: The media button event intent.
Return
Boolean: True if the event was handled, false otherwise.

onPause

open fun onPause(): Unit

Override to handle requests to pause playback.

onPlay

open fun onPlay(): Unit

Override to handle requests to begin playback.

onPlayFromMediaId

open fun onPlayFromMediaId(mediaId: String!, extras: Bundle!): Unit

Override to handle requests to play a specific mediaId that was provided by your app.

onPlayFromSearch

open fun onPlayFromSearch(query: String!, extras: Bundle!): Unit

Override to handle requests to begin playback from a search query. An empty query indicates that the app may play any music. The implementation should attempt to make a smart choice about what to play.

onPlayFromUri

open fun onPlayFromUri(uri: Uri!, extras: Bundle!): Unit

Override to handle requests to play a specific media item represented by a URI.

onPrepare

open fun onPrepare(): Unit

Override to handle requests to prepare playback. Override onPlay to handle requests for starting playback.

onPrepareFromMediaId

open fun onPrepareFromMediaId(mediaId: String!, extras: Bundle!): Unit

Override to handle requests to prepare for playing a specific mediaId that was provided by your app. Override onPlayFromMediaId to handle requests for starting playback.

onPrepareFromSearch

open fun onPrepareFromSearch(query: String!, extras: Bundle!): Unit

Override to handle requests to prepare playback from a search query. An empty query indicates that the app may prepare any music. The implementation should attempt to make a smart choice about what to play. Override onPlayFromSearch to handle requests for starting playback.

onPrepareFromUri

open fun onPrepareFromUri(uri: Uri!, extras: Bundle!): Unit

Override to handle requests to prepare a specific media item represented by a URI. Override onPlayFromUri to handle requests for starting playback.

onRemoveQueueItem

open fun onRemoveQueueItem(description: MediaDescriptionCompat!): Unit

Called when a MediaControllerCompat wants to remove the first occurrence of the specified QueueItem with the given description in the play queue.

Parameters
description MediaDescriptionCompat!: The MediaDescriptionCompat for denoting the QueueItem to be removed.

onRemoveQueueItemAt

open fun onRemoveQueueItemAt(index: Int): Unit

Deprecated: onRemoveQueueItem will be called instead.

Called when a MediaControllerCompat wants to remove a QueueItem at the specified position in the play queue.

Parameters
index Int: The index of the element to be removed.

onRewind

open fun onRewind(): Unit

Override to handle requests to rewind.

onSeekTo

open fun onSeekTo(pos: Long): Unit

Override to handle requests to seek to a specific position in ms.

Parameters
pos Long: New position to move to, in milliseconds.

onSetCaptioningEnabled

open fun onSetCaptioningEnabled(enabled: Boolean): Unit

Override to handle requests to enable/disable captioning.

Parameters
enabled Boolean: true to enable captioning, false to disable.

onSetRating

open fun onSetRating(rating: RatingCompat!): Unit

Override to handle the item being rated.

Parameters
rating RatingCompat!: The rating being set.

onSetRating

open fun onSetRating(rating: RatingCompat!, extras: Bundle!): Unit

Override to handle the item being rated.

Parameters
rating RatingCompat!: The rating being set.
extras RatingCompat!: The extras can include information about the media item being rated.

onSetRepeatMode

open fun onSetRepeatMode(repeatMode: Int): Unit

Override to handle the setting of the repeat mode.

You should call setRepeatMode before end of this method in order to notify the change to the MediaControllerCompat, or MediaControllerCompat#getRepeatMode could return an invalid value.

Parameters
repeatMode Int: The repeat mode which is one of followings: PlaybackStateCompat#REPEAT_MODE_NONE, PlaybackStateCompat#REPEAT_MODE_ONE, PlaybackStateCompat#REPEAT_MODE_ALL, PlaybackStateCompat#REPEAT_MODE_GROUP

onSetShuffleMode

open fun onSetShuffleMode(shuffleMode: Int): Unit

Override to handle the setting of the shuffle mode.

You should call setShuffleMode before the end of this method in order to notify the change to the MediaControllerCompat, or MediaControllerCompat#getShuffleMode could return an invalid value.

Parameters
shuffleMode Int: The shuffle mode which is one of followings: PlaybackStateCompat#SHUFFLE_MODE_NONE, PlaybackStateCompat#SHUFFLE_MODE_ALL, PlaybackStateCompat#SHUFFLE_MODE_GROUP

onSkipToNext

open fun onSkipToNext(): Unit

Override to handle requests to skip to the next media item.

onSkipToPrevious

open fun onSkipToPrevious(): Unit

Override to handle requests to skip to the previous media item.

onSkipToQueueItem

open fun onSkipToQueueItem(id: Long): Unit

Override to handle requests to play an item with a given id from the play queue.

onStop

open fun onStop(): Unit

Override to handle requests to stop playback.