ForwardingSimpleBasePlayer
@UnstableApi
class ForwardingSimpleBasePlayer : SimpleBasePlayer
| kotlin.Any | |||
| ↳ | androidx.media3.common.BasePlayer | ||
| ↳ | androidx.media3.common.SimpleBasePlayer | ||
| ↳ | androidx.media3.common.ForwardingSimpleBasePlayer |
A SimpleBasePlayer that forwards all calls to another Player instance.
The class can be used to selectively override getState or handle{Action} methods:
new ForwardingSimpleBasePlayer(player) { @Override protected State getState() { State state = super.getState(); // Modify current state as required: return state.buildUpon().setAvailableCommands(filteredCommands).build(); } @Override protected ListenableFuture<?> handleSetRepeatMode(int repeatMode) { // Modify actions by directly calling the underlying player as needed: getPlayer().setShuffleModeEnabled(true); // ..or forward to the default handling with modified parameters: return super.handleSetRepeatMode(Player.REPEAT_MODE_ALL); } }
SimpleBasePlayer for a more detailed description.
Summary
Public constructors |
|---|
ForwardingSimpleBasePlayer(player: Player!)Creates the forwarding player. |
Inherited Constants |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Inherited functions |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Inherited properties |
|---|
Public constructors
ForwardingSimpleBasePlayer
ForwardingSimpleBasePlayer(player: Player!)
Creates the forwarding player.
Protected functions
getState
protected fun getState(): SimpleBasePlayer.State!
Returns the current State of the player.
The State should include all available commands indicating which player methods are allowed to be called.
Note that this method won't be called while asynchronous handling of player methods is in progress. This means that the implementation doesn't need to handle state changes caused by these asynchronous operations until they are done and can return the currently known state directly. The placeholder state used while these asynchronous operations are in progress can be customized by overriding getPlaceholderState if required.
handleAddMediaItems
protected fun handleAddMediaItems(index: Int, mediaItems: (Mutable)List<MediaItem!>!): ListenableFuture<*>!
Handles calls to addMediaItem and addMediaItems.
Will only be called if COMMAND_CHANGE_MEDIA_ITEMS is available.
| Parameters | |
|---|---|
index: Int |
The index at which to add the items. The index is in the range 0 <= |
mediaItems: (Mutable)List<MediaItem!>! |
The media items to add. |
| Returns | |
|---|---|
ListenableFuture<*>! |
A |
handleClearVideoOutput
protected fun handleClearVideoOutput(videoOutput: Any?): ListenableFuture<*>!
Handles calls to clear the video output.
Will only be called if COMMAND_SET_VIDEO_SURFACE is available.
| Parameters | |
|---|---|
videoOutput: Any? |
The video output to clear. If null any current output should be cleared. If non-null, the output should only be cleared if it matches the provided argument. This is either a |
| Returns | |
|---|---|
ListenableFuture<*>! |
A |
handleDecreaseDeviceVolume
protected fun handleDecreaseDeviceVolume(@C.VolumeFlags flags: Int): ListenableFuture<*>!
Handles calls to decreaseDeviceVolume and decreaseDeviceVolume.
Will only be called if COMMAND_ADJUST_DEVICE_VOLUME or COMMAND_ADJUST_DEVICE_VOLUME_WITH_FLAGS is available.
| Parameters | |
|---|---|
@C.VolumeFlags flags: Int |
Either 0 or a bitwise combination of one or more |
| Returns | |
|---|---|
ListenableFuture<*>! |
A |
handleIncreaseDeviceVolume
protected fun handleIncreaseDeviceVolume(@C.VolumeFlags flags: Int): ListenableFuture<*>!
Handles calls to increaseDeviceVolume and increaseDeviceVolume.
Will only be called if COMMAND_ADJUST_DEVICE_VOLUME or COMMAND_ADJUST_DEVICE_VOLUME_WITH_FLAGS is available.
| Parameters | |
|---|---|
@C.VolumeFlags flags: Int |
Either 0 or a bitwise combination of one or more |
| Returns | |
|---|---|
ListenableFuture<*>! |
A |
handleMoveMediaItems
protected fun handleMoveMediaItems(fromIndex: Int, toIndex: Int, newIndex: Int): ListenableFuture<*>!
Handles calls to moveMediaItem and moveMediaItems.
Will only be called if COMMAND_CHANGE_MEDIA_ITEMS is available.
| Parameters | |
|---|---|
fromIndex: Int |
The start index of the items to move. The index is in the range 0 <= |
toIndex: Int |
The index of the first item not to be included in the move (exclusive). The index is in the range |
newIndex: Int |
The new index of the first moved item. The index is in the range |
| Returns | |
|---|---|
ListenableFuture<*>! |
A |
handlePrepare
protected fun handlePrepare(): ListenableFuture<*>!
Handles calls to prepare.
Will only be called if COMMAND_PREPARE is available.
| Returns | |
|---|---|
ListenableFuture<*>! |
A |
handleRelease
protected fun handleRelease(): ListenableFuture<*>!
Handles calls to release.
Will only be called if COMMAND_RELEASE is available.
| Returns | |
|---|---|
ListenableFuture<*>! |
A |
handleRemoveMediaItems
protected fun handleRemoveMediaItems(fromIndex: Int, toIndex: Int): ListenableFuture<*>!
Handles calls to removeMediaItem and removeMediaItems.
Will only be called if COMMAND_CHANGE_MEDIA_ITEMS is available.
| Parameters | |
|---|---|
fromIndex: Int |
The index at which to start removing media items. The index is in the range 0 <= |
toIndex: Int |
The index of the first item to be kept (exclusive). The index is in the range |
| Returns | |
|---|---|
ListenableFuture<*>! |
A |
handleReplaceMediaItems
protected fun handleReplaceMediaItems(
fromIndex: Int,
toIndex: Int,
mediaItems: (Mutable)List<MediaItem!>!
): ListenableFuture<*>!
Handles calls to replaceMediaItem and replaceMediaItems.
Will only be called if COMMAND_CHANGE_MEDIA_ITEMS is available.
| Parameters | |
|---|---|
fromIndex: Int |
The start index of the items to replace. The index is in the range 0 <= |
toIndex: Int |
The index of the first item not to be replaced (exclusive). The index is in the range |
mediaItems: (Mutable)List<MediaItem!>! |
The media items to replace the specified range with. |
| Returns | |
|---|---|
ListenableFuture<*>! |
A |
handleSeek
protected fun handleSeek(
mediaItemIndex: Int,
positionMs: Long,
@Player.Command seekCommand: Int
): ListenableFuture<*>!
Handles calls to seekTo and other seek operations (for example, seekToNext).
Will only be called if the appropriate Player.Command, for example COMMAND_SEEK_TO_MEDIA_ITEM or COMMAND_SEEK_TO_NEXT, is available.
| Parameters | |
|---|---|
mediaItemIndex: Int |
The media item index to seek to. If the original seek operation did not directly specify an index, this is the most likely implied index based on the available player state. If the implied action is to do nothing, this will be |
positionMs: Long |
The position in milliseconds to start playback from, or |
@Player.Command seekCommand: Int |
The |
| Returns | |
|---|---|
ListenableFuture<*>! |
A |
handleSetAudioAttributes
protected fun handleSetAudioAttributes(
audioAttributes: AudioAttributes!,
handleAudioFocus: Boolean
): ListenableFuture<*>!
Handles calls to set the audio attributes.
Will only be called if COMMAND_SET_AUDIO_ATTRIBUTES is available.
| Parameters | |
|---|---|
audioAttributes: AudioAttributes! |
The attributes to use for audio playback. |
handleAudioFocus: Boolean |
True if the player should handle audio focus, false otherwise. |
| Returns | |
|---|---|
ListenableFuture<*>! |
A |
handleSetDeviceMuted
protected fun handleSetDeviceMuted(muted: Boolean, @C.VolumeFlags flags: Int): ListenableFuture<*>!
Handles calls to setDeviceMuted and setDeviceMuted.
Will only be called if COMMAND_ADJUST_DEVICE_VOLUME or COMMAND_ADJUST_DEVICE_VOLUME_WITH_FLAGS is available.
| Parameters | |
|---|---|
muted: Boolean |
Whether the device was requested to be muted. |
@C.VolumeFlags flags: Int |
Either 0 or a bitwise combination of one or more |
| Returns | |
|---|---|
ListenableFuture<*>! |
A |
handleSetDeviceVolume
protected fun handleSetDeviceVolume(deviceVolume: Int, flags: Int): ListenableFuture<*>!
Handles calls to setDeviceVolume and setDeviceVolume.
Will only be called if COMMAND_SET_DEVICE_VOLUME or COMMAND_SET_DEVICE_VOLUME_WITH_FLAGS is available.
| Parameters | |
|---|---|
deviceVolume: Int |
The requested device volume. |
flags: Int |
Either 0 or a bitwise combination of one or more |
| Returns | |
|---|---|
ListenableFuture<*>! |
A |
handleSetMediaItems
protected fun handleSetMediaItems(
mediaItems: (Mutable)List<MediaItem!>!,
startIndex: Int,
startPositionMs: Long
): ListenableFuture<*>!
Handles calls to setMediaItem and setMediaItems.
Will only be called if COMMAND_SET_MEDIA_ITEM or COMMAND_CHANGE_MEDIA_ITEMS is available. If only COMMAND_SET_MEDIA_ITEM is available, the list of media items will always contain exactly one item.
| Parameters | |
|---|---|
mediaItems: (Mutable)List<MediaItem!>! |
The media items to add. |
startIndex: Int |
The index at which to start playback from, or |
startPositionMs: Long |
The position in milliseconds to start playback from, or |
| Returns | |
|---|---|
ListenableFuture<*>! |
A |
handleSetPlayWhenReady
protected fun handleSetPlayWhenReady(playWhenReady: Boolean): ListenableFuture<*>!
Handles calls to setPlayWhenReady, play and pause.
Will only be called if COMMAND_PLAY_PAUSE is available.
| Parameters | |
|---|---|
playWhenReady: Boolean |
The requested |
| Returns | |
|---|---|
ListenableFuture<*>! |
A |
handleSetPlaybackParameters
protected fun handleSetPlaybackParameters(playbackParameters: PlaybackParameters!): ListenableFuture<*>!
Handles calls to setPlaybackParameters or setPlaybackSpeed.
Will only be called if COMMAND_SET_SPEED_AND_PITCH is available.
| Parameters | |
|---|---|
playbackParameters: PlaybackParameters! |
The requested |
| Returns | |
|---|---|
ListenableFuture<*>! |
A |
handleSetPlaylistMetadata
protected fun handleSetPlaylistMetadata(playlistMetadata: MediaMetadata!): ListenableFuture<*>!
Handles calls to setPlaylistMetadata.
Will only be called if COMMAND_SET_PLAYLIST_METADATA is available.
| Parameters | |
|---|---|
playlistMetadata: MediaMetadata! |
The requested |
| Returns | |
|---|---|
ListenableFuture<*>! |
A |
handleSetRepeatMode
protected fun handleSetRepeatMode(@Player.RepeatMode repeatMode: Int): ListenableFuture<*>!
Handles calls to setRepeatMode.
Will only be called if COMMAND_SET_REPEAT_MODE is available.
| Parameters | |
|---|---|
@Player.RepeatMode repeatMode: Int |
The requested |
| Returns | |
|---|---|
ListenableFuture<*>! |
A |
handleSetShuffleModeEnabled
protected fun handleSetShuffleModeEnabled(shuffleModeEnabled: Boolean): ListenableFuture<*>!
Handles calls to setShuffleModeEnabled.
Will only be called if COMMAND_SET_SHUFFLE_MODE is available.
| Parameters | |
|---|---|
shuffleModeEnabled: Boolean |
Whether shuffle mode was requested to be enabled. |
| Returns | |
|---|---|
ListenableFuture<*>! |
A |
handleSetTrackSelectionParameters
protected fun handleSetTrackSelectionParameters(
trackSelectionParameters: TrackSelectionParameters!
): ListenableFuture<*>!
Handles calls to setTrackSelectionParameters.
Will only be called if COMMAND_SET_TRACK_SELECTION_PARAMETERS is available.
| Parameters | |
|---|---|
trackSelectionParameters: TrackSelectionParameters! |
The requested |
| Returns | |
|---|---|
ListenableFuture<*>! |
A |
handleSetVideoOutput
protected fun handleSetVideoOutput(videoOutput: Any!): ListenableFuture<*>!
Handles calls to set the video output.
Will only be called if COMMAND_SET_VIDEO_SURFACE is available.
| Parameters | |
|---|---|
videoOutput: Any! |
The requested video output. This is either a |
| Returns | |
|---|---|
ListenableFuture<*>! |
A |
handleSetVolume
protected fun handleSetVolume(
volume: Float,
@C.VolumeOperationType volumeOperationType: Int
): ListenableFuture<*>!
Handles calls to setVolume.
Will only be called if COMMAND_SET_VOLUME is available.
| Parameters | |
|---|---|
volume: Float |
The requested audio volume, with 0 being silence and 1 being unity gain (signal unchanged). |
@C.VolumeOperationType volumeOperationType: Int |
The |
| Returns | |
|---|---|
ListenableFuture<*>! |
A |
handleStop
protected fun handleStop(): ListenableFuture<*>!
Handles calls to stop.
Will only be called if COMMAND_STOP is available.
| Returns | |
|---|---|
ListenableFuture<*>! |
A |