ForwardingSimpleBasePlayer


@UnstableApi
class ForwardingSimpleBasePlayer : SimpleBasePlayer


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) {
  
  protected State getState() {
    State state = super.getState();
    // Modify current state as required:
    return state.buildUpon().setAvailableCommands(filteredCommands).build();
  }

  
  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);
  }
}
This base class handles many aspect of the player implementation to simplify the subclass, for example listener handling. See the documentation of SimpleBasePlayer for a more detailed description.

Summary

Public constructors

Creates the forwarding player.

Protected functions

SimpleBasePlayer.State!

Returns the current State of the player.

ListenableFuture<Any!>!
handleAddMediaItems(index: Int, mediaItems: (Mutable)List<MediaItem!>!)

Handles calls to addMediaItem and addMediaItems.

ListenableFuture<Any!>!
handleClearVideoOutput(videoOutput: Any?)

Handles calls to clear the video output.

ListenableFuture<Any!>!

Handles calls to decreaseDeviceVolume and decreaseDeviceVolume.

ListenableFuture<Any!>!

Handles calls to increaseDeviceVolume and increaseDeviceVolume.

ListenableFuture<Any!>!
handleMoveMediaItems(fromIndex: Int, toIndex: Int, newIndex: Int)

Handles calls to moveMediaItem and moveMediaItems.

ListenableFuture<Any!>!

Handles calls to prepare.

ListenableFuture<Any!>!

Handles calls to release.

ListenableFuture<Any!>!
handleRemoveMediaItems(fromIndex: Int, toIndex: Int)

Handles calls to removeMediaItem and removeMediaItems.

ListenableFuture<Any!>!
handleReplaceMediaItems(
    fromIndex: Int,
    toIndex: Int,
    mediaItems: (Mutable)List<MediaItem!>!
)

Handles calls to replaceMediaItem and replaceMediaItems.

ListenableFuture<Any!>!
handleSeek(
    mediaItemIndex: Int,
    positionMs: Long,
    @Player.Command seekCommand: Int
)

Handles calls to seekTo and other seek operations (for example, seekToNext).

ListenableFuture<Any!>!
handleSetAudioAttributes(
    audioAttributes: AudioAttributes!,
    handleAudioFocus: Boolean
)

Handles calls to set the audio attributes.

ListenableFuture<Any!>!

Handles calls to setDeviceMuted and setDeviceMuted.

ListenableFuture<Any!>!
handleSetDeviceVolume(deviceVolume: Int, flags: Int)

Handles calls to setDeviceVolume and setDeviceVolume.

ListenableFuture<Any!>!
handleSetMediaItems(
    mediaItems: (Mutable)List<MediaItem!>!,
    startIndex: Int,
    startPositionMs: Long
)

Handles calls to setMediaItem and setMediaItems.

ListenableFuture<Any!>!

Handles calls to setPlayWhenReady, play and pause.

ListenableFuture<Any!>!

Handles calls to setPlaybackParameters or setPlaybackSpeed.

ListenableFuture<Any!>!

Handles calls to setPlaylistMetadata.

ListenableFuture<Any!>!

Handles calls to setRepeatMode.

ListenableFuture<Any!>!
handleSetShuffleModeEnabled(shuffleModeEnabled: Boolean)

Handles calls to setShuffleModeEnabled.

ListenableFuture<Any!>!
handleSetTrackSelectionParameters(
    trackSelectionParameters: TrackSelectionParameters!
)

Handles calls to setTrackSelectionParameters.

ListenableFuture<Any!>!
handleSetVideoOutput(videoOutput: Any!)

Handles calls to set the video output.

ListenableFuture<Any!>!

Handles calls to setVolume.

ListenableFuture<Any!>!

Handles calls to stop.

Protected properties

Player!

Inherited Constants

From androidx.media3.common.Player
const Int

This property is deprecated.

Use COMMAND_ADJUST_DEVICE_VOLUME_WITH_FLAGS instead.

const Int

Command to increase and decrease the device volume and mute it with volume flags.

const Int

Command to change the media items in the playlist.

const Int

Command to get the player current AudioAttributes.

const Int

Command to get information about the currently playing MediaItem.

const Int

Command to get the device volume and whether it is muted.

const Int

This property is deprecated.

