public final class

SimpleBasePlayer.State.Builder

extends java.lang.Object

 java.lang.Object

↳androidx.media3.common.SimpleBasePlayer.State.Builder

Overview

A builder for SimpleBasePlayer.State objects.

Summary

Constructors
publicBuilder()

Creates the builder.

Methods
public SimpleBasePlayer.Statebuild()

Builds the SimpleBasePlayer.State.

public SimpleBasePlayer.State.BuilderclearPositionDiscontinuity()

Clears a previously set position discontinuity signal.

public SimpleBasePlayer.State.BuildersetAdBufferedPositionMs(SimpleBasePlayer.PositionSupplier adBufferedPositionMsSupplier)

Sets the SimpleBasePlayer.PositionSupplier for the estimated position up to which the currently playing ad is buffered, in milliseconds.

public SimpleBasePlayer.State.BuildersetAdPositionMs(long positionMs)

Sets the current ad playback position in milliseconds.

public SimpleBasePlayer.State.BuildersetAdPositionMs(SimpleBasePlayer.PositionSupplier adPositionMsSupplier)

Sets the SimpleBasePlayer.PositionSupplier for the current ad playback position in milliseconds.

public SimpleBasePlayer.State.BuildersetAudioAttributes(AudioAttributes audioAttributes)

Sets the current AudioAttributes.

public SimpleBasePlayer.State.BuildersetAvailableCommands(Player.Commands availableCommands)

Sets the available .

public SimpleBasePlayer.State.BuildersetContentBufferedPositionMs(SimpleBasePlayer.PositionSupplier contentBufferedPositionMsSupplier)

Sets the SimpleBasePlayer.PositionSupplier for the estimated position up to which the currently playing content is buffered, in milliseconds.

public SimpleBasePlayer.State.BuildersetContentPositionMs(long positionMs)

Sets the current content playback position in milliseconds.

public SimpleBasePlayer.State.BuildersetContentPositionMs(SimpleBasePlayer.PositionSupplier contentPositionMsSupplier)

Sets the SimpleBasePlayer.PositionSupplier for the current content playback position in milliseconds.

public SimpleBasePlayer.State.BuildersetCurrentAd(int adGroupIndex, int adIndexInAdGroup)

Sets the current ad indices, or C.INDEX_UNSET if no ad is playing.

public SimpleBasePlayer.State.BuildersetCurrentCues(CueGroup currentCues)

Sets the current cues.

public SimpleBasePlayer.State.BuildersetCurrentMediaItemIndex(int currentMediaItemIndex)

Sets the current media item index.

public SimpleBasePlayer.State.BuildersetDeviceInfo(DeviceInfo deviceInfo)

Sets the DeviceInfo.

public SimpleBasePlayer.State.BuildersetDeviceVolume(int deviceVolume)

Sets the current device volume.

public SimpleBasePlayer.State.BuildersetIsDeviceMuted(boolean isDeviceMuted)

Sets whether the device is muted.

public SimpleBasePlayer.State.BuildersetIsLoading(boolean isLoading)

Sets whether the player is currently loading its source.

public SimpleBasePlayer.State.BuildersetMaxSeekToPreviousPositionMs(long maxSeekToPreviousPositionMs)

Sets the maximum position for which BasePlayer.seekToPrevious() seeks to the previous item, in milliseconds.

