# Player.Listener

Artifact: [androidx.media3:media3-common](https://developer.android.com/jetpack/androidx/releases/media3) [View Source](https://cs.android.com/search?q=file:androidx/media3/common/Player.java+class:androidx.media3.common.Player.Listener)

*** ** * ** ***


```
public interface Player.Listener
```

<br />

Known direct subclasses [AnalyticsCollector](https://developer.android.com/reference/androidx/media3/exoplayer/analytics/AnalyticsCollector), [ExoPlayerTestRunner](https://developer.android.com/reference/androidx/media3/test/utils/ExoPlayerTestRunner), [WearUnsuitableOutputPlaybackSuppressionResolverListener](https://developer.android.com/reference/androidx/media3/ui/WearUnsuitableOutputPlaybackSuppressionResolverListener)

|---|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/analytics/AnalyticsCollector` | Interface for data collectors that forward analytics events to `https://developer.android.com/reference/androidx/media3/exoplayer/analytics/AnalyticsListener`. |
| `https://developer.android.com/reference/androidx/media3/test/utils/ExoPlayerTestRunner` | Helper class to run an ExoPlayer test. |
| `https://developer.android.com/reference/androidx/media3/ui/WearUnsuitableOutputPlaybackSuppressionResolverListener` | A `https://developer.android.com/reference/androidx/media3/common/Player.Listener` that launches a system dialog in response to `https://developer.android.com/reference/androidx/media3/common/Player#PLAYBACK_SUPPRESSION_REASON_UNSUITABLE_AUDIO_OUTPUT()` to allow the user to connect a suitable audio output. |

Known indirect subclasses [DefaultAnalyticsCollector](https://developer.android.com/reference/androidx/media3/exoplayer/analytics/DefaultAnalyticsCollector)

|---|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/analytics/DefaultAnalyticsCollector` | Data collector that forwards analytics events to `https://developer.android.com/reference/androidx/media3/exoplayer/analytics/AnalyticsListener`. |

*** ** * ** ***

Listener for changes in a `https://developer.android.com/reference/androidx/media3/common/Player`.

All methods have no-op default implementations to allow selective overrides.

If the return value of a `https://developer.android.com/reference/androidx/media3/common/Player` getter changes due to a change in `https://developer.android.com/reference/androidx/media3/common/Player.Listener#onAvailableCommandsChanged(androidx.media3.common.Player.Commands)`, the corresponding listener method(s) will be invoked. If the return value of a `https://developer.android.com/reference/androidx/media3/common/Player` getter does not change because the corresponding command is `https://developer.android.com/reference/androidx/media3/common/Player.Listener#onAvailableCommandsChanged(androidx.media3.common.Player.Commands)`, the corresponding listener method will not be invoked.

## Summary

| ### Public methods |
|---|---|
| `default void` | `https://developer.android.com/reference/androidx/media3/common/Player.Listener#onAudioAttributesChanged(androidx.media3.common.AudioAttributes)(https://developer.android.com/reference/androidx/media3/common/AudioAttributes audioAttributes)` Called when the value of `https://developer.android.com/reference/androidx/media3/common/Player#getAudioAttributes()` changes. |
| `default void` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/Player.Listener#onAudioSessionIdChanged(int)(int audioSessionId)` Called when the audio session ID changes. |
| `default void` | `https://developer.android.com/reference/androidx/media3/common/Player.Listener#onAvailableCommandsChanged(androidx.media3.common.Player.Commands)(https://developer.android.com/reference/androidx/media3/common/Player.Commands availableCommands)` Called when the value returned from `https://developer.android.com/reference/androidx/media3/common/Player#isCommandAvailable(int)` changes for at least one `https://developer.android.com/reference/androidx/media3/common/Player.Command`. |
| `default void` | `https://developer.android.com/reference/androidx/media3/common/Player.Listener#onCues(androidx.media3.common.text.CueGroup)(https://developer.android.com/reference/androidx/media3/common/text/CueGroup cueGroup)` Called when the value of `https://developer.android.com/reference/androidx/media3/common/Player#getCurrentCues()` changes. |
| `default void` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi [onCues](https://developer.android.com/reference/androidx/media3/common/Player.Listener#onCues(java.util.List<androidx.media3.common.text.Cue>))(https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/androidx/media3/common/text/Cue> cues)` **This method is deprecated.** Use `https://developer.android.com/reference/androidx/media3/common/Player.Listener#onCues(androidx.media3.common.text.CueGroup)` instead. <br /> |
| `default void` | `https://developer.android.com/reference/androidx/media3/common/Player.Listener#onDeviceInfoChanged(androidx.media3.common.DeviceInfo)(https://developer.android.com/reference/androidx/media3/common/DeviceInfo deviceInfo)` Called when the device information changes |
| `default void` | `https://developer.android.com/reference/androidx/media3/common/Player.Listener#onDeviceVolumeChanged(int,boolean)(int volume, boolean muted)` Called when the value of `https://developer.android.com/reference/androidx/media3/common/Player#getDeviceVolume()` or `https://developer.android.com/reference/androidx/media3/common/Player#isDeviceMuted()` changes. |
| `default void` | `https://developer.android.com/reference/androidx/media3/common/Player.Listener#onEvents(androidx.media3.common.Player,androidx.media3.common.Player.Events)(https://developer.android.com/reference/androidx/media3/common/Player player, https://developer.android.com/reference/androidx/media3/common/Player.Events events)` Called when one or more player states changed. |
| `default void` | `https://developer.android.com/reference/androidx/media3/common/Player.Listener#onIsLoadingChanged(boolean)(boolean isLoading)` Called when the player starts or stops loading the source. |
| `default void` | `https://developer.android.com/reference/androidx/media3/common/Player.Listener#onIsPlayingChanged(boolean)(boolean isPlaying)` Called when the value of `https://developer.android.com/reference/androidx/media3/common/Player#isPlaying()` changes. |
| `default void` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi [onLoadingChanged](https://developer.android.com/reference/androidx/media3/common/Player.Listener#onLoadingChanged(boolean))(boolean isLoading)` **This method is deprecated.** Use `https://developer.android.com/reference/androidx/media3/common/Player.Listener#onIsLoadingChanged(boolean)` instead. <br /> |
| `default void` | `https://developer.android.com/reference/androidx/media3/common/Player.Listener#onMaxSeekToPreviousPositionChanged(long)(long maxSeekToPreviousPositionMs)` Called when the value of `https://developer.android.com/reference/androidx/media3/common/Player#getMaxSeekToPreviousPosition()` changes. |
| `default void` | `https://developer.android.com/reference/androidx/media3/common/Player.Listener#onMediaItemTransition(androidx.media3.common.MediaItem,int)( @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/common/MediaItem mediaItem, @https://developer.android.com/reference/androidx/media3/common/Player.MediaItemTransitionReason int reason )` Called when playback transitions to a media item or starts repeating a media item according to the current `https://developer.android.com/reference/androidx/media3/common/Player#getRepeatMode()`. |
| `default void` | `https://developer.android.com/reference/androidx/media3/common/Player.Listener#onMediaMetadataChanged(androidx.media3.common.MediaMetadata)(https://developer.android.com/reference/androidx/media3/common/MediaMetadata mediaMetadata)` Called when the value of `https://developer.android.com/reference/androidx/media3/common/Player#getMediaMetadata()` changes. |
| `default void` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/Player.Listener#onMetadata(androidx.media3.common.Metadata)(https://developer.android.com/reference/androidx/media3/common/Metadata metadata)` Called when there is metadata associated with the current playback time. |
| `default void` | `https://developer.android.com/reference/androidx/media3/common/Player.Listener#onPlayWhenReadyChanged(boolean,int)( boolean playWhenReady, @https://developer.android.com/reference/androidx/media3/common/Player.PlayWhenReadyChangeReason int reason )` Called when the value returned from `https://developer.android.com/reference/androidx/media3/common/Player#getPlayWhenReady()` changes. |
| `default void` | `https://developer.android.com/reference/androidx/media3/common/Player.Listener#onPlaybackParametersChanged(androidx.media3.common.PlaybackParameters)(https://developer.android.com/reference/androidx/media3/common/PlaybackParameters playbackParameters)` Called when the value of `https://developer.android.com/reference/androidx/media3/common/Player#getPlaybackParameters()` changes. |
| `default void` | `https://developer.android.com/reference/androidx/media3/common/Player.Listener#onPlaybackStateChanged(int)(@https://developer.android.com/reference/androidx/media3/common/Player.State int playbackState)` Called when the value returned from `https://developer.android.com/reference/androidx/media3/common/Player#getPlaybackState()` changes. |
| `default void` | `https://developer.android.com/reference/androidx/media3/common/Player.Listener#onPlaybackSuppressionReasonChanged(int)( @https://developer.android.com/reference/androidx/media3/common/Player.PlaybackSuppressionReason int playbackSuppressionReason )` Called when the value returned from `https://developer.android.com/reference/androidx/media3/common/Player#getPlaybackSuppressionReason()` changes. |
| `default void` | `https://developer.android.com/reference/androidx/media3/common/Player.Listener#onPlayerError(androidx.media3.common.PlaybackException)(https://developer.android.com/reference/androidx/media3/common/PlaybackException error)` Called when an error occurs. |
| `default void` | `https://developer.android.com/reference/androidx/media3/common/Player.Listener#onPlayerErrorChanged(androidx.media3.common.PlaybackException)(@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/common/PlaybackException error)` Called when the `https://developer.android.com/reference/androidx/media3/common/PlaybackException` returned by `https://developer.android.com/reference/androidx/media3/common/Player#getPlayerError()` changes. |
| `default void` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi [onPlayerStateChanged](https://developer.android.com/reference/androidx/media3/common/Player.Listener#onPlayerStateChanged(boolean,int))( boolean playWhenReady, @https://developer.android.com/reference/androidx/media3/common/Player.State int playbackState )` **This method is deprecated.** Use `https://developer.android.com/reference/androidx/media3/common/Player.Listener#onPlaybackStateChanged(int)` and `https://developer.android.com/reference/androidx/media3/common/Player.Listener#onPlayWhenReadyChanged(boolean,int)` instead. <br /> |
| `default void` | `https://developer.android.com/reference/androidx/media3/common/Player.Listener#onPlaylistMetadataChanged(androidx.media3.common.MediaMetadata)(https://developer.android.com/reference/androidx/media3/common/MediaMetadata mediaMetadata)` Called when the value of `https://developer.android.com/reference/androidx/media3/common/Player#getPlaylistMetadata()` changes. |
| `default void` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi [onPositionDiscontinuity](https://developer.android.com/reference/androidx/media3/common/Player.Listener#onPositionDiscontinuity(int))(@https://developer.android.com/reference/androidx/media3/common/Player.DiscontinuityReason int reason)` **This method is deprecated.** Use `https://developer.android.com/reference/androidx/media3/common/Player.Listener#onPositionDiscontinuity(androidx.media3.common.Player.PositionInfo,androidx.media3.common.Player.PositionInfo,int)` instead. <br /> |
| `default void` | `https://developer.android.com/reference/androidx/media3/common/Player.Listener#onPositionDiscontinuity(androidx.media3.common.Player.PositionInfo,androidx.media3.common.Player.PositionInfo,int)( https://developer.android.com/reference/androidx/media3/common/Player.PositionInfo oldPosition, https://developer.android.com/reference/androidx/media3/common/Player.PositionInfo newPosition, @https://developer.android.com/reference/androidx/media3/common/Player.DiscontinuityReason int reason )` Called when a position discontinuity occurs. |
| `default void` | `https://developer.android.com/reference/androidx/media3/common/Player.Listener#onRenderedFirstFrame()()` Called when a frame is rendered for the first time since setting the surface, or since the renderer was reset, or since the stream being rendered was changed. |
| `default void` | `https://developer.android.com/reference/androidx/media3/common/Player.Listener#onRepeatModeChanged(int)(@https://developer.android.com/reference/androidx/media3/common/Player.RepeatMode int repeatMode)` Called when the value of `https://developer.android.com/reference/androidx/media3/common/Player#getRepeatMode()` changes. |
| `default void` | `https://developer.android.com/reference/androidx/media3/common/Player.Listener#onSeekBackIncrementChanged(long)(long seekBackIncrementMs)` Called when the value of `https://developer.android.com/reference/androidx/media3/common/Player#getSeekBackIncrement()` changes. |
| `default void` | `https://developer.android.com/reference/androidx/media3/common/Player.Listener#onSeekForwardIncrementChanged(long)(long seekForwardIncrementMs)` Called when the value of `https://developer.android.com/reference/androidx/media3/common/Player#getSeekForwardIncrement()` changes. |
| `default void` | `https://developer.android.com/reference/androidx/media3/common/Player.Listener#onShuffleModeEnabledChanged(boolean)(boolean shuffleModeEnabled)` Called when the value of `https://developer.android.com/reference/androidx/media3/common/Player#getShuffleModeEnabled()` changes. |
| `default void` | `https://developer.android.com/reference/androidx/media3/common/Player.Listener#onSkipSilenceEnabledChanged(boolean)(boolean skipSilenceEnabled)` Called when skipping silences is enabled or disabled in the audio stream. |
| `default void` | `https://developer.android.com/reference/androidx/media3/common/Player.Listener#onSurfaceSizeChanged(int,int)(int width, int height)` Called each time there's a change in the size of the surface onto which the video is being rendered. |
| `default void` | `https://developer.android.com/reference/androidx/media3/common/Player.Listener#onTimelineChanged(androidx.media3.common.Timeline,int)( https://developer.android.com/reference/androidx/media3/common/Timeline timeline, @https://developer.android.com/reference/androidx/media3/common/Player.TimelineChangeReason int reason )` Called when the value of `https://developer.android.com/reference/androidx/media3/common/Player#getCurrentTimeline()` changes. |
| `default void` | `https://developer.android.com/reference/androidx/media3/common/Player.Listener#onTrackSelectionParametersChanged(androidx.media3.common.TrackSelectionParameters)(https://developer.android.com/reference/androidx/media3/common/TrackSelectionParameters parameters)` Called when the value returned from `https://developer.android.com/reference/androidx/media3/common/Player#getTrackSelectionParameters()` changes. |
| `default void` | `https://developer.android.com/reference/androidx/media3/common/Player.Listener#onTracksChanged(androidx.media3.common.Tracks)(https://developer.android.com/reference/androidx/media3/common/Tracks tracks)` Called when the value of `https://developer.android.com/reference/androidx/media3/common/Player#getCurrentTracks()` changes. |
| `default void` | `https://developer.android.com/reference/androidx/media3/common/Player.Listener#onVideoSizeChanged(androidx.media3.common.VideoSize)(https://developer.android.com/reference/androidx/media3/common/VideoSize videoSize)` Called each time when `https://developer.android.com/reference/androidx/media3/common/Player#getVideoSize()` changes. |
| `default void` | `https://developer.android.com/reference/androidx/media3/common/Player.Listener#onVolumeChanged(float)(float volume)` Called when the value of `https://developer.android.com/reference/androidx/media3/common/Player#getVolume()` changes. |

## Public methods

### onAudioAttributesChanged

```
default void onAudioAttributesChanged(AudioAttributes audioAttributes)
```

Called when the value of `https://developer.android.com/reference/androidx/media3/common/Player#getAudioAttributes()` changes.

`https://developer.android.com/reference/androidx/media3/common/Player.Listener#onEvents(androidx.media3.common.Player,androidx.media3.common.Player.Events)` will also be called to report this event along with other events that happen in the same `https://developer.android.com/reference/android/os/Looper.html` message queue iteration.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/AudioAttributes audioAttributes` | The audio attributes. |

### onAudioSessionIdChanged

```
@UnstableApi
default void onAudioSessionIdChanged(int audioSessionId)
```

Called when the audio session ID changes.

`https://developer.android.com/reference/androidx/media3/common/Player.Listener#onEvents(androidx.media3.common.Player,androidx.media3.common.Player.Events)` will also be called to report this event along with other events that happen in the same `https://developer.android.com/reference/android/os/Looper.html` message queue iteration.

| Parameters |
|---|---|
| `int audioSessionId` | The audio session ID. |

### onAvailableCommandsChanged

```
default void onAvailableCommandsChanged(Player.Commands availableCommands)
```

Called when the value returned from `https://developer.android.com/reference/androidx/media3/common/Player#isCommandAvailable(int)` changes for at least one `https://developer.android.com/reference/androidx/media3/common/Player.Command`.

`https://developer.android.com/reference/androidx/media3/common/Player.Listener#onEvents(androidx.media3.common.Player,androidx.media3.common.Player.Events)` will also be called to report this event along with other events that happen in the same `https://developer.android.com/reference/android/os/Looper.html` message queue iteration.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/Player.Commands availableCommands` | The available `https://developer.android.com/reference/androidx/media3/common/Player.Commands`. |

### onCues

```
default void onCues(CueGroup cueGroup)
```

Called when the value of `https://developer.android.com/reference/androidx/media3/common/Player#getCurrentCues()` changes.

Both this method and `https://developer.android.com/reference/androidx/media3/common/Player.Listener#onCues(java.util.List<androidx.media3.common.text.Cue>)` are called when there is a change in the cues. You should only implement one or the other.

`https://developer.android.com/reference/androidx/media3/common/Player.Listener#onEvents(androidx.media3.common.Player,androidx.media3.common.Player.Events)` will also be called to report this event along with other events that happen in the same `https://developer.android.com/reference/android/os/Looper.html` message queue iteration.

### onCues

```
@UnstableApi
default void [onCues](https://developer.android.com/reference/androidx/media3/common/Player.Listener#onCues(java.util.List<androidx.media3.common.text.Cue>))(List<Cue> cues)
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/androidx/media3/common/Player.Listener#onCues(androidx.media3.common.text.CueGroup)` instead.

Called when the value of `https://developer.android.com/reference/androidx/media3/common/Player#getCurrentCues()` changes.

Both this method and `https://developer.android.com/reference/androidx/media3/common/Player.Listener#onCues(androidx.media3.common.text.CueGroup)` are called when there is a change in the cues. You should only implement one or the other.

`https://developer.android.com/reference/androidx/media3/common/Player.Listener#onEvents(androidx.media3.common.Player,androidx.media3.common.Player.Events)` will also be called to report this event along with other events that happen in the same `https://developer.android.com/reference/android/os/Looper.html` message queue iteration.

### onDeviceInfoChanged

```
default void onDeviceInfoChanged(DeviceInfo deviceInfo)
```

Called when the device information changes

`https://developer.android.com/reference/androidx/media3/common/Player.Listener#onEvents(androidx.media3.common.Player,androidx.media3.common.Player.Events)` will also be called to report this event along with other events that happen in the same `https://developer.android.com/reference/android/os/Looper.html` message queue iteration.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/DeviceInfo deviceInfo` | The new `https://developer.android.com/reference/androidx/media3/common/DeviceInfo`. |

### onDeviceVolumeChanged

```
default void onDeviceVolumeChanged(int volume, boolean muted)
```

Called when the value of `https://developer.android.com/reference/androidx/media3/common/Player#getDeviceVolume()` or `https://developer.android.com/reference/androidx/media3/common/Player#isDeviceMuted()` changes.

`https://developer.android.com/reference/androidx/media3/common/Player.Listener#onEvents(androidx.media3.common.Player,androidx.media3.common.Player.Events)` will also be called to report this event along with other events that happen in the same `https://developer.android.com/reference/android/os/Looper.html` message queue iteration.

| Parameters |
|---|---|
| `int volume` | The new device volume, with 0 being silence and 1 being unity gain. |
| `boolean muted` | Whether the device is muted. |

### onEvents

```
default void onEvents(Player player, Player.Events events)
```

Called when one or more player states changed.

State changes and events that happen within one `https://developer.android.com/reference/android/os/Looper.html` message queue iteration are reported together and only after all individual callbacks were triggered.

Listeners should prefer this method over individual callbacks in the following cases:

- They intend to trigger the same logic for multiple events (e.g. when updating a UI for both `https://developer.android.com/reference/androidx/media3/common/Player.Listener#onPlaybackStateChanged(int)` and `https://developer.android.com/reference/androidx/media3/common/Player.Listener#onPlayWhenReadyChanged(boolean,int)`).
- They need access to the `https://developer.android.com/reference/androidx/media3/common/Player` object to trigger further events (e.g. to call `https://developer.android.com/reference/androidx/media3/common/Player#seekTo(long)` after a `https://developer.android.com/reference/androidx/media3/common/Player.Listener#onMediaItemTransition(androidx.media3.common.MediaItem,int)`).
- They intend to use multiple state values together or in combination with `https://developer.android.com/reference/androidx/media3/common/Player` getter methods. For example using `https://developer.android.com/reference/androidx/media3/common/Player#getCurrentMediaItemIndex()` with the `
  timeline` provided in `https://developer.android.com/reference/androidx/media3/common/Player.Listener#onTimelineChanged(androidx.media3.common.Timeline,int)` is only safe from within this method.
- They are interested in events that logically happened together (e.g `https://developer.android.com/reference/androidx/media3/common/Player.Listener#onPlaybackStateChanged(int)` to `https://developer.android.com/reference/androidx/media3/common/Player#STATE_BUFFERING()` because of `https://developer.android.com/reference/androidx/media3/common/Player.Listener#onMediaItemTransition(androidx.media3.common.MediaItem,int)`).

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/Player player` | The `https://developer.android.com/reference/androidx/media3/common/Player` whose state changed. Use the getters to obtain the latest states. |
| `https://developer.android.com/reference/androidx/media3/common/Player.Events events` | The `https://developer.android.com/reference/androidx/media3/common/Player.Events` that happened in this iteration, indicating which player states changed. |

### onIsLoadingChanged

```
default void onIsLoadingChanged(boolean isLoading)
```

Called when the player starts or stops loading the source.

`https://developer.android.com/reference/androidx/media3/common/Player.Listener#onEvents(androidx.media3.common.Player,androidx.media3.common.Player.Events)` will also be called to report this event along with other events that happen in the same `https://developer.android.com/reference/android/os/Looper.html` message queue iteration.

| Parameters |
|---|---|
| `boolean isLoading` | Whether the source is currently being loaded. |

### onIsPlayingChanged

```
default void onIsPlayingChanged(boolean isPlaying)
```

Called when the value of `https://developer.android.com/reference/androidx/media3/common/Player#isPlaying()` changes.

`https://developer.android.com/reference/androidx/media3/common/Player.Listener#onEvents(androidx.media3.common.Player,androidx.media3.common.Player.Events)` will also be called to report this event along with other events that happen in the same `https://developer.android.com/reference/android/os/Looper.html` message queue iteration.

| Parameters |
|---|---|
| `boolean isPlaying` | Whether the player is playing. |

### onLoadingChanged

```
@UnstableApi
default void [onLoadingChanged](https://developer.android.com/reference/androidx/media3/common/Player.Listener#onLoadingChanged(boolean))(boolean isLoading)
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/androidx/media3/common/Player.Listener#onIsLoadingChanged(boolean)` instead.

### onMaxSeekToPreviousPositionChanged

```
default void onMaxSeekToPreviousPositionChanged(long maxSeekToPreviousPositionMs)
```

Called when the value of `https://developer.android.com/reference/androidx/media3/common/Player#getMaxSeekToPreviousPosition()` changes.

`https://developer.android.com/reference/androidx/media3/common/Player.Listener#onEvents(androidx.media3.common.Player,androidx.media3.common.Player.Events)` will also be called to report this event along with other events that happen in the same `https://developer.android.com/reference/android/os/Looper.html` message queue iteration.

| Parameters |
|---|---|
| `long maxSeekToPreviousPositionMs` | The maximum position for which `https://developer.android.com/reference/androidx/media3/common/Player#seekToPrevious()` seeks to the previous position, in milliseconds. |

### onMediaItemTransition

```
default void onMediaItemTransition(
    @Nullable MediaItem mediaItem,
    @Player.MediaItemTransitionReason int reason
)
```

Called when playback transitions to a media item or starts repeating a media item according to the current `https://developer.android.com/reference/androidx/media3/common/Player#getRepeatMode()`.

Note that this callback is also called when the value of `https://developer.android.com/reference/androidx/media3/common/Player#getCurrentTimeline()` becomes non-empty or empty.

`https://developer.android.com/reference/androidx/media3/common/Player.Listener#onEvents(androidx.media3.common.Player,androidx.media3.common.Player.Events)` will also be called to report this event along with other events that happen in the same `https://developer.android.com/reference/android/os/Looper.html` message queue iteration.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/common/MediaItem mediaItem` | The `https://developer.android.com/reference/androidx/media3/common/MediaItem`. May be null if the playlist becomes empty. |
| `@https://developer.android.com/reference/androidx/media3/common/Player.MediaItemTransitionReason int reason` | The reason for the transition. |

### onMediaMetadataChanged

```
default void onMediaMetadataChanged(MediaMetadata mediaMetadata)
```

Called when the value of `https://developer.android.com/reference/androidx/media3/common/Player#getMediaMetadata()` changes.

This method may be called multiple times in quick succession.

`https://developer.android.com/reference/androidx/media3/common/Player.Listener#onEvents(androidx.media3.common.Player,androidx.media3.common.Player.Events)` will also be called to report this event along with other events that happen in the same `https://developer.android.com/reference/android/os/Looper.html` message queue iteration.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/MediaMetadata mediaMetadata` | The combined `https://developer.android.com/reference/androidx/media3/common/MediaMetadata`. |

### onMetadata

```
@UnstableApi
default void onMetadata(Metadata metadata)
```

Called when there is metadata associated with the current playback time.

`https://developer.android.com/reference/androidx/media3/common/Player.Listener#onEvents(androidx.media3.common.Player,androidx.media3.common.Player.Events)` will also be called to report this event along with other events that happen in the same `https://developer.android.com/reference/android/os/Looper.html` message queue iteration.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/Metadata metadata` | The metadata. |

### onPlayWhenReadyChanged

```
default void onPlayWhenReadyChanged(
    boolean playWhenReady,
    @Player.PlayWhenReadyChangeReason int reason
)
```

Called when the value returned from `https://developer.android.com/reference/androidx/media3/common/Player#getPlayWhenReady()` changes.

The current `playWhenReady` value may be re-reported if the `reason` for this value changes.

`https://developer.android.com/reference/androidx/media3/common/Player.Listener#onEvents(androidx.media3.common.Player,androidx.media3.common.Player.Events)` will also be called to report this event along with other events that happen in the same `https://developer.android.com/reference/android/os/Looper.html` message queue iteration.

| Parameters |
|---|---|
| `boolean playWhenReady` | Whether playback will proceed when ready. |
| `@https://developer.android.com/reference/androidx/media3/common/Player.PlayWhenReadyChangeReason int reason` | The `https://developer.android.com/reference/androidx/media3/common/Player.PlayWhenReadyChangeReason` for the change. |

### onPlaybackParametersChanged

```
default void onPlaybackParametersChanged(PlaybackParameters playbackParameters)
```

Called when the value of `https://developer.android.com/reference/androidx/media3/common/Player#getPlaybackParameters()` changes. The playback parameters may change due to a call to `https://developer.android.com/reference/androidx/media3/common/Player#setPlaybackParameters(androidx.media3.common.PlaybackParameters)`, or the player itself may change them (for example, if audio playback switches to passthrough or offload mode, where speed adjustment is no longer possible).

`https://developer.android.com/reference/androidx/media3/common/Player.Listener#onEvents(androidx.media3.common.Player,androidx.media3.common.Player.Events)` will also be called to report this event along with other events that happen in the same `https://developer.android.com/reference/android/os/Looper.html` message queue iteration.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/PlaybackParameters playbackParameters` | The playback parameters. |

### onPlaybackStateChanged

```
default void onPlaybackStateChanged(@Player.State int playbackState)
```

Called when the value returned from `https://developer.android.com/reference/androidx/media3/common/Player#getPlaybackState()` changes.

`https://developer.android.com/reference/androidx/media3/common/Player.Listener#onEvents(androidx.media3.common.Player,androidx.media3.common.Player.Events)` will also be called to report this event along with other events that happen in the same `https://developer.android.com/reference/android/os/Looper.html` message queue iteration.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/media3/common/Player.State int playbackState` | The new playback `https://developer.android.com/reference/androidx/media3/common/Player.State`. |

### onPlaybackSuppressionReasonChanged

```
default void onPlaybackSuppressionReasonChanged(
    @Player.PlaybackSuppressionReason int playbackSuppressionReason
)
```

Called when the value returned from `https://developer.android.com/reference/androidx/media3/common/Player#getPlaybackSuppressionReason()` changes.

`https://developer.android.com/reference/androidx/media3/common/Player.Listener#onEvents(androidx.media3.common.Player,androidx.media3.common.Player.Events)` will also be called to report this event along with other events that happen in the same `https://developer.android.com/reference/android/os/Looper.html` message queue iteration.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/media3/common/Player.PlaybackSuppressionReason int playbackSuppressionReason` | The current `https://developer.android.com/reference/androidx/media3/common/Player.PlaybackSuppressionReason`. |

### onPlayerError

```
default void onPlayerError(PlaybackException error)
```

Called when an error occurs. The playback state will transition to `https://developer.android.com/reference/androidx/media3/common/Player#STATE_IDLE()` immediately after this method is called. The player instance can still be used, and `https://developer.android.com/reference/androidx/media3/common/Player#release()` must still be called on the player should it no longer be required.

`https://developer.android.com/reference/androidx/media3/common/Player.Listener#onEvents(androidx.media3.common.Player,androidx.media3.common.Player.Events)` will also be called to report this event along with other events that happen in the same `https://developer.android.com/reference/android/os/Looper.html` message queue iteration.

Implementations of Player may pass an instance of a subclass of `https://developer.android.com/reference/androidx/media3/common/PlaybackException` to this method in order to include more information about the error.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/PlaybackException error` | The error. |

### onPlayerErrorChanged

```
default void onPlayerErrorChanged(@Nullable PlaybackException error)
```

Called when the `https://developer.android.com/reference/androidx/media3/common/PlaybackException` returned by `https://developer.android.com/reference/androidx/media3/common/Player#getPlayerError()` changes.

`https://developer.android.com/reference/androidx/media3/common/Player.Listener#onEvents(androidx.media3.common.Player,androidx.media3.common.Player.Events)` will also be called to report this event along with other events that happen in the same `https://developer.android.com/reference/android/os/Looper.html` message queue iteration.

Implementations of Player may pass an instance of a subclass of `https://developer.android.com/reference/androidx/media3/common/PlaybackException` to this method in order to include more information about the error.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/common/PlaybackException error` | The new error, or null if the error is being cleared. |

### onPlayerStateChanged

```
@UnstableApi
default void [onPlayerStateChanged](https://developer.android.com/reference/androidx/media3/common/Player.Listener#onPlayerStateChanged(boolean,int))(
    boolean playWhenReady,
    @Player.State int playbackState
)
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/androidx/media3/common/Player.Listener#onPlaybackStateChanged(int)` and `https://developer.android.com/reference/androidx/media3/common/Player.Listener#onPlayWhenReadyChanged(boolean,int)` instead.

### onPlaylistMetadataChanged

```
default void onPlaylistMetadataChanged(MediaMetadata mediaMetadata)
```

Called when the value of `https://developer.android.com/reference/androidx/media3/common/Player#getPlaylistMetadata()` changes.

`https://developer.android.com/reference/androidx/media3/common/Player.Listener#onEvents(androidx.media3.common.Player,androidx.media3.common.Player.Events)` will also be called to report this event along with other events that happen in the same `https://developer.android.com/reference/android/os/Looper.html` message queue iteration.

### onPositionDiscontinuity

```
@UnstableApi
default void [onPositionDiscontinuity](https://developer.android.com/reference/androidx/media3/common/Player.Listener#onPositionDiscontinuity(int))(@Player.DiscontinuityReason int reason)
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/androidx/media3/common/Player.Listener#onPositionDiscontinuity(androidx.media3.common.Player.PositionInfo,androidx.media3.common.Player.PositionInfo,int)` instead.

### onPositionDiscontinuity

```
default void onPositionDiscontinuity(
    Player.PositionInfo oldPosition,
    Player.PositionInfo newPosition,
    @Player.DiscontinuityReason int reason
)
```

Called when a position discontinuity occurs.

A position discontinuity occurs when the playing period changes, the playback position jumps within the period currently being played, or when the playing period has been skipped or removed.

`https://developer.android.com/reference/androidx/media3/common/Player.Listener#onEvents(androidx.media3.common.Player,androidx.media3.common.Player.Events)` will also be called to report this event along with other events that happen in the same `https://developer.android.com/reference/android/os/Looper.html` message queue iteration.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/Player.PositionInfo oldPosition` | The position before the discontinuity. |
| `https://developer.android.com/reference/androidx/media3/common/Player.PositionInfo newPosition` | The position after the discontinuity. |
| `@https://developer.android.com/reference/androidx/media3/common/Player.DiscontinuityReason int reason` | The `https://developer.android.com/reference/androidx/media3/common/Player.DiscontinuityReason` responsible for the discontinuity. |

### onRenderedFirstFrame

```
default void onRenderedFirstFrame()
```

Called when a frame is rendered for the first time since setting the surface, or since the renderer was reset, or since the stream being rendered was changed.

`https://developer.android.com/reference/androidx/media3/common/Player.Listener#onEvents(androidx.media3.common.Player,androidx.media3.common.Player.Events)` will also be called to report this event along with other events that happen in the same `https://developer.android.com/reference/android/os/Looper.html` message queue iteration.

### onRepeatModeChanged

```
default void onRepeatModeChanged(@Player.RepeatMode int repeatMode)
```

Called when the value of `https://developer.android.com/reference/androidx/media3/common/Player#getRepeatMode()` changes.

`https://developer.android.com/reference/androidx/media3/common/Player.Listener#onEvents(androidx.media3.common.Player,androidx.media3.common.Player.Events)` will also be called to report this event along with other events that happen in the same `https://developer.android.com/reference/android/os/Looper.html` message queue iteration.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/media3/common/Player.RepeatMode int repeatMode` | The `https://developer.android.com/reference/androidx/media3/common/Player.RepeatMode` used for playback. |

### onSeekBackIncrementChanged

```
default void onSeekBackIncrementChanged(long seekBackIncrementMs)
```

Called when the value of `https://developer.android.com/reference/androidx/media3/common/Player#getSeekBackIncrement()` changes.

`https://developer.android.com/reference/androidx/media3/common/Player.Listener#onEvents(androidx.media3.common.Player,androidx.media3.common.Player.Events)` will also be called to report this event along with other events that happen in the same `https://developer.android.com/reference/android/os/Looper.html` message queue iteration.

| Parameters |
|---|---|
| `long seekBackIncrementMs` | The `https://developer.android.com/reference/androidx/media3/common/Player#seekBack()` increment, in milliseconds. |

### onSeekForwardIncrementChanged

```
default void onSeekForwardIncrementChanged(long seekForwardIncrementMs)
```

Called when the value of `https://developer.android.com/reference/androidx/media3/common/Player#getSeekForwardIncrement()` changes.

`https://developer.android.com/reference/androidx/media3/common/Player.Listener#onEvents(androidx.media3.common.Player,androidx.media3.common.Player.Events)` will also be called to report this event along with other events that happen in the same `https://developer.android.com/reference/android/os/Looper.html` message queue iteration.

| Parameters |
|---|---|
| `long seekForwardIncrementMs` | The `https://developer.android.com/reference/androidx/media3/common/Player#seekForward()` increment, in milliseconds. |

### onShuffleModeEnabledChanged

```
default void onShuffleModeEnabledChanged(boolean shuffleModeEnabled)
```

Called when the value of `https://developer.android.com/reference/androidx/media3/common/Player#getShuffleModeEnabled()` changes.

`https://developer.android.com/reference/androidx/media3/common/Player.Listener#onEvents(androidx.media3.common.Player,androidx.media3.common.Player.Events)` will also be called to report this event along with other events that happen in the same `https://developer.android.com/reference/android/os/Looper.html` message queue iteration.

| Parameters |
|---|---|
| `boolean shuffleModeEnabled` | Whether shuffling of `https://developer.android.com/reference/androidx/media3/common/MediaItem` is enabled. |

### onSkipSilenceEnabledChanged

```
default void onSkipSilenceEnabledChanged(boolean skipSilenceEnabled)
```

Called when skipping silences is enabled or disabled in the audio stream.

`https://developer.android.com/reference/androidx/media3/common/Player.Listener#onEvents(androidx.media3.common.Player,androidx.media3.common.Player.Events)` will also be called to report this event along with other events that happen in the same `https://developer.android.com/reference/android/os/Looper.html` message queue iteration.

| Parameters |
|---|---|
| `boolean skipSilenceEnabled` | Whether skipping silences in the audio stream is enabled. |

### onSurfaceSizeChanged

```
default void onSurfaceSizeChanged(int width, int height)
```

Called each time there's a change in the size of the surface onto which the video is being rendered.

`https://developer.android.com/reference/androidx/media3/common/Player.Listener#onEvents(androidx.media3.common.Player,androidx.media3.common.Player.Events)` will also be called to report this event along with other events that happen in the same `https://developer.android.com/reference/android/os/Looper.html` message queue iteration.

| Parameters |
|---|---|
| `int width` | The surface width in pixels. May be `https://developer.android.com/reference/androidx/media3/common/C#LENGTH_UNSET()` if unknown, or 0 if the video is not rendered onto a surface. |
| `int height` | The surface height in pixels. May be `https://developer.android.com/reference/androidx/media3/common/C#LENGTH_UNSET()` if unknown, or 0 if the video is not rendered onto a surface. |

### onTimelineChanged

```
default void onTimelineChanged(
    Timeline timeline,
    @Player.TimelineChangeReason int reason
)
```

Called when the value of `https://developer.android.com/reference/androidx/media3/common/Player#getCurrentTimeline()` changes.

Note that the current `https://developer.android.com/reference/androidx/media3/common/MediaItem` or playback position may change as a result of a timeline change. If playback can't continue smoothly because of this timeline change, a separate `https://developer.android.com/reference/androidx/media3/common/Player.Listener#onPositionDiscontinuity(androidx.media3.common.Player.PositionInfo,androidx.media3.common.Player.PositionInfo,int)` callback will be triggered.

`https://developer.android.com/reference/androidx/media3/common/Player.Listener#onEvents(androidx.media3.common.Player,androidx.media3.common.Player.Events)` will also be called to report this event along with other events that happen in the same `https://developer.android.com/reference/android/os/Looper.html` message queue iteration.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/Timeline timeline` | The latest timeline. Never null, but may be empty. |
| `@https://developer.android.com/reference/androidx/media3/common/Player.TimelineChangeReason int reason` | The `https://developer.android.com/reference/androidx/media3/common/Player.TimelineChangeReason` responsible for this timeline change. |

### onTrackSelectionParametersChanged

```
default void onTrackSelectionParametersChanged(TrackSelectionParameters parameters)
```

Called when the value returned from `https://developer.android.com/reference/androidx/media3/common/Player#getTrackSelectionParameters()` changes.

`https://developer.android.com/reference/androidx/media3/common/Player.Listener#onEvents(androidx.media3.common.Player,androidx.media3.common.Player.Events)` will also be called to report this event along with other events that happen in the same `https://developer.android.com/reference/android/os/Looper.html` message queue iteration.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/TrackSelectionParameters parameters` | The new `https://developer.android.com/reference/androidx/media3/common/TrackSelectionParameters`. |

### onTracksChanged

```
default void onTracksChanged(Tracks tracks)
```

Called when the value of `https://developer.android.com/reference/androidx/media3/common/Player#getCurrentTracks()` changes.

`https://developer.android.com/reference/androidx/media3/common/Player.Listener#onEvents(androidx.media3.common.Player,androidx.media3.common.Player.Events)` will also be called to report this event along with other events that happen in the same `https://developer.android.com/reference/android/os/Looper.html` message queue iteration.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/Tracks tracks` | The available tracks information. Never null, but may be of length zero. |

### onVideoSizeChanged

```
default void onVideoSizeChanged(VideoSize videoSize)
```

Called each time when `https://developer.android.com/reference/androidx/media3/common/Player#getVideoSize()` changes.

`https://developer.android.com/reference/androidx/media3/common/Player.Listener#onEvents(androidx.media3.common.Player,androidx.media3.common.Player.Events)` will also be called to report this event along with other events that happen in the same `https://developer.android.com/reference/android/os/Looper.html` message queue iteration.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/VideoSize videoSize` | The new size of the video. |

### onVolumeChanged

```
default void onVolumeChanged(float volume)
```

Called when the value of `https://developer.android.com/reference/androidx/media3/common/Player#getVolume()` changes.

`https://developer.android.com/reference/androidx/media3/common/Player.Listener#onEvents(androidx.media3.common.Player,androidx.media3.common.Player.Events)` will also be called to report this event along with other events that happen in the same `https://developer.android.com/reference/android/os/Looper.html` message queue iteration.

| Parameters |
|---|---|
| `float volume` | The new volume, with 0 being silence and 1 being unity gain. |