Use COMMAND_GET_METADATA instead.

const Int

Command to get metadata related to the playlist and current MediaItem.

const Int

Command to get the text that should currently be displayed by the player.

const Int

Command to get the information about the current timeline.

const Int

Command to get details of the current track selection.

const Int

Command to get the player volume.

const Int

Represents an invalid Command.

const Int

Command to start, pause or resume playback.

const Int

Command to prepare the player.

const Int

Command to release the player.

const Int

Command to seek back by a fixed increment inside the current MediaItem.

const Int

Command to seek forward by a fixed increment inside the current MediaItem.

const Int

Command to seek anywhere inside the current MediaItem.

const Int

This property is deprecated.

Use COMMAND_SEEK_IN_CURRENT_MEDIA_ITEM instead.

const Int

Command to seek to the default position of the current MediaItem.

const Int

Command to seek anywhere in any MediaItem.

const Int

Command to seek to a later position in the current MediaItem or the default position of the next MediaItem.

const Int

Command to seek to the default position of the next MediaItem.

const Int

This property is deprecated.

Use COMMAND_SEEK_TO_NEXT_MEDIA_ITEM instead.

const Int

Command to seek to an earlier position in the current MediaItem or the default position of the previous MediaItem.

const Int

Command to seek to the default position of the previous MediaItem.

const Int

This property is deprecated.

Use COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM instead.

const Int

This property is deprecated.

Use COMMAND_SEEK_TO_MEDIA_ITEM instead.

const Int

Command to set the player's audio attributes.

const Int

This property is deprecated.

Use COMMAND_SET_DEVICE_VOLUME_WITH_FLAGS instead.

const Int

Command to set the device volume with volume flags.

const Int

Command to set a MediaItem.

const Int

This property is deprecated.

Use COMMAND_SET_PLAYLIST_METADATA instead.

const Int

Command to set the playlist metadata.

const Int

Command to set the repeat mode.

const Int

Command to enable shuffling.

const Int

Command to set the playback speed and pitch.

const Int

Command to set the player's track selection parameters.

const Int

Command to set and clear the surface on which to render the video.

const Int

Command to set the player volume.

const Int

Command to stop playback.

const Int

Automatic playback transition from one period in the timeline to the next.

const Int

Discontinuity introduced internally (e.g. by the source).

const Int

Discontinuity caused by the removal of the current period from the Timeline.

const Int

Seek within the current period or to another period.

const Int

Seek adjustment due to being unable to seek to the requested position or because the seek was permitted to be inexact.

const Int

Discontinuity introduced by a skipped silence.

const Int

Discontinuity introduced by a skipped period (for instance a skipped ad).

const Int

getAudioAttributes changed.

const Int

The audio session id was set.

const Int

isCommandAvailable changed for at least one Command.

const Int

getCurrentCues changed.

const Int

getDeviceInfo changed.

const Int

getDeviceVolume changed.

const Int

isLoading ()} changed.

const Int

isPlaying changed.

const Int

getMaxSeekToPreviousPosition changed.

const Int

getCurrentMediaItem changed or the player started repeating the current item.

const Int

getMediaMetadata changed.

const Int

Metadata associated with the current playback time changed.

const Int

getPlaybackParameters changed.

const Int

getPlaybackState changed.

const Int

getPlaybackSuppressionReason changed.

const Int

getPlayerError changed.

const Int

getPlaylistMetadata changed.

const Int

getPlayWhenReady changed.

const Int

A position discontinuity occurred.

const Int

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.

const Int

getRepeatMode changed.

const Int

getSeekBackIncrement changed.

const Int

getSeekForwardIncrement changed.

const Int

getShuffleModeEnabled changed.

const Int

Skipping silences in the audio stream is enabled or disabled.

const Int

The size of the surface onto which the video is being rendered changed.

const Int

getCurrentTimeline changed.

const Int

getCurrentTracks changed.

const Int

getTrackSelectionParameters changed.

const Int

getVideoSize changed.

const Int

getVolume changed.

const Int

Playback has automatically transitioned to the next media item.

const Int

The current media item has changed because of a change in the playlist.

const Int

The media item has been repeated.

const Int

A seek to another media item has occurred.

const Int

Playback is not suppressed.

const Int

Playback is suppressed due to transient audio focus loss.

