# MediaController

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

*** ** * ** ***


```
@DoNotMock
public class MediaController implements Player
```

<br />

Known direct subclasses [MediaBrowser](https://developer.android.com/reference/androidx/media3/session/MediaBrowser)

|---|---|
| `https://developer.android.com/reference/androidx/media3/session/MediaBrowser` | Browses media content offered by a `https://developer.android.com/reference/androidx/media3/session/MediaLibraryService` in addition to the `https://developer.android.com/reference/androidx/media3/session/MediaController` functions. |

*** ** * ** ***

A controller that interacts with a `https://developer.android.com/reference/androidx/media3/session/MediaSession`, a `https://developer.android.com/reference/androidx/media3/session/MediaSessionService` hosting a `https://developer.android.com/reference/androidx/media3/session/MediaSession`, or a `https://developer.android.com/reference/androidx/media3/session/MediaLibraryService` hosting a `https://developer.android.com/reference/androidx/media3/session/MediaLibraryService.MediaLibrarySession`. The `https://developer.android.com/reference/androidx/media3/session/MediaSession` typically resides in a remote process like another app but may be in the same process as this controller. It implements `https://developer.android.com/reference/androidx/media3/common/Player` and the player commands are sent to the underlying `https://developer.android.com/reference/androidx/media3/common/Player` of the connected `https://developer.android.com/reference/androidx/media3/session/MediaSession`. It also has session-specific commands that can be handled by `https://developer.android.com/reference/androidx/media3/session/MediaSession.Callback`.

Topics covered here:

1. [Controller Lifecycle](https://developer.android.com/reference/androidx/media3/session/MediaController#ControllerLifeCycle)
2. [Threading Model](https://developer.android.com/reference/androidx/media3/session/MediaController#ThreadingModel)
3. [Package Visibility Filter](https://developer.android.com/reference/androidx/media3/session/MediaController#PackageVisibilityFilter)
4. [Backward Compatibility with platform and legacy media sessions](https://developer.android.com/reference/androidx/media3/session/MediaController#BackwardCompatibility)

## Controller Lifecycle

When a controller is created with the `https://developer.android.com/reference/androidx/media3/session/SessionToken` for a `https://developer.android.com/reference/androidx/media3/session/MediaSession` (i.e. session token type is `https://developer.android.com/reference/androidx/media3/session/SessionToken#TYPE_SESSION()`), the controller will connect to the specific session.

When a controller is created with the `https://developer.android.com/reference/androidx/media3/session/SessionToken` for a `https://developer.android.com/reference/androidx/media3/session/MediaSessionService` (i.e. session token type is `https://developer.android.com/reference/androidx/media3/session/SessionToken#TYPE_SESSION_SERVICE()` or `https://developer.android.com/reference/androidx/media3/session/SessionToken#TYPE_LIBRARY_SERVICE()`), the controller binds to the service for connecting to a `https://developer.android.com/reference/androidx/media3/session/MediaSession` in it. `https://developer.android.com/reference/androidx/media3/session/MediaSessionService` will provide a session to connect.

When you're done, use `https://developer.android.com/reference/androidx/media3/session/MediaController#releaseFuture(java.util.concurrent.Future<? extends androidx.media3.session.MediaController>)` or `https://developer.android.com/reference/androidx/media3/session/MediaController#release()` to clean up resources. This also helps the session service to be destroyed when there's no controller associated with it. Releasing the controller will still deliver all pending commands sent to the session and only unbind from the session service once these commands have been handled, or after a timeout of `https://developer.android.com/reference/androidx/media3/session/MediaController#RELEASE_UNBIND_TIMEOUT_MS()`.

## Threading Model

Methods of this class should be called from the application thread associated with the `https://developer.android.com/reference/androidx/media3/session/MediaController#getApplicationLooper()`. Otherwise, `https://developer.android.com/reference/java/lang/IllegalStateException.html` will be thrown. Also, the methods of `https://developer.android.com/reference/androidx/media3/common/Player.Listener` and `https://developer.android.com/reference/androidx/media3/session/MediaController.Listener` will be called from the application thread.

## Package Visibility Filter

The app targeting API level 30 or higher must include a `<queries>` element in their manifest to connect to a service component of another app like `https://developer.android.com/reference/androidx/media3/session/MediaSessionService`, `https://developer.android.com/reference/androidx/media3/session/MediaLibraryService`, or `androidx.media.MediaBrowserServiceCompat`). See the following example and [this guide](https://developer.android.com/training/package-visibility) for more information.

```
<!-- As intent actions -->
<intent>
  <action android:name="androidx.media3.session.MediaSessionService" />
</intent>
<intent>
  <action android:name="androidx.media3.session.MediaLibraryService" />
</intent>
<intent>
  <action android:name="android.media.browse.MediaBrowserService" />
</intent>
<!-- Or, as a package name -->
<package android:name="package_name_of_the_other_app" />
```

## Backward Compatibility with platform and legacy media sessions

In addition to `https://developer.android.com/reference/androidx/media3/session/MediaSession`, the controller also supports connecting to a platform or legacy media session - `https://developer.android.com/reference/android/media/session/MediaSession.html` and `
android.support.v4.media.session.MediaSessionCompat`.

To request legacy sessions to play media, use one of the `https://developer.android.com/reference/androidx/media3/session/MediaController#setMediaItem(androidx.media3.common.MediaItem)` methods and set either `https://developer.android.com/reference/androidx/media3/common/MediaItem#mediaId()`, `https://developer.android.com/reference/androidx/media3/common/MediaItem.RequestMetadata#mediaUri()` or `https://developer.android.com/reference/androidx/media3/common/MediaItem.RequestMetadata#searchQuery()`. Once the controller is `https://developer.android.com/reference/androidx/media3/session/MediaController#prepare()`, the controller triggers one of the following methods on `
android.support.v4.media.session.MediaSessionCompat.Callback` depending on the provided information and the value of `https://developer.android.com/reference/androidx/media3/session/MediaController#getPlayWhenReady()`:

- `onPrepareFromUri`
- `onPlayFromUri`
- `onPrepareFromMediaId`
- `onPlayFromMediaId`
- `onPrepareFromSearch`
- `onPlayFromSearch`

Other playlist change methods, like `https://developer.android.com/reference/androidx/media3/session/MediaController#addMediaItem(androidx.media3.common.MediaItem)` or `https://developer.android.com/reference/androidx/media3/session/MediaController#removeMediaItem(int)`, trigger the `MediaSessionCompat.Callback.onAddQueueItem` and `
MediaSessionCompat.Callback.onRemoveQueueItem` callbacks. Check `https://developer.android.com/reference/androidx/media3/session/MediaController#getAvailableCommands()` to see if playlist modifications are `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_CHANGE_MEDIA_ITEMS()` by the legacy session.

When connected to a platform or legacy media session, some `https://developer.android.com/reference/androidx/media3/common/Player` methods and features are not supported by the underlying legacy API:

- Tracks and track selection: `https://developer.android.com/reference/androidx/media3/session/MediaController#getCurrentTracks()` returns `https://developer.android.com/reference/androidx/media3/common/Tracks#EMPTY()`, `https://developer.android.com/reference/androidx/media3/session/MediaController#getTrackSelectionParameters()` returns `https://developer.android.com/reference/androidx/media3/common/TrackSelectionParameters#DEFAULT()`, and `https://developer.android.com/reference/androidx/media3/session/MediaController#setTrackSelectionParameters(androidx.media3.common.TrackSelectionParameters)` is ignored.
- Video surfaces: Setting a video surface via `https://developer.android.com/reference/androidx/media3/session/MediaController#setVideoSurface(android.view.Surface)`, `https://developer.android.com/reference/androidx/media3/session/MediaController#setVideoSurfaceHolder(android.view.SurfaceHolder)`, `https://developer.android.com/reference/androidx/media3/session/MediaController#setVideoSurfaceView(android.view.SurfaceView)`, or `https://developer.android.com/reference/androidx/media3/session/MediaController#setVideoTextureView(android.view.TextureView)` logs a warning and is ignored.
- Player volume: `https://developer.android.com/reference/androidx/media3/session/MediaController#getVolume()` returns `1.0f`, and `https://developer.android.com/reference/androidx/media3/session/MediaController#setVolume(float)` logs a warning and is ignored. Note that device volume control via `https://developer.android.com/reference/androidx/media3/session/MediaController#setDeviceVolume(int)` is supported if the session provides remote volume handling.
- Text cues: `https://developer.android.com/reference/androidx/media3/session/MediaController#getCurrentCues()` returns `https://developer.android.com/reference/androidx/media3/common/text/CueGroup#EMPTY_TIME_ZERO()`.
- Playback suppression: `https://developer.android.com/reference/androidx/media3/session/MediaController#getPlaybackSuppressionReason()` returns `https://developer.android.com/reference/androidx/media3/common/Player#PLAYBACK_SUPPRESSION_REASON_NONE()`.
- Ad information: `https://developer.android.com/reference/androidx/media3/session/MediaController#getCurrentAdGroupIndex()` and `https://developer.android.com/reference/androidx/media3/session/MediaController#getCurrentAdIndexInAdGroup()` return `https://developer.android.com/reference/androidx/media3/common/C#INDEX_UNSET()`.
- Playlist metadata: `https://developer.android.com/reference/androidx/media3/session/MediaController#setPlaylistMetadata(androidx.media3.common.MediaMetadata)` is ignored.
- Ratings: `https://developer.android.com/reference/androidx/media3/session/MediaController#setRating(java.lang.String,androidx.media3.common.Rating)` is only supported for the currently playing media item; calling it for any other item is ignored.

## Summary

| ### Nested types |
|---|
| `public final class https://developer.android.com/reference/androidx/media3/session/MediaController.Builder` A builder for `https://developer.android.com/reference/androidx/media3/session/MediaController`. |
| `public interface https://developer.android.com/reference/androidx/media3/session/MediaController.Listener` A listener for events and incoming commands from `https://developer.android.com/reference/androidx/media3/session/MediaSession`. |
| `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi public interface https://developer.android.com/reference/androidx/media3/session/MediaController.ProgressListener` A listener to receive progress updates of a custom command when a custom command is sent and a non-null `https://developer.android.com/reference/androidx/media3/session/MediaController.ProgressListener` is passed into `https://developer.android.com/reference/androidx/media3/session/MediaController#sendCustomCommand(androidx.media3.session.SessionCommand,android.os.Bundle,androidx.media3.session.MediaController.ProgressListener)`. |

| ### Constants |
|---|---|
| `static final long` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/session/MediaController#DEFAULT_PLATFORM_CALLBACK_AGGREGATION_TIMEOUT_MS() = 100` |
| `static final https://developer.android.com/reference/java/lang/String.html` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/session/MediaController#KEY_MEDIA_NOTIFICATION_CONTROLLER_FLAG() = "androidx.media3.session.MediaNotificationManager"` Key to mark the connection hints of the media notification controller. |
| `static final long` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/session/MediaController#RELEASE_UNBIND_TIMEOUT_MS() = 30000` The timeout for handling pending commands after calling `https://developer.android.com/reference/androidx/media3/session/MediaController#release()`. |

| ### Public methods |
|---|---|
| `final void` | `https://developer.android.com/reference/androidx/media3/session/MediaController#addListener(androidx.media3.common.Player.Listener)(https://developer.android.com/reference/androidx/media3/common/Player.Listener listener)` Registers a listener to receive all events from the player. |
| `final void` | `https://developer.android.com/reference/androidx/media3/session/MediaController#addMediaItem(androidx.media3.common.MediaItem)(https://developer.android.com/reference/androidx/media3/common/MediaItem mediaItem)` Adds a media item to the end of the playlist. |
| `final void` | `https://developer.android.com/reference/androidx/media3/session/MediaController#addMediaItem(int,androidx.media3.common.MediaItem)(int index, https://developer.android.com/reference/androidx/media3/common/MediaItem mediaItem)` Adds a media item at the given index of the playlist. |
| `final void` | `https://developer.android.com/reference/androidx/media3/session/MediaController#addMediaItems(java.util.List<androidx.media3.common.MediaItem>)(https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/androidx/media3/common/MediaItem> mediaItems)` Adds a list of media items to the end of the playlist. |
| `final void` | `https://developer.android.com/reference/androidx/media3/session/MediaController#addMediaItems(int,java.util.List<androidx.media3.common.MediaItem>)(int index, https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/androidx/media3/common/MediaItem> mediaItems)` Adds a list of media items at the given index of the playlist. |
| `final boolean` | `https://developer.android.com/reference/androidx/media3/session/MediaController#canAdvertiseSession()()` Returns whether the player can be used to advertise a media session. |
| `final void` | `https://developer.android.com/reference/androidx/media3/session/MediaController#clearMediaItems()()` Clears the playlist. |
| `final void` | `https://developer.android.com/reference/androidx/media3/session/MediaController#clearVideoSurface()()` Clears any , , or currently set on the player. |
| `final void` | `https://developer.android.com/reference/androidx/media3/session/MediaController#clearVideoSurface(android.view.Surface)(@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/android/view/Surface.html surface)` Clears the onto which video is being rendered if it matches the one passed. |
| `final void` | `https://developer.android.com/reference/androidx/media3/session/MediaController#clearVideoSurfaceHolder(android.view.SurfaceHolder)(@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/android/view/SurfaceHolder.html surfaceHolder)` Clears the that holds the onto which video is being rendered if it matches the one passed. |
| `final void` | `https://developer.android.com/reference/androidx/media3/session/MediaController#clearVideoSurfaceView(android.view.SurfaceView)(@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/android/view/SurfaceView.html surfaceView)` Clears the onto which video is being rendered if it matches the one passed. |
| `final void` | `https://developer.android.com/reference/androidx/media3/session/MediaController#clearVideoTextureView(android.view.TextureView)(@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/android/view/TextureView.html textureView)` Clears the onto which video is being rendered if it matches the one passed. |
| `final void` | `[decreaseDeviceVolume](https://developer.android.com/reference/androidx/media3/session/MediaController#decreaseDeviceVolume())()` **This method is deprecated.** Use `https://developer.android.com/reference/androidx/media3/session/MediaController#decreaseDeviceVolume(int)` instead. <br /> |
| `final void` | `https://developer.android.com/reference/androidx/media3/session/MediaController#decreaseDeviceVolume(int)(@https://developer.android.com/reference/androidx/media3/common/C.VolumeFlags int flags)` Decreases the volume of the device. |
| `final https://developer.android.com/reference/android/os/Looper.html` | `https://developer.android.com/reference/androidx/media3/session/MediaController#getApplicationLooper()()` Returns the `https://developer.android.com/reference/android/os/Looper.html` associated with the application thread that's used to access the player and on which player events are received. |
| `final https://developer.android.com/reference/androidx/media3/common/AudioAttributes` | `https://developer.android.com/reference/androidx/media3/session/MediaController#getAudioAttributes()()` Returns the attributes for audio playback. |
| `final int` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/session/MediaController#getAudioSessionId()()` Returns the audio session identifier, or `https://developer.android.com/reference/androidx/media3/common/C#AUDIO_SESSION_ID_UNSET()` if not set. |
| `final https://developer.android.com/reference/androidx/media3/common/Player.Commands` | `https://developer.android.com/reference/androidx/media3/session/MediaController#getAvailableCommands()()` Returns the player's currently available `https://developer.android.com/reference/androidx/media3/common/Player.Commands`. |
| `final https://developer.android.com/reference/androidx/media3/session/SessionCommands` | `https://developer.android.com/reference/androidx/media3/session/MediaController#getAvailableSessionCommands()()` Returns the current available session commands from `https://developer.android.com/reference/androidx/media3/session/MediaController.Listener#onAvailableSessionCommandsChanged(androidx.media3.session.MediaController,androidx.media3.session.SessionCommands)`, or `https://developer.android.com/reference/androidx/media3/session/SessionCommands#EMPTY()` if it is not connected. |
| `final @https://developer.android.com/reference/androidx/annotation/IntRange(from = 0, to = 100) int` | `https://developer.android.com/reference/androidx/media3/session/MediaController#getBufferedPercentage()()` Returns an estimate of the percentage in the current content or ad up to which data is buffered, or 0 if no estimate is available. |
| `final long` | `https://developer.android.com/reference/androidx/media3/session/MediaController#getBufferedPosition()()` Returns an estimate of the position in the current content or ad up to which data is buffered, in milliseconds. |
| `final https://guava.dev/releases/snapshot-android/api/docs/com/google/common/collect/ImmutableList.html<https://developer.android.com/reference/androidx/media3/session/CommandButton>` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/session/MediaController#getCommandButtonsForMediaItem(androidx.media3.common.MediaItem)(https://developer.android.com/reference/androidx/media3/common/MediaItem mediaItem)` Returns the command buttons that are supported for the given `https://developer.android.com/reference/androidx/media3/common/MediaItem`. |
| `final @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/session/SessionToken` | `https://developer.android.com/reference/androidx/media3/session/MediaController#getConnectedToken()()` Returns the `https://developer.android.com/reference/androidx/media3/session/SessionToken` of the connected session, or `null` if it is not connected. |
| `final long` | `https://developer.android.com/reference/androidx/media3/session/MediaController#getContentBufferedPosition()()` If #isPlayingAd() returns true}, returns an estimate of the content position in the current content up to which data is buffered, in milliseconds. |
| `final long` | `https://developer.android.com/reference/androidx/media3/session/MediaController#getContentDuration()()` If #isPlayingAd() returns true}, returns the duration of the current content in milliseconds, or C#TIME_UNSET if the duration is not known. |
| `final long` | `https://developer.android.com/reference/androidx/media3/session/MediaController#getContentPosition()()` If #isPlayingAd() returns true}, returns the content position that will be played once all ads in the ad group have finished playing, in milliseconds. |
| `final int` | `https://developer.android.com/reference/androidx/media3/session/MediaController#getCurrentAdGroupIndex()()` If #isPlayingAd() returns true, returns the index of the ad group in the period currently being played. |
| `final int` | `https://developer.android.com/reference/androidx/media3/session/MediaController#getCurrentAdIndexInAdGroup()()` If #isPlayingAd() returns true, returns the index of the ad in its ad group. |
| `final https://developer.android.com/reference/androidx/media3/common/text/CueGroup` | `https://developer.android.com/reference/androidx/media3/session/MediaController#getCurrentCues()()` Returns the current . |
| `final long` | `https://developer.android.com/reference/androidx/media3/session/MediaController#getCurrentLiveOffset()()` Returns the offset of the current playback position from the live edge in milliseconds, or `https://developer.android.com/reference/androidx/media3/common/C#TIME_UNSET()` if the current `https://developer.android.com/reference/androidx/media3/common/MediaItem``https://developer.android.com/reference/androidx/media3/common/Player#isCurrentMediaItemLive()` or the offset is unknown. |
| `final @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/Object.html` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/session/MediaController#getCurrentManifest()()` Returns `null`. |
| `final @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/common/MediaItem` | `https://developer.android.com/reference/androidx/media3/session/MediaController#getCurrentMediaItem()()` Returns the currently playing `https://developer.android.com/reference/androidx/media3/common/MediaItem`. |
| `final int` | `https://developer.android.com/reference/androidx/media3/session/MediaController#getCurrentMediaItemIndex()()` Returns the index of the current `https://developer.android.com/reference/androidx/media3/common/MediaItem` in the `https://developer.android.com/reference/androidx/media3/common/Player#getCurrentTimeline()`, or the prospective index if the `https://developer.android.com/reference/androidx/media3/common/Player#getCurrentTimeline()` is empty. |
| `final int` | `https://developer.android.com/reference/androidx/media3/session/MediaController#getCurrentPeriodIndex()()` Returns the index of the period currently being played. |
| `final long` | `https://developer.android.com/reference/androidx/media3/session/MediaController#getCurrentPosition()()` Returns the playback position in the current content or ad, in milliseconds, or the prospective position in milliseconds if the `https://developer.android.com/reference/androidx/media3/common/Player#getCurrentTimeline()` is empty. |
| `final https://developer.android.com/reference/androidx/media3/common/Timeline` | `https://developer.android.com/reference/androidx/media3/session/MediaController#getCurrentTimeline()()` Returns the current . |
| `final https://developer.android.com/reference/androidx/media3/common/Tracks` | `https://developer.android.com/reference/androidx/media3/session/MediaController#getCurrentTracks()()` Returns the current tracks. |
| `final int` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi [getCurrentWindowIndex](https://developer.android.com/reference/androidx/media3/session/MediaController#getCurrentWindowIndex())()` **This method is deprecated.** Use `https://developer.android.com/reference/androidx/media3/session/MediaController#getCurrentMediaItemIndex()` instead. <br /> |
| `final https://guava.dev/releases/snapshot-android/api/docs/com/google/common/collect/ImmutableList.html<https://developer.android.com/reference/androidx/media3/session/CommandButton>` | `https://developer.android.com/reference/androidx/media3/session/MediaController#getCustomLayout()()` Returns the custom layout. |
| `final https://developer.android.com/reference/androidx/media3/common/DeviceInfo` | `https://developer.android.com/reference/androidx/media3/session/MediaController#getDeviceInfo()()` Gets the device information. |
| `final @https://developer.android.com/reference/androidx/annotation/IntRange(from = 0) int` | `https://developer.android.com/reference/androidx/media3/session/MediaController#getDeviceVolume()()` Gets the current volume of the device. |
| `final long` | `https://developer.android.com/reference/androidx/media3/session/MediaController#getDuration()()` Returns the duration of the current content or ad in milliseconds, or `https://developer.android.com/reference/androidx/media3/common/C#TIME_UNSET()` if the duration is not known. |
| `final long` | `https://developer.android.com/reference/androidx/media3/session/MediaController#getMaxSeekToPreviousPosition()()` Returns the maximum position for which #seekToPrevious() seeks to the previous \* , in milliseconds. |
| `final https://guava.dev/releases/snapshot-android/api/docs/com/google/common/collect/ImmutableList.html<https://developer.android.com/reference/androidx/media3/session/CommandButton>` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/session/MediaController#getMediaButtonPreferences()()` Returns the media button preferences. |
| `final https://developer.android.com/reference/androidx/media3/common/MediaItem` | `https://developer.android.com/reference/androidx/media3/session/MediaController#getMediaItemAt(int)(int index)` Returns the `https://developer.android.com/reference/androidx/media3/common/MediaItem` at the given index. |
| `final int` | `https://developer.android.com/reference/androidx/media3/session/MediaController#getMediaItemCount()()` Returns the number of `https://developer.android.com/reference/androidx/media3/common/MediaItem` in the playlist. |
| `final https://developer.android.com/reference/androidx/media3/common/MediaMetadata` | `https://developer.android.com/reference/androidx/media3/session/MediaController#getMediaMetadata()()` Returns the current combined `https://developer.android.com/reference/androidx/media3/common/MediaMetadata`, or `https://developer.android.com/reference/androidx/media3/common/MediaMetadata#EMPTY()` if not supported. |
| `final int` | `https://developer.android.com/reference/androidx/media3/session/MediaController#getNextMediaItemIndex()()` Returns the index of the that will be played if \* #seekToNextMediaItem() is called, which may depend on the current repeat mode and whether shuffle mode is enabled. |
| `final int` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi [getNextWindowIndex](https://developer.android.com/reference/androidx/media3/session/MediaController#getNextWindowIndex())()` **This method is deprecated.** Use `https://developer.android.com/reference/androidx/media3/session/MediaController#getNextMediaItemIndex()` instead. <br /> |
| `final boolean` | `https://developer.android.com/reference/androidx/media3/session/MediaController#getPlayWhenReady()()` Whether playback will proceed when `https://developer.android.com/reference/androidx/media3/common/Player#getPlaybackState()` == `https://developer.android.com/reference/androidx/media3/common/Player#STATE_READY()`. |
| `final https://developer.android.com/reference/androidx/media3/common/PlaybackParameters` | `https://developer.android.com/reference/androidx/media3/session/MediaController#getPlaybackParameters()()` Returns the currently active playback parameters. |
| `final int` | `@https://developer.android.com/reference/androidx/media3/common/Player.State https://developer.android.com/reference/androidx/media3/session/MediaController#getPlaybackState()()` Returns the current `https://developer.android.com/reference/androidx/media3/common/Player.State` of the player. |
| `final int` | `@https://developer.android.com/reference/androidx/media3/common/Player.PlaybackSuppressionReason https://developer.android.com/reference/androidx/media3/session/MediaController#getPlaybackSuppressionReason()()` Returns the reason why playback is suppressed even though #getPlayWhenReady() is \*true, or #PLAYBACK_SUPPRESSION_REASON_NONE if playback is not suppressed. |
| `final @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/common/PlaybackException` | `https://developer.android.com/reference/androidx/media3/session/MediaController#getPlayerError()()` Returns the error that caused playback to fail. |
| `final https://developer.android.com/reference/androidx/media3/common/MediaMetadata` | `https://developer.android.com/reference/androidx/media3/session/MediaController#getPlaylistMetadata()()` Returns the playlist `https://developer.android.com/reference/androidx/media3/common/MediaMetadata`, as set by `https://developer.android.com/reference/androidx/media3/common/Player#setPlaylistMetadata(androidx.media3.common.MediaMetadata)`, or `https://developer.android.com/reference/androidx/media3/common/MediaMetadata#EMPTY()` if not supported. |
| `final int` | `https://developer.android.com/reference/androidx/media3/session/MediaController#getPreviousMediaItemIndex()()` Returns the index of the that will be played if \* #seekToPreviousMediaItem() is called, which may depend on the current repeat mode and whether shuffle mode is enabled. |
| `final int` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi [getPreviousWindowIndex](https://developer.android.com/reference/androidx/media3/session/MediaController#getPreviousWindowIndex())()` **This method is deprecated.** Use `https://developer.android.com/reference/androidx/media3/session/MediaController#getPreviousMediaItemIndex()` instead. <br /> |
| `final int` | `@https://developer.android.com/reference/androidx/media3/common/Player.RepeatMode https://developer.android.com/reference/androidx/media3/session/MediaController#getRepeatMode()()` Returns the current `https://developer.android.com/reference/androidx/media3/common/Player.RepeatMode` used for playback. |
| `final long` | `https://developer.android.com/reference/androidx/media3/session/MediaController#getSeekBackIncrement()()` Returns the #seekBack() increment. |
| `final long` | `https://developer.android.com/reference/androidx/media3/session/MediaController#getSeekForwardIncrement()()` Returns the #seekForward() increment. |
| `final @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/android/app/PendingIntent.html` | `https://developer.android.com/reference/androidx/media3/session/MediaController#getSessionActivity()()` Returns an intent for launching UI associated with the session if exists, or `null`. |
| `final https://developer.android.com/reference/android/os/Bundle.html` | `https://developer.android.com/reference/androidx/media3/session/MediaController#getSessionExtras()()` Returns the session extras. |
| `final boolean` | `https://developer.android.com/reference/androidx/media3/session/MediaController#getShuffleModeEnabled()()` Returns whether shuffling of media items is enabled. |
| `final https://developer.android.com/reference/androidx/media3/common/util/Size` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/session/MediaController#getSurfaceSize()()` Gets the size of the surface on which the video is rendered. |
| `final long` | `https://developer.android.com/reference/androidx/media3/session/MediaController#getTotalBufferedDuration()()` Returns an estimate of the total buffered duration from the current position, in milliseconds. |
| `final https://developer.android.com/reference/androidx/media3/common/TrackSelectionParameters` | `https://developer.android.com/reference/androidx/media3/session/MediaController#getTrackSelectionParameters()()` Returns the parameters constraining the track selection. |
| `final https://developer.android.com/reference/androidx/media3/common/VideoSize` | `https://developer.android.com/reference/androidx/media3/session/MediaController#getVideoSize()()` Gets the size of the video. |
| `final @https://developer.android.com/reference/androidx/annotation/FloatRange(from = 0, to = 1) float` | `https://developer.android.com/reference/androidx/media3/session/MediaController#getVolume()()` Returns the audio volume, with 0 being silence and 1 being unity gain (signal unchanged). |
| `final boolean` | `https://developer.android.com/reference/androidx/media3/session/MediaController#hasNextMediaItem()()` Returns whether a next `https://developer.android.com/reference/androidx/media3/common/MediaItem` exists, which may depend on the current repeat mode and whether shuffle mode is enabled. |
| `final boolean` | `https://developer.android.com/reference/androidx/media3/session/MediaController#hasPreviousMediaItem()()` Returns whether a previous media item exists, which may depend on the current repeat mode and whether shuffle mode is enabled. |
| `final void` | `[increaseDeviceVolume](https://developer.android.com/reference/androidx/media3/session/MediaController#increaseDeviceVolume())()` **This method is deprecated.** Use `https://developer.android.com/reference/androidx/media3/session/MediaController#increaseDeviceVolume(int)` instead. <br /> |
| `final void` | `https://developer.android.com/reference/androidx/media3/session/MediaController#increaseDeviceVolume(int)(@https://developer.android.com/reference/androidx/media3/common/C.VolumeFlags int flags)` Increases the volume of the device. |
| `final boolean` | `https://developer.android.com/reference/androidx/media3/session/MediaController#isCommandAvailable(int)(@https://developer.android.com/reference/androidx/media3/common/Player.Command int command)` Returns whether the provided `https://developer.android.com/reference/androidx/media3/common/Player.Command` is available. |
| `final boolean` | `https://developer.android.com/reference/androidx/media3/session/MediaController#isConnected()()` Returns whether this controller is connected to a `https://developer.android.com/reference/androidx/media3/session/MediaSession` or not. |
| `final boolean` | `https://developer.android.com/reference/androidx/media3/session/MediaController#isCurrentMediaItemDynamic()()` Returns whether the current `https://developer.android.com/reference/androidx/media3/common/MediaItem` is dynamic (may change when the `https://developer.android.com/reference/androidx/media3/common/Timeline` is updated), or `false` if the `https://developer.android.com/reference/androidx/media3/common/Timeline` is empty. |
| `final boolean` | `https://developer.android.com/reference/androidx/media3/session/MediaController#isCurrentMediaItemLive()()` Returns whether the current `https://developer.android.com/reference/androidx/media3/common/MediaItem` is live, or `false` if the `https://developer.android.com/reference/androidx/media3/common/Timeline` is empty. |
| `final boolean` | `https://developer.android.com/reference/androidx/media3/session/MediaController#isCurrentMediaItemSeekable()()` Returns whether the current `https://developer.android.com/reference/androidx/media3/common/MediaItem` is seekable, or `false` if the `https://developer.android.com/reference/androidx/media3/common/Timeline` is empty. |
| `final boolean` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi [isCurrentWindowDynamic](https://developer.android.com/reference/androidx/media3/session/MediaController#isCurrentWindowDynamic())()` **This method is deprecated.** Use `https://developer.android.com/reference/androidx/media3/session/MediaController#isCurrentMediaItemDynamic()` instead. <br /> |
| `final boolean` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi [isCurrentWindowLive](https://developer.android.com/reference/androidx/media3/session/MediaController#isCurrentWindowLive())()` **This method is deprecated.** Use `https://developer.android.com/reference/androidx/media3/session/MediaController#isCurrentMediaItemLive()` instead. <br /> |
| `final boolean` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi [isCurrentWindowSeekable](https://developer.android.com/reference/androidx/media3/session/MediaController#isCurrentWindowSeekable())()` **This method is deprecated.** Use `https://developer.android.com/reference/androidx/media3/session/MediaController#isCurrentMediaItemSeekable()` instead. <br /> |
| `final boolean` | `https://developer.android.com/reference/androidx/media3/session/MediaController#isDeviceMuted()()` Gets whether the device is muted or not. |
| `final boolean` | `https://developer.android.com/reference/androidx/media3/session/MediaController#isLoading()()` Whether the player is currently loading the source. |
| `final boolean` | `https://developer.android.com/reference/androidx/media3/session/MediaController#isPlaying()()` Returns whether the player is playing, i.e. `https://developer.android.com/reference/androidx/media3/common/Player#getCurrentPosition()` is advancing. |
| `final boolean` | `https://developer.android.com/reference/androidx/media3/session/MediaController#isPlayingAd()()` Returns whether the player is currently playing an ad. |
| `final boolean` | `https://developer.android.com/reference/androidx/media3/session/MediaController#isSessionCommandAvailable(int)( @https://developer.android.com/reference/androidx/media3/session/SessionCommand.CommandCode int sessionCommandCode )` Returns whether the `https://developer.android.com/reference/androidx/media3/session/SessionCommand.CommandCode` is available. |
| `final boolean` | `https://developer.android.com/reference/androidx/media3/session/MediaController#isSessionCommandAvailable(androidx.media3.session.SessionCommand)(https://developer.android.com/reference/androidx/media3/session/SessionCommand sessionCommand)` Returns whether the `https://developer.android.com/reference/androidx/media3/session/SessionCommand` is available. |
| `final void` | `https://developer.android.com/reference/androidx/media3/session/MediaController#moveMediaItem(int,int)(int currentIndex, int newIndex)` Moves the media item at the current index to the new index. |
| `final void` | `https://developer.android.com/reference/androidx/media3/session/MediaController#moveMediaItems(int,int,int)(int fromIndex, int toIndex, int newIndex)` Moves the media item range to the new index. |
| `final void` | `https://developer.android.com/reference/androidx/media3/session/MediaController#mute()()` Sets the audio volume to 0. |
| `final void` | `https://developer.android.com/reference/androidx/media3/session/MediaController#pause()()` Pauses playback. |
| `final void` | `https://developer.android.com/reference/androidx/media3/session/MediaController#play()()` Resumes playback as soon as `https://developer.android.com/reference/androidx/media3/common/Player#getPlaybackState()` == `https://developer.android.com/reference/androidx/media3/common/Player#STATE_READY()`. |
| `final void` | `https://developer.android.com/reference/androidx/media3/session/MediaController#prepare()()` Prepares the player. |
| `final void` | `https://developer.android.com/reference/androidx/media3/session/MediaController#release()()` Releases the connection between `https://developer.android.com/reference/androidx/media3/session/MediaController` and `https://developer.android.com/reference/androidx/media3/session/MediaSession`. |
| `static void` | `https://developer.android.com/reference/androidx/media3/session/MediaController#releaseFuture(java.util.concurrent.Future<? extends androidx.media3.session.MediaController>)(https://developer.android.com/reference/java/util/concurrent/Future.html<https://developer.android.com/reference/androidx/media3/session/MediaController> controllerFuture)` Releases the future controller returned by `https://developer.android.com/reference/androidx/media3/session/MediaController.Builder#buildAsync()`. |
| `final void` | `https://developer.android.com/reference/androidx/media3/session/MediaController#removeListener(androidx.media3.common.Player.Listener)(https://developer.android.com/reference/androidx/media3/common/Player.Listener listener)` Unregister a listener registered through `https://developer.android.com/reference/androidx/media3/common/Player#addListener(androidx.media3.common.Player.Listener)`. |
| `final void` | `https://developer.android.com/reference/androidx/media3/session/MediaController#removeMediaItem(int)(int index)` Removes the media item at the given index of the playlist. |
| `final void` | `https://developer.android.com/reference/androidx/media3/session/MediaController#removeMediaItems(int,int)(int fromIndex, int toIndex)` Removes a range of media items from the playlist. |
| `final void` | `https://developer.android.com/reference/androidx/media3/session/MediaController#replaceMediaItem(int,androidx.media3.common.MediaItem)(int index, https://developer.android.com/reference/androidx/media3/common/MediaItem mediaItem)` Replaces the media item at the given index of the playlist. |
| `final void` | `https://developer.android.com/reference/androidx/media3/session/MediaController#replaceMediaItems(int,int,java.util.List<androidx.media3.common.MediaItem>)( int fromIndex, int toIndex, https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/androidx/media3/common/MediaItem> mediaItems )` Replaces the media items at the given range of the playlist. |
| `final void` | `https://developer.android.com/reference/androidx/media3/session/MediaController#seekBack()()` Seeks back in the current by #getSeekBackIncrement() milliseconds. |
| `final void` | `https://developer.android.com/reference/androidx/media3/session/MediaController#seekForward()()` Seeks forward in the current by #getSeekForwardIncrement() milliseconds. |
| `final void` | `https://developer.android.com/reference/androidx/media3/session/MediaController#seekTo(long)(long positionMs)` Seeks to a position specified in milliseconds in the current `https://developer.android.com/reference/androidx/media3/common/MediaItem`. |
| `final void` | `https://developer.android.com/reference/androidx/media3/session/MediaController#seekTo(int,long)(int mediaItemIndex, long positionMs)` Seeks to a position specified in milliseconds in the specified `https://developer.android.com/reference/androidx/media3/common/MediaItem`. |
| `final void` | `https://developer.android.com/reference/androidx/media3/session/MediaController#seekToDefaultPosition()()` Seeks to the default position associated with the current `https://developer.android.com/reference/androidx/media3/common/MediaItem`. |
| `final void` | `https://developer.android.com/reference/androidx/media3/session/MediaController#seekToDefaultPosition(int)(int mediaItemIndex)` Seeks to the default position associated with the specified `https://developer.android.com/reference/androidx/media3/common/MediaItem`. |
| `final void` | `https://developer.android.com/reference/androidx/media3/session/MediaController#seekToNext()()` Seeks to a later position in the current or next (if available). |
| `final void` | `https://developer.android.com/reference/androidx/media3/session/MediaController#seekToNextMediaItem()()` Seeks to the default position of the next , which may depend on the current repeat mode and whether shuffle mode is enabled. |
| `final void` | `https://developer.android.com/reference/androidx/media3/session/MediaController#seekToPrevious()()` Seeks to an earlier position in the current or previous (if available). |
| `final void` | `https://developer.android.com/reference/androidx/media3/session/MediaController#seekToPreviousMediaItem()()` Seeks to the default position of the previous , which may depend on the current repeat mode and whether shuffle mode is enabled. |
| `final https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html<https://developer.android.com/reference/androidx/media3/session/SessionResult>` | `https://developer.android.com/reference/androidx/media3/session/MediaController#sendCustomCommand(androidx.media3.session.SessionCommand,android.os.Bundle)(https://developer.android.com/reference/androidx/media3/session/SessionCommand command, https://developer.android.com/reference/android/os/Bundle.html args)` Sends a custom command to the session. |
| `final https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html<https://developer.android.com/reference/androidx/media3/session/SessionResult>` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/session/MediaController#sendCustomCommand(androidx.media3.session.SessionCommand,android.os.Bundle,androidx.media3.session.MediaController.ProgressListener)( https://developer.android.com/reference/androidx/media3/session/SessionCommand command, https://developer.android.com/reference/android/os/Bundle.html args, @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/session/MediaController.ProgressListener progressListener )` Sends a custom command to the session. |
| `final https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html<https://developer.android.com/reference/androidx/media3/session/SessionResult>` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/session/MediaController#sendCustomCommand(androidx.media3.session.SessionCommand,androidx.media3.common.MediaItem,android.os.Bundle)( https://developer.android.com/reference/androidx/media3/session/SessionCommand command, https://developer.android.com/reference/androidx/media3/common/MediaItem mediaItem, https://developer.android.com/reference/android/os/Bundle.html args )` Sends a custom command to the session for the given `https://developer.android.com/reference/androidx/media3/common/MediaItem`. |
| `final https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html<https://developer.android.com/reference/androidx/media3/session/SessionResult>` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/session/MediaController#sendCustomCommand(androidx.media3.session.SessionCommand,androidx.media3.common.MediaItem,android.os.Bundle,androidx.media3.session.MediaController.ProgressListener)( https://developer.android.com/reference/androidx/media3/session/SessionCommand command, https://developer.android.com/reference/androidx/media3/common/MediaItem mediaItem, https://developer.android.com/reference/android/os/Bundle.html args, @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/session/MediaController.ProgressListener progressListener )` Sends a custom command to the session for the given `https://developer.android.com/reference/androidx/media3/common/MediaItem`. |
| `final void` | `https://developer.android.com/reference/androidx/media3/session/MediaController#setAudioAttributes(androidx.media3.common.AudioAttributes,boolean)( https://developer.android.com/reference/androidx/media3/common/AudioAttributes audioAttributes, boolean handleAudioFocus )` Sets the attributes for audio playback, used by the underlying audio track. |
| `final void` | `[setDeviceMuted](https://developer.android.com/reference/androidx/media3/session/MediaController#setDeviceMuted(boolean))(boolean muted)` **This method is deprecated.** Use `https://developer.android.com/reference/androidx/media3/session/MediaController#setDeviceMuted(boolean,int)` instead. <br /> |
| `final void` | `https://developer.android.com/reference/androidx/media3/session/MediaController#setDeviceMuted(boolean,int)(boolean muted, @https://developer.android.com/reference/androidx/media3/common/C.VolumeFlags int flags)` Sets the mute state of the device. |
| `final void` | `[setDeviceVolume](https://developer.android.com/reference/androidx/media3/session/MediaController#setDeviceVolume(int))(@https://developer.android.com/reference/androidx/annotation/IntRange(from = 0) int volume)` **This method is deprecated.** Use `https://developer.android.com/reference/androidx/media3/session/MediaController#setDeviceVolume(int,int)` instead. <br /> |
| `final void` | `https://developer.android.com/reference/androidx/media3/session/MediaController#setDeviceVolume(int,int)(@https://developer.android.com/reference/androidx/annotation/IntRange(from = 0) int volume, @https://developer.android.com/reference/androidx/media3/common/C.VolumeFlags int flags)` Sets the volume of the device with volume flags. |
| `final void` | `https://developer.android.com/reference/androidx/media3/session/MediaController#setMediaItem(androidx.media3.common.MediaItem)(https://developer.android.com/reference/androidx/media3/common/MediaItem mediaItem)` Clears the playlist, adds the specified `https://developer.android.com/reference/androidx/media3/common/MediaItem` and resets the position to the default position. |
| `final void` | `https://developer.android.com/reference/androidx/media3/session/MediaController#setMediaItem(androidx.media3.common.MediaItem,boolean)(https://developer.android.com/reference/androidx/media3/common/MediaItem mediaItem, boolean resetPosition)` Clears the playlist and adds the specified `https://developer.android.com/reference/androidx/media3/common/MediaItem`. |
| `final void` | `https://developer.android.com/reference/androidx/media3/session/MediaController#setMediaItem(androidx.media3.common.MediaItem,long)(https://developer.android.com/reference/androidx/media3/common/MediaItem mediaItem, long startPositionMs)` Clears the playlist and adds the specified `https://developer.android.com/reference/androidx/media3/common/MediaItem`. |
| `final void` | `https://developer.android.com/reference/androidx/media3/session/MediaController#setMediaItems(java.util.List<androidx.media3.common.MediaItem>)(https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/androidx/media3/common/MediaItem> mediaItems)` Clears the playlist, adds the specified `https://developer.android.com/reference/androidx/media3/common/MediaItem` and resets the position to the default position. |
| `final void` | `https://developer.android.com/reference/androidx/media3/session/MediaController#setMediaItems(java.util.List<androidx.media3.common.MediaItem>,boolean)(https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/androidx/media3/common/MediaItem> mediaItems, boolean resetPosition)` Clears the playlist and adds the specified `https://developer.android.com/reference/androidx/media3/common/MediaItem`. |
| `final void` | `https://developer.android.com/reference/androidx/media3/session/MediaController#setMediaItems(java.util.List<androidx.media3.common.MediaItem>,int,long)( https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/androidx/media3/common/MediaItem> mediaItems, int startIndex, long startPositionMs )` Clears the playlist and adds the specified `https://developer.android.com/reference/androidx/media3/common/MediaItem`. |
| `final void` | `https://developer.android.com/reference/androidx/media3/session/MediaController#setPlayWhenReady(boolean)(boolean playWhenReady)` Sets whether playback should proceed when `https://developer.android.com/reference/androidx/media3/common/Player#getPlaybackState()` == `https://developer.android.com/reference/androidx/media3/common/Player#STATE_READY()`. |
| `final void` | `https://developer.android.com/reference/androidx/media3/session/MediaController#setPlaybackParameters(androidx.media3.common.PlaybackParameters)(https://developer.android.com/reference/androidx/media3/common/PlaybackParameters playbackParameters)` Attempts to set the playback parameters. |
| `final void` | `https://developer.android.com/reference/androidx/media3/session/MediaController#setPlaybackSpeed(float)(float speed)` Changes the rate at which playback occurs. |
| `final void` | `https://developer.android.com/reference/androidx/media3/session/MediaController#setPlaylistMetadata(androidx.media3.common.MediaMetadata)(https://developer.android.com/reference/androidx/media3/common/MediaMetadata playlistMetadata)` Sets the playlist . |
| `final https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html<https://developer.android.com/reference/androidx/media3/session/SessionResult>` | `https://developer.android.com/reference/androidx/media3/session/MediaController#setRating(androidx.media3.common.Rating)(https://developer.android.com/reference/androidx/media3/common/Rating rating)` Requests that the connected `https://developer.android.com/reference/androidx/media3/session/MediaSession` rates the current media item. |
| `final https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html<https://developer.android.com/reference/androidx/media3/session/SessionResult>` | `https://developer.android.com/reference/androidx/media3/session/MediaController#setRating(java.lang.String,androidx.media3.common.Rating)(https://developer.android.com/reference/java/lang/String.html mediaId, https://developer.android.com/reference/androidx/media3/common/Rating rating)` Requests that the connected `https://developer.android.com/reference/androidx/media3/session/MediaSession` rates the media. |
| `final void` | `https://developer.android.com/reference/androidx/media3/session/MediaController#setRepeatMode(int)(@https://developer.android.com/reference/androidx/media3/common/Player.RepeatMode int repeatMode)` Sets the `https://developer.android.com/reference/androidx/media3/common/Player.RepeatMode` to be used for playback. |
| `final void` | `https://developer.android.com/reference/androidx/media3/session/MediaController#setShuffleModeEnabled(boolean)(boolean shuffleModeEnabled)` Sets whether shuffling of media items is enabled. |
| `final void` | `https://developer.android.com/reference/androidx/media3/session/MediaController#setTrackSelectionParameters(androidx.media3.common.TrackSelectionParameters)(https://developer.android.com/reference/androidx/media3/common/TrackSelectionParameters parameters)` Sets the parameters constraining the track selection. |
| `final void` | `https://developer.android.com/reference/androidx/media3/session/MediaController#setVideoSurface(android.view.Surface)(@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/android/view/Surface.html surface)` Sets the onto which video will be rendered. |
| `final void` | `https://developer.android.com/reference/androidx/media3/session/MediaController#setVideoSurfaceHolder(android.view.SurfaceHolder)(@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/android/view/SurfaceHolder.html surfaceHolder)` Sets the that holds the onto which video will be rendered. |
| `final void` | `https://developer.android.com/reference/androidx/media3/session/MediaController#setVideoSurfaceView(android.view.SurfaceView)(@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/android/view/SurfaceView.html surfaceView)` Sets the onto which video will be rendered. |
| `final void` | `https://developer.android.com/reference/androidx/media3/session/MediaController#setVideoTextureView(android.view.TextureView)(@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/android/view/TextureView.html textureView)` Sets the onto which video will be rendered. |
| `final void` | `https://developer.android.com/reference/androidx/media3/session/MediaController#setVolume(float)(@https://developer.android.com/reference/androidx/annotation/FloatRange(from = 0, to = 1) float volume)` Sets the audio volume, valid values are between 0 (silence) and 1 (unity gain, signal unchanged), inclusive. |
| `final void` | `https://developer.android.com/reference/androidx/media3/session/MediaController#stop()()` Stops playback without resetting the playlist. |
| `final void` | `https://developer.android.com/reference/androidx/media3/session/MediaController#unmute()()` If the audio volume is 0, sets the audio volume to a non-zero value decided by the Player to be the most appropriate. |

### Inherited Constants

From [androidx.media3.common.Player](https://developer.android.com/reference/androidx/media3/common/Player) `static final int` `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_ADJUST_DEVICE_VOLUME() = 26`

**This field is deprecated.**

Use `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_ADJUST_DEVICE_VOLUME_WITH_FLAGS()` instead.

<br />

`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_ADJUST_DEVICE_VOLUME_WITH_FLAGS() = 34`

Command to increase and decrease the device volume and mute it with volume flags.
`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_CHANGE_MEDIA_ITEMS() = 20`

Command to change the `https://developer.android.com/reference/androidx/media3/common/MediaItem` in the playlist.
`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_GET_AUDIO_ATTRIBUTES() = 21`

Command to get the player current `https://developer.android.com/reference/androidx/media3/common/AudioAttributes`.
`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_GET_CURRENT_MEDIA_ITEM() = 16`

Command to get information about the currently playing `https://developer.android.com/reference/androidx/media3/common/MediaItem`.
`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_GET_DEVICE_VOLUME() = 23`

Command to get the device volume and whether it is muted.
`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_GET_MEDIA_ITEMS_METADATA() = 18`

**This field is deprecated.**

Use `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_GET_METADATA()` instead.

<br />

`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_GET_METADATA() = 18`

Command to get metadata related to the playlist and current `https://developer.android.com/reference/androidx/media3/common/MediaItem`.
`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_GET_TEXT() = 28`

Command to get the text that should currently be displayed by the player.
`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_GET_TIMELINE() = 17`

Command to get the information about the current timeline.
`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_GET_TRACKS() = 30`

Command to get details of the current track selection.
`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_GET_VOLUME() = 22`

Command to get the player volume.
`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_INVALID() = -1`

Represents an invalid `https://developer.android.com/reference/androidx/media3/common/Player.Command`.
`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_PLAY_PAUSE() = 1`

Command to start, pause or resume playback.
`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_PREPARE() = 2`

Command to prepare the player.
`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_RELEASE() = 32`

Command to release the player.
`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_SEEK_BACK() = 11`

Command to seek back by a fixed increment inside the current `https://developer.android.com/reference/androidx/media3/common/MediaItem`.
`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_SEEK_FORWARD() = 12`

Command to seek forward by a fixed increment inside the current `https://developer.android.com/reference/androidx/media3/common/MediaItem`.
`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_SEEK_IN_CURRENT_MEDIA_ITEM() = 5`

Command to seek anywhere inside the current `https://developer.android.com/reference/androidx/media3/common/MediaItem`.
`static final int` `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi
https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_SEEK_IN_CURRENT_WINDOW() = 5`

**This field is deprecated.**

Use `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_SEEK_IN_CURRENT_MEDIA_ITEM()` instead.

<br />

`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_SEEK_TO_DEFAULT_POSITION() = 4`

Command to seek to the default position of the current `https://developer.android.com/reference/androidx/media3/common/MediaItem`.
`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_SEEK_TO_MEDIA_ITEM() = 10`

Command to seek anywhere in any `https://developer.android.com/reference/androidx/media3/common/MediaItem`.
`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_SEEK_TO_NEXT() = 9`

Command to seek to a later position in the current `https://developer.android.com/reference/androidx/media3/common/MediaItem` or the default position of the next `https://developer.android.com/reference/androidx/media3/common/MediaItem`.
`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_SEEK_TO_NEXT_MEDIA_ITEM() = 8`

Command to seek to the default position of the next `https://developer.android.com/reference/androidx/media3/common/MediaItem`.
`static final int` `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi
https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_SEEK_TO_NEXT_WINDOW() = 8`

**This field is deprecated.**

Use `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_SEEK_TO_NEXT_MEDIA_ITEM()` instead.

<br />

`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_SEEK_TO_PREVIOUS() = 7`

Command to seek to an earlier position in the current `https://developer.android.com/reference/androidx/media3/common/MediaItem` or the default position of the previous `https://developer.android.com/reference/androidx/media3/common/MediaItem`.
`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM() = 6`

Command to seek to the default position of the previous `https://developer.android.com/reference/androidx/media3/common/MediaItem`.
`static final int` `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi
https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_SEEK_TO_PREVIOUS_WINDOW() = 6`

**This field is deprecated.**

Use `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM()` instead.

<br />

`static final int` `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi
https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_SEEK_TO_WINDOW() = 10`

**This field is deprecated.**

Use `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_SEEK_TO_MEDIA_ITEM()` instead.

<br />

`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_SET_AUDIO_ATTRIBUTES() = 35`

Command to set the player's audio attributes.
`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_SET_DEVICE_VOLUME() = 25`

**This field is deprecated.**

Use `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_SET_DEVICE_VOLUME_WITH_FLAGS()` instead.

<br />

`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_SET_DEVICE_VOLUME_WITH_FLAGS() = 33`

Command to set the device volume with volume flags.
`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_SET_MEDIA_ITEM() = 31`

Command to set a `https://developer.android.com/reference/androidx/media3/common/MediaItem`.
`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_SET_MEDIA_ITEMS_METADATA() = 19`

**This field is deprecated.**

Use `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_SET_PLAYLIST_METADATA()` instead.

<br />

`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_SET_PLAYLIST_METADATA() = 19`

Command to set the playlist metadata.
`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_SET_REPEAT_MODE() = 15`

Command to set the repeat mode.
`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_SET_SHUFFLE_MODE() = 14`

Command to enable shuffling.
`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_SET_SPEED_AND_PITCH() = 13`

Command to set the playback speed and pitch.
`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_SET_TRACK_SELECTION_PARAMETERS() = 29`

Command to set the player's track selection parameters.
`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_SET_VIDEO_SURFACE() = 27`

Command to set and clear the surface on which to render the video.
`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_SET_VOLUME() = 24`

Command to set the player volume.
`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_STOP() = 3`

Command to stop playback.
`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#DISCONTINUITY_REASON_AUTO_TRANSITION() = 0`

Automatic playback transition from one period in the timeline to the next.
`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#DISCONTINUITY_REASON_INTERNAL() = 5`

Discontinuity introduced internally (e.g. by the source).
`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#DISCONTINUITY_REASON_REMOVE() = 4`

Discontinuity caused by the removal of the current period from the `https://developer.android.com/reference/androidx/media3/common/Timeline`.
`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#DISCONTINUITY_REASON_SEEK() = 1`

Seek within the current period or to another period.
`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#DISCONTINUITY_REASON_SEEK_ADJUSTMENT() = 2`

Seek adjustment due to being unable to seek to the requested position or because the seek was permitted to be inexact.
`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#DISCONTINUITY_REASON_SILENCE_SKIP() = 6`

Discontinuity introduced by a skipped silence.
`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#DISCONTINUITY_REASON_SKIP() = 3`

Discontinuity introduced by a skipped period (for instance a skipped ad).
`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#EVENT_AUDIO_ATTRIBUTES_CHANGED() = 20`

`https://developer.android.com/reference/androidx/media3/common/Player#getAudioAttributes()` changed.
`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#EVENT_AUDIO_SESSION_ID() = 21`

The audio session id was set.
`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#EVENT_AVAILABLE_COMMANDS_CHANGED() = 13`

`https://developer.android.com/reference/androidx/media3/common/Player#isCommandAvailable(int)` changed for at least one `https://developer.android.com/reference/androidx/media3/common/Player.Command`.
`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#EVENT_CUES() = 27`

`https://developer.android.com/reference/androidx/media3/common/Player#getCurrentCues()` changed.
`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#EVENT_DEVICE_INFO_CHANGED() = 29`

`https://developer.android.com/reference/androidx/media3/common/Player#getDeviceInfo()` changed.
`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#EVENT_DEVICE_VOLUME_CHANGED() = 30`

`https://developer.android.com/reference/androidx/media3/common/Player#getDeviceVolume()` or `https://developer.android.com/reference/androidx/media3/common/Player#isDeviceMuted()` changed.
`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#EVENT_IS_LOADING_CHANGED() = 3`

`https://developer.android.com/reference/androidx/media3/common/Player#isLoading()` ()} changed.
`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#EVENT_IS_PLAYING_CHANGED() = 7`

`https://developer.android.com/reference/androidx/media3/common/Player#isPlaying()` changed.
`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#EVENT_MAX_SEEK_TO_PREVIOUS_POSITION_CHANGED() = 18`

`https://developer.android.com/reference/androidx/media3/common/Player#getMaxSeekToPreviousPosition()` changed.
`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#EVENT_MEDIA_ITEM_TRANSITION() = 1`

`https://developer.android.com/reference/androidx/media3/common/Player#getCurrentMediaItem()` changed or the player started repeating the current item.
`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#EVENT_MEDIA_METADATA_CHANGED() = 14`

`https://developer.android.com/reference/androidx/media3/common/Player#getMediaMetadata()` changed.
`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#EVENT_METADATA() = 28`

Metadata associated with the current playback time changed.
`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#EVENT_PLAYBACK_PARAMETERS_CHANGED() = 12`

`https://developer.android.com/reference/androidx/media3/common/Player#getPlaybackParameters()` changed.
`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#EVENT_PLAYBACK_STATE_CHANGED() = 4`

`https://developer.android.com/reference/androidx/media3/common/Player#getPlaybackState()` changed.
`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#EVENT_PLAYBACK_SUPPRESSION_REASON_CHANGED() = 6`

`https://developer.android.com/reference/androidx/media3/common/Player#getPlaybackSuppressionReason()` changed.
`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#EVENT_PLAYER_ERROR() = 10`

`https://developer.android.com/reference/androidx/media3/common/Player#getPlayerError()` changed.
`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#EVENT_PLAYLIST_METADATA_CHANGED() = 15`

`https://developer.android.com/reference/androidx/media3/common/Player#getPlaylistMetadata()` changed.
`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#EVENT_PLAY_WHEN_READY_CHANGED() = 5`

`https://developer.android.com/reference/androidx/media3/common/Player#getPlayWhenReady()` changed.
`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#EVENT_POSITION_DISCONTINUITY() = 11`

A position discontinuity occurred.
`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#EVENT_RENDERED_FIRST_FRAME() = 26`

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.
`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#EVENT_REPEAT_MODE_CHANGED() = 8`

`https://developer.android.com/reference/androidx/media3/common/Player#getRepeatMode()` changed.
`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#EVENT_SEEK_BACK_INCREMENT_CHANGED() = 16`

`https://developer.android.com/reference/androidx/media3/common/Player#getSeekBackIncrement()` changed.
`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#EVENT_SEEK_FORWARD_INCREMENT_CHANGED() = 17`

`https://developer.android.com/reference/androidx/media3/common/Player#getSeekForwardIncrement()` changed.
`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#EVENT_SHUFFLE_MODE_ENABLED_CHANGED() = 9`

`https://developer.android.com/reference/androidx/media3/common/Player#getShuffleModeEnabled()` changed.
`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#EVENT_SKIP_SILENCE_ENABLED_CHANGED() = 23`

Skipping silences in the audio stream is enabled or disabled.
`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#EVENT_SURFACE_SIZE_CHANGED() = 24`

The size of the surface onto which the video is being rendered changed.
`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#EVENT_TIMELINE_CHANGED() = 0`

`https://developer.android.com/reference/androidx/media3/common/Player#getCurrentTimeline()` changed.
`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#EVENT_TRACKS_CHANGED() = 2`

`https://developer.android.com/reference/androidx/media3/common/Player#getCurrentTracks()` changed.
`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#EVENT_TRACK_SELECTION_PARAMETERS_CHANGED() = 19`

`https://developer.android.com/reference/androidx/media3/common/Player#getTrackSelectionParameters()` changed.
`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#EVENT_VIDEO_SIZE_CHANGED() = 25`

`https://developer.android.com/reference/androidx/media3/common/Player#getVideoSize()` changed.
`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#EVENT_VOLUME_CHANGED() = 22`

`https://developer.android.com/reference/androidx/media3/common/Player#getVolume()` changed.
`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#MEDIA_ITEM_TRANSITION_REASON_AUTO() = 1`

Playback has automatically transitioned to the next media item.
`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#MEDIA_ITEM_TRANSITION_REASON_PLAYLIST_CHANGED() = 3`

The current media item has changed because of a change in the playlist.
`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#MEDIA_ITEM_TRANSITION_REASON_REPEAT() = 0`

The media item has been repeated.
`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#MEDIA_ITEM_TRANSITION_REASON_SEEK() = 2`

A seek to another media item has occurred.
`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#PLAYBACK_SUPPRESSION_REASON_NONE() = 0`

Playback is not suppressed.
`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#PLAYBACK_SUPPRESSION_REASON_SCRUBBING() = 4`

Playback is suppressed because the player is currently scrubbing.
`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#PLAYBACK_SUPPRESSION_REASON_TRANSIENT_AUDIO_FOCUS_LOSS() = 1`

Playback is suppressed due to transient audio focus loss.
`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#PLAYBACK_SUPPRESSION_REASON_UNSUITABLE_AUDIO_OUTPUT() = 3`

Playback is suppressed due to attempt to play on an unsuitable audio output (e.g. attempt to play on built-in speaker on a Wear OS device).
`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#PLAYBACK_SUPPRESSION_REASON_UNSUITABLE_AUDIO_ROUTE() = 2`

**This field is deprecated.**

Use `https://developer.android.com/reference/androidx/media3/common/Player#PLAYBACK_SUPPRESSION_REASON_UNSUITABLE_AUDIO_OUTPUT()` instead.

<br />

`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#PLAY_WHEN_READY_CHANGE_REASON_AUDIO_BECOMING_NOISY() = 3`

Playback has been paused to avoid becoming noisy.
`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#PLAY_WHEN_READY_CHANGE_REASON_AUDIO_FOCUS_LOSS() = 2`

Playback has been paused because of a loss of audio focus.
`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#PLAY_WHEN_READY_CHANGE_REASON_END_OF_MEDIA_ITEM() = 5`

Playback has been paused at the end of a media item.
`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#PLAY_WHEN_READY_CHANGE_REASON_REMOTE() = 4`

Playback has been started or paused because of a remote change.
`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#PLAY_WHEN_READY_CHANGE_REASON_SUPPRESSED_TOO_LONG() = 6`

Playback has been paused because playback has been `https://developer.android.com/reference/androidx/media3/common/Player#getPlaybackSuppressionReason()` too long.
`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#PLAY_WHEN_READY_CHANGE_REASON_USER_REQUEST() = 1`

Playback has been started or paused by a call to `https://developer.android.com/reference/androidx/media3/common/Player#setPlayWhenReady(boolean)`.
`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#REPEAT_MODE_ALL() = 2`

Repeats the entire timeline infinitely.
`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#REPEAT_MODE_OFF() = 0`

Normal playback without repetition.
`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#REPEAT_MODE_ONE() = 1`

Repeats the currently playing `https://developer.android.com/reference/androidx/media3/common/MediaItem` infinitely during ongoing playback.
`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#STATE_BUFFERING() = 2`

The player is not able to immediately play the media, but is doing work toward being able to do so.
`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#STATE_ENDED() = 4`

The player has finished playing the media.
`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#STATE_IDLE() = 1`

The player is idle, meaning it holds only limited resources.
`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#STATE_READY() = 3`

The player is able to immediately play from its current position.
`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED() = 0`

Timeline changed as a result of a change of the playlist items or the order of the items.
`static final int` `https://developer.android.com/reference/androidx/media3/common/Player#TIMELINE_CHANGE_REASON_SOURCE_UPDATE() = 1`

Timeline changed as a result of a source update (e.g. result of a dynamic update by the played media).

## Constants

### DEFAULT_PLATFORM_CALLBACK_AGGREGATION_TIMEOUT_MS

```
@UnstableApi
protected static final long DEFAULT_PLATFORM_CALLBACK_AGGREGATION_TIMEOUT_MS = 100
```

### KEY_MEDIA_NOTIFICATION_CONTROLLER_FLAG

```
@UnstableApi
public static final String KEY_MEDIA_NOTIFICATION_CONTROLLER_FLAG = "androidx.media3.session.MediaNotificationManager"
```

Key to mark the connection hints of the media notification controller.

For a controller to be `https://developer.android.com/reference/androidx/media3/session/MediaSession#isMediaNotificationController(androidx.media3.session.MediaSession.ControllerInfo)`, this key needs to be used to `https://developer.android.com/reference/android/os/BaseBundle.html#putBoolean(java.lang.String, boolean)` in the connection hints to true. Only an internal controller that has the same package name as the session can be used as a media notification controller.

When using a session within a `https://developer.android.com/reference/androidx/media3/session/MediaSessionService` or `https://developer.android.com/reference/androidx/media3/session/MediaLibraryService`, the service connects a media notification controller automatically. Apps can do this for standalone session to configure the platform session in the same way.

### RELEASE_UNBIND_TIMEOUT_MS

```
@UnstableApi
public static final long RELEASE_UNBIND_TIMEOUT_MS = 30000
```

The timeout for handling pending commands after calling `https://developer.android.com/reference/androidx/media3/session/MediaController#release()`. If the timeout is reached, the controller is unbound from the session service even if commands are still pending.

## Public methods

### addListener

```
public final void addListener(Player.Listener listener)
```

Registers a listener to receive all events from the player.

The listener's methods will be called on the thread associated with `https://developer.android.com/reference/androidx/media3/common/Player#getApplicationLooper()`.

This method can be called from any thread.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/Player.Listener listener` | The listener to register. |

### addMediaItem

```
public final void addMediaItem(MediaItem mediaItem)
```

Adds a media item to the end of the playlist.

This method must only be called if `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_CHANGE_MEDIA_ITEMS()` is `https://developer.android.com/reference/androidx/media3/common/Player#getAvailableCommands()`.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/MediaItem mediaItem` | The `https://developer.android.com/reference/androidx/media3/common/MediaItem` to add. |

### addMediaItem

```
public final void addMediaItem(int index, MediaItem mediaItem)
```

Adds a media item at the given index of the playlist.

This method must only be called if `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_CHANGE_MEDIA_ITEMS()` is `https://developer.android.com/reference/androidx/media3/common/Player#getAvailableCommands()`.

| Parameters |
|---|---|
| `int index` | The index at which to add the media item. If the index is larger than the size of the playlist, the media item is added to the end of the playlist. |
| `https://developer.android.com/reference/androidx/media3/common/MediaItem mediaItem` | The `https://developer.android.com/reference/androidx/media3/common/MediaItem` to add. |

### addMediaItems

```
public final void addMediaItems(List<MediaItem> mediaItems)
```

Adds a list of media items to the end of the playlist.

This method must only be called if `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_CHANGE_MEDIA_ITEMS()` is `https://developer.android.com/reference/androidx/media3/common/Player#getAvailableCommands()`.

| Parameters |
|---|---|
| `https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/androidx/media3/common/MediaItem> mediaItems` | The `https://developer.android.com/reference/androidx/media3/common/MediaItem` to add. |

### addMediaItems

```
public final void addMediaItems(int index, List<MediaItem> mediaItems)
```

Adds a list of media items at the given index of the playlist.

This method must only be called if `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_CHANGE_MEDIA_ITEMS()` is `https://developer.android.com/reference/androidx/media3/common/Player#getAvailableCommands()`.

| Parameters |
|---|---|
| `int index` | The index at which to add the media items. If the index is larger than the size of the playlist, the media items are added to the end of the playlist. |
| `https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/androidx/media3/common/MediaItem> mediaItems` | The `https://developer.android.com/reference/androidx/media3/common/MediaItem` to add. |

### canAdvertiseSession

```
public final boolean canAdvertiseSession()
```

Returns whether the player can be used to advertise a media session.

The MediaController returns `false`.

### clearMediaItems

```
public final void clearMediaItems()
```

Clears the playlist.

This method must only be called if `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_CHANGE_MEDIA_ITEMS()` is `https://developer.android.com/reference/androidx/media3/common/Player#getAvailableCommands()`.

### clearVideoSurface

```
public final void clearVideoSurface()
```

Clears any , , or currently set on the player.

This method must only be called if #COMMAND_SET_VIDEO_SURFACE is \* #getAvailableCommands() available.

Interoperability: When connected to `
android.support.v4.media.session.MediaSessionCompat`, video surfaces are not supported and calls to this method are ignored.

### clearVideoSurface

```
public final void clearVideoSurface(@Nullable Surface surface)
```

Clears the onto which video is being rendered if it matches the one passed. Else does nothing.

This method must only be called if #COMMAND_SET_VIDEO_SURFACE is \* #getAvailableCommands() available.

Interoperability: When connected to `
android.support.v4.media.session.MediaSessionCompat`, video surfaces are not supported and calls to this method are ignored.

### clearVideoSurfaceHolder

```
public final void clearVideoSurfaceHolder(@Nullable SurfaceHolder surfaceHolder)
```

Clears the that holds the onto which video is being rendered if it matches the one passed. Else does nothing.

This method must only be called if #COMMAND_SET_VIDEO_SURFACE is \* #getAvailableCommands() available.

Interoperability: When connected to `
android.support.v4.media.session.MediaSessionCompat`, video surfaces are not supported and calls to this method are ignored.

### clearVideoSurfaceView

```
public final void clearVideoSurfaceView(@Nullable SurfaceView surfaceView)
```

Clears the onto which video is being rendered if it matches the one passed. Else does nothing.

This method must only be called if #COMMAND_SET_VIDEO_SURFACE is \* #getAvailableCommands() available.

Interoperability: When connected to `
android.support.v4.media.session.MediaSessionCompat`, video surfaces are not supported and calls to this method are ignored.

### clearVideoTextureView

```
public final void clearVideoTextureView(@Nullable TextureView textureView)
```

Clears the onto which video is being rendered if it matches the one passed. Else does nothing.

This method must only be called if #COMMAND_SET_VIDEO_SURFACE is \* #getAvailableCommands() available.

Interoperability: When connected to `
android.support.v4.media.session.MediaSessionCompat`, video surfaces are not supported and calls to this method are ignored.

### decreaseDeviceVolume

```
public final void [decreaseDeviceVolume](https://developer.android.com/reference/androidx/media3/session/MediaController#decreaseDeviceVolume())()
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/androidx/media3/session/MediaController#decreaseDeviceVolume(int)` instead.

### decreaseDeviceVolume

```
public final void decreaseDeviceVolume(@C.VolumeFlags int flags)
```

Decreases the volume of the device.

The `https://developer.android.com/reference/androidx/media3/common/Player#getDeviceVolume()` device volume cannot be decreased below `https://developer.android.com/reference/androidx/media3/common/DeviceInfo#minVolume()`.

Note that this method affects the device volume. To change the volume of the current stream only, use `https://developer.android.com/reference/androidx/media3/common/Player#setVolume(float)`.

This method must only be called if `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_ADJUST_DEVICE_VOLUME_WITH_FLAGS()` is `https://developer.android.com/reference/androidx/media3/common/Player#getAvailableCommands()`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/media3/common/C.VolumeFlags int flags` | Either 0 or a bitwise combination of one or more `https://developer.android.com/reference/androidx/media3/common/C.VolumeFlags`. |

### getApplicationLooper

```
public final Looper getApplicationLooper()
```

Returns the `https://developer.android.com/reference/android/os/Looper.html` associated with the application thread that's used to access the player and on which player events are received.

This method can be called from any thread.

### getAudioAttributes

```
public final AudioAttributes getAudioAttributes()
```

Returns the attributes for audio playback.

This method must only be called if `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_GET_AUDIO_ATTRIBUTES()` is `https://developer.android.com/reference/androidx/media3/common/Player#getAvailableCommands()`.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/Player.Listener#onAudioAttributesChanged(androidx.media3.common.AudioAttributes)` |   |

### getAudioSessionId

```
@UnstableApi
public final int getAudioSessionId()
```

Returns the audio session identifier, or `https://developer.android.com/reference/androidx/media3/common/C#AUDIO_SESSION_ID_UNSET()` if not set.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/Player.Listener#onAudioSessionIdChanged(int)` |   |

### getAvailableCommands

```
public final Player.Commands getAvailableCommands()
```

Returns the player's currently available `https://developer.android.com/reference/androidx/media3/common/Player.Commands`.

The returned `https://developer.android.com/reference/androidx/media3/common/Player.Commands` are not updated when available commands change. Use `https://developer.android.com/reference/androidx/media3/common/Player.Listener#onAvailableCommandsChanged(androidx.media3.common.Player.Commands)` to get an update when the available commands change.

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

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/Player.Listener#onAvailableCommandsChanged(androidx.media3.common.Player.Commands)` |   |

### getAvailableSessionCommands

```
public final SessionCommands getAvailableSessionCommands()
```

Returns the current available session commands from `https://developer.android.com/reference/androidx/media3/session/MediaController.Listener#onAvailableSessionCommandsChanged(androidx.media3.session.MediaController,androidx.media3.session.SessionCommands)`, or `https://developer.android.com/reference/androidx/media3/session/SessionCommands#EMPTY()` if it is not connected.

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/media3/session/SessionCommands` | The available session commands. |

### getBufferedPercentage

```
public final @IntRange(from = 0, to = 100) int getBufferedPercentage()
```

Returns an estimate of the percentage in the current content or ad up to which data is buffered, or 0 if no estimate is available.

### getBufferedPosition

```
public final long getBufferedPosition()
```

Returns an estimate of the position in the current content or ad up to which data is buffered, in milliseconds.

This method must only be called if `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_GET_CURRENT_MEDIA_ITEM()` is `https://developer.android.com/reference/androidx/media3/common/Player#getAvailableCommands()`.

### getCommandButtonsForMediaItem

```
@UnstableApi
public final ImmutableList<CommandButton> getCommandButtonsForMediaItem(MediaItem mediaItem)
```

Returns the command buttons that are supported for the given `https://developer.android.com/reference/androidx/media3/common/MediaItem`.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/MediaItem mediaItem` | The media item for which to get command buttons. |

| Returns |
|---|---|
| `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/collect/ImmutableList.html<https://developer.android.com/reference/androidx/media3/session/CommandButton>` | The `https://developer.android.com/reference/androidx/media3/session/CommandButton` that are supported for the given media item. |

### getConnectedToken

```
public final @Nullable SessionToken getConnectedToken()
```

Returns the `https://developer.android.com/reference/androidx/media3/session/SessionToken` of the connected session, or `null` if it is not connected.

This may differ from the `https://developer.android.com/reference/androidx/media3/session/SessionToken` from the constructor. For example, if the controller is created with the token for `https://developer.android.com/reference/androidx/media3/session/MediaSessionService`, this will return a token for the `https://developer.android.com/reference/androidx/media3/session/MediaSession` in the service.

### getContentBufferedPosition

```
public final long getContentBufferedPosition()
```

If #isPlayingAd() returns true}, returns an estimate of the content position in the current content up to which data is buffered, in milliseconds. If there is no ad playing, the returned position is the same as that returned by #getBufferedPosition().

This method must only be called if #COMMAND_GET_CURRENT_MEDIA_ITEM is \* #getAvailableCommands() available.

Interoperability: When connected to `
android.support.v4.media.session.MediaSessionCompat`, it's the same as `https://developer.android.com/reference/androidx/media3/session/MediaController#getBufferedPosition()` because content buffered position isn't available.

### getContentDuration

```
public final long getContentDuration()
```

If #isPlayingAd() returns true}, returns the duration of the current content in milliseconds, or C#TIME_UNSET if the duration is not known. If there is no ad playing, the returned duration is the same as that returned by #getDuration().

This method must only be called if #COMMAND_GET_CURRENT_MEDIA_ITEM is \* #getAvailableCommands() available.

Interoperability: When connected to `
android.support.v4.media.session.MediaSessionCompat`, it's the same as `https://developer.android.com/reference/androidx/media3/session/MediaController#getDuration()` to match the behavior with `https://developer.android.com/reference/androidx/media3/session/MediaController#getContentPosition()` and `https://developer.android.com/reference/androidx/media3/session/MediaController#getContentBufferedPosition()`.

### getContentPosition

```
public final long getContentPosition()
```

If #isPlayingAd() returns true}, returns the content position that will be played once all ads in the ad group have finished playing, in milliseconds. If there is no ad playing, the returned position is the same as that returned by #getCurrentPosition().

This method must only be called if #COMMAND_GET_CURRENT_MEDIA_ITEM is \* #getAvailableCommands() available.

Interoperability: When connected to `
android.support.v4.media.session.MediaSessionCompat`, it's the same as `https://developer.android.com/reference/androidx/media3/session/MediaController#getCurrentPosition()` because content position isn't available.

### getCurrentAdGroupIndex

```
public final int getCurrentAdGroupIndex()
```

If #isPlayingAd() returns true, returns the index of the ad group in the period currently being played. Returns C#INDEX_UNSET otherwise.

This method must only be called if #COMMAND_GET_CURRENT_MEDIA_ITEM is \* #getAvailableCommands() available.

Interoperability: When connected to `
android.support.v4.media.session.MediaSessionCompat`, ad playback is not supported and this method always returns `https://developer.android.com/reference/androidx/media3/common/C#INDEX_UNSET()`.

### getCurrentAdIndexInAdGroup

```
public final int getCurrentAdIndexInAdGroup()
```

If #isPlayingAd() returns true, returns the index of the ad in its ad group. Returns C#INDEX_UNSET otherwise.

This method must only be called if #COMMAND_GET_CURRENT_MEDIA_ITEM is \* #getAvailableCommands() available.

Interoperability: When connected to `
android.support.v4.media.session.MediaSessionCompat`, ad playback is not supported and this method always returns `https://developer.android.com/reference/androidx/media3/common/C#INDEX_UNSET()`.

### getCurrentCues

```
public final CueGroup getCurrentCues()
```

Returns the current .

This method must only be called if #COMMAND_GET_TEXT is \* #getAvailableCommands() available.

Interoperability: When connected to `
android.support.v4.media.session.MediaSessionCompat`, text cues are not supported and this method returns `https://developer.android.com/reference/androidx/media3/common/text/CueGroup#EMPTY_TIME_ZERO()`.

### getCurrentLiveOffset

```
public final long getCurrentLiveOffset()
```

Returns the offset of the current playback position from the live edge in milliseconds, or `https://developer.android.com/reference/androidx/media3/common/C#TIME_UNSET()` if the current `https://developer.android.com/reference/androidx/media3/common/MediaItem``https://developer.android.com/reference/androidx/media3/common/Player#isCurrentMediaItemLive()` or the offset is unknown.

The offset is calculated as `currentTime - playbackPosition`, so should usually be positive.

Note that this offset may rely on an accurate local time, so this method may return an incorrect value if the difference between system clock and server clock is unknown.

This method must only be called if `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_GET_CURRENT_MEDIA_ITEM()` is `https://developer.android.com/reference/androidx/media3/common/Player#getAvailableCommands()`.

### getCurrentManifest

```
@UnstableApi
public final @Nullable Object getCurrentManifest()
```

Returns `null`.

### getCurrentMediaItem

```
public final @Nullable MediaItem getCurrentMediaItem()
```

Returns the currently playing `https://developer.android.com/reference/androidx/media3/common/MediaItem`. May be null if the timeline is empty.

This method must only be called if `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_GET_CURRENT_MEDIA_ITEM()` is `https://developer.android.com/reference/androidx/media3/common/Player#getAvailableCommands()`.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/Player.Listener#onMediaItemTransition(androidx.media3.common.MediaItem,int)` |   |

### getCurrentMediaItemIndex

```
public final int getCurrentMediaItemIndex()
```

Returns the index of the current `https://developer.android.com/reference/androidx/media3/common/MediaItem` in the `https://developer.android.com/reference/androidx/media3/common/Player#getCurrentTimeline()`, or the prospective index if the `https://developer.android.com/reference/androidx/media3/common/Player#getCurrentTimeline()` is empty.

This method must only be called if `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_GET_TIMELINE()` is `https://developer.android.com/reference/androidx/media3/common/Player#getAvailableCommands()`.

### getCurrentPeriodIndex

```
public final int getCurrentPeriodIndex()
```

Returns the index of the period currently being played.

This method must only be called if `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_GET_TIMELINE()` is `https://developer.android.com/reference/androidx/media3/common/Player#getAvailableCommands()`.

### getCurrentPosition

```
public final long getCurrentPosition()
```

Returns the playback position in the current content or ad, in milliseconds, or the prospective position in milliseconds if the `https://developer.android.com/reference/androidx/media3/common/Player#getCurrentTimeline()` is empty.

This method must only be called if `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_GET_CURRENT_MEDIA_ITEM()` is `https://developer.android.com/reference/androidx/media3/common/Player#getAvailableCommands()`.

### getCurrentTimeline

```
public final Timeline getCurrentTimeline()
```

Returns the current . Never null, but may be empty.

This method must only be called if #COMMAND_GET_TIMELINE is \* #getAvailableCommands() available.

### getCurrentTracks

```
public final Tracks getCurrentTracks()
```

Returns the current tracks.

This method must only be called if #COMMAND_GET_TRACKS is \* #getAvailableCommands() available.

Interoperability: When connected to `
android.support.v4.media.session.MediaSessionCompat`, tracks are not supported and this method returns `https://developer.android.com/reference/androidx/media3/common/Tracks#EMPTY()`.

### getCurrentWindowIndex

```
@UnstableApi
public final int [getCurrentWindowIndex](https://developer.android.com/reference/androidx/media3/session/MediaController#getCurrentWindowIndex())()
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/androidx/media3/session/MediaController#getCurrentMediaItemIndex()` instead.

### getCustomLayout

```
public final ImmutableList<CommandButton> getCustomLayout()
```

Returns the custom layout.

This method will be deprecated, prefer to use `https://developer.android.com/reference/androidx/media3/session/MediaController#getMediaButtonPreferences()` instead. Note that the media button preferences use `https://developer.android.com/reference/androidx/media3/session/CommandButton#slots()` to define the allowed button placement.

After being connected, a change of the custom layout is reported with `https://developer.android.com/reference/androidx/media3/session/MediaController.Listener#onCustomLayoutChanged(androidx.media3.session.MediaController,java.util.List<androidx.media3.session.CommandButton>)`.

Note that the `https://developer.android.com/reference/androidx/media3/session/CommandButton#isEnabled()` flag is set to `false` if the available commands do not allow to use a button.

| Returns |
|---|---|
| `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/collect/ImmutableList.html<https://developer.android.com/reference/androidx/media3/session/CommandButton>` | The custom layout. |

### getDeviceInfo

```
public final DeviceInfo getDeviceInfo()
```

Gets the device information.

### getDeviceVolume

```
public final @IntRange(from = 0) int getDeviceVolume()
```

Gets the current volume of the device.

For devices with `https://developer.android.com/reference/androidx/media3/common/DeviceInfo#PLAYBACK_TYPE_LOCAL()`, the volume returned by this method varies according to the current `https://developer.android.com/reference/androidx/media3/common/C.StreamType`. The stream type is determined by `https://developer.android.com/reference/androidx/media3/common/AudioAttributes#getStreamType()`.

For devices with `https://developer.android.com/reference/androidx/media3/common/DeviceInfo#PLAYBACK_TYPE_REMOTE()`, the volume of the remote device is returned.

Note that this method returns the volume of the device. To check the current stream volume, use `https://developer.android.com/reference/androidx/media3/common/Player#getVolume()`.

This method must only be called if `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_GET_DEVICE_VOLUME()` is `https://developer.android.com/reference/androidx/media3/common/Player#getAvailableCommands()`.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/Player.Listener#onDeviceVolumeChanged(int,boolean)` |   |

### getDuration

```
public final long getDuration()
```

Returns the duration of the current content or ad in milliseconds, or `https://developer.android.com/reference/androidx/media3/common/C#TIME_UNSET()` if the duration is not known.

This method must only be called if `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_GET_CURRENT_MEDIA_ITEM()` is `https://developer.android.com/reference/androidx/media3/common/Player#getAvailableCommands()`.

### getMaxSeekToPreviousPosition

```
public final long getMaxSeekToPreviousPosition()
```

Returns the maximum position for which #seekToPrevious() seeks to the previous \* , in milliseconds.

Interoperability: When connected to `
android.support.v4.media.session.MediaSessionCompat`, it always returns `0`.

### getMediaButtonPreferences

```
@UnstableApi
public final ImmutableList<CommandButton> getMediaButtonPreferences()
```

Returns the media button preferences.

After being connected, a change of the media button preferences is reported with `https://developer.android.com/reference/androidx/media3/session/MediaController.Listener#onMediaButtonPreferencesChanged(androidx.media3.session.MediaController,java.util.List<androidx.media3.session.CommandButton>)`.

Note that the `https://developer.android.com/reference/androidx/media3/session/CommandButton#isEnabled()` flag is set to `false` if the available commands do not allow to use a button.

| Returns |
|---|---|
| `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/collect/ImmutableList.html<https://developer.android.com/reference/androidx/media3/session/CommandButton>` | The media button preferences. |

### getMediaItemAt

```
public final MediaItem getMediaItemAt(int index)
```

Returns the `https://developer.android.com/reference/androidx/media3/common/MediaItem` at the given index.

This method must only be called if `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_GET_TIMELINE()` is `https://developer.android.com/reference/androidx/media3/common/Player#getAvailableCommands()`.

### getMediaItemCount

```
public final int getMediaItemCount()
```

Returns the number of `https://developer.android.com/reference/androidx/media3/common/MediaItem` in the playlist.

This method must only be called if `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_GET_TIMELINE()` is `https://developer.android.com/reference/androidx/media3/common/Player#getAvailableCommands()`.

### getMediaMetadata

```
public final MediaMetadata getMediaMetadata()
```

Returns the current combined `https://developer.android.com/reference/androidx/media3/common/MediaMetadata`, or `https://developer.android.com/reference/androidx/media3/common/MediaMetadata#EMPTY()` if not supported.

This `https://developer.android.com/reference/androidx/media3/common/MediaMetadata` is a combination of the `https://developer.android.com/reference/androidx/media3/common/MediaItem#mediaMetadata()`, the static metadata in the media's `https://developer.android.com/reference/androidx/media3/common/Format#metadata()`, and any timed metadata that has been parsed from the media and output via `https://developer.android.com/reference/androidx/media3/common/Player.Listener#onMetadata(androidx.media3.common.Metadata)`. If a field is populated in the `https://developer.android.com/reference/androidx/media3/common/MediaItem#mediaMetadata()`, it will be prioritised above the same field coming from static or timed metadata.

This method must only be called if `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_GET_METADATA()` is `https://developer.android.com/reference/androidx/media3/common/Player#getAvailableCommands()`.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/Player.Listener#onMediaMetadataChanged(androidx.media3.common.MediaMetadata)` |   |

### getNextMediaItemIndex

```
public final int getNextMediaItemIndex()
```

Returns the index of the that will be played if \* #seekToNextMediaItem() is called, which may depend on the current repeat mode and whether shuffle mode is enabled. Returns C#INDEX_UNSET if #hasNextMediaItem() is \*false.

Note: When the repeat mode is #REPEAT_MODE_ONE, this method behaves the same as when the current repeat mode is #REPEAT_MODE_OFF. See #REPEAT_MODE_ONE for more details.

This method must only be called if #COMMAND_GET_TIMELINE is \* #getAvailableCommands() available.

Interoperability: When connected to `
android.support.v4.media.session.MediaSessionCompat`, this will always return `https://developer.android.com/reference/androidx/media3/common/C#INDEX_UNSET()` even when `https://developer.android.com/reference/androidx/media3/session/MediaController#hasNextMediaItem()` is `true`.

### getNextWindowIndex

```
@UnstableApi
public final int [getNextWindowIndex](https://developer.android.com/reference/androidx/media3/session/MediaController#getNextWindowIndex())()
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/androidx/media3/session/MediaController#getNextMediaItemIndex()` instead.

### getPlayWhenReady

```
public final boolean getPlayWhenReady()
```

Whether playback will proceed when `https://developer.android.com/reference/androidx/media3/common/Player#getPlaybackState()` == `https://developer.android.com/reference/androidx/media3/common/Player#STATE_READY()`.

| Returns |
|---|---|
| `boolean` | Whether playback will proceed when ready. |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/Player.Listener#onPlayWhenReadyChanged(boolean,int)` |   |

### getPlaybackParameters

```
public final PlaybackParameters getPlaybackParameters()
```

Returns the currently active playback parameters.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/Player.Listener#onPlaybackParametersChanged(androidx.media3.common.PlaybackParameters)` |   |

### getPlaybackState

```
@Player.State
public final int getPlaybackState()
```

Returns the current `https://developer.android.com/reference/androidx/media3/common/Player.State` of the player.

| Returns |
|---|---|
| `int` | The current `https://developer.android.com/reference/androidx/media3/common/Player.State`. |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/Player.Listener#onPlaybackStateChanged(int)` |   |

### getPlaybackSuppressionReason

```
@Player.PlaybackSuppressionReason
public final int getPlaybackSuppressionReason()
```

Returns the reason why playback is suppressed even though #getPlayWhenReady() is \*true, or #PLAYBACK_SUPPRESSION_REASON_NONE if playback is not suppressed.

Interoperability: When connected to `
android.support.v4.media.session.MediaSessionCompat`, playback suppression reasons are not supported and this method always returns `https://developer.android.com/reference/androidx/media3/common/Player#PLAYBACK_SUPPRESSION_REASON_NONE()`.

### getPlayerError

```
public final @Nullable PlaybackException getPlayerError()
```

Returns the error that caused playback to fail. This is the same error that will have been reported via `https://developer.android.com/reference/androidx/media3/common/Player.Listener#onPlayerError(androidx.media3.common.PlaybackException)` at the time of failure. It can be queried using this method until the player is re-prepared.

Note that this method will always return `null` if `https://developer.android.com/reference/androidx/media3/common/Player#getPlaybackState()` is not `https://developer.android.com/reference/androidx/media3/common/Player#STATE_IDLE()`.

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/common/PlaybackException` | The error, or `null`. |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/Player.Listener#onPlayerError(androidx.media3.common.PlaybackException)` |   |

### getPlaylistMetadata

```
public final MediaMetadata getPlaylistMetadata()
```

Returns the playlist `https://developer.android.com/reference/androidx/media3/common/MediaMetadata`, as set by `https://developer.android.com/reference/androidx/media3/common/Player#setPlaylistMetadata(androidx.media3.common.MediaMetadata)`, or `https://developer.android.com/reference/androidx/media3/common/MediaMetadata#EMPTY()` if not supported.

This method must only be called if `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_GET_METADATA()` is `https://developer.android.com/reference/androidx/media3/common/Player#getAvailableCommands()`.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/Player.Listener#onPlaylistMetadataChanged(androidx.media3.common.MediaMetadata)` |   |

### getPreviousMediaItemIndex

```
public final int getPreviousMediaItemIndex()
```

Returns the index of the that will be played if \* #seekToPreviousMediaItem() is called, which may depend on the current repeat mode and whether shuffle mode is enabled. Returns C#INDEX_UNSET if #hasPreviousMediaItem() is false}.

Note: When the repeat mode is #REPEAT_MODE_ONE, this method behaves the same as when the current repeat mode is #REPEAT_MODE_OFF. See #REPEAT_MODE_ONE for more details.

This method must only be called if #COMMAND_GET_TIMELINE is \* #getAvailableCommands() available.

Interoperability: When connected to `
android.support.v4.media.session.MediaSessionCompat`, this will always return `https://developer.android.com/reference/androidx/media3/common/C#INDEX_UNSET()` even when `https://developer.android.com/reference/androidx/media3/session/MediaController#hasPreviousMediaItem()` is `true`.

### getPreviousWindowIndex

```
@UnstableApi
public final int [getPreviousWindowIndex](https://developer.android.com/reference/androidx/media3/session/MediaController#getPreviousWindowIndex())()
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/androidx/media3/session/MediaController#getPreviousMediaItemIndex()` instead.

### getRepeatMode

```
@Player.RepeatMode
public final int getRepeatMode()
```

Returns the current `https://developer.android.com/reference/androidx/media3/common/Player.RepeatMode` used for playback.

| Returns |
|---|---|
| `int` | The current repeat mode. |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/Player.Listener#onRepeatModeChanged(int)` |   |

### getSeekBackIncrement

```
public final long getSeekBackIncrement()
```

Returns the #seekBack() increment.

Interoperability: When connected to `
android.support.v4.media.session.MediaSessionCompat`, it returns `0`.

### getSeekForwardIncrement

```
public final long getSeekForwardIncrement()
```

Returns the #seekForward() increment.

Interoperability: When connected to `
android.support.v4.media.session.MediaSessionCompat`, it returns `0`.

### getSessionActivity

```
public final @Nullable PendingIntent getSessionActivity()
```

Returns an intent for launching UI associated with the session if exists, or `null`.

### getSessionExtras

```
public final Bundle getSessionExtras()
```

Returns the session extras.

After being connected, `https://developer.android.com/reference/androidx/media3/session/MediaController.Listener#onExtrasChanged(androidx.media3.session.MediaController,android.os.Bundle)` is called when the extras on the session are set.

| Returns |
|---|---|
| `https://developer.android.com/reference/android/os/Bundle.html` | The session extras. |

### getShuffleModeEnabled

```
public final boolean getShuffleModeEnabled()
```

Returns whether shuffling of media items is enabled.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/Player.Listener#onShuffleModeEnabledChanged(boolean)` |   |

### getSurfaceSize

```
@UnstableApi
public final Size getSurfaceSize()
```

Gets the size of the surface on which the video is rendered.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/Player.Listener#onSurfaceSizeChanged(int,int)` |   |

### getTotalBufferedDuration

```
public final long getTotalBufferedDuration()
```

Returns an estimate of the total buffered duration from the current position, in milliseconds. This includes pre-buffered data for subsequent ads and `https://developer.android.com/reference/androidx/media3/common/MediaItem`.

This method must only be called if `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_GET_CURRENT_MEDIA_ITEM()` is `https://developer.android.com/reference/androidx/media3/common/Player#getAvailableCommands()`.

### getTrackSelectionParameters

```
public final TrackSelectionParameters getTrackSelectionParameters()
```

Returns the parameters constraining the track selection.

Interoperability: When connected to `
android.support.v4.media.session.MediaSessionCompat`, track selection parameters are not supported and this method returns `https://developer.android.com/reference/androidx/media3/common/TrackSelectionParameters#DEFAULT()`.

### getVideoSize

```
public final VideoSize getVideoSize()
```

Gets the size of the video.

The video's width and height are `0` if there is `https://developer.android.com/reference/androidx/media3/common/Tracks#isTypeSupported(int)` or its size has not been determined yet.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/Player.Listener#onVideoSizeChanged(androidx.media3.common.VideoSize)` |   |

### getVolume

```
public final @FloatRange(from = 0, to = 1) float getVolume()
```

Returns the audio volume, with 0 being silence and 1 being unity gain (signal unchanged).

This method must only be called if #COMMAND_GET_VOLUME is \* #getAvailableCommands() available.

Interoperability: When connected to `
android.support.v4.media.session.MediaSessionCompat`, player volume is not supported and this method returns `1.0f`. Remote device volume is accessible via `https://developer.android.com/reference/androidx/media3/session/MediaController#getDeviceVolume()`.

### hasNextMediaItem

```
public final boolean hasNextMediaItem()
```

Returns whether a next `https://developer.android.com/reference/androidx/media3/common/MediaItem` exists, which may depend on the current repeat mode and whether shuffle mode is enabled.

Note: When the repeat mode is `https://developer.android.com/reference/androidx/media3/common/Player#REPEAT_MODE_ONE()`, this method behaves the same as when the current repeat mode is `https://developer.android.com/reference/androidx/media3/common/Player#REPEAT_MODE_OFF()`. See `https://developer.android.com/reference/androidx/media3/common/Player#REPEAT_MODE_ONE()` for more details.

This method must only be called if `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_GET_TIMELINE()` is `https://developer.android.com/reference/androidx/media3/common/Player#getAvailableCommands()`.

### hasPreviousMediaItem

```
public final boolean hasPreviousMediaItem()
```

Returns whether a previous media item exists, which may depend on the current repeat mode and whether shuffle mode is enabled.

Note: When the repeat mode is `https://developer.android.com/reference/androidx/media3/common/Player#REPEAT_MODE_ONE()`, this method behaves the same as when the current repeat mode is `https://developer.android.com/reference/androidx/media3/common/Player#REPEAT_MODE_OFF()`. See `https://developer.android.com/reference/androidx/media3/common/Player#REPEAT_MODE_ONE()` for more details.

This method must only be called if `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_GET_TIMELINE()` is `https://developer.android.com/reference/androidx/media3/common/Player#getAvailableCommands()`.

### increaseDeviceVolume

```
public final void [increaseDeviceVolume](https://developer.android.com/reference/androidx/media3/session/MediaController#increaseDeviceVolume())()
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/androidx/media3/session/MediaController#increaseDeviceVolume(int)` instead.

### increaseDeviceVolume

```
public final void increaseDeviceVolume(@C.VolumeFlags int flags)
```

Increases the volume of the device.

The `https://developer.android.com/reference/androidx/media3/common/Player#getDeviceVolume()` device volume cannot be increased above `https://developer.android.com/reference/androidx/media3/common/DeviceInfo#maxVolume()`, if defined.

Note that this method affects the device volume. To change the volume of the current stream only, use `https://developer.android.com/reference/androidx/media3/common/Player#setVolume(float)`.

This method must only be called if `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_ADJUST_DEVICE_VOLUME_WITH_FLAGS()` is `https://developer.android.com/reference/androidx/media3/common/Player#getAvailableCommands()`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/media3/common/C.VolumeFlags int flags` | Either 0 or a bitwise combination of one or more `https://developer.android.com/reference/androidx/media3/common/C.VolumeFlags`. |

### isCommandAvailable

```
public final boolean isCommandAvailable(@Player.Command int command)
```

Returns whether the provided `https://developer.android.com/reference/androidx/media3/common/Player.Command` is available.

This method does not execute the command.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/media3/common/Player.Command int command` | A `https://developer.android.com/reference/androidx/media3/common/Player.Command`. |

| Returns |
|---|---|
| `boolean` | Whether the `https://developer.android.com/reference/androidx/media3/common/Player.Command` is available. |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/Player.Listener#onAvailableCommandsChanged(androidx.media3.common.Player.Commands)` |   |

### isConnected

```
public final boolean isConnected()
```

Returns whether this controller is connected to a `https://developer.android.com/reference/androidx/media3/session/MediaSession` or not.

### isCurrentMediaItemDynamic

```
public final boolean isCurrentMediaItemDynamic()
```

Returns whether the current `https://developer.android.com/reference/androidx/media3/common/MediaItem` is dynamic (may change when the `https://developer.android.com/reference/androidx/media3/common/Timeline` is updated), or `false` if the `https://developer.android.com/reference/androidx/media3/common/Timeline` is empty.

This method must only be called if `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_GET_CURRENT_MEDIA_ITEM()` is `https://developer.android.com/reference/androidx/media3/common/Player#getAvailableCommands()`.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/Timeline.Window#isDynamic()` |   |

### isCurrentMediaItemLive

```
public final boolean isCurrentMediaItemLive()
```

Returns whether the current `https://developer.android.com/reference/androidx/media3/common/MediaItem` is live, or `false` if the `https://developer.android.com/reference/androidx/media3/common/Timeline` is empty.

This method must only be called if `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_GET_CURRENT_MEDIA_ITEM()` is `https://developer.android.com/reference/androidx/media3/common/Player#getAvailableCommands()`.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/Timeline.Window#isLive()` |   |

### isCurrentMediaItemSeekable

```
public final boolean isCurrentMediaItemSeekable()
```

Returns whether the current `https://developer.android.com/reference/androidx/media3/common/MediaItem` is seekable, or `false` if the `https://developer.android.com/reference/androidx/media3/common/Timeline` is empty.

This method must only be called if `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_GET_CURRENT_MEDIA_ITEM()` is `https://developer.android.com/reference/androidx/media3/common/Player#getAvailableCommands()`.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/Timeline.Window#isSeekable()` |   |

### isCurrentWindowDynamic

```
@UnstableApi
public final boolean [isCurrentWindowDynamic](https://developer.android.com/reference/androidx/media3/session/MediaController#isCurrentWindowDynamic())()
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/androidx/media3/session/MediaController#isCurrentMediaItemDynamic()` instead.

### isCurrentWindowLive

```
@UnstableApi
public final boolean [isCurrentWindowLive](https://developer.android.com/reference/androidx/media3/session/MediaController#isCurrentWindowLive())()
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/androidx/media3/session/MediaController#isCurrentMediaItemLive()` instead.

### isCurrentWindowSeekable

```
@UnstableApi
public final boolean [isCurrentWindowSeekable](https://developer.android.com/reference/androidx/media3/session/MediaController#isCurrentWindowSeekable())()
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/androidx/media3/session/MediaController#isCurrentMediaItemSeekable()` instead.

### isDeviceMuted

```
public final boolean isDeviceMuted()
```

Gets whether the device is muted or not.

Note that this method returns the mute state of the device. To check if the current stream is muted, use `getVolume() == 0`.

This method must only be called if `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_GET_DEVICE_VOLUME()` is `https://developer.android.com/reference/androidx/media3/common/Player#getAvailableCommands()`.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/Player.Listener#onDeviceVolumeChanged(int,boolean)` |   |

### isLoading

```
public final boolean isLoading()
```

Whether the player is currently loading the source.

| Returns |
|---|---|
| `boolean` | Whether the player is currently loading the source. |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/Player.Listener#onIsLoadingChanged(boolean)` |   |

### isPlaying

```
public final boolean isPlaying()
```

Returns whether the player is playing, i.e. `https://developer.android.com/reference/androidx/media3/common/Player#getCurrentPosition()` is advancing.

If `false`, then at least one of the following is true:

- The `https://developer.android.com/reference/androidx/media3/common/Player#getPlaybackState()` is not `https://developer.android.com/reference/androidx/media3/common/Player#STATE_READY()`.
- There is no `https://developer.android.com/reference/androidx/media3/common/Player#getPlayWhenReady()`.
- Playback is `https://developer.android.com/reference/androidx/media3/common/Player#getPlaybackSuppressionReason()`.

| Returns |
|---|---|
| `boolean` | Whether the player is playing. |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/Player.Listener#onIsPlayingChanged(boolean)` |   |

### isPlayingAd

```
public final boolean isPlayingAd()
```

Returns whether the player is currently playing an ad.

This method must only be called if `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_GET_CURRENT_MEDIA_ITEM()` is `https://developer.android.com/reference/androidx/media3/common/Player#getAvailableCommands()`.

### isSessionCommandAvailable

```
public final boolean isSessionCommandAvailable(
    @SessionCommand.CommandCode int sessionCommandCode
)
```

Returns whether the `https://developer.android.com/reference/androidx/media3/session/SessionCommand.CommandCode` is available. The `
sessionCommandCode` must not be `https://developer.android.com/reference/androidx/media3/session/SessionCommand#COMMAND_CODE_CUSTOM()`. Use `https://developer.android.com/reference/androidx/media3/session/MediaController#isSessionCommandAvailable(androidx.media3.session.SessionCommand)` for custom commands.

### isSessionCommandAvailable

```
public final boolean isSessionCommandAvailable(SessionCommand sessionCommand)
```

Returns whether the `https://developer.android.com/reference/androidx/media3/session/SessionCommand` is available.

### moveMediaItem

```
public final void moveMediaItem(int currentIndex, int newIndex)
```

Moves the media item at the current index to the new index.

This method must only be called if `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_CHANGE_MEDIA_ITEMS()` is `https://developer.android.com/reference/androidx/media3/common/Player#getAvailableCommands()`.

| Parameters |
|---|---|
| `int currentIndex` | The current index of the media item to move. If the index is larger than the size of the playlist, the request is ignored. |
| `int newIndex` | The new index of the media item. If the new index is larger than the size of the playlist the item is moved to the end of the playlist. |

### moveMediaItems

```
public final void moveMediaItems(int fromIndex, int toIndex, int newIndex)
```

Moves the media item range to the new index.

This method must only be called if `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_CHANGE_MEDIA_ITEMS()` is `https://developer.android.com/reference/androidx/media3/common/Player#getAvailableCommands()`.

| Parameters |
|---|---|
| `int fromIndex` | The start of the range to move. If the index is larger than the size of the playlist, the request is ignored. |
| `int toIndex` | The first item not to be included in the range (exclusive). If the index is larger than the size of the playlist, items up to the end of the playlist are moved. |
| `int newIndex` | The new index of the first media item of the range. If the new index is larger than the size of the remaining playlist after removing the range, the range is moved to the end of the playlist. |

### mute

```
public final void mute()
```

Sets the audio volume to 0.

This method must only be called if #COMMAND_SET_VOLUME is \* #getAvailableCommands() available.

Interoperability: When connected to `
android.support.v4.media.session.MediaSessionCompat`, muting the player is not supported and calls to this method are ignored. Remote device volume can be muted via `https://developer.android.com/reference/androidx/media3/session/MediaController#setDeviceMuted(boolean)`.

### pause

```
public final void pause()
```

Pauses playback. Equivalent to `https://developer.android.com/reference/androidx/media3/common/Player#setPlayWhenReady(boolean)`.

This method must only be called if `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_PLAY_PAUSE()` is `https://developer.android.com/reference/androidx/media3/common/Player#getAvailableCommands()`.

### play

```
public final void play()
```

Resumes playback as soon as `https://developer.android.com/reference/androidx/media3/common/Player#getPlaybackState()` == `https://developer.android.com/reference/androidx/media3/common/Player#STATE_READY()`. Equivalent to `https://developer.android.com/reference/androidx/media3/common/Player#setPlayWhenReady(boolean)`.

This method must only be called if `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_PLAY_PAUSE()` is `https://developer.android.com/reference/androidx/media3/common/Player#getAvailableCommands()`.

### prepare

```
public final void prepare()
```

Prepares the player.

This method must only be called if `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_PREPARE()` is `https://developer.android.com/reference/androidx/media3/common/Player#getAvailableCommands()`.

This will move the player out of `https://developer.android.com/reference/androidx/media3/common/Player#STATE_IDLE()` and the player will start loading media and acquire resources needed for playback.

### release

```
public final void release()
```

Releases the connection between `https://developer.android.com/reference/androidx/media3/session/MediaController` and `https://developer.android.com/reference/androidx/media3/session/MediaSession`. This method must be called when the controller is no longer required. The controller must not be used after calling this method.

This method does not call `https://developer.android.com/reference/androidx/media3/common/Player#release()` of the underlying player in the session.

### releaseFuture

```
public static void releaseFuture(Future<MediaController> controllerFuture)
```

Releases the future controller returned by `https://developer.android.com/reference/androidx/media3/session/MediaController.Builder#buildAsync()`. It makes sure that the controller is released by canceling the future if the future is not yet done.

Must be called on the `https://developer.android.com/reference/androidx/media3/session/MediaController#getApplicationLooper()` of the media controller.

### removeListener

```
public final void removeListener(Player.Listener listener)
```

Unregister a listener registered through `https://developer.android.com/reference/androidx/media3/common/Player#addListener(androidx.media3.common.Player.Listener)`. The listener will no longer receive events.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/Player.Listener listener` | The listener to unregister. |

### removeMediaItem

```
public final void removeMediaItem(int index)
```

Removes the media item at the given index of the playlist.

This method must only be called if `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_CHANGE_MEDIA_ITEMS()` is `https://developer.android.com/reference/androidx/media3/common/Player#getAvailableCommands()`.

| Parameters |
|---|---|
| `int index` | The index at which to remove the media item. If the index is larger than the size of the playlist, the request is ignored. |

### removeMediaItems

```
public final void removeMediaItems(int fromIndex, int toIndex)
```

Removes a range of media items from the playlist.

This method must only be called if `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_CHANGE_MEDIA_ITEMS()` is `https://developer.android.com/reference/androidx/media3/common/Player#getAvailableCommands()`.

| Parameters |
|---|---|
| `int fromIndex` | The index at which to start removing media items. If the index is larger than the size of the playlist, the request is ignored. |
| `int toIndex` | The index of the first item to be kept (exclusive). If the index is larger than the size of the playlist, media items up to the end of the playlist are removed. |

### replaceMediaItem

```
public final void replaceMediaItem(int index, MediaItem mediaItem)
```

Replaces the media item at the given index of the playlist.

Implementations of this method may attempt to seamlessly continue playback if the currently playing media item is replaced with a compatible one (e.g. same URL, only metadata has changed).

This method must only be called if `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_CHANGE_MEDIA_ITEMS()` is `https://developer.android.com/reference/androidx/media3/common/Player#getAvailableCommands()`.

| Parameters |
|---|---|
| `int index` | The index at which to replace the media item. If the index is larger than the size of the playlist, the request is ignored. |
| `https://developer.android.com/reference/androidx/media3/common/MediaItem mediaItem` | The new `https://developer.android.com/reference/androidx/media3/common/MediaItem`. |

### replaceMediaItems

```
public final void replaceMediaItems(
    int fromIndex,
    int toIndex,
    List<MediaItem> mediaItems
)
```

Replaces the media items at the given range of the playlist.

Implementations of this method may attempt to seamlessly continue playback if the currently playing media item is replaced with a compatible one (e.g. same URL, only metadata has changed).

This method must only be called if `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_CHANGE_MEDIA_ITEMS()` is `https://developer.android.com/reference/androidx/media3/common/Player#getAvailableCommands()`.

Note that it is possible to replace a range with an arbitrary number of new items, so that the number of removed items defined by `fromIndex` and `toIndex` does not have to match the number of added items defined by `mediaItems`. As result, it may also change the index of subsequent items not touched by this operation.

| Parameters |
|---|---|
| `int fromIndex` | The start of the range. If the index is larger than the size of the playlist, the request is ignored. |
| `int toIndex` | The first item not to be included in the range (exclusive). If the index is larger than the size of the playlist, items up to the end of the playlist are replaced. |
| `https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/androidx/media3/common/MediaItem> mediaItems` | The `https://developer.android.com/reference/androidx/media3/common/MediaItem` to replace the range with. |

### seekBack

```
public final void seekBack()
```

Seeks back in the current by #getSeekBackIncrement() milliseconds.

This method must only be called if #COMMAND_SEEK_BACK is \* #getAvailableCommands() available.

Interoperability: When connected to `
android.support.v4.media.session.MediaSessionCompat`, it calls `
android.support.v4.media.session.MediaControllerCompat.TransportControls.rewind()`.

### seekForward

```
public final void seekForward()
```

Seeks forward in the current by #getSeekForwardIncrement() milliseconds.

This method must only be called if #COMMAND_SEEK_FORWARD is \* #getAvailableCommands() available.

Interoperability: When connected to `
android.support.v4.media.session.MediaSessionCompat`, it calls `
android.support.v4.media.session.MediaControllerCompat.TransportControls.fastForward()`.

### seekTo

```
public final void seekTo(long positionMs)
```

Seeks to a position specified in milliseconds in the current `https://developer.android.com/reference/androidx/media3/common/MediaItem`.

This method must only be called if `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_SEEK_IN_CURRENT_MEDIA_ITEM()` is `https://developer.android.com/reference/androidx/media3/common/Player#getAvailableCommands()`.

| Parameters |
|---|---|
| `long positionMs` | The seek position in the current `https://developer.android.com/reference/androidx/media3/common/MediaItem`, or `https://developer.android.com/reference/androidx/media3/common/C#TIME_UNSET()` to seek to the media item's default position. |

### seekTo

```
public final void seekTo(int mediaItemIndex, long positionMs)
```

Seeks to a position specified in milliseconds in the specified `https://developer.android.com/reference/androidx/media3/common/MediaItem`.

This method must only be called if `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_SEEK_TO_MEDIA_ITEM()` is `https://developer.android.com/reference/androidx/media3/common/Player#getAvailableCommands()`.

| Parameters |
|---|---|
| `int mediaItemIndex` | The index of the `https://developer.android.com/reference/androidx/media3/common/MediaItem`. If the index is larger than the size of the playlist, the request is ignored. |
| `long positionMs` | The seek position in the specified `https://developer.android.com/reference/androidx/media3/common/MediaItem`, or `https://developer.android.com/reference/androidx/media3/common/C#TIME_UNSET()` to seek to the media item's default position. |

### seekToDefaultPosition

```
public final void seekToDefaultPosition()
```

Seeks to the default position associated with the current `https://developer.android.com/reference/androidx/media3/common/MediaItem`. The position can depend on the type of media being played. For live streams it will typically be the live edge. For other streams it will typically be the start.

This method must only be called if `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_SEEK_TO_DEFAULT_POSITION()` is `https://developer.android.com/reference/androidx/media3/common/Player#getAvailableCommands()`.

### seekToDefaultPosition

```
public final void seekToDefaultPosition(int mediaItemIndex)
```

Seeks to the default position associated with the specified `https://developer.android.com/reference/androidx/media3/common/MediaItem`. The position can depend on the type of media being played. For live streams it will typically be the live edge. For other streams it will typically be the start.

This method must only be called if `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_SEEK_TO_MEDIA_ITEM()` is `https://developer.android.com/reference/androidx/media3/common/Player#getAvailableCommands()`.

| Parameters |
|---|---|
| `int mediaItemIndex` | The index of the `https://developer.android.com/reference/androidx/media3/common/MediaItem` whose associated default position should be seeked to. If the index is larger than the size of the playlist, the request is ignored. |

### seekToNext

```
public final void seekToNext()
```

Seeks to a later position in the current or next (if available). More precisely:

- If the timeline is empty or seeking is not possible, does nothing.
- Otherwise, if #hasNextMediaItem() a next media item exists, seeks to the default position of the next .
- Otherwise, if the current is #isCurrentMediaItemLive() live and has not ended, seeks to the live edge of the current .
- Otherwise, does nothing.

This method must only be called if #COMMAND_SEEK_TO_NEXT is \* #getAvailableCommands() available.

Interoperability: When connected to `
android.support.v4.media.session.MediaSessionCompat`, it won't update the current media item index immediately because the previous media item index is unknown.

### seekToNextMediaItem

```
public final void seekToNextMediaItem()
```

Seeks to the default position of the next , which may depend on the current repeat mode and whether shuffle mode is enabled. Does nothing if #hasNextMediaItem() is false}.

Note: When the repeat mode is #REPEAT_MODE_ONE, this method behaves the same as when the current repeat mode is #REPEAT_MODE_OFF. See #REPEAT_MODE_ONE for more details.

This method must only be called if #COMMAND_SEEK_TO_NEXT_MEDIA_ITEM is \* #getAvailableCommands() available.

Interoperability: When connected to `
android.support.v4.media.session.MediaSessionCompat`, it's the same as `https://developer.android.com/reference/androidx/media3/session/MediaController#seekToNext()`.

### seekToPrevious

```
public final void seekToPrevious()
```

Seeks to an earlier position in the current or previous (if available). More precisely:

- If the timeline is empty or seeking is not possible, does nothing.
- Otherwise, if the current is #isCurrentMediaItemLive() live and #isCurrentMediaItemSeekable() unseekable, then:
  - If #hasPreviousMediaItem() a previous media item exists, seeks to the default position of the previous media item.
  - Otherwise, does nothing.
- Otherwise, if #hasPreviousMediaItem() a previous media item exists and the #getCurrentPosition() current position is less than \* #getMaxSeekToPreviousPosition(), seeks to the default position of the previous \* .
- Otherwise, seeks to 0 in the current .

This method must only be called if #COMMAND_SEEK_TO_PREVIOUS is \* #getAvailableCommands() available.

Interoperability: When connected to `
android.support.v4.media.session.MediaSessionCompat`, it won't update the current media item index immediately because the previous media item index is unknown.

### seekToPreviousMediaItem

```
public final void seekToPreviousMediaItem()
```

Seeks to the default position of the previous , which may depend on the current repeat mode and whether shuffle mode is enabled. Does nothing if \* #hasPreviousMediaItem() is false}.

Note: When the repeat mode is #REPEAT_MODE_ONE, this method behaves the same as when the current repeat mode is #REPEAT_MODE_OFF. See #REPEAT_MODE_ONE for more details.

This method must only be called if #COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM is #getAvailableCommands() available.

Interoperability: When connected to `
android.support.v4.media.session.MediaSessionCompat`, it's the same as `https://developer.android.com/reference/androidx/media3/session/MediaController#seekToPrevious()`.

### sendCustomCommand

```
public final ListenableFuture<SessionResult> sendCustomCommand(SessionCommand command, Bundle args)
```

Sends a custom command to the session.

A command is not accepted if it is not a custom command or the command is not in the list of `https://developer.android.com/reference/androidx/media3/session/MediaController#getAvailableSessionCommands()`.

Interoperability: When sending a custom command to `
android.support.v4.media.session.MediaSessionCompat`, `https://developer.android.com/reference/androidx/media3/session/SessionResult#resultCode()` will always be `https://developer.android.com/reference/androidx/media3/session/SessionResult#RESULT_SUCCESS()` because the session has no way to send a result back from `
android.support.v4.media.session.MediaSessionCompat.Callback#onCustomAction(String, Bundle)`.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/session/SessionCommand command` | The custom command. |
| `https://developer.android.com/reference/android/os/Bundle.html args` | The additional arguments. May be empty. |

| Returns |
|---|---|
| `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html<https://developer.android.com/reference/androidx/media3/session/SessionResult>` | A `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html` of `https://developer.android.com/reference/androidx/media3/session/SessionResult` representing the pending completion. |

### sendCustomCommand

```
@UnstableApi
public final ListenableFuture<SessionResult> sendCustomCommand(
    SessionCommand command,
    Bundle args,
    @Nullable MediaController.ProgressListener progressListener
)
```

Sends a custom command to the session.

A controller can request progress updates by passing in a non-null `https://developer.android.com/reference/androidx/media3/session/MediaController.ProgressListener`. Whether or not the session sends progress updates depends on the implementation of the session callback that responds to the given `https://developer.android.com/reference/androidx/media3/session/SessionCommand`.

Interoperability: When sending a custom command to `
android.support.v4.media.session.MediaSessionCompat`, `https://developer.android.com/reference/androidx/media3/session/SessionResult#resultCode()` will always be `https://developer.android.com/reference/androidx/media3/session/SessionResult#RESULT_SUCCESS()` because the session has no way to send a result back from `
android.support.v4.media.session.MediaSessionCompat.Callback#onCustomAction(String, Bundle)`, and `progressListener` is ignored.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/session/SessionCommand command` | The custom command. |
| `https://developer.android.com/reference/android/os/Bundle.html args` | The additional arguments. May be empty. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/session/MediaController.ProgressListener progressListener` | A `https://developer.android.com/reference/androidx/media3/session/MediaController.ProgressListener` to receive progress updates. May be null. |

| Returns |
|---|---|
| `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html<https://developer.android.com/reference/androidx/media3/session/SessionResult>` | A `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html` of `https://developer.android.com/reference/androidx/media3/session/SessionResult` representing the pending completion. |

### sendCustomCommand

```
@UnstableApi
public final ListenableFuture<SessionResult> sendCustomCommand(
    SessionCommand command,
    MediaItem mediaItem,
    Bundle args
)
```

Sends a custom command to the session for the given `https://developer.android.com/reference/androidx/media3/common/MediaItem`.

Calling this method is equivalent to calling `https://developer.android.com/reference/androidx/media3/session/MediaController#sendCustomCommand(androidx.media3.session.SessionCommand,android.os.Bundle)` and including the `https://developer.android.com/reference/androidx/media3/common/MediaItem#mediaId()` in the argument bundle with key `https://developer.android.com/reference/androidx/media3/session/MediaConstants#EXTRA_KEY_MEDIA_ID()`.

A command is not accepted if it is not a custom command or the command is not in the list of `https://developer.android.com/reference/androidx/media3/session/MediaController#getAvailableSessionCommands()`.

Interoperability: When sending a custom command to `
android.support.v4.media.session.MediaSessionCompat`, `https://developer.android.com/reference/androidx/media3/session/SessionResult#resultCode()` will always be `https://developer.android.com/reference/androidx/media3/session/SessionResult#RESULT_SUCCESS()` because the session has no way to send a result back from `
android.support.v4.media.session.MediaSessionCompat.Callback#onCustomAction(String, Bundle)`.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/session/SessionCommand command` | The custom command. |
| `https://developer.android.com/reference/androidx/media3/common/MediaItem mediaItem` | The media item for which the command is sent. |
| `https://developer.android.com/reference/android/os/Bundle.html args` | The additional arguments. May be empty. |

| Returns |
|---|---|
| `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html<https://developer.android.com/reference/androidx/media3/session/SessionResult>` | A `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html` of `https://developer.android.com/reference/androidx/media3/session/SessionResult` representing the pending completion. |

### sendCustomCommand

```
@UnstableApi
public final ListenableFuture<SessionResult> sendCustomCommand(
    SessionCommand command,
    MediaItem mediaItem,
    Bundle args,
    @Nullable MediaController.ProgressListener progressListener
)
```

Sends a custom command to the session for the given `https://developer.android.com/reference/androidx/media3/common/MediaItem`.

A controller can request progress updates by passing in a non-null `https://developer.android.com/reference/androidx/media3/session/MediaController.ProgressListener`. Whether or not the session sends progress updates depends on the implementation of the session callback that responds to the given `https://developer.android.com/reference/androidx/media3/session/SessionCommand`.

Calling this method is equivalent to calling `https://developer.android.com/reference/androidx/media3/session/MediaController#sendCustomCommand(androidx.media3.session.SessionCommand,android.os.Bundle)` and including the `https://developer.android.com/reference/androidx/media3/common/MediaItem#mediaId()` in the argument bundle with key `https://developer.android.com/reference/androidx/media3/session/MediaConstants#EXTRA_KEY_MEDIA_ID()`.

A command is not accepted if it is not a custom command or the command is not in the list of `https://developer.android.com/reference/androidx/media3/session/MediaController#getAvailableSessionCommands()`.

Interoperability: When sending a custom command to `
android.support.v4.media.session.MediaSessionCompat`, `https://developer.android.com/reference/androidx/media3/session/SessionResult#resultCode()` will always be `https://developer.android.com/reference/androidx/media3/session/SessionResult#RESULT_SUCCESS()` because the session has no way to send a result back from `
android.support.v4.media.session.MediaSessionCompat.Callback#onCustomAction(String, Bundle)`, and `progressListener` is ignored.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/session/SessionCommand command` | The custom command. |
| `https://developer.android.com/reference/androidx/media3/common/MediaItem mediaItem` | The media item for which the command is sent. |
| `https://developer.android.com/reference/android/os/Bundle.html args` | The additional arguments. May be empty. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/session/MediaController.ProgressListener progressListener` | A `https://developer.android.com/reference/androidx/media3/session/MediaController.ProgressListener` to receive progress updates. May be null. |

| Returns |
|---|---|
| `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html<https://developer.android.com/reference/androidx/media3/session/SessionResult>` | A `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html` of `https://developer.android.com/reference/androidx/media3/session/SessionResult` representing the pending completion. |

### setAudioAttributes

```
public final void setAudioAttributes(
    AudioAttributes audioAttributes,
    boolean handleAudioFocus
)
```

Sets the attributes for audio playback, used by the underlying audio track. If not set, the default audio attributes will be used. They are suitable for general media playback.

Setting the audio attributes during playback may introduce a short gap in audio output as the audio track is recreated. A new audio session id will also be generated.

If tunneling is enabled by the track selector, the specified audio attributes will be ignored, but they will take effect if audio is later played without tunneling.

If audio focus should be handled, the `https://developer.android.com/reference/androidx/media3/common/AudioAttributes#usage()` must be `https://developer.android.com/reference/androidx/media3/common/C#USAGE_MEDIA()` or `https://developer.android.com/reference/androidx/media3/common/C#USAGE_GAME()`. Other usages will throw an `https://developer.android.com/reference/java/lang/IllegalArgumentException.html`.

This method must only be called if `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_SET_AUDIO_ATTRIBUTES()` is `https://developer.android.com/reference/androidx/media3/common/Player#getAvailableCommands()`.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/AudioAttributes audioAttributes` | The attributes to use for audio playback. |
| `boolean handleAudioFocus` | True if the player should handle audio focus, false otherwise. |

### setDeviceMuted

```
public final void [setDeviceMuted](https://developer.android.com/reference/androidx/media3/session/MediaController#setDeviceMuted(boolean))(boolean muted)
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/androidx/media3/session/MediaController#setDeviceMuted(boolean,int)` instead.

### setDeviceMuted

```
public final void setDeviceMuted(boolean muted, @C.VolumeFlags int flags)
```

Sets the mute state of the device.

Note that this method affects the device volume. To mute just the current stream, use `
setVolume(0)` instead.

This method must only be called if `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_ADJUST_DEVICE_VOLUME_WITH_FLAGS()` is `https://developer.android.com/reference/androidx/media3/common/Player#getAvailableCommands()`.

| Parameters |
|---|---|
| `boolean muted` | Whether to set the device to be muted or not |
| `@https://developer.android.com/reference/androidx/media3/common/C.VolumeFlags int flags` | Either 0 or a bitwise combination of one or more `https://developer.android.com/reference/androidx/media3/common/C.VolumeFlags`. |

### setDeviceVolume

```
public final void [setDeviceVolume](https://developer.android.com/reference/androidx/media3/session/MediaController#setDeviceVolume(int))(@IntRange(from = 0) int volume)
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/androidx/media3/session/MediaController#setDeviceVolume(int,int)` instead.

### setDeviceVolume

```
public final void setDeviceVolume(@IntRange(from = 0) int volume, @C.VolumeFlags int flags)
```

Sets the volume of the device with volume flags.

Note that this method affects the device volume. To change the volume of the current stream only, use `https://developer.android.com/reference/androidx/media3/common/Player#setVolume(float)`.

This method must only be called if `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_SET_DEVICE_VOLUME_WITH_FLAGS()` is `https://developer.android.com/reference/androidx/media3/common/Player#getAvailableCommands()`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/IntRange(from = 0) int volume` | The volume to set. |
| `@https://developer.android.com/reference/androidx/media3/common/C.VolumeFlags int flags` | Either 0 or a bitwise combination of one or more `https://developer.android.com/reference/androidx/media3/common/C.VolumeFlags`. |

### setMediaItem

```
public final void setMediaItem(MediaItem mediaItem)
```

Clears the playlist, adds the specified `https://developer.android.com/reference/androidx/media3/common/MediaItem` and resets the position to the default position.

To replace a media item (possibly seamlessly) without clearing the playlist, use `https://developer.android.com/reference/androidx/media3/common/Player#replaceMediaItem(int,androidx.media3.common.MediaItem)`.

This method must only be called if `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_SET_MEDIA_ITEM()` is `https://developer.android.com/reference/androidx/media3/common/Player#getAvailableCommands()`.

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

### setMediaItem

```
public final void setMediaItem(MediaItem mediaItem, boolean resetPosition)
```

Clears the playlist and adds the specified `https://developer.android.com/reference/androidx/media3/common/MediaItem`.

To replace a media item (possibly seamlessly) without clearing the playlist, use `https://developer.android.com/reference/androidx/media3/common/Player#replaceMediaItem(int,androidx.media3.common.MediaItem)`.

This method must only be called if `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_SET_MEDIA_ITEM()` is `https://developer.android.com/reference/androidx/media3/common/Player#getAvailableCommands()`.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/MediaItem mediaItem` | The new `https://developer.android.com/reference/androidx/media3/common/MediaItem`. |
| `boolean resetPosition` | Whether the playback position should be reset to the default position. If false, playback will start from the position defined by `https://developer.android.com/reference/androidx/media3/common/Player#getCurrentMediaItemIndex()` and `https://developer.android.com/reference/androidx/media3/common/Player#getCurrentPosition()`. |

### setMediaItem

```
public final void setMediaItem(MediaItem mediaItem, long startPositionMs)
```

Clears the playlist and adds the specified `https://developer.android.com/reference/androidx/media3/common/MediaItem`.

To replace a media item (possibly seamlessly) without clearing the playlist, use `https://developer.android.com/reference/androidx/media3/common/Player#replaceMediaItem(int,androidx.media3.common.MediaItem)`.

This method must only be called if `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_SET_MEDIA_ITEM()` is `https://developer.android.com/reference/androidx/media3/common/Player#getAvailableCommands()`.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/MediaItem mediaItem` | The new `https://developer.android.com/reference/androidx/media3/common/MediaItem`. |
| `long startPositionMs` | The position in milliseconds to start playback from. If `https://developer.android.com/reference/androidx/media3/common/C#TIME_UNSET()` is passed, the default position of the given `https://developer.android.com/reference/androidx/media3/common/MediaItem` is used. |

### setMediaItems

```
public final void setMediaItems(List<MediaItem> mediaItems)
```

Clears the playlist, adds the specified `https://developer.android.com/reference/androidx/media3/common/MediaItem` and resets the position to the default position.

To replace a span of media items (possibly seamlessly) without clearing the playlist, use `https://developer.android.com/reference/androidx/media3/common/Player#replaceMediaItems(int,int,java.util.List<androidx.media3.common.MediaItem>)`.

This method must only be called if `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_CHANGE_MEDIA_ITEMS()` is `https://developer.android.com/reference/androidx/media3/common/Player#getAvailableCommands()`.

| Parameters |
|---|---|
| `https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/androidx/media3/common/MediaItem> mediaItems` | The new `https://developer.android.com/reference/androidx/media3/common/MediaItem`. |

### setMediaItems

```
public final void setMediaItems(List<MediaItem> mediaItems, boolean resetPosition)
```

Clears the playlist and adds the specified `https://developer.android.com/reference/androidx/media3/common/MediaItem`.

To replace a span of media items (possibly seamlessly) without clearing the playlist, use `https://developer.android.com/reference/androidx/media3/common/Player#replaceMediaItems(int,int,java.util.List<androidx.media3.common.MediaItem>)`.

This method must only be called if `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_CHANGE_MEDIA_ITEMS()` is `https://developer.android.com/reference/androidx/media3/common/Player#getAvailableCommands()`.

| Parameters |
|---|---|
| `https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/androidx/media3/common/MediaItem> mediaItems` | The new `https://developer.android.com/reference/androidx/media3/common/MediaItem`. |
| `boolean resetPosition` | Whether the playback position should be reset to the default position in the first `https://developer.android.com/reference/androidx/media3/common/Timeline.Window`. If false, playback will start from the position defined by `https://developer.android.com/reference/androidx/media3/common/Player#getCurrentMediaItemIndex()` and `https://developer.android.com/reference/androidx/media3/common/Player#getCurrentPosition()`. |

### setMediaItems

```
public final void setMediaItems(
    List<MediaItem> mediaItems,
    int startIndex,
    long startPositionMs
)
```

Clears the playlist and adds the specified `https://developer.android.com/reference/androidx/media3/common/MediaItem`.

To replace a span of media items (possibly seamlessly) without clearing the playlist, use `https://developer.android.com/reference/androidx/media3/common/Player#replaceMediaItems(int,int,java.util.List<androidx.media3.common.MediaItem>)`.

This method must only be called if `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_CHANGE_MEDIA_ITEMS()` is `https://developer.android.com/reference/androidx/media3/common/Player#getAvailableCommands()`.

| Parameters |
|---|---|
| `https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/androidx/media3/common/MediaItem> mediaItems` | The new `https://developer.android.com/reference/androidx/media3/common/MediaItem`. |
| `int startIndex` | The `https://developer.android.com/reference/androidx/media3/common/MediaItem` index to start playback from. If `https://developer.android.com/reference/androidx/media3/common/C#INDEX_UNSET()` is passed, the current position is not reset. |
| `long startPositionMs` | The position in milliseconds to start playback from. If `https://developer.android.com/reference/androidx/media3/common/C#TIME_UNSET()` is passed, the default position of the given `https://developer.android.com/reference/androidx/media3/common/MediaItem` is used. In any case, if `startIndex` is set to `https://developer.android.com/reference/androidx/media3/common/C#INDEX_UNSET()`, this parameter is ignored and the position is not reset at all. |

| Throws |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/IllegalSeekPositionException` | If the provided `startIndex` is not within the bounds of the list of media items. |

### setPlayWhenReady

```
public final void setPlayWhenReady(boolean playWhenReady)
```

Sets whether playback should proceed when `https://developer.android.com/reference/androidx/media3/common/Player#getPlaybackState()` == `https://developer.android.com/reference/androidx/media3/common/Player#STATE_READY()`.

If the player is already in the ready state then this method pauses and resumes playback.

This method must only be called if `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_PLAY_PAUSE()` is `https://developer.android.com/reference/androidx/media3/common/Player#getAvailableCommands()`.

| Parameters |
|---|---|
| `boolean playWhenReady` | Whether playback should proceed when ready. |

### setPlaybackParameters

```
public final void setPlaybackParameters(PlaybackParameters playbackParameters)
```

Attempts to set the playback parameters. Passing `https://developer.android.com/reference/androidx/media3/common/PlaybackParameters#DEFAULT()` resets the player to the default, which means there is no speed or pitch adjustment.

Playback parameters changes may cause the player to buffer. `https://developer.android.com/reference/androidx/media3/common/Player.Listener#onPlaybackParametersChanged(androidx.media3.common.PlaybackParameters)` will be called whenever the currently active playback parameters change.

This method must only be called if `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_SET_SPEED_AND_PITCH()` is `https://developer.android.com/reference/androidx/media3/common/Player#getAvailableCommands()`.

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

### setPlaybackSpeed

```
public final void setPlaybackSpeed(float speed)
```

Changes the rate at which playback occurs. The pitch is not changed.

This is equivalent to `
setPlaybackParameters(getPlaybackParameters().withSpeed(speed))`.

This method must only be called if `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_SET_SPEED_AND_PITCH()` is `https://developer.android.com/reference/androidx/media3/common/Player#getAvailableCommands()`.

| Parameters |
|---|---|
| `float speed` | The linear factor by which playback will be sped up. Must be higher than 0. 1 is normal speed, 2 is twice as fast, 0.5 is half normal speed. |

### setPlaylistMetadata

```
public final void setPlaylistMetadata(MediaMetadata playlistMetadata)
```

Sets the playlist .

This method must only be called if #COMMAND_SET_PLAYLIST_METADATA is \* #getAvailableCommands() available.

Interoperability: When connected to `
android.support.v4.media.session.MediaSessionCompat`, setting playlist metadata is not supported and calls to this method are ignored.

### setRating

```
public final ListenableFuture<SessionResult> setRating(Rating rating)
```

Requests that the connected `https://developer.android.com/reference/androidx/media3/session/MediaSession` rates the current media item. This will cause the rating to be set for the current user. The rating style must follow the user rating style from the session. You can get the rating style from the session through the `https://developer.android.com/reference/androidx/media3/common/MediaMetadata#userRating()`.

If the user rating was `null`, the media item does not accept setting user rating.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/Rating rating` | The rating to set. |

| Returns |
|---|---|
| `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html<https://developer.android.com/reference/androidx/media3/session/SessionResult>` | A `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html` of `https://developer.android.com/reference/androidx/media3/session/SessionResult` representing the pending completion. |

### setRating

```
public final ListenableFuture<SessionResult> setRating(String mediaId, Rating rating)
```

Requests that the connected `https://developer.android.com/reference/androidx/media3/session/MediaSession` rates the media. This will cause the rating to be set for the current user. The rating style must follow the user rating style from the session. You can get the rating style from the session through the `https://developer.android.com/reference/androidx/media3/common/MediaMetadata#userRating()`.

If the user rating was `null`, the media item does not accept setting user rating.

Interoperability: When connected to `
android.support.v4.media.session.MediaSessionCompat`, setting a rating is only supported for the currently playing media item. If `mediaId` does not match the current media item's media ID, the call is ignored.

| Parameters |
|---|---|
| `https://developer.android.com/reference/java/lang/String.html mediaId` | The non-empty `https://developer.android.com/reference/androidx/media3/common/MediaItem#mediaId()`. |
| `https://developer.android.com/reference/androidx/media3/common/Rating rating` | The rating to set. |

| Returns |
|---|---|
| `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html<https://developer.android.com/reference/androidx/media3/session/SessionResult>` | A `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html` of `https://developer.android.com/reference/androidx/media3/session/SessionResult` representing the pending completion. |

### setRepeatMode

```
public final void setRepeatMode(@Player.RepeatMode int repeatMode)
```

Sets the `https://developer.android.com/reference/androidx/media3/common/Player.RepeatMode` to be used for playback.

This method must only be called if `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_SET_REPEAT_MODE()` is `https://developer.android.com/reference/androidx/media3/common/Player#getAvailableCommands()`.

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

### setShuffleModeEnabled

```
public final void setShuffleModeEnabled(boolean shuffleModeEnabled)
```

Sets whether shuffling of media items is enabled.

This method must only be called if `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_SET_SHUFFLE_MODE()` is `https://developer.android.com/reference/androidx/media3/common/Player#getAvailableCommands()`.

| Parameters |
|---|---|
| `boolean shuffleModeEnabled` | Whether shuffling is enabled. |

### setTrackSelectionParameters

```
public final void setTrackSelectionParameters(TrackSelectionParameters parameters)
```

Sets the parameters constraining the track selection.

Unsupported parameters will be silently ignored.

Use #getTrackSelectionParameters() to retrieve the current parameters. For example, the following snippet restricts video to SD whilst keep other track selection parameters unchanged:

```
*player.setTrackSelectionParameters(
  player.getTrackSelectionParameters()
        .buildUpon()
        .setMaxVideoSizeSd()
        .build())
```

This method must only be called if #COMMAND_SET_TRACK_SELECTION_PARAMETERS is #getAvailableCommands() available.

Interoperability: When connected to `
android.support.v4.media.session.MediaSessionCompat`, track selection parameters are not supported and calls to this method are ignored.

### setVideoSurface

```
public final void setVideoSurface(@Nullable Surface surface)
```

Sets the onto which video will be rendered. The caller is responsible for tracking the lifecycle of the surface, and must clear the surface by calling \*setVideoSurface(null) if the surface is destroyed.

If the surface is held by a , or \* then it's recommended to use #setVideoSurfaceView(SurfaceView), \* #setVideoTextureView(TextureView) or #setVideoSurfaceHolder(SurfaceHolder) rather than this method, since passing the holder allows the player to track the lifecycle of the surface automatically.

This method must only be called if #COMMAND_SET_VIDEO_SURFACE is \* #getAvailableCommands() available.

Interoperability: When connected to `
android.support.v4.media.session.MediaSessionCompat`, setting a video surface is not supported and calls to this method are ignored.

### setVideoSurfaceHolder

```
public final void setVideoSurfaceHolder(@Nullable SurfaceHolder surfaceHolder)
```

Sets the that holds the onto which video will be rendered. The player will track the lifecycle of the surface automatically.

The thread that calls the methods must be the thread associated with #getApplicationLooper().

This method must only be called if #COMMAND_SET_VIDEO_SURFACE is \* #getAvailableCommands() available.

Interoperability: When connected to `
android.support.v4.media.session.MediaSessionCompat`, setting a video surface is not supported and calls to this method are ignored.

### setVideoSurfaceView

```
public final void setVideoSurfaceView(@Nullable SurfaceView surfaceView)
```

Sets the onto which video will be rendered. The player will track the lifecycle of the surface automatically.

The thread that calls the methods must be the thread associated with #getApplicationLooper().

This method must only be called if #COMMAND_SET_VIDEO_SURFACE is \* #getAvailableCommands() available.

Interoperability: When connected to `
android.support.v4.media.session.MediaSessionCompat`, setting a video surface is not supported and calls to this method are ignored.

### setVideoTextureView

```
public final void setVideoTextureView(@Nullable TextureView textureView)
```

Sets the onto which video will be rendered. The player will track the lifecycle of the surface automatically.

Consider using via #setVideoSurfaceView instead of \* . generally causes lower battery consumption, and has better handling for HDR and secure content. See [Choosing a surface type](https://developer.android.com/guide/topics/media/ui/playerview#surfacetype) for more information.

The thread that calls the methods must be the thread associated with #getApplicationLooper().

This method must only be called if #COMMAND_SET_VIDEO_SURFACE is \* #getAvailableCommands() available.

Interoperability: When connected to `
android.support.v4.media.session.MediaSessionCompat`, setting a video surface is not supported and calls to this method are ignored.

### setVolume

```
public final void setVolume(@FloatRange(from = 0, to = 1) float volume)
```

Sets the audio volume, valid values are between 0 (silence) and 1 (unity gain, signal unchanged), inclusive.

This method must only be called if #COMMAND_SET_VOLUME is \* #getAvailableCommands() available.

Interoperability: When connected to `
android.support.v4.media.session.MediaSessionCompat`, setting player volume is not supported and calls to this method are ignored. Remote device volume can be controlled via `https://developer.android.com/reference/androidx/media3/session/MediaController#setDeviceVolume(int)`.

### stop

```
public final void stop()
```

Stops playback without resetting the playlist. Use `https://developer.android.com/reference/androidx/media3/common/Player#pause()` rather than this method if the intention is to pause playback.

Calling this method will cause the playback state to transition to `https://developer.android.com/reference/androidx/media3/common/Player#STATE_IDLE()` and the player will release the loaded media and resources required for playback. The player instance can still be used by calling `https://developer.android.com/reference/androidx/media3/common/Player#prepare()` again, and `https://developer.android.com/reference/androidx/media3/common/Player#release()` must still be called on the player if it's no longer required.

Calling this method does not clear the playlist, reset the playback position or the playback error.

This method must only be called if `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_STOP()` is `https://developer.android.com/reference/androidx/media3/common/Player#getAvailableCommands()`.

### unmute

```
public final void unmute()
```

If the audio volume is 0, sets the audio volume to a non-zero value decided by the Player to be the most appropriate.

This method must only be called if #COMMAND_SET_VOLUME is \* #getAvailableCommands() available.

Interoperability: When connected to `
android.support.v4.media.session.MediaSessionCompat`, unmuting the player is not supported and calls to this method are ignored. Remote device volume can be unmuted via `https://developer.android.com/reference/androidx/media3/session/MediaController#setDeviceMuted(boolean)`.