@UnstableApi
public final class FakePlayer extends SimpleBasePlayer


A fake Player that uses SimpleBasePlayer's minimal number of default methods implementations to build upon to simulate realistic playback scenarios for testing.

Summary

Public fields

final boolean

Whether the player is released

Public constructors

FakePlayer(
    @Player.State int playbackState,
    boolean playWhenReady,
    @NonNull List<@NonNull SimpleBasePlayer.MediaItemData> playlist,
    float playbackSpeed,
    long bufferingDelayMs
)

Public methods

final void
addCommands(@Player.Command int... commands)

Add commands to those already available to the player.

final Object

Current video output

final void
removeCommands(@Player.Command int... commands)

Remove commands from those already available to the player.

final void
renderFirstFrame(boolean newlyRenderedFirstFrame)

Sets whether a frame has been rendered for the first time since setting the surface, a rendering reset, or since the stream being rendered was changed.

final void
setBufferedPositionMs(long bufferedPositionMs)

Sets the buffered content playback position in milliseconds.

final void
setDuration(@NonNull String uid, long durationMs)

Sets the duration of the media item in the playlist, in milliseconds.

final void
setPlaybackState(@Player.State int playbackState)

Sets the {@linkplain Player.State state} of the player.

final void
setPosition(long positionMs)

Sets the current content playback position in milliseconds.

final void

Sets the PositionSupplier for the current content playback position using extrapolation.

final void
setSeekBackIncrementMs(long seekBackIncrementMs)

Sets the Player.seekBack increment in milliseconds.

final void
setSeekForwardIncrementMs(long seekForwardIncrementMs)

Sets the Player.seekForward increment in milliseconds.

final void

Sets the current video size.

Protected methods

@NonNull SimpleBasePlayer.State

Returns the current State of the player.

@NonNull ListenableFuture<@NonNull ?>

Handles calls to clear the video output.

@NonNull ListenableFuture<@NonNull ?>

Handles calls to prepare.

@NonNull ListenableFuture<@NonNull ?>

Handles calls to release.

@NonNull ListenableFuture<@NonNull ?>
handleSeek(
    int mediaItemIndex,
    long positionMs,
    @Player.Command int seekCommand
)

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

@NonNull ListenableFuture<@NonNull ?>
handleSetMediaItems(
    @NonNull List<@NonNull MediaItem> mediaItems,
    int startIndex,
    long startPositionMs
)

Handles calls to setMediaItem and setMediaItems.

@NonNull ListenableFuture<@NonNull ?>
handleSetPlayWhenReady(boolean playWhenReady)

Handles calls to setPlayWhenReady, play and pause.

@NonNull ListenableFuture<@NonNull ?>

Handles calls to setPlaybackParameters or setPlaybackSpeed.

@NonNull ListenableFuture<@NonNull ?>
handleSetRepeatMode(int repeatMode)

Handles calls to setRepeatMode.

@NonNull ListenableFuture<@NonNull ?>
handleSetShuffleModeEnabled(boolean shuffleModeEnabled)

Handles calls to setShuffleModeEnabled.

@NonNull ListenableFuture<@NonNull ?>

Handles calls to set the video output.

@NonNull ListenableFuture<@NonNull ?>
handleSetVolume(
    float volume,
    @C.VolumeOperationType int volumeOperationType
)

Handles calls to setVolume.

@NonNull ListenableFuture<@NonNull ?>

Handles calls to stop.

Inherited methods

From androidx.media3.common.BasePlayer
final void

Adds a media item to the end of the playlist.

final void
addMediaItem(int index, @NonNull MediaItem mediaItem)

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

final void

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

final boolean

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

final void

Clears the playlist.

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

final long

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

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

final @Nullable Object

Returns the current manifest.

final @Nullable MediaItem

Returns the currently playing MediaItem.

final int

This method is deprecated.

Use getCurrentMediaItemIndex instead.

final @NonNull MediaItem
getMediaItemAt(int index)

Returns the MediaItem at the given index.

final int

Returns the number of media items in the playlist.

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

final int

This method is deprecated.

Use getNextMediaItemIndex instead.

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

final int

This method is deprecated.

Use getPreviousMediaItemIndex instead.