const Int

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

const Int

This property is deprecated.

Use PLAYBACK_SUPPRESSION_REASON_UNSUITABLE_AUDIO_OUTPUT instead.

const Int

Playback has been paused to avoid becoming noisy.

const Int

Playback has been paused because of a loss of audio focus.

const Int

Playback has been paused at the end of a media item.

const Int

Playback has been started or paused because of a remote change.

const Int

Playback has been paused because playback has been suppressed too long.

const Int

Playback has been started or paused by a call to setPlayWhenReady.

const Int

Repeats the entire timeline infinitely.

const Int

Normal playback without repetition.

const Int

Repeats the currently playing MediaItem infinitely during ongoing playback.

const Int

The player is not able to immediately play the media, but is doing work toward being able to do so.

const Int

The player has finished playing the media.

const Int

The player is idle, meaning it holds only limited resources.

const Int

The player is able to immediately play from its current position.

const Int

Timeline changed as a result of a change of the playlist items or the order of the items.

const Int

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

Inherited functions

From androidx.media3.common.BasePlayer
Unit
addMediaItem(mediaItem: MediaItem!)

Adds a media item to the end of the playlist.

Unit
addMediaItem(index: Int, mediaItem: MediaItem!)

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

Unit

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

Boolean

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

Unit

Clears the playlist.

Int

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.

Long

If isPlayingAd returns true, returns the duration of the current content in milliseconds, or TIME_UNSET if the duration is not known.

Long

Returns the offset of the current playback position from the live edge in milliseconds, or TIME_UNSET if the current MediaItemisn't live or the offset is unknown.

Any?

Returns the current manifest.

MediaItem?

Returns the currently playing MediaItem.

Int

This function is deprecated.

Use getCurrentMediaItemIndex instead.

MediaItem!

Returns the MediaItem at the given index.

Int

Returns the number of media items in the playlist.

Int

Returns the index of the MediaItem that will be played if seekToNextMediaItem is called, which may depend on the current repeat mode and whether shuffle mode is enabled.

Int

This function is deprecated.

Use getNextMediaItemIndex instead.

Int

Returns the index of the MediaItem that will be played if seekToPreviousMediaItem is called, which may depend on the current repeat mode and whether shuffle mode is enabled.

Int

This function is deprecated.

Use getPreviousMediaItemIndex instead.

Boolean

This function is deprecated.

Use hasNextMediaItem instead.

Boolean

Returns whether a next MediaItem exists, which may depend on the current repeat mode and whether shuffle mode is enabled.

Boolean

This function is deprecated.

Use hasNextMediaItem instead.

Boolean

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

Boolean

Returns whether the provided Command is available.

Boolean

Returns whether the current MediaItem is dynamic (may change when the Timeline is updated), or false if the Timeline is empty.

Boolean

Returns whether the current MediaItem is live, or false if the Timeline is empty.

Boolean

Returns whether the current MediaItem is seekable, or false if the is empty.

Boolean

This function is deprecated.

Use isCurrentMediaItemDynamic instead.

Boolean

This function is deprecated.

Use isCurrentMediaItemLive instead.

Boolean

This function is deprecated.

Use isCurrentMediaItemSeekable instead.

Boolean

Returns whether the player is playing, i.e. getCurrentPosition is advancing.

Unit
moveMediaItem(currentIndex: Int, newIndex: Int)

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

Unit

This function is deprecated.

Use seekToNextMediaItem instead.

Unit

Pauses playback.

Unit

Resumes playback as soon as getPlaybackState == STATE_READY.

Unit

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

Unit
replaceMediaItem(index: Int, mediaItem: MediaItem!)

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

Unit

Seeks back in the current MediaItem by getSeekBackIncrement milliseconds.

Unit

Seeks forward in the current MediaItem by getSeekForwardIncrement milliseconds.

Unit
seekTo(positionMs: Long)

Seeks to a position specified in milliseconds in the current MediaItem.

Unit
seekTo(mediaItemIndex: Int, positionMs: Long)

Seeks to a position specified in milliseconds in the specified MediaItem.

Unit

Seeks to the default position associated with the current MediaItem.

Unit
seekToDefaultPosition(mediaItemIndex: Int)

Seeks to the default position associated with the specified MediaItem.

Unit

