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 |
|
---|---|
<init>() |
Public methods |
|
---|---|
open Unit |
onAddQueueItem(description: MediaDescriptionCompat!) Called when a |
open Unit |
onAddQueueItem(description: MediaDescriptionCompat!, index: Int) Called when a |
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 |
open Unit |
Override to handle requests to fast forward. |
open Boolean |
onMediaButtonEvent(mediaButtonEvent: Intent!) Override to handle media button events. |
open Unit |
onPause() Override to handle requests to pause playback. |
open Unit |
onPlay() 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 |
onRemoveQueueItem(description: MediaDescriptionCompat!) Called when a |
open Unit |
onRemoveQueueItemAt(index: Int) Called when a |
open Unit |
onRewind() Override to handle requests to rewind. |
open Unit |
Override to handle requests to seek to a specific position in ms. |
open Unit |
onSetCaptioningEnabled(enabled: Boolean) Override to handle requests to enable/disable captioning. |
open Unit |
onSetRating(rating: RatingCompat!) 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 |
onSkipToQueueItem(id: Long) Override to handle requests to play an item with a given id from the play queue. |
open Unit |
onStop() 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 . |
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. |