final boolean

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

final boolean

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

final boolean

Returns whether the provided Command is available.

final boolean

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

final boolean

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

final boolean

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

final boolean

This method is deprecated.

Use isCurrentMediaItemDynamic instead.

final boolean

This method is deprecated.

Use isCurrentMediaItemLive instead.

final boolean

This method is deprecated.

Use isCurrentMediaItemSeekable instead.

final boolean

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

final void
moveMediaItem(int currentIndex, int newIndex)

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

final void

Pauses playback.

final void

Resumes playback as soon as getPlaybackState == STATE_READY.

final void
removeMediaItem(int index)

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

final void
replaceMediaItem(int index, @NonNull MediaItem mediaItem)

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

final void

Seeks back in the current MediaItem by getSeekBackIncrement milliseconds.

final void

Seeks forward in the current MediaItem by getSeekForwardIncrement milliseconds.

final void
seekTo(long positionMs)

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

final void
seekTo(int mediaItemIndex, long positionMs)

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

final void

Seeks to the default position associated with the current MediaItem.

final void
seekToDefaultPosition(int mediaItemIndex)

Seeks to the default position associated with the specified MediaItem.

final void

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

final void

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

final void

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

final void

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

final void

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

final void
setMediaItem(@NonNull MediaItem mediaItem, boolean resetPosition)

Clears the playlist and adds the specified MediaItem.

final void
setMediaItem(@NonNull MediaItem mediaItem, long startPositionMs)

Clears the playlist and adds the specified MediaItem.

final void

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

final void
setPlaybackSpeed(float speed)

Changes the rate at which playback occurs.

From androidx.media3.common.SimpleBasePlayer
final void

Registers a listener to receive all events from the player.

final void
addMediaItems(int index, @NonNull List<@NonNull MediaItem> mediaItems)

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

final void

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

final void

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

final void

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

final void

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

final void

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

final void

This method is deprecated.

Use decreaseDeviceVolume instead.

final void

Decreases the volume of the device.

final @NonNull Looper

Returns the Looper associated with the application thread that's used to access the player and on which player events are received.

final @NonNull AudioAttributes

Returns the attributes for audio playback.

final int

Returns the audio session identifier, or AUDIO_SESSION_ID_UNSET if not set.

final @NonNull Player.Commands

Returns the player's currently available Commands.

final long

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

final long

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

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

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

final int

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

final @NonNull CueGroup

Returns the current CueGroup.

final int

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

final int

Returns the index of the period currently being played.

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

final @NonNull Timeline

Returns the current Timeline.

final @NonNull Tracks

Returns the current tracks.

final @NonNull DeviceInfo

Gets the device information.

final int

Gets the current volume of the device.

final long

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

final long

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

final @NonNull MediaMetadata

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

@NonNull SimpleBasePlayer.MediaItemData

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

@NonNull SimpleBasePlayer.State
@ForOverride
getPlaceholderState(
    @NonNull SimpleBasePlayer.State suggestedPlaceholderState
)

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

final boolean

Whether playback will proceed when getPlaybackState == STATE_READY.

final @NonNull PlaybackParameters

Returns the currently active playback parameters.

final int

Returns the current playback state of the player.

final int

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

final @Nullable PlaybackException

Returns the error that caused playback to fail.

final @NonNull MediaMetadata

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

final int

Returns the current RepeatMode used for playback.

final long

Returns the seekBack increment.

final long

Returns the seekForward increment.

final boolean

Returns whether shuffling of media items is enabled.

final @NonNull Size

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

final long

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

final @NonNull TrackSelectionParameters

Returns the parameters constraining the track selection.

final @NonNull VideoSize

Gets the size of the video.

final float

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

@NonNull ListenableFuture<@NonNull ?>
@ForOverride
handleAddMediaItems(
    int index,
    @NonNull List<@NonNull MediaItem> mediaItems
)

Handles calls to addMediaItem and addMediaItems.

@NonNull ListenableFuture<@NonNull ?>

Handles calls to decreaseDeviceVolume and decreaseDeviceVolume.

@NonNull ListenableFuture<@NonNull ?>

Handles calls to increaseDeviceVolume and increaseDeviceVolume.