Seeks to a later position in the current or next MediaItem (if available).

Unit

Seeks to the default position of the next MediaItem, which may depend on the current repeat mode and whether shuffle mode is enabled.

Unit

This function is deprecated.

Use seekToNextMediaItem instead.

Unit

Seeks to an earlier position in the current or previous MediaItem (if available).

Unit

Seeks to the default position of the previous MediaItem, which may depend on the current repeat mode and whether shuffle mode is enabled.

Unit

This function is deprecated.

Use seekToPreviousMediaItem instead.

Unit
setMediaItem(mediaItem: MediaItem!)

Clears the playlist, adds the specified MediaItem and resets the position to the default position.

Unit
setMediaItem(mediaItem: MediaItem!, resetPosition: Boolean)

Clears the playlist and adds the specified MediaItem.

Unit
setMediaItem(mediaItem: MediaItem!, startPositionMs: Long)

Clears the playlist and adds the specified MediaItem.

Unit

Clears the playlist, adds the specified media items and resets the position to the default position.

Unit

Changes the rate at which playback occurs.

From androidx.media3.common.Player
abstract Unit
setDeviceVolume(volume: @IntRange(from = 0) Int)

This function is deprecated.

Use setDeviceVolume instead.

abstract Unit
setDeviceVolume(volume: @IntRange(from = 0) Int, @C.VolumeFlags flags: Int)

Sets the volume of the device with volume flags.

abstract Unit
setMediaItems(
    mediaItems: (Mutable)List<MediaItem!>!,
    startIndex: Int,
    startPositionMs: Long
)

Clears the playlist and adds the specified media items.

abstract Unit
setPlaybackSpeed(speed: @FloatRange(from = 0, fromInclusive = false) Float)

Changes the rate at which playback occurs.

abstract Unit

Sets the RepeatMode to be used for playback.

abstract Unit
setVolume(volume: @FloatRange(from = 0, to = 1.0) Float)

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

From androidx.media3.common.SimpleBasePlayer
Unit

Registers a listener to receive all events from the player.

Unit
addMediaItems(index: Int, mediaItems: (Mutable)List<MediaItem!>!)

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

Unit

Clears any Surface, SurfaceHolder, SurfaceView or TextureView currently set on the player.

Unit

Clears the Surface onto which video is being rendered if it matches the one passed.

Unit

Clears the SurfaceHolder that holds the Surface onto which video is being rendered if it matches the one passed.

Unit

Clears the SurfaceView onto which video is being rendered if it matches the one passed.

Unit

Clears the TextureView onto which video is being rendered if it matches the one passed.

Unit

This function is deprecated.

Use decreaseDeviceVolume instead.

Unit

Decreases the volume of the device.

AudioAttributes!

Returns the attributes for audio playback.

Player.Commands!

Returns the player's currently available Commands.

Long

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

Long

If isPlayingAd returns true, returns an estimate of the content position in the current content up to which data is buffered, in milliseconds.

Long

If isPlayingAd returns true, returns the content position that will be played once all ads in the ad group have finished playing, in milliseconds.

Int

If isPlayingAd returns true, returns the index of the ad group in the period currently being played.

Int

If isPlayingAd returns true, returns the index of the ad in its ad group.

CueGroup!

Returns the current CueGroup.

Int

Returns the index of the current MediaItem in the timeline, or the prospective index if the current timeline is empty.

Int

Returns the index of the period currently being played.

Long

Returns the playback position in the current content or ad, in milliseconds, or the prospective position in milliseconds if the current timeline is empty.

Timeline!

Returns the current Timeline.

Tracks!

Returns the current tracks.

DeviceInfo!

Gets the device information.

Int

Gets the current volume of the device.

Long

Returns the duration of the current content or ad in milliseconds, or TIME_UNSET if the duration is not known.

Long

Returns the maximum position for which seekToPrevious seeks to the previous , in milliseconds.

MediaMetadata!

Returns the current combined MediaMetadata, or EMPTY if not supported.

SimpleBasePlayer.MediaItemData!

Returns the placeholder MediaItemData used for a new MediaItem added to the playlist.

SimpleBasePlayer.State!

Returns the placeholder state used while a player method is handled asynchronously.

Boolean

Whether playback will proceed when getPlaybackState == STATE_READY.

PlaybackParameters!

