# MediaSessionCompat.Callback

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  
belongs to Maven artifact com.android.support:support-media-compat:28.0.0-alpha1  
Summary:[Ctors](https://developer.android.com/reference/android/support/v4-media-session/MediaSessionCompat.Callback#pubctors)\|[Methods](https://developer.android.com/reference/android/support/v4-media-session/MediaSessionCompat.Callback#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/android/support/v4-media-session/MediaSessionCompat.Callback#inhmethods)\|[\[Expand All\]](https://developer.android.com/reference/android/support/v4-media-session/MediaSessionCompat.Callback#)  

# MediaSessionCompat.Callback

| This package is part of the Android[support library](https://developer.android.com/topic/libraries/support-library)which is no longer maintained. The support library has been superseded by[AndroidX](https://developer.android.com/jetpack/androidx)which is part of[Jetpack](https://developer.android.com/jetpack). We recommend using the AndroidX libraries in all new projects. You should also consider[migrating](https://developer.android.com/jetpack/androidx/migrate)existing projects to AndroidX. To find the AndroidX class that maps to this deprecated class, see the AndroidX support library[class mappings](https://developer.android.com/jetpack/androidx/migrate/class-mappings).

`
public
static

abstract
class
MediaSessionCompat.Callback
`  
`

extends Object


``


`

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

<br />

*** ** * ** ***

Receives transport controls, media buttons, and commands from controllers and the system. The callback may be set using[setCallback(MediaSessionCompat.Callback)](https://developer.android.com/reference/android/support/v4/media/session/MediaSessionCompat#setCallback(android.support.v4.media.session.MediaSessionCompat.Callback)).

## Summary

|                                                                           ### Public constructors                                                                            ||
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| ` `[MediaSessionCompat.Callback](https://developer.android.com/reference/android/support/v4/media/session/MediaSessionCompat.Callback#MediaSessionCompat.Callback())`() ` |

|                                                                                                                                                                                                                                                                                                                                                                                                  ### Public methods                                                                                                                                                                                                                                                                                                                                                                                                  ||
|------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` void`    | ` `[onAddQueueItem](https://developer.android.com/reference/android/support/v4/media/session/MediaSessionCompat.Callback#onAddQueueItem(android.support.v4.media.MediaDescriptionCompat, int))`(`[MediaDescriptionCompat](https://developer.android.com/reference/android/support/v4/media/MediaDescriptionCompat)` description, int index) ` Called when a[MediaControllerCompat](https://developer.android.com/reference/android/support/v4/media/session/MediaControllerCompat)wants to add a[MediaSessionCompat.QueueItem](https://developer.android.com/reference/android/support/v4/media/session/MediaSessionCompat.QueueItem)with the given[description](https://developer.android.com/reference/android/support/v4/media/MediaDescriptionCompat)at the specified position in the play queue.    |
| ` void`    | ` `[onAddQueueItem](https://developer.android.com/reference/android/support/v4/media/session/MediaSessionCompat.Callback#onAddQueueItem(android.support.v4.media.MediaDescriptionCompat))`(`[MediaDescriptionCompat](https://developer.android.com/reference/android/support/v4/media/MediaDescriptionCompat)` description) ` Called when a[MediaControllerCompat](https://developer.android.com/reference/android/support/v4/media/session/MediaControllerCompat)wants to add a[MediaSessionCompat.QueueItem](https://developer.android.com/reference/android/support/v4/media/session/MediaSessionCompat.QueueItem)with the given[description](https://developer.android.com/reference/android/support/v4/media/MediaDescriptionCompat)at the end of the play queue.                                   |
| ` void`    | ` `[onCommand](https://developer.android.com/reference/android/support/v4/media/session/MediaSessionCompat.Callback#onCommand(java.lang.String, android.os.Bundle, android.os.ResultReceiver))`(String command, `[Bundle](https://developer.android.com/reference/android/os/Bundle.html)` extras, `[ResultReceiver](https://developer.android.com/reference/android/os/ResultReceiver.html)` cb) ` Called when a controller has sent a custom command to this session.                                                                                                                                                                                                                                                                                                                                  |
| ` void`    | ` `[onCustomAction](https://developer.android.com/reference/android/support/v4/media/session/MediaSessionCompat.Callback#onCustomAction(java.lang.String, android.os.Bundle))`(String action, `[Bundle](https://developer.android.com/reference/android/os/Bundle.html)` extras) ` Called when a[MediaControllerCompat](https://developer.android.com/reference/android/support/v4/media/session/MediaControllerCompat)wants a[PlaybackStateCompat.CustomAction](https://developer.android.com/reference/android/support/v4/media/session/PlaybackStateCompat.CustomAction)to be performed.                                                                                                                                                                                                              |
| ` void`    | ` `[onFastForward](https://developer.android.com/reference/android/support/v4/media/session/MediaSessionCompat.Callback#onFastForward())`() ` Override to handle requests to fast forward.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| ` boolean` | ` `[onMediaButtonEvent](https://developer.android.com/reference/android/support/v4/media/session/MediaSessionCompat.Callback#onMediaButtonEvent(android.content.Intent))`(`[Intent](https://developer.android.com/reference/android/content/Intent.html)` mediaButtonEvent) ` Override to handle media button events.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| ` void`    | ` `[onPause](https://developer.android.com/reference/android/support/v4/media/session/MediaSessionCompat.Callback#onPause())`() ` Override to handle requests to pause playback.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| ` void`    | ` `[onPlay](https://developer.android.com/reference/android/support/v4/media/session/MediaSessionCompat.Callback#onPlay())`() ` Override to handle requests to begin playback.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| ` void`    | ` `[onPlayFromMediaId](https://developer.android.com/reference/android/support/v4/media/session/MediaSessionCompat.Callback#onPlayFromMediaId(java.lang.String, android.os.Bundle))`(String mediaId, `[Bundle](https://developer.android.com/reference/android/os/Bundle.html)` extras) ` Override to handle requests to play a specific mediaId that was provided by your app.                                                                                                                                                                                                                                                                                                                                                                                                                          |
| ` void`    | ` `[onPlayFromSearch](https://developer.android.com/reference/android/support/v4/media/session/MediaSessionCompat.Callback#onPlayFromSearch(java.lang.String, android.os.Bundle))`(String query, `[Bundle](https://developer.android.com/reference/android/os/Bundle.html)` extras) ` Override to handle requests to begin playback from a search query.                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| ` void`    | ` `[onPlayFromUri](https://developer.android.com/reference/android/support/v4/media/session/MediaSessionCompat.Callback#onPlayFromUri(android.net.Uri, android.os.Bundle))`(`[Uri](https://developer.android.com/reference/android/net/Uri.html)` uri, `[Bundle](https://developer.android.com/reference/android/os/Bundle.html)` extras) ` Override to handle requests to play a specific media item represented by a URI.                                                                                                                                                                                                                                                                                                                                                                              |
| ` void`    | ` `[onPrepare](https://developer.android.com/reference/android/support/v4/media/session/MediaSessionCompat.Callback#onPrepare())`() ` Override to handle requests to prepare playback.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| ` void`    | ` `[onPrepareFromMediaId](https://developer.android.com/reference/android/support/v4/media/session/MediaSessionCompat.Callback#onPrepareFromMediaId(java.lang.String, android.os.Bundle))`(String mediaId, `[Bundle](https://developer.android.com/reference/android/os/Bundle.html)` extras) ` Override to handle requests to prepare for playing a specific mediaId that was provided by your app.                                                                                                                                                                                                                                                                                                                                                                                                     |
| ` void`    | ` `[onPrepareFromSearch](https://developer.android.com/reference/android/support/v4/media/session/MediaSessionCompat.Callback#onPrepareFromSearch(java.lang.String, android.os.Bundle))`(String query, `[Bundle](https://developer.android.com/reference/android/os/Bundle.html)` extras) ` Override to handle requests to prepare playback from a search query.                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| ` void`    | ` `[onPrepareFromUri](https://developer.android.com/reference/android/support/v4/media/session/MediaSessionCompat.Callback#onPrepareFromUri(android.net.Uri, android.os.Bundle))`(`[Uri](https://developer.android.com/reference/android/net/Uri.html)` uri, `[Bundle](https://developer.android.com/reference/android/os/Bundle.html)` extras) ` Override to handle requests to prepare a specific media item represented by a URI.                                                                                                                                                                                                                                                                                                                                                                     |
| ` void`    | ` `[onRemoveQueueItem](https://developer.android.com/reference/android/support/v4/media/session/MediaSessionCompat.Callback#onRemoveQueueItem(android.support.v4.media.MediaDescriptionCompat))`(`[MediaDescriptionCompat](https://developer.android.com/reference/android/support/v4/media/MediaDescriptionCompat)` description) ` Called when a[MediaControllerCompat](https://developer.android.com/reference/android/support/v4/media/session/MediaControllerCompat)wants to remove the first occurrence of the specified[MediaSessionCompat.QueueItem](https://developer.android.com/reference/android/support/v4/media/session/MediaSessionCompat.QueueItem)with the given[description](https://developer.android.com/reference/android/support/v4/media/MediaDescriptionCompat)in the play queue. |
| ` void`    | ` `[onRemoveQueueItemAt](https://developer.android.com/reference/android/support/v4/media/session/MediaSessionCompat.Callback#onRemoveQueueItemAt(int))`(int index) ` *This method was deprecated in API level 26.1.0.[onRemoveQueueItem(MediaDescriptionCompat)](https://developer.android.com/reference/android/support/v4/media/session/MediaSessionCompat.Callback#onRemoveQueueItem(android.support.v4.media.MediaDescriptionCompat))will be called instead.*                                                                                                                                                                                                                                                                                                                                       |
| ` void`    | ` `[onRewind](https://developer.android.com/reference/android/support/v4/media/session/MediaSessionCompat.Callback#onRewind())`() ` Override to handle requests to rewind.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| ` void`    | ` `[onSeekTo](https://developer.android.com/reference/android/support/v4/media/session/MediaSessionCompat.Callback#onSeekTo(long))`(long pos) ` Override to handle requests to seek to a specific position in ms.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| ` void`    | ` `[onSetCaptioningEnabled](https://developer.android.com/reference/android/support/v4/media/session/MediaSessionCompat.Callback#onSetCaptioningEnabled(boolean))`(boolean enabled) ` Override to handle requests to enable/disable captioning.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| ` void`    | ` `[onSetRating](https://developer.android.com/reference/android/support/v4/media/session/MediaSessionCompat.Callback#onSetRating(android.support.v4.media.RatingCompat))`(`[RatingCompat](https://developer.android.com/reference/android/support/v4/media/RatingCompat)` rating) ` Override to handle the item being rated.                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| ` void`    | ` `[onSetRating](https://developer.android.com/reference/android/support/v4/media/session/MediaSessionCompat.Callback#onSetRating(android.support.v4.media.RatingCompat, android.os.Bundle))`(`[RatingCompat](https://developer.android.com/reference/android/support/v4/media/RatingCompat)` rating, `[Bundle](https://developer.android.com/reference/android/os/Bundle.html)` extras) ` Override to handle the item being rated.                                                                                                                                                                                                                                                                                                                                                                      |
| ` void`    | ` `[onSetRepeatMode](https://developer.android.com/reference/android/support/v4/media/session/MediaSessionCompat.Callback#onSetRepeatMode(int))`(int repeatMode) ` Override to handle the setting of the repeat mode.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| ` void`    | ` `[onSetShuffleMode](https://developer.android.com/reference/android/support/v4/media/session/MediaSessionCompat.Callback#onSetShuffleMode(int))`(int shuffleMode) ` Override to handle the setting of the shuffle mode.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| ` void`    | ` `[onSkipToNext](https://developer.android.com/reference/android/support/v4/media/session/MediaSessionCompat.Callback#onSkipToNext())`() ` Override to handle requests to skip to the next media item.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| ` void`    | ` `[onSkipToPrevious](https://developer.android.com/reference/android/support/v4/media/session/MediaSessionCompat.Callback#onSkipToPrevious())`() ` Override to handle requests to skip to the previous media item.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| ` void`    | ` `[onSkipToQueueItem](https://developer.android.com/reference/android/support/v4/media/session/MediaSessionCompat.Callback#onSkipToQueueItem(long))`(long id) ` Override to handle requests to play an item with a given id from the play queue.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| ` void`    | ` `[onStop](https://developer.android.com/reference/android/support/v4/media/session/MediaSessionCompat.Callback#onStop())`() ` Override to handle requests to stop playback.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |

| ### Inherited methods |
|-----------------------|---|
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/v4-media-session/MediaSessionCompat.Callback#)From class` java.lang.Object ` |-------------------|-------------------------------| | ` Object`         | ` clone() `                   | | ` boolean`        | ` equals(Object arg0) `       | | ` void`           | ` finalize() `                | | ` final Class<?>` | ` getClass() `                | | ` int`            | ` hashCode() `                | | ` final void`     | ` notify() `                  | | ` final void`     | ` notifyAll() `               | | ` String`         | ` toString() `                | | ` final void`     | ` wait(long arg0, int arg1) ` | | ` final void`     | ` wait(long arg0) `           | | ` final void`     | ` wait() `                    | ||

## Public constructors

### MediaSessionCompat.Callback

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
MediaSessionCompat.Callback ()
```

<br />

<br />

## Public methods

### onAddQueueItem

added in[version 25.4.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void onAddQueueItem (MediaDescriptionCompat description,
                int index)
```

Called when a[MediaControllerCompat](https://developer.android.com/reference/android/support/v4/media/session/MediaControllerCompat)wants to add a[MediaSessionCompat.QueueItem](https://developer.android.com/reference/android/support/v4/media/session/MediaSessionCompat.QueueItem)with the given[description](https://developer.android.com/reference/android/support/v4/media/MediaDescriptionCompat)at the specified position in the play queue.

<br />

|                                                                                                                                                                Parameters                                                                                                                                                                ||
|---------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `description` | `MediaDescriptionCompat`: The[MediaDescriptionCompat](https://developer.android.com/reference/android/support/v4/media/MediaDescriptionCompat)for creating the[MediaSessionCompat.QueueItem](https://developer.android.com/reference/android/support/v4/media/session/MediaSessionCompat.QueueItem)to be inserted. <br /> |
| `index`       | `int`: The index at which the created[MediaSessionCompat.QueueItem](https://developer.android.com/reference/android/support/v4/media/session/MediaSessionCompat.QueueItem)is to be inserted. <br />                                                                                                                       |

### onAddQueueItem

added in[version 25.4.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void onAddQueueItem (MediaDescriptionCompat description)
```

Called when a[MediaControllerCompat](https://developer.android.com/reference/android/support/v4/media/session/MediaControllerCompat)wants to add a[MediaSessionCompat.QueueItem](https://developer.android.com/reference/android/support/v4/media/session/MediaSessionCompat.QueueItem)with the given[description](https://developer.android.com/reference/android/support/v4/media/MediaDescriptionCompat)at the end of the play queue.

<br />

|                                                                                                                                                                Parameters                                                                                                                                                                ||
|---------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `description` | `MediaDescriptionCompat`: The[MediaDescriptionCompat](https://developer.android.com/reference/android/support/v4/media/MediaDescriptionCompat)for creating the[MediaSessionCompat.QueueItem](https://developer.android.com/reference/android/support/v4/media/session/MediaSessionCompat.QueueItem)to be inserted. <br /> |

### onCommand

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
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.

<br />

|                                                    Parameters                                                    ||
|-----------|-------------------------------------------------------------------------------------------------------|
| `command` | `String`: The command name. <br />                                                                    |
| `extras`  | `Bundle`: Optional parameters for the command, may be null. <br />                                    |
| `cb`      | `ResultReceiver`: A result receiver to which a result may be sent by the command, may be null. <br /> |

### onCustomAction

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void onCustomAction (String action,
                Bundle extras)
```

Called when a[MediaControllerCompat](https://developer.android.com/reference/android/support/v4/media/session/MediaControllerCompat)wants a[PlaybackStateCompat.CustomAction](https://developer.android.com/reference/android/support/v4/media/session/PlaybackStateCompat.CustomAction)to be performed.

<br />

|                                                                                                     Parameters                                                                                                      ||
|----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `action` | `String`: The action that was originally sent in the[PlaybackStateCompat.CustomAction](https://developer.android.com/reference/android/support/v4/media/session/PlaybackStateCompat.CustomAction). <br /> |
| `extras` | `Bundle`: Optional extras specified by the[MediaControllerCompat](https://developer.android.com/reference/android/support/v4/media/session/MediaControllerCompat). <br />                                 |

**See also:**

- [ACTION_FLAG_AS_INAPPROPRIATE](https://developer.android.com/reference/android/support/v4/media/session/MediaSessionCompat#ACTION_FLAG_AS_INAPPROPRIATE)
- [ACTION_SKIP_AD](https://developer.android.com/reference/android/support/v4/media/session/MediaSessionCompat#ACTION_SKIP_AD)
- [ACTION_FOLLOW](https://developer.android.com/reference/android/support/v4/media/session/MediaSessionCompat#ACTION_FOLLOW)
- [ACTION_UNFOLLOW](https://developer.android.com/reference/android/support/v4/media/session/MediaSessionCompat#ACTION_UNFOLLOW)  

### onFastForward

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void onFastForward ()
```

Override to handle requests to fast forward.

<br />

### onMediaButtonEvent

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
boolean onMediaButtonEvent (Intent mediaButtonEvent)
```

Override to handle media button events.

The double tap of[KEYCODE_MEDIA_PLAY_PAUSE](https://developer.android.com/reference/android/view/KeyEvent.html#KEYCODE_MEDIA_PLAY_PAUSE)or[KEYCODE_HEADSETHOOK](https://developer.android.com/reference/android/view/KeyEvent.html#KEYCODE_HEADSETHOOK)will call the[onSkipToNext()](https://developer.android.com/reference/android/support/v4/media/session/MediaSessionCompat.Callback#onSkipToNext())by default.

<br />

|                             Parameters                              ||
|--------------------|-------------------------------------------------|
| `mediaButtonEvent` | `Intent`: The media button event intent. <br /> |

|                              Returns                              ||
|-----------|--------------------------------------------------------|
| `boolean` | True if the event was handled, false otherwise. <br /> |

### onPause

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void onPause ()
```

Override to handle requests to pause playback.

<br />

### onPlay

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void onPlay ()
```

Override to handle requests to begin playback.

<br />

### onPlayFromMediaId

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void onPlayFromMediaId (String mediaId,
                Bundle extras)
```

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

<br />

|         Parameters         ||
|-----------|-----------------|
| `mediaId` | `String` <br /> |
| `extras`  | `Bundle` <br /> |

### onPlayFromSearch

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
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.

<br />

|        Parameters         ||
|----------|-----------------|
| `query`  | `String` <br /> |
| `extras` | `Bundle` <br /> |

### onPlayFromUri

added in[version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void onPlayFromUri (Uri uri,
                Bundle extras)
```

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

<br />

|        Parameters         ||
|----------|-----------------|
| `uri`    | `Uri` <br />    |
| `extras` | `Bundle` <br /> |

### onPrepare

added in[version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void onPrepare ()
```

Override to handle requests to prepare playback. Override[onPlay()](https://developer.android.com/reference/android/support/v4/media/session/MediaSessionCompat.Callback#onPlay())to handle requests for starting playback.

<br />

### onPrepareFromMediaId

added in[version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void onPrepareFromMediaId (String mediaId,
                Bundle extras)
```

Override to handle requests to prepare for playing a specific mediaId that was provided by your app. Override[onPlayFromMediaId(String, Bundle)](https://developer.android.com/reference/android/support/v4/media/session/MediaSessionCompat.Callback#onPlayFromMediaId(java.lang.String, android.os.Bundle))to handle requests for starting playback.

<br />

|         Parameters         ||
|-----------|-----------------|
| `mediaId` | `String` <br /> |
| `extras`  | `Bundle` <br /> |

### onPrepareFromSearch

added in[version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
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. Override[onPlayFromSearch(String, Bundle)](https://developer.android.com/reference/android/support/v4/media/session/MediaSessionCompat.Callback#onPlayFromSearch(java.lang.String, android.os.Bundle))to handle requests for starting playback.

<br />

|        Parameters         ||
|----------|-----------------|
| `query`  | `String` <br /> |
| `extras` | `Bundle` <br /> |

### onPrepareFromUri

added in[version 24.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void onPrepareFromUri (Uri uri,
                Bundle extras)
```

Override to handle requests to prepare a specific media item represented by a URI. Override[onPlayFromUri(Uri, Bundle)](https://developer.android.com/reference/android/support/v4/media/session/MediaSessionCompat.Callback#onPlayFromUri(android.net.Uri, android.os.Bundle))to handle requests for starting playback.

<br />

|        Parameters         ||
|----------|-----------------|
| `uri`    | `Uri` <br />    |
| `extras` | `Bundle` <br /> |

### onRemoveQueueItem

added in[version 25.4.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void onRemoveQueueItem (MediaDescriptionCompat description)
```

Called when a[MediaControllerCompat](https://developer.android.com/reference/android/support/v4/media/session/MediaControllerCompat)wants to remove the first occurrence of the specified[MediaSessionCompat.QueueItem](https://developer.android.com/reference/android/support/v4/media/session/MediaSessionCompat.QueueItem)with the given[description](https://developer.android.com/reference/android/support/v4/media/MediaDescriptionCompat)in the play queue.

<br />

|                                                                                                                                                               Parameters                                                                                                                                                                ||
|---------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `description` | `MediaDescriptionCompat`: The[MediaDescriptionCompat](https://developer.android.com/reference/android/support/v4/media/MediaDescriptionCompat)for denoting the[MediaSessionCompat.QueueItem](https://developer.android.com/reference/android/support/v4/media/session/MediaSessionCompat.QueueItem)to be removed. <br /> |

### onRemoveQueueItemAt

added in[version 25.4.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void onRemoveQueueItemAt (int index)
```

<br />

**This method was deprecated in API level 26.1.0.**   
[onRemoveQueueItem(MediaDescriptionCompat)](https://developer.android.com/reference/android/support/v4/media/session/MediaSessionCompat.Callback#onRemoveQueueItem(android.support.v4.media.MediaDescriptionCompat))will be called instead.

Called when a[MediaControllerCompat](https://developer.android.com/reference/android/support/v4/media/session/MediaControllerCompat)wants to remove a[MediaSessionCompat.QueueItem](https://developer.android.com/reference/android/support/v4/media/session/MediaSessionCompat.QueueItem)at the specified position in the play queue.

<br />

|                           Parameters                           ||
|---------|-------------------------------------------------------|
| `index` | `int`: The index of the element to be removed. <br /> |

### onRewind

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void onRewind ()
```

Override to handle requests to rewind.

<br />

### onSeekTo

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void onSeekTo (long pos)
```

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

<br />

|                           Parameters                            ||
|-------|----------------------------------------------------------|
| `pos` | `long`: New position to move to, in milliseconds. <br /> |

### onSetCaptioningEnabled

added in[version 25.4.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void onSetCaptioningEnabled (boolean enabled)
```

Override to handle requests to enable/disable captioning.

<br />

|                                Parameters                                 ||
|-----------|----------------------------------------------------------------|
| `enabled` | `boolean`:`true`to enable captioning,`false`to disable. <br /> |

### onSetRating

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void onSetRating (RatingCompat rating)
```

Override to handle the item being rated.

<br />

|                       Parameters                       ||
|----------|----------------------------------------------|
| `rating` | `RatingCompat`: The rating being set. <br /> |

### onSetRating

added in[version 26.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void onSetRating (RatingCompat rating,
                Bundle extras)
```

Override to handle the item being rated.

<br />

|                                           Parameters                                            ||
|----------|---------------------------------------------------------------------------------------|
| `rating` | `RatingCompat`: The rating being set. <br />                                          |
| `extras` | `Bundle`: The extras can include information about the media item being rated. <br /> |

### onSetRepeatMode

added in[version 25.4.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void onSetRepeatMode (int repeatMode)
```

Override to handle the setting of the repeat mode.

You should call[setRepeatMode(int)](https://developer.android.com/reference/android/support/v4/media/session/MediaSessionCompat#setRepeatMode(int))before end of this method in order to notify the change to the[MediaControllerCompat](https://developer.android.com/reference/android/support/v4/media/session/MediaControllerCompat), or[getRepeatMode()](https://developer.android.com/reference/android/support/v4/media/session/MediaControllerCompat#getRepeatMode())could return an invalid value.

<br />

|                                                                                                                                                                                                                                                                                                  Parameters                                                                                                                                                                                                                                                                                                  ||
|--------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `repeatMode` | `int`: The repeat mode which is one of followings:[REPEAT_MODE_NONE](https://developer.android.com/reference/android/support/v4/media/session/PlaybackStateCompat#REPEAT_MODE_NONE),[REPEAT_MODE_ONE](https://developer.android.com/reference/android/support/v4/media/session/PlaybackStateCompat#REPEAT_MODE_ONE),[REPEAT_MODE_ALL](https://developer.android.com/reference/android/support/v4/media/session/PlaybackStateCompat#REPEAT_MODE_ALL),[REPEAT_MODE_GROUP](https://developer.android.com/reference/android/support/v4/media/session/PlaybackStateCompat#REPEAT_MODE_GROUP) <br /> |

### onSetShuffleMode

added in[version 26.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void onSetShuffleMode (int shuffleMode)
```

Override to handle the setting of the shuffle mode.

You should call[setShuffleMode(int)](https://developer.android.com/reference/android/support/v4/media/session/MediaSessionCompat#setShuffleMode(int))before the end of this method in order to notify the change to the[MediaControllerCompat](https://developer.android.com/reference/android/support/v4/media/session/MediaControllerCompat), or[getShuffleMode()](https://developer.android.com/reference/android/support/v4/media/session/MediaControllerCompat#getShuffleMode())could return an invalid value.

<br />

|                                                                                                                                                                                                                                      Parameters                                                                                                                                                                                                                                      ||
|---------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `shuffleMode` | `int`: The shuffle mode which is one of followings:[SHUFFLE_MODE_NONE](https://developer.android.com/reference/android/support/v4/media/session/PlaybackStateCompat#SHUFFLE_MODE_NONE),[SHUFFLE_MODE_ALL](https://developer.android.com/reference/android/support/v4/media/session/PlaybackStateCompat#SHUFFLE_MODE_ALL),[SHUFFLE_MODE_GROUP](https://developer.android.com/reference/android/support/v4/media/session/PlaybackStateCompat#SHUFFLE_MODE_GROUP) <br /> |

### onSkipToNext

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void onSkipToNext ()
```

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

<br />

### onSkipToPrevious

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void onSkipToPrevious ()
```

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

<br />

### onSkipToQueueItem

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void onSkipToQueueItem (long id)
```

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

<br />

|     Parameters      ||
|------|---------------|
| `id` | `long` <br /> |

### onStop

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void onStop ()
```

Override to handle requests to stop playback.

<br />

-

  ## Interfaces

  - [MediaSessionCompat.OnActiveChangeListener](https://developer.android.com/reference/android/support/v4/media/session/MediaSessionCompat.OnActiveChangeListener)
-

  ## Classes

  - [MediaButtonReceiver](https://developer.android.com/reference/android/support/v4/media/session/MediaButtonReceiver)
  - [MediaControllerCompat](https://developer.android.com/reference/android/support/v4/media/session/MediaControllerCompat)
  - [MediaControllerCompat.Callback](https://developer.android.com/reference/android/support/v4/media/session/MediaControllerCompat.Callback)
  - [MediaControllerCompat.PlaybackInfo](https://developer.android.com/reference/android/support/v4/media/session/MediaControllerCompat.PlaybackInfo)
  - [MediaControllerCompat.TransportControls](https://developer.android.com/reference/android/support/v4/media/session/MediaControllerCompat.TransportControls)
  - [MediaSessionCompat](https://developer.android.com/reference/android/support/v4/media/session/MediaSessionCompat)
  - [MediaSessionCompat.Callback](https://developer.android.com/reference/android/support/v4/media/session/MediaSessionCompat.Callback)
  - [MediaSessionCompat.QueueItem](https://developer.android.com/reference/android/support/v4/media/session/MediaSessionCompat.QueueItem)
  - [MediaSessionCompat.Token](https://developer.android.com/reference/android/support/v4/media/session/MediaSessionCompat.Token)
  - [ParcelableVolumeInfo](https://developer.android.com/reference/android/support/v4/media/session/ParcelableVolumeInfo)
  - [PlaybackStateCompat](https://developer.android.com/reference/android/support/v4/media/session/PlaybackStateCompat)
  - [PlaybackStateCompat.Builder](https://developer.android.com/reference/android/support/v4/media/session/PlaybackStateCompat.Builder)
  - [PlaybackStateCompat.CustomAction](https://developer.android.com/reference/android/support/v4/media/session/PlaybackStateCompat.CustomAction)
  - [PlaybackStateCompat.CustomAction.Builder](https://developer.android.com/reference/android/support/v4/media/session/PlaybackStateCompat.CustomAction.Builder)