@NonNull ListenableFuture<@NonNull ?>
@ForOverride
handleMoveMediaItems(int fromIndex, int toIndex, int newIndex)

Handles calls to moveMediaItem and moveMediaItems.

@NonNull ListenableFuture<@NonNull ?>
@ForOverride
handleRemoveMediaItems(int fromIndex, int toIndex)

Handles calls to removeMediaItem and removeMediaItems.

@NonNull ListenableFuture<@NonNull ?>
@ForOverride
handleReplaceMediaItems(
    int fromIndex,
    int toIndex,
    @NonNull List<@NonNull MediaItem> mediaItems
)

Handles calls to replaceMediaItem and replaceMediaItems.

@NonNull ListenableFuture<@NonNull ?>
@ForOverride
handleSetAudioAttributes(
    @NonNull AudioAttributes audioAttributes,
    boolean handleAudioFocus
)

Handles calls to set the audio attributes.

@NonNull ListenableFuture<@NonNull ?>
@ForOverride
handleSetDeviceMuted(boolean muted, @C.VolumeFlags int flags)

Handles calls to setDeviceMuted and setDeviceMuted.

@NonNull ListenableFuture<@NonNull ?>
@ForOverride
handleSetDeviceVolume(
    @IntRange(from = 0) int deviceVolume,
    @C.VolumeFlags int flags
)

Handles calls to setDeviceVolume and setDeviceVolume.

@NonNull ListenableFuture<@NonNull ?>

Handles calls to setPlaylistMetadata.

@NonNull ListenableFuture<@NonNull ?>

Handles calls to setTrackSelectionParameters.

@NonNull ListenableFuture<@NonNull ?>
@ForOverride
handleSetVolume(@FloatRange(from = 0, to = 1.0) float volume)

This method is deprecated.

Use handleSetVolume instead.

final void

This method is deprecated.

Use increaseDeviceVolume instead.

final void

Increases the volume of the device.

final void

Invalidates the current state.

final boolean

Gets whether the device is muted or not.

final boolean

Whether the player is currently loading the source.

final boolean

Returns whether the player is currently playing an ad.

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

Moves the media item range to the new index.

final void

Sets the audio volume to 0.

final void

Prepares the player.

final void

Releases the player.

final void

Unregister a listener registered through addListener.

final void
removeMediaItems(int fromIndex, int toIndex)

Removes a range of media items from the playlist.

final void
replaceMediaItems(
    int fromIndex,
    int toIndex,
    @NonNull List<@NonNull MediaItem> mediaItems
)

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

final void
seekTo(
    int mediaItemIndex,
    long positionMs,
    @Player.Command int seekCommand,
    boolean isRepeatingCurrentItem
)

Seeks to a position in the specified MediaItem.

final void
setAudioAttributes(
    @NonNull AudioAttributes audioAttributes,
    boolean handleAudioFocus
)

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

final void
setDeviceMuted(boolean muted)

This method is deprecated.

Use setDeviceMuted instead.

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

Sets the mute state of the device.

final void
setDeviceVolume(int volume)

This method is deprecated.

Use setDeviceVolume instead.

final void
setDeviceVolume(int volume, @C.VolumeFlags int flags)

Sets the volume of the device with volume flags.

final void
setMediaItems(
    @NonNull List<@NonNull MediaItem> mediaItems,
    boolean resetPosition
)

Clears the playlist and adds the specified media items.

final void
setMediaItems(
    @NonNull List<@NonNull MediaItem> mediaItems,
    int startIndex,
    long startPositionMs
)

Clears the playlist and adds the specified media items.

final void
setPlayWhenReady(boolean playWhenReady)

Sets whether playback should proceed when getPlaybackState == STATE_READY.

final void

Attempts to set the playback parameters.

final void

Sets the playlist MediaMetadata.

final void

Sets the RepeatMode to be used for playback.

final void
setShuffleModeEnabled(boolean shuffleModeEnabled)

Sets whether shuffling of media items is enabled.

final void

Sets the parameters constraining the track selection.

final void

Sets the Surface onto which video will be rendered.

final void

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

final void

Sets the SurfaceView onto which video will be rendered.

final void

Sets the TextureView onto which video will be rendered.