Returns the currently active playback parameters.

Int

Returns the current playback state of the player.

Int

Returns the reason why playback is suppressed even though getPlayWhenReady is true, or PLAYBACK_SUPPRESSION_REASON_NONE if playback is not suppressed.

PlaybackException?

Returns the error that caused playback to fail.

MediaMetadata!

Returns the playlist MediaMetadata, as set by setPlaylistMetadata, or EMPTY if not supported.

Int

Returns the current RepeatMode used for playback.

Long

Returns the seekBack increment.

Long

Returns the seekForward increment.

Boolean

Returns whether shuffling of media items is enabled.

Size!

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

Long

Returns an estimate of the total buffered duration from the current position, in milliseconds.

TrackSelectionParameters!

Returns the parameters constraining the track selection.

VideoSize!

Gets the size of the video.

Float

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

Unit

This function is deprecated.

Use increaseDeviceVolume instead.

Unit

Increases the volume of the device.

Unit

Invalidates the current state.

Boolean

Gets whether the device is muted or not.

Boolean

Whether the player is currently loading the source.

Boolean

Returns whether the player is currently playing an ad.

Unit
moveMediaItems(fromIndex: Int, toIndex: Int, newIndex: Int)

Moves the media item range to the new index.

Unit

Prepares the player.

Unit

Releases the player.

Unit

Unregister a listener registered through addListener.

Unit
removeMediaItems(fromIndex: Int, toIndex: Int)

Removes a range of media items from the playlist.

Unit
replaceMediaItems(
    fromIndex: Int,
    toIndex: Int,
    mediaItems: (Mutable)List<MediaItem!>!
)

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

Unit
@VisibleForTesting(otherwise = 4)
seekTo(
    mediaItemIndex: Int,
    positionMs: Long,
    @Player.Command seekCommand: Int,
    isRepeatingCurrentItem: Boolean
)

Seeks to a position in the specified MediaItem.

Unit
setAudioAttributes(
    audioAttributes: AudioAttributes!,
    handleAudioFocus: Boolean
)

Sets the attributes for audio playback, used by the underlying audio track.

Unit

This function is deprecated.

Use setDeviceMuted instead.

Unit

Sets the mute state of the device.

Unit

This function is deprecated.

Use setDeviceVolume instead.

Unit
setDeviceVolume(volume: Int, @C.VolumeFlags flags: Int)

Sets the volume of the device with volume flags.

Unit
setMediaItems(
    mediaItems: (Mutable)List<MediaItem!>!,
    resetPosition: Boolean
)

Clears the playlist and adds the specified media items.

Unit
setMediaItems(
    mediaItems: (Mutable)List<MediaItem!>!,
    startIndex: Int,
    startPositionMs: Long
)

Clears the playlist and adds the specified media items.

Unit
setPlayWhenReady(playWhenReady: Boolean)

Sets whether playback should proceed when getPlaybackState == STATE_READY.

Unit

Attempts to set the playback parameters.

Unit

Sets the playlist MediaMetadata.

Unit

Sets the RepeatMode to be used for playback.

Unit
setShuffleModeEnabled(shuffleModeEnabled: Boolean)

Sets whether shuffling of media items is enabled.

Unit

Sets the parameters constraining the track selection.

Unit

Sets the Surface onto which video will be rendered.

Unit

Sets the SurfaceHolder that holds the Surface onto which video will be rendered.

Unit

Sets the SurfaceView onto which video will be rendered.

Unit

Sets the TextureView onto which video will be rendered.

Unit
setVolume(volume: Float)

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

Unit

Stops playback without resetting the playlist.

Unit

Throws an IllegalStateException if the the thread calling this method does not match the Looper thread that was specified upon construction of this instance.

Public constructors

ForwardingSimpleBasePlayer

ForwardingSimpleBasePlayer(player: Player!)

Creates the forwarding player.

Parameters
player: Player!

The Player to forward to.

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<Any!>!

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 <= index<= getMediaItemCount.

mediaItems: (Mutable)List<MediaItem!>!

The media items to add.

Returns
ListenableFuture<Any!>!

A ListenableFuture indicating the completion of all immediate State changes caused by this call.

handleClearVideoOutput

