public abstract static class MediaSession.Callback extends Object
MediaSession.setCallback(android.media.session.MediaSession.Callback)
.Constructor and Description |
---|
Callback() |
Modifier and Type | Method and Description |
---|---|
void |
onCommand(String command,
Bundle args,
ResultReceiver cb)
Called when a controller has sent a command to this session.
|
void |
onCustomAction(String action,
Bundle extras)
Called when a
MediaController wants a PlaybackState.CustomAction to be
performed. |
void |
onFastForward()
Override to handle requests to fast forward.
|
boolean |
onMediaButtonEvent(Intent mediaButtonIntent)
Called when a media button is pressed and this session has the
highest priority or a controller sends a media button event to the
session.
|
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's
MediaBrowserService . |
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's
MediaBrowserService . |
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(Rating 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.
|
public void onCommand(String command, Bundle args, ResultReceiver cb)
command
- The command name.args
- Optional parameters for the command, may be null.cb
- A result receiver to which a result may be sent by the command, may be null.public boolean onMediaButtonEvent(Intent mediaButtonIntent)
The intent will be of type Intent.ACTION_MEDIA_BUTTON
with a
KeyEvent in Intent.EXTRA_KEY_EVENT
mediaButtonIntent
- an intent containing the KeyEvent as an
extrapublic void onPrepare()
PlaybackState.STATE_PAUSED
after the preparation is
done.public void onPrepareFromMediaId(String mediaId, Bundle extras)
MediaBrowserService
. During the preparation, a session should not
hold audio focus in order to allow other sessions play seamlessly. The state of playback
should be updated to PlaybackState.STATE_PAUSED
after the preparation is done.
The playback of the prepared content should start in the implementation of
onPlay()
. Override onPlayFromMediaId(java.lang.String, android.os.Bundle)
to handle requests for starting
playback without preparation.public void onPrepareFromSearch(String query, Bundle extras)
PlaybackState.STATE_PAUSED
after the preparation is done. The playback
of the prepared content should start in the implementation of onPlay()
. Override
onPlayFromSearch(java.lang.String, android.os.Bundle)
to handle requests for starting playback without preparation.public void onPrepareFromUri(Uri uri, Bundle extras)
PlaybackState.STATE_PAUSED
after the preparation is done.
The playback of the prepared content should start in the implementation of
onPlay()
. Override onPlayFromUri(android.net.Uri, android.os.Bundle)
to handle requests
for starting playback without preparation.public void onPlay()
public void onPlayFromSearch(String query, Bundle extras)
public void onPlayFromMediaId(String mediaId, Bundle extras)
MediaBrowserService
.public void onPlayFromUri(Uri uri, Bundle extras)
public void onSkipToQueueItem(long id)
public void onPause()
public void onSkipToNext()
public void onSkipToPrevious()
public void onFastForward()
public void onRewind()
public void onStop()
public void onSeekTo(long pos)
pos
- New position to move to, in milliseconds.public void onSetRating(Rating rating)
rating
- public void onCustomAction(String action, Bundle extras)
MediaController
wants a PlaybackState.CustomAction
to be
performed.action
- The action that was originally sent in the
PlaybackState.CustomAction
.extras
- Optional extras specified by the MediaController
.