Android APIs
public static abstract class

MediaSessionCompat.Callback

extends Object
java.lang.Object
   ↳ android.support.v4.media.session.MediaSessionCompat.Callback

Class Overview

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

Summary

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 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 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 onStop()
Override to handle requests to stop playback.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public MediaSessionCompat.Callback ()

Public Methods

public 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 The command name.
extras 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 void onFastForward ()

Override to handle requests to fast forward.

public boolean onMediaButtonEvent (Intent mediaButtonEvent)

Override to handle media button events.

Parameters
mediaButtonEvent The media button event intent.
Returns
  • True if the event was handled, false otherwise.

public void onPause ()

Override to handle requests to pause playback.

public void onPlay ()

Override to handle requests to begin playback.

public void onRewind ()

Override to handle requests to rewind.

public void onSeekTo (long pos)

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

Parameters
pos New position to move to, in milliseconds.

public void onSetRating (RatingCompat rating)

Override to handle the item being rated.

public void onSkipToNext ()

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

public void onSkipToPrevious ()

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

public void onStop ()

Override to handle requests to stop playback.