protected fun handleClearVideoOutput(videoOutput: Any?): ListenableFuture<Any!>!

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 Surface, SurfaceHolder, TextureView or .

Returns
ListenableFuture<Any!>!

A ListenableFuture indicating the completion of all immediate State changes caused by this call.

handleDecreaseDeviceVolume

protected fun handleDecreaseDeviceVolume(@C.VolumeFlags flags: Int): ListenableFuture<Any!>!

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 C.VolumeFlags.

Returns
ListenableFuture<Any!>!

A ListenableFuture indicating the completion of all immediate State changes caused by this call.

handleIncreaseDeviceVolume

protected fun handleIncreaseDeviceVolume(@C.VolumeFlags flags: Int): ListenableFuture<Any!>!

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 C.VolumeFlags.

Returns
ListenableFuture<Any!>!

A ListenableFuture indicating the completion of all immediate State changes caused by this call.

handleMoveMediaItems

protected fun handleMoveMediaItems(fromIndex: Int, toIndex: Int, newIndex: Int): ListenableFuture<Any!>!

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 <= fromIndex<getMediaItemCount.

toIndex: Int

The index of the first item not to be included in the move (exclusive). The index is in the range fromIndex<toIndex<= getMediaItemCount.

newIndex: Int

The new index of the first moved item. The index is in the range 0<= newIndex<- (toIndex - fromIndex).

Returns
ListenableFuture<Any!>!

A ListenableFuture indicating the completion of all immediate State changes caused by this call.

handlePrepare

protected fun handlePrepare(): ListenableFuture<Any!>!

Handles calls to prepare.

Will only be called if COMMAND_PREPARE is available.

Returns
ListenableFuture<Any!>!

A ListenableFuture indicating the completion of all immediate State changes caused by this call.

handleRelease

protected fun handleRelease(): ListenableFuture<Any!>!

Handles calls to release.

Will only be called if COMMAND_RELEASE is available.

Returns
ListenableFuture<Any!>!

A ListenableFuture indicating the completion of all immediate State changes caused by this call.

handleRemoveMediaItems

protected fun handleRemoveMediaItems(fromIndex: Int, toIndex: Int): ListenableFuture<Any!>!

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 <= fromIndex<getMediaItemCount.

toIndex: Int

The index of the first item to be kept (exclusive). The index is in the range fromIndex<toIndex<= getMediaItemCount.

Returns
ListenableFuture<Any!>!

A ListenableFuture indicating the completion of all immediate State changes caused by this call.

handleReplaceMediaItems

protected fun handleReplaceMediaItems(
    fromIndex: Int,
    toIndex: Int,
    mediaItems: (Mutable)List<MediaItem!>!
): ListenableFuture<Any!>!

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 <= fromIndex<getMediaItemCount.

toIndex: Int

The index of the first item not to be replaced (exclusive). The index is in the range fromIndex<toIndex<= getMediaItemCount.

mediaItems: (Mutable)List<MediaItem!>!

The media items to replace the specified range with.

Returns
ListenableFuture<Any!>!

A ListenableFuture indicating the completion of all immediate State changes caused by this call.

handleSeek

protected fun handleSeek(
    mediaItemIndex: Int,
    positionMs: Long,
    @Player.Command seekCommand: Int
): ListenableFuture<Any!>!

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

positionMs: Long

The position in milliseconds to start playback from, or TIME_UNSET to start at the default position in the media item. If the original seek operation did not directly specify a position, this is the most likely implied position based on the available player state.

@Player.Command seekCommand: Int

The Player.Command used to trigger the seek.

Returns
ListenableFuture<Any!>!

A ListenableFuture indicating the completion of all immediate State changes caused by this call.

handleSetAudioAttributes

protected fun handleSetAudioAttributes(
    audioAttributes: AudioAttributes!,
    handleAudioFocus: Boolean
): ListenableFuture<Any!>!

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<Any!>!

A ListenableFuture indicating the completion of all immediate State changes caused by this call.

handleSetDeviceMuted

protected fun handleSetDeviceMuted(muted: Boolean, @C.VolumeFlags flags: Int): ListenableFuture<Any!>!

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 C.VolumeFlags.

Returns
ListenableFuture<Any!>!

A ListenableFuture indicating the completion of all immediate State changes caused by this call.

handleSetDeviceVolume

