# MediaController.Callback

Added in[API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

# Callback

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/android/media/session/MediaController.Callback "View this page in Java")  

```
abstract class Callback
```

|---|--------------------------------------------------------------------------------------------------------------------------------------------------|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)                                                                   ||
| ↳ | [android.media.session.MediaController.Callback](https://developer.android.com/reference/kotlin/android/media/session/MediaController.Callback#) |

Callback for receiving updates from the session. A Callback can be registered using #registerCallback.

## Summary

|                                                        Public constructors                                                         ||
|---------------------------------------------------------------------------------------------------------------------------------|---|
| [Callback](https://developer.android.com/reference/kotlin/android/media/session/MediaController.Callback#Callback())`()` <br /> |

|                                                                                                                                                                                                                                                                                     Public methods                                                                                                                                                                                                                                                                                      ||
|----------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onAudioInfoChanged](https://developer.android.com/reference/kotlin/android/media/session/MediaController.Callback#onAudioInfoChanged(android.media.session.MediaController.PlaybackInfo))`(`playbackInfo:` `[MediaController.PlaybackInfo](https://developer.android.com/reference/kotlin/android/media/session/MediaController.PlaybackInfo)`)` Signals a change in the session's[PlaybackInfo](https://developer.android.com/reference/kotlin/android/media/session/MediaController.PlaybackInfo). |
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onExtrasChanged](https://developer.android.com/reference/kotlin/android/media/session/MediaController.Callback#onExtrasChanged(android.os.Bundle))`(`extras:` `[Bundle](https://developer.android.com/reference/kotlin/android/os/Bundle.html#)?`)` Override to handle changes to the[MediaSession](https://developer.android.com/reference/kotlin/android/media/session/MediaSession)extras.                                                                                                        |
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onMetadataChanged](https://developer.android.com/reference/kotlin/android/media/session/MediaController.Callback#onMetadataChanged(android.media.MediaMetadata))`(`metadata:` `[MediaMetadata](https://developer.android.com/reference/kotlin/android/media/MediaMetadata.html#)?`)` Override to handle changes to the current metadata.                                                                                                                                                             |
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onPlaybackStateChanged](https://developer.android.com/reference/kotlin/android/media/session/MediaController.Callback#onPlaybackStateChanged(android.media.session.PlaybackState))`(`state:` `[PlaybackState](https://developer.android.com/reference/kotlin/android/media/session/PlaybackState)?`)` Override to handle changes in playback state.                                                                                                                                                  |
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onQueueChanged](https://developer.android.com/reference/kotlin/android/media/session/MediaController.Callback#onQueueChanged(kotlin.collections.MutableList))`(`queue:` `[MutableList](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html)<[MediaSession.QueueItem](https://developer.android.com/reference/kotlin/android/media/session/MediaSession.QueueItem)!>?`)` Override to handle changes to items in the queue.                                       |
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onQueueTitleChanged](https://developer.android.com/reference/kotlin/android/media/session/MediaController.Callback#onQueueTitleChanged(kotlin.CharSequence))`(`title:` `[CharSequence](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char-sequence/index.html)?`)` Override to handle changes to the queue title.                                                                                                                                                                             |
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onSessionDestroyed](https://developer.android.com/reference/kotlin/android/media/session/MediaController.Callback#onSessionDestroyed())`()` Override to handle the session being destroyed.                                                                                                                                                                                                                                                                                                          |
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onSessionEvent](https://developer.android.com/reference/kotlin/android/media/session/MediaController.Callback#onSessionEvent(kotlin.String,%20android.os.Bundle))`(`event:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, `extras:` `[Bundle](https://developer.android.com/reference/kotlin/android/os/Bundle.html#)?`)` Override to handle custom events sent by the session owner without a specified interface.                                            |

## Public constructors

### Callback

```
Callback()
```

## Public methods

### onAudioInfoChanged

Added in[API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun onAudioInfoChanged(playbackInfo: MediaController.PlaybackInfo): Unit
```

Signals a change in the session's[PlaybackInfo](https://developer.android.com/reference/kotlin/android/media/session/MediaController.PlaybackInfo).

|                                                                                                              Parameters                                                                                                              ||
|----------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `playbackInfo` | [MediaController.PlaybackInfo](https://developer.android.com/reference/kotlin/android/media/session/MediaController.PlaybackInfo):The latest known state of the session's playback info. This value cannot be`null`. |

### onExtrasChanged

Added in[API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun onExtrasChanged(extras: Bundle?): Unit
```

Override to handle changes to the[MediaSession](https://developer.android.com/reference/kotlin/android/media/session/MediaSession)extras.

|                                                                                                                                        Parameters                                                                                                                                        ||
|----------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `extras` | [Bundle](https://developer.android.com/reference/kotlin/android/os/Bundle.html#)?:The extras that can include other information associated with the[MediaSession](https://developer.android.com/reference/kotlin/android/media/session/MediaSession). This value may be`null`. |

### onMetadataChanged

Added in[API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun onMetadataChanged(metadata: MediaMetadata?): Unit
```

Override to handle changes to the current metadata.

|                                                                              Parameters                                                                              ||
|------------|----------------------------------------------------------------------------------------------------------------------------------------------------------|
| `metadata` | [MediaMetadata](https://developer.android.com/reference/kotlin/android/media/MediaMetadata.html#)?:The current metadata for the session or null if none. |

**See Also**

- [android.media.MediaMetadata](https://developer.android.com/reference/kotlin/android/media/MediaMetadata.html#)  

### onPlaybackStateChanged

Added in[API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun onPlaybackStateChanged(state: PlaybackState?): Unit
```

Override to handle changes in playback state.

|                                                                                  Parameters                                                                                  ||
|---------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `state` | [PlaybackState](https://developer.android.com/reference/kotlin/android/media/session/PlaybackState)?:The new playback state of the session This value may be`null`. |

### onQueueChanged

Added in[API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun onQueueChanged(queue: MutableList<MediaSession.QueueItem!>?): Unit
```

Override to handle changes to items in the queue.

|                                                                                                                                                                                                     Parameters                                                                                                                                                                                                     ||
|---------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `queue` | [MutableList](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html)\<[MediaSession.QueueItem](https://developer.android.com/reference/kotlin/android/media/session/MediaSession.QueueItem)!\>?:A list of items in the current play queue. It should include the currently playing item as well as previous and upcoming items if applicable. This value may be`null`. |

**See Also**

- [android.media.session.MediaSession.QueueItem](https://developer.android.com/reference/kotlin/android/media/session/MediaSession.QueueItem)  

### onQueueTitleChanged

Added in[API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun onQueueTitleChanged(title: CharSequence?): Unit
```

Override to handle changes to the queue title.

|                                                                                                             Parameters                                                                                                             ||
|---------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `title` | [CharSequence](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char-sequence/index.html)?:The title that should be displayed along with the play queue such as "Now Playing". May be null if there is no such title. |

### onSessionDestroyed

Added in[API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun onSessionDestroyed(): Unit
```

Override to handle the session being destroyed. The session is no longer valid after this call and calls to it will be ignored.  

### onSessionEvent

Added in[API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun onSessionEvent(
    event: String, 
    extras: Bundle?
): Unit
```

Override to handle custom events sent by the session owner without a specified interface. Controllers should only handle these for sessions they own.

|                                                                     Parameters                                                                     ||
|----------|------------------------------------------------------------------------------------------------------------------------------------------|
| `event`  | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html):The event from the session. This value cannot be`null`. |
| `extras` | [Bundle](https://developer.android.com/reference/kotlin/android/os/Bundle.html#)?:Optional parameters for the event, may be null.        |