Class SimpleBasePlayer.State.Builder
- java.lang.Object
-
- com.google.android.exoplayer2.SimpleBasePlayer.State.Builder
-
- Enclosing class:
- SimpleBasePlayer.State
public static final class SimpleBasePlayer.State.Builder extends Object
A builder forSimpleBasePlayer.State
objects.
-
-
Constructor Summary
Constructors Constructor Description Builder()
Creates the builder.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SimpleBasePlayer.State
build()
Builds theSimpleBasePlayer.State
.SimpleBasePlayer.State.Builder
clearPositionDiscontinuity()
Clears a previously set position discontinuity signal.SimpleBasePlayer.State.Builder
setAdBufferedPositionMs(SimpleBasePlayer.PositionSupplier adBufferedPositionMsSupplier)
Sets theSimpleBasePlayer.PositionSupplier
for the estimated position up to which the currently playing ad is buffered, in milliseconds.SimpleBasePlayer.State.Builder
setAdPositionMs(long positionMs)
Sets the current ad playback position in milliseconds.SimpleBasePlayer.State.Builder
setAdPositionMs(SimpleBasePlayer.PositionSupplier adPositionMsSupplier)
Sets theSimpleBasePlayer.PositionSupplier
for the current ad playback position in milliseconds.SimpleBasePlayer.State.Builder
setAudioAttributes(AudioAttributes audioAttributes)
Sets the currentAudioAttributes
.SimpleBasePlayer.State.Builder
setAvailableCommands(Player.Commands availableCommands)
Sets the availablePlayer.Commands
.SimpleBasePlayer.State.Builder
setContentBufferedPositionMs(SimpleBasePlayer.PositionSupplier contentBufferedPositionMsSupplier)
Sets theSimpleBasePlayer.PositionSupplier
for the estimated position up to which the currently playing content is buffered, in milliseconds.SimpleBasePlayer.State.Builder
setContentPositionMs(long positionMs)
Sets the current content playback position in milliseconds.SimpleBasePlayer.State.Builder
setContentPositionMs(SimpleBasePlayer.PositionSupplier contentPositionMsSupplier)
Sets theSimpleBasePlayer.PositionSupplier
for the current content playback position in milliseconds.SimpleBasePlayer.State.Builder
setCurrentAd(int adGroupIndex, int adIndexInAdGroup)
Sets the current ad indices, orC.INDEX_UNSET
if no ad is playing.SimpleBasePlayer.State.Builder
setCurrentCues(CueGroup currentCues)
Sets the current cues.SimpleBasePlayer.State.Builder
setCurrentMediaItemIndex(int currentMediaItemIndex)
Sets the current media item index.SimpleBasePlayer.State.Builder
setDeviceInfo(DeviceInfo deviceInfo)
Sets theDeviceInfo
.SimpleBasePlayer.State.Builder
setDeviceVolume(int deviceVolume)
Sets the current device volume.SimpleBasePlayer.State.Builder
setIsDeviceMuted(boolean isDeviceMuted)
Sets whether the device is muted.SimpleBasePlayer.State.Builder
setIsLoading(boolean isLoading)
Sets whether the player is currently loading its source.SimpleBasePlayer.State.Builder
setMaxSeekToPreviousPositionMs(long maxSeekToPreviousPositionMs)
Sets the maximum position for whichBasePlayer.seekToPrevious()
seeks to the previous item, in milliseconds.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.SimpleBasePlayer.State.Builder
setPlaybackParameters(PlaybackParameters playbackParameters)
Sets the currently activePlaybackParameters
.SimpleBasePlayer.State.Builder
setPlaybackState(@com.google.android.exoplayer2.Player.State int playbackState)
Sets the state of the player.SimpleBasePlayer.State.Builder
setPlaybackSuppressionReason(@com.google.android.exoplayer2.Player.PlaybackSuppressionReason int playbackSuppressionReason)
Sets the reason why playback is suppressed even ifSimpleBasePlayer.getPlayWhenReady()
is true.SimpleBasePlayer.State.Builder
setPlayerError(PlaybackException playerError)
Sets last error that caused playback to fail, or null if there was no error.SimpleBasePlayer.State.Builder
setPlaylist(List<SimpleBasePlayer.MediaItemData> playlist)
Sets the list ofmedia items
in the playlist.SimpleBasePlayer.State.Builder
setPlaylistMetadata(MediaMetadata playlistMetadata)
Sets the playlistMediaMetadata
.SimpleBasePlayer.State.Builder
setPlayWhenReady(boolean playWhenReady, @com.google.android.exoplayer2.Player.PlayWhenReadyChangeReason int playWhenReadyChangeReason)
Sets whether playback should proceed when ready and not suppressed.SimpleBasePlayer.State.Builder
setPositionDiscontinuity(@com.google.android.exoplayer2.Player.DiscontinuityReason int positionDiscontinuityReason, long discontinuityPositionMs)
Signals that a position discontinuity happened since the last player update and sets the reason for it.SimpleBasePlayer.State.Builder
setRepeatMode(@com.google.android.exoplayer2.Player.RepeatMode int repeatMode)
Sets thePlayer.RepeatMode
used for playback.SimpleBasePlayer.State.Builder
setSeekBackIncrementMs(long seekBackIncrementMs)
Sets thePlayer.seekBack()
increment in milliseconds.SimpleBasePlayer.State.Builder
setSeekForwardIncrementMs(long seekForwardIncrementMs)
Sets thePlayer.seekForward()
increment in milliseconds.SimpleBasePlayer.State.Builder
setShuffleModeEnabled(boolean shuffleModeEnabled)
Sets whether shuffling of media items is enabled.SimpleBasePlayer.State.Builder
setSurfaceSize(Size surfaceSize)
Sets the size of the surface onto which the video is being rendered.SimpleBasePlayer.State.Builder
setTimedMetadata(Metadata timedMetadata)
Sets the most recent timedMetadata
.SimpleBasePlayer.State.Builder
setTotalBufferedDurationMs(SimpleBasePlayer.PositionSupplier totalBufferedDurationMsSupplier)
Sets theSimpleBasePlayer.PositionSupplier
for the estimated total buffered duration in milliseconds.SimpleBasePlayer.State.Builder
setTrackSelectionParameters(TrackSelectionParameters trackSelectionParameters)
Sets the currently activeTrackSelectionParameters
.SimpleBasePlayer.State.Builder
setVideoSize(VideoSize videoSize)
Sets the current video size.SimpleBasePlayer.State.Builder
setVolume(float volume)
Sets the current audio volume, with 0 being silence and 1 being unity gain (signal unchanged).
-
-
-
Method Detail
-
setAvailableCommands
@CanIgnoreReturnValue public SimpleBasePlayer.State.Builder setAvailableCommands(Player.Commands availableCommands)
Sets the availablePlayer.Commands
.- Parameters:
availableCommands
- The availablePlayer.Commands
.- Returns:
- This builder.
-
setPlayWhenReady
@CanIgnoreReturnValue public SimpleBasePlayer.State.Builder setPlayWhenReady(boolean playWhenReady, @PlayWhenReadyChangeReason @com.google.android.exoplayer2.Player.PlayWhenReadyChangeReason 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 reason for changing the value.- Returns:
- This builder.
-
setPlaybackState
@CanIgnoreReturnValue public SimpleBasePlayer.State.Builder setPlaybackState(@State @com.google.android.exoplayer2.Player.State int playbackState)
Sets the state of the player.If the playlist is empty, the state must be either
Player.STATE_IDLE
orPlayer.STATE_ENDED
.- Parameters:
playbackState
- The state of the player.- Returns:
- This builder.
-
setPlaybackSuppressionReason
@CanIgnoreReturnValue public SimpleBasePlayer.State.Builder setPlaybackSuppressionReason(@PlaybackSuppressionReason @com.google.android.exoplayer2.Player.PlaybackSuppressionReason int playbackSuppressionReason)
Sets the reason why playback is suppressed even ifSimpleBasePlayer.getPlayWhenReady()
is true.- Parameters:
playbackSuppressionReason
- ThePlayer.PlaybackSuppressionReason
why playback is suppressed even ifSimpleBasePlayer.getPlayWhenReady()
is true.- Returns:
- This builder.
-
setPlayerError
@CanIgnoreReturnValue public SimpleBasePlayer.State.Builder setPlayerError(@Nullable 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.
-
setRepeatMode
@CanIgnoreReturnValue public SimpleBasePlayer.State.Builder setRepeatMode(@RepeatMode @com.google.android.exoplayer2.Player.RepeatMode int repeatMode)
Sets thePlayer.RepeatMode
used for playback.- Parameters:
repeatMode
- ThePlayer.RepeatMode
used for playback.- Returns:
- This builder.
-
setShuffleModeEnabled
@CanIgnoreReturnValue 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.
-
setIsLoading
@CanIgnoreReturnValue 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
orPlayer.STATE_ENDED
.- Parameters:
isLoading
- Whether the player is currently loading its source.- Returns:
- This builder.
-
setSeekBackIncrementMs
@CanIgnoreReturnValue public SimpleBasePlayer.State.Builder setSeekBackIncrementMs(long seekBackIncrementMs)
Sets thePlayer.seekBack()
increment in milliseconds.- Parameters:
seekBackIncrementMs
- ThePlayer.seekBack()
increment in milliseconds.- Returns:
- This builder.
-
setSeekForwardIncrementMs
@CanIgnoreReturnValue public SimpleBasePlayer.State.Builder setSeekForwardIncrementMs(long seekForwardIncrementMs)
Sets thePlayer.seekForward()
increment in milliseconds.- Parameters:
seekForwardIncrementMs
- ThePlayer.seekForward()
increment in milliseconds.- Returns:
- This builder.
-
setMaxSeekToPreviousPositionMs
@CanIgnoreReturnValue public SimpleBasePlayer.State.Builder setMaxSeekToPreviousPositionMs(long maxSeekToPreviousPositionMs)
Sets the maximum position for whichBasePlayer.seekToPrevious()
seeks to the previous item, in milliseconds.- Parameters:
maxSeekToPreviousPositionMs
- The maximum position for whichBasePlayer.seekToPrevious()
seeks to the previous item, in milliseconds.- Returns:
- This builder.
-
setPlaybackParameters
@CanIgnoreReturnValue public SimpleBasePlayer.State.Builder setPlaybackParameters(PlaybackParameters playbackParameters)
Sets the currently activePlaybackParameters
.- Parameters:
playbackParameters
- The currently activePlaybackParameters
.- Returns:
- This builder.
-
setTrackSelectionParameters
@CanIgnoreReturnValue public SimpleBasePlayer.State.Builder setTrackSelectionParameters(TrackSelectionParameters trackSelectionParameters)
Sets the currently activeTrackSelectionParameters
.- Parameters:
trackSelectionParameters
- The currently activeTrackSelectionParameters
.- Returns:
- This builder.
-
setAudioAttributes
@CanIgnoreReturnValue public SimpleBasePlayer.State.Builder setAudioAttributes(AudioAttributes audioAttributes)
Sets the currentAudioAttributes
.- Parameters:
audioAttributes
- The currentAudioAttributes
.- Returns:
- This builder.
-
setVolume
@CanIgnoreReturnValue public SimpleBasePlayer.State.Builder setVolume(@FloatRange(from=0.0,to=1.0) 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.
-
setVideoSize
@CanIgnoreReturnValue public SimpleBasePlayer.State.Builder setVideoSize(VideoSize videoSize)
Sets the current video size.- Parameters:
videoSize
- The current video size.- Returns:
- This builder.
-
setCurrentCues
@CanIgnoreReturnValue public SimpleBasePlayer.State.Builder setCurrentCues(CueGroup currentCues)
Sets the current cues.- Parameters:
currentCues
- The current cues.- Returns:
- This builder.
-
setDeviceInfo
@CanIgnoreReturnValue public SimpleBasePlayer.State.Builder setDeviceInfo(DeviceInfo deviceInfo)
Sets theDeviceInfo
.- Parameters:
deviceInfo
- TheDeviceInfo
.- Returns:
- This builder.
-
setDeviceVolume
@CanIgnoreReturnValue public SimpleBasePlayer.State.Builder setDeviceVolume(@IntRange(from=0L) int deviceVolume)
Sets the current device volume.- Parameters:
deviceVolume
- The current device volume.- Returns:
- This builder.
-
setIsDeviceMuted
@CanIgnoreReturnValue public SimpleBasePlayer.State.Builder setIsDeviceMuted(boolean isDeviceMuted)
Sets whether the device is muted.- Parameters:
isDeviceMuted
- Whether the device is muted.- Returns:
- This builder.
-
setSurfaceSize
@CanIgnoreReturnValue 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 beC.LENGTH_UNSET
if unknown, or 0 if the video is not rendered onto a surface.- Returns:
- This builder.
-
setNewlyRenderedFirstFrame
@CanIgnoreReturnValue 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
Player.Listener.onRenderedFirstFrame()
event, the flag should only be set for the firstSimpleBasePlayer.State
update after the first frame was rendered.- Parameters:
newlyRenderedFirstFrame
- Whether the first frame was newly rendered.- Returns:
- This builder.
-
setTimedMetadata
@CanIgnoreReturnValue public SimpleBasePlayer.State.Builder setTimedMetadata(Metadata timedMetadata)
Sets the most recent timedMetadata
.Metadata with a
Metadata.presentationTimeUs
ofC.TIME_UNSET
will not be forwarded to listeners.- Parameters:
timedMetadata
- The most recent timedMetadata
.- Returns:
- This builder.
-
setPlaylist
@CanIgnoreReturnValue public SimpleBasePlayer.State.Builder setPlaylist(List<SimpleBasePlayer.MediaItemData> playlist)
Sets the list ofmedia items
in the playlist.All items must have unique UIDs.
- Parameters:
playlist
- The list ofmedia items
in the playlist.- Returns:
- This builder.
-
setPlaylistMetadata
@CanIgnoreReturnValue public SimpleBasePlayer.State.Builder setPlaylistMetadata(MediaMetadata playlistMetadata)
Sets the playlistMediaMetadata
.- Parameters:
playlistMetadata
- The playlistMediaMetadata
.- Returns:
- This builder.
-
setCurrentMediaItemIndex
@CanIgnoreReturnValue 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, orC.INDEX_UNSET
to assume the default first item in the playlist.- Returns:
- This builder.
-
setCurrentAd
@CanIgnoreReturnValue public SimpleBasePlayer.State.Builder setCurrentAd(int adGroupIndex, int adIndexInAdGroup)
Sets the current ad indices, orC.INDEX_UNSET
if no ad is playing.Either both indices need to be
C.INDEX_UNSET
or both are notC.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, orC.INDEX_UNSET
if no ad is playing.adIndexInAdGroup
- The current ad index in the ad group, orC.INDEX_UNSET
if no ad is playing.- Returns:
- This builder.
-
setContentPositionMs
@CanIgnoreReturnValue 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 viasetContentPositionMs(PositionSupplier)
.- Parameters:
positionMs
- The current content playback position in milliseconds, orC.TIME_UNSET
to indicate the default start position.- Returns:
- This builder.
-
setContentPositionMs
@CanIgnoreReturnValue public SimpleBasePlayer.State.Builder setContentPositionMs(SimpleBasePlayer.PositionSupplier contentPositionMsSupplier)
Sets theSimpleBasePlayer.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
setContentPositionMs(long)
.- Parameters:
contentPositionMsSupplier
- TheSimpleBasePlayer.PositionSupplier
for the current content playback position in milliseconds, orC.TIME_UNSET
to indicate the default start position.- Returns:
- This builder.
-
setAdPositionMs
@CanIgnoreReturnValue 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 viasetAdPositionMs(PositionSupplier)
.- Parameters:
positionMs
- The current ad playback position in milliseconds.- Returns:
- This builder.
-
setAdPositionMs
@CanIgnoreReturnValue public SimpleBasePlayer.State.Builder setAdPositionMs(SimpleBasePlayer.PositionSupplier adPositionMsSupplier)
Sets theSimpleBasePlayer.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
setAdPositionMs(long)
.- Parameters:
adPositionMsSupplier
- TheSimpleBasePlayer.PositionSupplier
for the current ad playback position in milliseconds. The value is unused if no ad is playing.- Returns:
- This builder.
-
setContentBufferedPositionMs
@CanIgnoreReturnValue public SimpleBasePlayer.State.Builder setContentBufferedPositionMs(SimpleBasePlayer.PositionSupplier contentBufferedPositionMsSupplier)
Sets theSimpleBasePlayer.PositionSupplier
for the estimated position up to which the currently playing content is buffered, in milliseconds.- Parameters:
contentBufferedPositionMsSupplier
- TheSimpleBasePlayer.PositionSupplier
for the estimated position up to which the currently playing content is buffered, in milliseconds, orC.TIME_UNSET
to indicate the default start position.- Returns:
- This builder.
-
setAdBufferedPositionMs
@CanIgnoreReturnValue public SimpleBasePlayer.State.Builder setAdBufferedPositionMs(SimpleBasePlayer.PositionSupplier adBufferedPositionMsSupplier)
Sets theSimpleBasePlayer.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
- TheSimpleBasePlayer.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.
-
setTotalBufferedDurationMs
@CanIgnoreReturnValue public SimpleBasePlayer.State.Builder setTotalBufferedDurationMs(SimpleBasePlayer.PositionSupplier totalBufferedDurationMsSupplier)
Sets theSimpleBasePlayer.PositionSupplier
for the estimated total buffered duration in milliseconds.- Parameters:
totalBufferedDurationMsSupplier
- TheSimpleBasePlayer.PositionSupplier
for the estimated total buffered duration in milliseconds.- Returns:
- This builder.
-
setPositionDiscontinuity
@CanIgnoreReturnValue public SimpleBasePlayer.State.Builder setPositionDiscontinuity(@DiscontinuityReason @com.google.android.exoplayer2.Player.DiscontinuityReason 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:
clearPositionDiscontinuity()
-
clearPositionDiscontinuity
@CanIgnoreReturnValue public SimpleBasePlayer.State.Builder clearPositionDiscontinuity()
Clears a previously set position discontinuity signal.- Returns:
- This builder.
- See Also:
hasPositionDiscontinuity
-
build
public SimpleBasePlayer.State build()
Builds theSimpleBasePlayer.State
.
-
-