protected fun handleSetDeviceVolume(deviceVolume: Int, flags: Int): ListenableFuture<Any!>!

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 C.VolumeFlags.

Returns
ListenableFuture<Any!>!

A ListenableFuture indicating the completion of all immediate State changes caused by this call.

handleSetMediaItems

protected fun handleSetMediaItems(
    mediaItems: (Mutable)List<MediaItem!>!,
    startIndex: Int,
    startPositionMs: Long
): ListenableFuture<Any!>!

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 INDEX_UNSET to start at the default item.

startPositionMs: Long

The position in milliseconds to start playback from, or TIME_UNSET to start at the default position in the media item.

Returns
ListenableFuture<Any!>!

A ListenableFuture indicating the completion of all immediate State changes caused by this call.

handleSetPlayWhenReady

protected fun handleSetPlayWhenReady(playWhenReady: Boolean): ListenableFuture<Any!>!

Handles calls to setPlayWhenReady, play and pause.

Will only be called if COMMAND_PLAY_PAUSE is available.

Parameters
playWhenReady: Boolean

The requested playWhenReady

Returns
ListenableFuture<Any!>!

A ListenableFuture indicating the completion of all immediate State changes caused by this call.

handleSetPlaybackParameters

protected fun handleSetPlaybackParameters(playbackParameters: PlaybackParameters!): ListenableFuture<Any!>!

Handles calls to setPlaybackParameters or setPlaybackSpeed.

Will only be called if COMMAND_SET_SPEED_AND_PITCH is available.

Parameters
playbackParameters: PlaybackParameters!

The requested PlaybackParameters.

Returns
ListenableFuture<Any!>!

A ListenableFuture indicating the completion of all immediate State changes caused by this call.

handleSetPlaylistMetadata

protected fun handleSetPlaylistMetadata(playlistMetadata: MediaMetadata!): ListenableFuture<Any!>!

Handles calls to setPlaylistMetadata.

Will only be called if COMMAND_SET_PLAYLIST_METADATA is available.

Parameters
playlistMetadata: MediaMetadata!

The requested playlist metadata.

Returns
ListenableFuture<Any!>!

A ListenableFuture indicating the completion of all immediate State changes caused by this call.

handleSetRepeatMode

protected fun handleSetRepeatMode(@Player.RepeatMode repeatMode: Int): ListenableFuture<Any!>!

Handles calls to setRepeatMode.

Will only be called if COMMAND_SET_REPEAT_MODE is available.

Parameters
@Player.RepeatMode repeatMode: Int

The requested RepeatMode.

Returns
ListenableFuture<Any!>!

A ListenableFuture indicating the completion of all immediate State changes caused by this call.

handleSetShuffleModeEnabled

protected fun handleSetShuffleModeEnabled(shuffleModeEnabled: Boolean): ListenableFuture<Any!>!

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<Any!>!

A ListenableFuture indicating the completion of all immediate State changes caused by this call.

handleSetTrackSelectionParameters

protected fun handleSetTrackSelectionParameters(
    trackSelectionParameters: TrackSelectionParameters!
): ListenableFuture<Any!>!

Handles calls to setTrackSelectionParameters.

Will only be called if COMMAND_SET_TRACK_SELECTION_PARAMETERS is available.

Parameters
trackSelectionParameters: TrackSelectionParameters!

The requested TrackSelectionParameters.

Returns
ListenableFuture<Any!>!

A ListenableFuture indicating the completion of all immediate State changes caused by this call.

handleSetVideoOutput

protected fun handleSetVideoOutput(videoOutput: Any!): ListenableFuture<Any!>!

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 Surface, , TextureView or SurfaceView.

Returns
ListenableFuture<Any!>!

A ListenableFuture indicating the completion of all immediate State changes caused by this call.

handleSetVolume

protected fun handleSetVolume(volume: Float): ListenableFuture<Any!>!

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

Returns
ListenableFuture<Any!>!

A ListenableFuture indicating the completion of all immediate State changes caused by this call.

handleStop

protected fun handleStop(): ListenableFuture<Any!>!

Handles calls to stop.

Will only be called if COMMAND_STOP is available.

Returns
ListenableFuture<Any!>!

A ListenableFuture indicating the completion of all immediate State changes caused by this call.

Protected properties

player

protected val playerPlayer!