final void
setVolume(float volume)

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

final void

Stops playback without resetting the playlist.

final void

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

final void

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 fields

released

public final boolean released

Whether the player is released

Public constructors

FakePlayer

public FakePlayer(
    @Player.State int playbackState,
    boolean playWhenReady,
    @NonNull List<@NonNull SimpleBasePlayer.MediaItemData> playlist,
    float playbackSpeed,
    long bufferingDelayMs
)
Parameters
@Player.State int playbackState

The initial playback state of the player.

boolean playWhenReady

Whether playback should start automatically when ready.

@NonNull List<@NonNull SimpleBasePlayer.MediaItemData> playlist

The initial list of media items to play.

float playbackSpeed

The initial playback speed.

long bufferingDelayMs

The time spent in Player#STATE_BUFFERING when preparing or seeking, in milliseconds. A value of zero will result in the player transitioning directly to Player#STATE_READY without entering Player#STATE_BUFFERING. Must not be negative.

Public methods

addCommands

public final void addCommands(@Player.Command int... commands)

Add commands to those already available to the player.

getVideoOutput

public final Object getVideoOutput()

Current video output

removeCommands

public final void removeCommands(@Player.Command int... commands)

Remove commands from those already available to the player.

renderFirstFrame

public final void renderFirstFrame(boolean newlyRenderedFirstFrame)

Sets whether a frame has been rendered for the first time since setting the surface, a rendering reset, or since the stream being rendered was changed.

setBufferedPositionMs

public final void setBufferedPositionMs(long bufferedPositionMs)

Sets the buffered content playback position in milliseconds.

Parameters
long bufferedPositionMs

The buffered content playback position in milliseconds.

setDuration

public final void setDuration(@NonNull String uid, long durationMs)

Sets the duration of the media item in the playlist, in milliseconds.

Parameters
@NonNull String uid

Unique id of the media item whose duration is being set.

long durationMs

