public
static
abstract
class
MediaSessionCompat.Callback
extends Object
java.lang.Object | |
↳ | 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(MediaSessionCompat.Callback)
.
Public constructors | |
---|---|
MediaSessionCompat.Callback()
|
Public methods | |
---|---|
void
|
onCommand(String command, Bundle extras, ResultReceiver cb)
Called when a controller has sent a custom command to this session. |
void
|
onCustomAction(String action, Bundle extras)
Called when a |
void
|
onFastForward()
Override to handle requests to fast forward. |
boolean
|
onMediaButtonEvent(Intent mediaButtonEvent)
Override to handle media button events. |
void
|
onPause()
Override to handle requests to pause playback. |
void
|
onPlay()
Override to handle requests to begin playback. |
void
|
onPlayFromMediaId(String mediaId, Bundle extras)
Override to handle requests to play a specific mediaId that was provided by your app. |
void
|
onPlayFromSearch(String query, Bundle extras)
Override to handle requests to begin playback from a search query. |
void
|
onPlayFromUri(Uri uri, Bundle extras)
Override to handle requests to play a specific media item represented by a URI. |
void
|
onPrepare()
Override to handle requests to prepare playback. |
void
|
onPrepareFromMediaId(String mediaId, Bundle extras)
Override to handle requests to prepare for playing a specific mediaId that was provided by your app. |
void
|
onPrepareFromSearch(String query, Bundle extras)
Override to handle requests to prepare playback from a search query. |
void
|
onPrepareFromUri(Uri uri, Bundle extras)
Override to handle requests to prepare a specific media item represented by a URI. |
void
|
onRewind()
Override to handle requests to rewind. |
void
|
onSeekTo(long pos)
Override to handle requests to seek to a specific position in ms. |
void
|
onSetRating(RatingCompat rating)
Override to handle the item being rated. |
void
|
onSkipToNext()
Override to handle requests to skip to the next media item. |
void
|
onSkipToPrevious()
Override to handle requests to skip to the previous media item. |
void
|
onSkipToQueueItem(long id)
Override to handle requests to play an item with a given id from the play queue. |
void
|
onStop()
Override to handle requests to stop playback. |
Inherited methods | |
---|---|
From
class
java.lang.Object
|
MediaSessionCompat.Callback ()
void onCommand (String command, Bundle extras, ResultReceiver cb)
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 |
Bundle :
Optional parameters for the command, may be null. |
cb |
ResultReceiver :
A result receiver to which a result may be sent by the command, may be null.
|
void onCustomAction (String action, Bundle extras)
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 |
Bundle :
Optional extras specified by the
MediaControllerCompat .
|
void onFastForward ()
Override to handle requests to fast forward.
boolean onMediaButtonEvent (Intent mediaButtonEvent)
Override to handle media button events.
Parameters | |
---|---|
mediaButtonEvent |
Intent :
The media button event intent. |
Returns | |
---|---|
boolean |
True if the event was handled, false otherwise. |
void onPause ()
Override to handle requests to pause playback.
void onPlay ()
Override to handle requests to begin playback.
void onPlayFromMediaId (String mediaId, Bundle extras)
Override to handle requests to play a specific mediaId that was provided by your app.
Parameters | |
---|---|
mediaId |
String
|
extras |
Bundle
|
void onPlayFromSearch (String query, Bundle extras)
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.
Parameters | |
---|---|
query |
String
|
extras |
Bundle
|
void onPlayFromUri (Uri uri, Bundle extras)
Override to handle requests to play a specific media item represented by a URI.
Parameters | |
---|---|
uri |
Uri
|
extras |
Bundle
|
void onPrepare ()
Override to handle requests to prepare playback. During the preparation, a session
should not hold audio focus in order to allow other session play seamlessly.
The state of playback should be updated to STATE_PAUSED
after the preparation is done.
void onPrepareFromMediaId (String mediaId, Bundle extras)
Override to handle requests to prepare for playing a specific mediaId that was provided
by your app. During the preparation, a session should not hold audio focus in order to
allow other session play seamlessly. The state of playback should be updated to
STATE_PAUSED
after the preparation is done. The playback
of the prepared content should start in the implementation of onPlay()
. Override
onPlayFromMediaId(String, Bundle)
to handle requests for starting playback without preparation.
Parameters | |
---|---|
mediaId |
String
|
extras |
Bundle
|
void onPrepareFromSearch (String query, Bundle extras)
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. During the preparation, a session should not hold audio focus in order to allow
other session play seamlessly. The state of playback should be updated to
STATE_PAUSED
after the preparation is done.
The playback of the prepared content should start in the implementation of
onPlay()
. Override onPlayFromSearch(String, Bundle)
to handle requests for
starting playback without preparation.
Parameters | |
---|---|
query |
String
|
extras |
Bundle
|
void onPrepareFromUri (Uri uri, Bundle extras)
Override to handle requests to prepare a specific media item represented by a URI.
During the preparation, a session should not hold audio focus in order to allow other
session play seamlessly. The state of playback should be updated to
STATE_PAUSED
after the preparation is done. The playback of
the prepared content should start in the implementation of onPlay()
. Override
onPlayFromUri(Uri, Bundle)
to handle requests for starting playback without preparation.
Parameters | |
---|---|
uri |
Uri
|
extras |
Bundle
|
void onRewind ()
Override to handle requests to rewind.
void onSeekTo (long pos)
Override to handle requests to seek to a specific position in ms.
Parameters | |
---|---|
pos |
long :
New position to move to, in milliseconds.
|
void onSkipToNext ()
Override to handle requests to skip to the next media item.
void onSkipToPrevious ()
Override to handle requests to skip to the previous media item.
void onSkipToQueueItem (long id)
Override to handle requests to play an item with a given id from the play queue.
Parameters | |
---|---|
id |
long
|
void onStop ()
Override to handle requests to stop playback.