public SimpleBasePlayer.State.BuildersetNewlyRenderedFirstFrame(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.

public SimpleBasePlayer.State.BuildersetPlaybackParameters(PlaybackParameters playbackParameters)

Sets the currently active PlaybackParameters.

public SimpleBasePlayer.State.BuildersetPlaybackState(int playbackState)

Sets the state of the player.

public SimpleBasePlayer.State.BuildersetPlaybackSuppressionReason(int playbackSuppressionReason)

Sets the reason why playback is suppressed even if SimpleBasePlayer.getPlayWhenReady() is true.

public SimpleBasePlayer.State.BuildersetPlayerError(PlaybackException playerError)

Sets last error that caused playback to fail, or null if there was no error.

public SimpleBasePlayer.State.BuildersetPlaylist(java.util.List<SimpleBasePlayer.MediaItemData> playlist)

Sets the playlist as a list of media items.

public SimpleBasePlayer.State.BuildersetPlaylist(Timeline timeline, Tracks currentTracks, MediaMetadata currentMetadata)

Sets the playlist as a Timeline with information about the current Tracks and MediaMetadata.

public SimpleBasePlayer.State.BuildersetPlaylistMetadata(MediaMetadata playlistMetadata)

Sets the playlist MediaMetadata.

public SimpleBasePlayer.State.BuildersetPlayWhenReady(boolean playWhenReady, int playWhenReadyChangeReason)

Sets whether playback should proceed when ready and not suppressed.

public SimpleBasePlayer.State.BuildersetPositionDiscontinuity(int positionDiscontinuityReason, long discontinuityPositionMs)

Signals that a position discontinuity happened since the last player update and sets the reason for it.

public SimpleBasePlayer.State.BuildersetRepeatMode(int repeatMode)

Sets the used for playback.

public SimpleBasePlayer.State.BuildersetSeekBackIncrementMs(long seekBackIncrementMs)

Sets the Player.seekBack() increment in milliseconds.

public SimpleBasePlayer.State.BuildersetSeekForwardIncrementMs(long seekForwardIncrementMs)

Sets the Player.seekForward() increment in milliseconds.

public SimpleBasePlayer.State.BuildersetShuffleModeEnabled(boolean shuffleModeEnabled)

Sets whether shuffling of media items is enabled.

public SimpleBasePlayer.State.BuildersetSurfaceSize(Size surfaceSize)

Sets the size of the surface onto which the video is being rendered.

public SimpleBasePlayer.State.BuildersetTimedMetadata(Metadata timedMetadata)

Sets the most recent timed Metadata.

public SimpleBasePlayer.State.BuildersetTotalBufferedDurationMs(SimpleBasePlayer.PositionSupplier totalBufferedDurationMsSupplier)

Sets the SimpleBasePlayer.PositionSupplier for the estimated total buffered duration in milliseconds.

public SimpleBasePlayer.State.BuildersetTrackSelectionParameters(TrackSelectionParameters trackSelectionParameters)

Sets the currently active TrackSelectionParameters.

public SimpleBasePlayer.State.BuildersetVideoSize(VideoSize videoSize)

Sets the current video size.

public SimpleBasePlayer.State.BuildersetVolume(float volume)

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

from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructors

public Builder()

Creates the builder.

Methods

public SimpleBasePlayer.State.Builder setAvailableCommands(Player.Commands availableCommands)

Sets the available .

Parameters:

availableCommands: The available .

Returns:

This builder.

public SimpleBasePlayer.State.Builder setPlayWhenReady(boolean playWhenReady, int playWhenReadyChangeReason)

Sets whether playback should proceed when ready and not suppressed.

Parameters:

playWhenReady: Whether playback should proceed when ready and not suppressed.
playWhenReadyChangeReason: The for changing the value.

Returns:

This builder.

public SimpleBasePlayer.State.Builder setPlaybackState(int playbackState)

Sets the state of the player.

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

Parameters:

playbackState: The state of the player.

Returns:

This builder.

public SimpleBasePlayer.State.Builder setPlaybackSuppressionReason(int playbackSuppressionReason)

Sets the reason why playback is suppressed even if SimpleBasePlayer.getPlayWhenReady() is true.

Parameters:

playbackSuppressionReason: The Player.PlaybackSuppressionReason why playback is suppressed even if SimpleBasePlayer.getPlayWhenReady() is true.

Returns:

This builder.

public SimpleBasePlayer.State.Builder setPlayerError(PlaybackException playerError)

Sets last error that caused playback to fail, or null if there was no error.

The playback state must be set to Player.STATE_IDLE while an error is set.

Parameters:

playerError: The last error that caused playback to fail, or null if there was no error.

Returns:

This builder.

public SimpleBasePlayer.State.Builder setRepeatMode(int repeatMode)

Sets the used for playback.

Parameters:

repeatMode: The used for playback.

Returns:

This builder.

public SimpleBasePlayer.State.Builder setShuffleModeEnabled(boolean shuffleModeEnabled)

Sets whether shuffling of media items is enabled.

Parameters:

shuffleModeEnabled: Whether shuffling of media items is enabled.

Returns:

This builder.

public SimpleBasePlayer.State.Builder setIsLoading(boolean isLoading)

Sets whether the player is currently loading its source.

The player can not be marked as loading if the state is Player.STATE_IDLE or Player.STATE_ENDED.

Parameters:

isLoading: Whether the player is currently loading its source.

Returns:

This builder.

public SimpleBasePlayer.State.Builder setSeekBackIncrementMs(long seekBackIncrementMs)

Sets the Player.seekBack() increment in milliseconds.

Parameters:

seekBackIncrementMs: The Player.seekBack() increment in milliseconds.

Returns:

This builder.

public SimpleBasePlayer.State.Builder setSeekForwardIncrementMs(long seekForwardIncrementMs)

Sets the Player.seekForward() increment in milliseconds.

Parameters:

seekForwardIncrementMs: The Player.seekForward() increment in milliseconds.

Returns:

This builder.

public SimpleBasePlayer.State.Builder setMaxSeekToPreviousPositionMs(long maxSeekToPreviousPositionMs)

Sets the maximum position for which BasePlayer.seekToPrevious() seeks to the previous item, in milliseconds.

Parameters:

maxSeekToPreviousPositionMs: The maximum position for which BasePlayer.seekToPrevious() seeks to the previous item, in milliseconds.

Returns:

This builder.

public SimpleBasePlayer.State.Builder setPlaybackParameters(PlaybackParameters playbackParameters)

Sets the currently active PlaybackParameters.

Parameters:

playbackParameters: The currently active PlaybackParameters.

Returns:

This builder.

public SimpleBasePlayer.State.Builder setTrackSelectionParameters(TrackSelectionParameters trackSelectionParameters)

Sets the currently active TrackSelectionParameters.

Parameters:

trackSelectionParameters: The currently active TrackSelectionParameters.

Returns:

This builder.

public SimpleBasePlayer.State.Builder setAudioAttributes(AudioAttributes audioAttributes)

Sets the current AudioAttributes.

Parameters:

audioAttributes: The current AudioAttributes.

Returns:

This builder.

public SimpleBasePlayer.State.Builder setVolume(float volume)

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

Parameters:

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

Returns:

This builder.

public SimpleBasePlayer.State.Builder setVideoSize(VideoSize videoSize)

Sets the current video size.

Parameters:

videoSize: The current video size.

Returns:

This builder.

public SimpleBasePlayer.State.Builder setCurrentCues(CueGroup currentCues)

Sets the current cues.

Parameters:

currentCues: The current cues.

Returns:

This builder.

public SimpleBasePlayer.State.Builder setDeviceInfo(DeviceInfo deviceInfo)

Sets the DeviceInfo.

Parameters:

deviceInfo: The DeviceInfo.

Returns:

This builder.

public SimpleBasePlayer.State.Builder setDeviceVolume(int deviceVolume)

Sets the current device volume.

Parameters:

deviceVolume: The current device volume.

Returns:

This builder.

public SimpleBasePlayer.State.Builder setIsDeviceMuted(boolean isDeviceMuted)

Sets whether the device is muted.

Parameters:

isDeviceMuted: Whether the device is muted.

Returns:

This builder.

public SimpleBasePlayer.State.Builder setSurfaceSize(Size surfaceSize)

Sets the size of the surface onto which the video is being rendered.

Parameters:

surfaceSize: The surface size. Dimensions may be C.LENGTH_UNSET if unknown, or 0 if the video is not rendered onto a surface.

Returns:

This builder.

public SimpleBasePlayer.State.Builder setNewlyRenderedFirstFrame(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.

Note: As this will trigger a event, the flag should only be set for the first SimpleBasePlayer.State update after the first frame was rendered.

Parameters:

newlyRenderedFirstFrame: Whether the first frame was newly rendered.

Returns:

This builder.

public SimpleBasePlayer.State.Builder setTimedMetadata(Metadata timedMetadata)

Sets the most recent timed Metadata.

Metadata with a Metadata.presentationTimeUs of C.TIME_UNSET will not be forwarded to listeners.

Parameters:

timedMetadata: The most recent timed Metadata.

Returns:

This builder.

public SimpleBasePlayer.State.Builder setPlaylist(java.util.List<SimpleBasePlayer.MediaItemData> playlist)

Sets the playlist as a list of media items.

All items must have unique UIDs.

This call replaces any previous playlist set via SimpleBasePlayer.State.Builder.setPlaylist(Timeline, Tracks, MediaMetadata).

Parameters:

playlist: The list of media items in the playlist.

Returns:

This builder.

public SimpleBasePlayer.State.Builder setPlaylist(Timeline timeline, Tracks currentTracks, MediaMetadata currentMetadata)

Sets the playlist as a Timeline with information about the current Tracks and MediaMetadata.

This call replaces any previous playlist set via SimpleBasePlayer.State.Builder.setPlaylist(List).

Parameters:

timeline: The Timeline containing the playlist data.
currentTracks: The Tracks of the current media item.
currentMetadata: The combined MediaMetadata of the current media item. If null, the current metadata is assumed to be the combination of the MediaItem metadata and the metadata of the selected Formats.

Returns:

This builder.

public SimpleBasePlayer.State.Builder setPlaylistMetadata(MediaMetadata playlistMetadata)

Sets the playlist MediaMetadata.

Parameters:

playlistMetadata: The playlist MediaMetadata.

Returns:

This builder.

public SimpleBasePlayer.State.Builder setCurrentMediaItemIndex(int currentMediaItemIndex)

Sets the current media item index.

The media item index must be less than the number of media items in the playlist, if set.

Parameters:

currentMediaItemIndex: The current media item index, or C.INDEX_UNSET to assume the default first item in the playlist.

Returns:

This builder.

public SimpleBasePlayer.State.Builder setCurrentAd(int adGroupIndex, int adIndexInAdGroup)

Sets the current ad indices, or C.INDEX_UNSET if no ad is playing.

Either both indices need to be C.INDEX_UNSET or both are not C.INDEX_UNSET.

Ads indices can only be set if there is a corresponding AdPlaybackState defined in the current period.

Parameters:

adGroupIndex: The current ad group index, or C.INDEX_UNSET if no ad is playing.
adIndexInAdGroup: The current ad index in the ad group, or C.INDEX_UNSET if no ad is playing.

Returns:

This builder.

public SimpleBasePlayer.State.Builder setContentPositionMs(long positionMs)

Sets the current content playback position in milliseconds.

This position will be converted to an advancing SimpleBasePlayer.PositionSupplier if the overall state indicates an advancing playback position.

This method overrides any other SimpleBasePlayer.PositionSupplier set via SimpleBasePlayer.State.Builder.

Parameters:

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

Returns:

This builder.

public SimpleBasePlayer.State.Builder setContentPositionMs(SimpleBasePlayer.PositionSupplier contentPositionMsSupplier)

Sets the SimpleBasePlayer.PositionSupplier for the current content playback position in milliseconds.

The supplier is expected to return the updated position on every call if the playback is advancing, for example by using SimpleBasePlayer.PositionSupplier.getExtrapolating(long, float).

This method overrides any other position set via SimpleBasePlayer.State.Builder.setContentPositionMs(long).

Parameters:

contentPositionMsSupplier: The SimpleBasePlayer.PositionSupplier for the current content playback position in milliseconds, or C.TIME_UNSET to indicate the default start position.

Returns:

This builder.

public SimpleBasePlayer.State.Builder setAdPositionMs(long positionMs)

Sets the current ad playback position in milliseconds. The value is unused if no ad is playing.

This position will be converted to an advancing SimpleBasePlayer.PositionSupplier if the overall state indicates an advancing ad playback position.

This method overrides any other SimpleBasePlayer.PositionSupplier set via SimpleBasePlayer.State.Builder.

Parameters:

positionMs: The current ad playback position in milliseconds.

Returns:

This builder.

public SimpleBasePlayer.State.Builder setAdPositionMs(SimpleBasePlayer.PositionSupplier adPositionMsSupplier)

Sets the SimpleBasePlayer.PositionSupplier for the current ad playback position in milliseconds. The value is unused if no ad is playing.

The supplier is expected to return the updated position on every call if the playback is advancing, for example by using SimpleBasePlayer.PositionSupplier.getExtrapolating(long, float).

This method overrides any other position set via SimpleBasePlayer.State.Builder.setAdPositionMs(long).

Parameters:

adPositionMsSupplier: The SimpleBasePlayer.PositionSupplier for the current ad playback position in milliseconds. The value is unused if no ad is playing.

Returns:

This builder.

public SimpleBasePlayer.State.Builder setContentBufferedPositionMs(SimpleBasePlayer.PositionSupplier contentBufferedPositionMsSupplier)

Sets the SimpleBasePlayer.PositionSupplier for the estimated position up to which the currently playing content is buffered, in milliseconds.

Parameters:

contentBufferedPositionMsSupplier: The SimpleBasePlayer.PositionSupplier for the estimated position up to which the currently playing content is buffered, in milliseconds, or C.TIME_UNSET to indicate the default start position.

Returns:

This builder.

public SimpleBasePlayer.State.Builder setAdBufferedPositionMs(SimpleBasePlayer.PositionSupplier adBufferedPositionMsSupplier)

Sets the SimpleBasePlayer.PositionSupplier for the estimated position up to which the currently playing ad is buffered, in milliseconds. The value is unused if no ad is playing.

Parameters:

adBufferedPositionMsSupplier: The SimpleBasePlayer.PositionSupplier for the estimated position up to which the currently playing ad is buffered, in milliseconds. The value is unused if no ad is playing.

Returns:

This builder.

public SimpleBasePlayer.State.Builder setTotalBufferedDurationMs(SimpleBasePlayer.PositionSupplier totalBufferedDurationMsSupplier)

Sets the SimpleBasePlayer.PositionSupplier for the estimated total buffered duration in milliseconds.

Parameters:

totalBufferedDurationMsSupplier: The SimpleBasePlayer.PositionSupplier for the estimated total buffered duration in milliseconds.

Returns:

This builder.

public SimpleBasePlayer.State.Builder setPositionDiscontinuity(int positionDiscontinuityReason, long discontinuityPositionMs)

Signals that a position discontinuity happened since the last player update and sets the reason for it.

Parameters:

positionDiscontinuityReason: The reason for the discontinuity.
discontinuityPositionMs: The position, in milliseconds, in the current content or ad from which playback continues after the discontinuity.

Returns:

This builder.

See also: SimpleBasePlayer.State.Builder.clearPositionDiscontinuity()

public SimpleBasePlayer.State.Builder clearPositionDiscontinuity()

Clears a previously set position discontinuity signal.

Returns:

This builder.

See also: SimpleBasePlayer.State.Builder.hasPositionDiscontinuity

public SimpleBasePlayer.State build()

Builds the SimpleBasePlayer.State.