The duration of the media item, in milliseconds, or {@link C#TIME_UNSET} if unknown.

setPlaybackState

public final void setPlaybackState(@Player.State int playbackState)

Sets the {@linkplain Player.State state} of the player.

If the playlist is empty, the state must be either Player.STATE_IDLE or Player.STATE_ENDED.

Parameters
@Player.State int playbackState

The Player.State of the player.

setPosition

public final void setPosition(long positionMs)

Sets the current content playback position in milliseconds.

Parameters
long positionMs

The current content playback position in milliseconds, or C.TIME_UNSET to indicate the default start position.

setPositionSupplierDrivenBy

public final void setPositionSupplierDrivenBy(
    @NonNull TestCoroutineScheduler testScheduler
)

Sets the PositionSupplier for the current content playback position using extrapolation. Start and elapsed time are measured using the TestCoroutineScheduler, and playback speed is taken into account.

Note, that this approach only works

  • for a single media item (does not consider current item's duration and playlist length)

  • assuming the Player is playing (does not react to pauses and discontinuities)

  • assuming the playback speed does not change after the supplier is set

setSeekBackIncrementMs

public final void setSeekBackIncrementMs(long seekBackIncrementMs)

Sets the Player.seekBack increment in milliseconds.

Parameters
long seekBackIncrementMs

The Player.seekBack increment in milliseconds.

setSeekForwardIncrementMs

public final void setSeekForwardIncrementMs(long seekForwardIncrementMs)

Sets the Player.seekForward increment in milliseconds.

Parameters
long seekForwardIncrementMs

The Player.seekForward increment in milliseconds.

setVideoSize

public final void setVideoSize(@NonNull VideoSize videoSize)

Sets the current video size.

Parameters
@NonNull VideoSize videoSize

The current video size.

Protected methods

getState

protected @NonNull SimpleBasePlayer.State getState()

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.

handleClearVideoOutput

protected @NonNull ListenableFuture<@NonNull ?> handleClearVideoOutput(Object videoOutput)

Handles calls to clear the video output.

Will only be called if COMMAND_SET_VIDEO_SURFACE is available.

Parameters
Object videoOutput

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

Returns
@NonNull ListenableFuture<@NonNull ?>

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

handlePrepare

protected @NonNull ListenableFuture<@NonNull ?> handlePrepare()

Handles calls to prepare.

Will only be called if COMMAND_PREPARE is available.

Returns
@NonNull ListenableFuture<@NonNull ?>

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

handleRelease

protected @NonNull ListenableFuture<@NonNull ?> handleRelease()

Handles calls to release.

Will only be called if COMMAND_RELEASE is available.

Returns
@NonNull ListenableFuture<@NonNull ?>

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

handleSeek

protected @NonNull ListenableFuture<@NonNull ?> handleSeek(
    int mediaItemIndex,
    long positionMs,
    @Player.Command int seekCommand
)

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
int mediaItemIndex

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.

long positionMs

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 int seekCommand

The Player.Command used to trigger the seek.

Returns
@NonNull ListenableFuture<@NonNull ?>

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

handleSetMediaItems

protected @NonNull ListenableFuture<@NonNull ?> handleSetMediaItems(
    @NonNull List<@NonNull MediaItem> mediaItems,
    int startIndex,
    long startPositionMs
)

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
@NonNull List<@NonNull MediaItem> mediaItems

The media items to add.

int startIndex

The index at which to start playback from, or INDEX_UNSET to start at the default item.

long startPositionMs

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

Returns
@NonNull ListenableFuture<@NonNull ?>

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

handleSetPlayWhenReady

protected @NonNull ListenableFuture<@NonNull ?> handleSetPlayWhenReady(boolean playWhenReady)

Handles calls to setPlayWhenReady, play and pause.

Will only be called if COMMAND_PLAY_PAUSE is available.

Parameters
boolean playWhenReady

The requested playWhenReady

Returns
@NonNull ListenableFuture<@NonNull ?>

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

handleSetPlaybackParameters

protected @NonNull ListenableFuture<@NonNull ?> handleSetPlaybackParameters(
    @NonNull PlaybackParameters playbackParameters
)

Handles calls to setPlaybackParameters or setPlaybackSpeed.

Will only be called if COMMAND_SET_SPEED_AND_PITCH is available.

Parameters
@NonNull PlaybackParameters playbackParameters

The requested PlaybackParameters.

Returns
@NonNull ListenableFuture<@NonNull ?>

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

handleSetRepeatMode

protected @NonNull ListenableFuture<@NonNull ?> handleSetRepeatMode(int repeatMode)

Handles calls to setRepeatMode.

Will only be called if COMMAND_SET_REPEAT_MODE is available.

Parameters
int repeatMode

The requested RepeatMode.

Returns
@NonNull ListenableFuture<@NonNull ?>

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

handleSetShuffleModeEnabled

protected @NonNull ListenableFuture<@NonNull ?> handleSetShuffleModeEnabled(boolean shuffleModeEnabled)

Handles calls to setShuffleModeEnabled.

Will only be called if COMMAND_SET_SHUFFLE_MODE is available.

Parameters
boolean shuffleModeEnabled

Whether shuffle mode was requested to be enabled.

Returns
@NonNull ListenableFuture<@NonNull ?>

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

handleSetVideoOutput

protected @NonNull ListenableFuture<@NonNull ?> handleSetVideoOutput(@NonNull Object videoOutput)

Handles calls to set the video output.

Will only be called if COMMAND_SET_VIDEO_SURFACE is available.

Parameters
@NonNull Object videoOutput

The requested video output. This is either a Surface, SurfaceHolder, TextureView or SurfaceView.

Returns
@NonNull ListenableFuture<@NonNull ?>

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

handleSetVolume

protected @NonNull ListenableFuture<@NonNull ?> handleSetVolume(
    float volume,
    @C.VolumeOperationType int volumeOperationType
)

Handles calls to setVolume.

Will only be called if COMMAND_SET_VOLUME is available.

Parameters
float volume

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

@C.VolumeOperationType int volumeOperationType

The C.VolumeOperationType that corresponds to the original command for changing of the volume.

Returns
@NonNull ListenableFuture<@NonNull ?>

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

handleStop

protected @NonNull ListenableFuture<@NonNull ?> handleStop()

Handles calls to stop.

Will only be called if COMMAND_STOP is available.

Returns
@NonNull ListenableFuture<@NonNull ?>

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