SimpleBasePlayer.State.Builder


class SimpleBasePlayer.State.Builder


A builder for State objects.

Summary

Public constructors

Creates the builder.

Public functions

SimpleBasePlayer.State!

Builds the State.

SimpleBasePlayer.State.Builder!

Clears a previously set position discontinuity signal.

SimpleBasePlayer.State.Builder!

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

SimpleBasePlayer.State.Builder!

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

SimpleBasePlayer.State.Builder!

Sets the current ad playback position in milliseconds.

SimpleBasePlayer.State.Builder!

Sets the current AudioAttributes.

SimpleBasePlayer.State.Builder!

Sets the available Commands.

SimpleBasePlayer.State.Builder!

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

SimpleBasePlayer.State.Builder!

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

SimpleBasePlayer.State.Builder!

Sets the current content playback position in milliseconds.

SimpleBasePlayer.State.Builder!
@CanIgnoreReturnValue
setCurrentAd(adGroupIndex: Int, adIndexInAdGroup: Int)

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

SimpleBasePlayer.State.Builder!

Sets the current cues.

SimpleBasePlayer.State.Builder!

Sets the current media item index.

SimpleBasePlayer.State.Builder!

Sets the DeviceInfo.

SimpleBasePlayer.State.Builder!
@CanIgnoreReturnValue
setDeviceVolume(deviceVolume: @IntRange(from = 0) Int)

Sets the current device volume.

SimpleBasePlayer.State.Builder!

Sets whether the device is muted.

SimpleBasePlayer.State.Builder!

Sets whether the player is currently loading its source.

SimpleBasePlayer.State.Builder!

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

SimpleBasePlayer.State.Builder!

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!
@CanIgnoreReturnValue
setPlayWhenReady(
    playWhenReady: Boolean,
    @Player.PlayWhenReadyChangeReason playWhenReadyChangeReason: Int
)

Sets whether playback should proceed when ready and not suppressed.

SimpleBasePlayer.State.Builder!

Sets the currently active PlaybackParameters.

SimpleBasePlayer.State.Builder!

Sets the state of the player.

SimpleBasePlayer.State.Builder!

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

SimpleBasePlayer.State.Builder!

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

SimpleBasePlayer.State.Builder!

Sets the playlist as a list of media items.

SimpleBasePlayer.State.Builder!
@CanIgnoreReturnValue
setPlaylist(
    timeline: Timeline!,
    currentTracks: Tracks!,
    currentMetadata: MediaMetadata?
)

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

SimpleBasePlayer.State.Builder!

Sets the playlist MediaMetadata.

SimpleBasePlayer.State.Builder!
@CanIgnoreReturnValue
setPositionDiscontinuity(
    @Player.DiscontinuityReason positionDiscontinuityReason: Int,
    discontinuityPositionMs: Long
)

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

SimpleBasePlayer.State.Builder!

Sets the RepeatMode used for playback.

SimpleBasePlayer.State.Builder!

Sets the seekBack increment in milliseconds.

SimpleBasePlayer.State.Builder!

Sets the seekForward increment in milliseconds.

SimpleBasePlayer.State.Builder!

Sets whether shuffling of media items is enabled.

SimpleBasePlayer.State.Builder!

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

SimpleBasePlayer.State.Builder!

Sets the most recent timed Metadata.

SimpleBasePlayer.State.Builder!

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

SimpleBasePlayer.State.Builder!

Sets the currently active TrackSelectionParameters.

SimpleBasePlayer.State.Builder!

Sets the current video size.

SimpleBasePlayer.State.Builder!
@CanIgnoreReturnValue
setVolume(volume: @FloatRange(from = 0, to = 1.0) Float)

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

Public constructors

Builder

Builder()

Creates the builder.

Public functions

build

fun build(): SimpleBasePlayer.State!

Builds the State.

clearPositionDiscontinuity

@CanIgnoreReturnValue
fun clearPositionDiscontinuity(): SimpleBasePlayer.State.Builder!

Clears a previously set position discontinuity signal.

Returns
SimpleBasePlayer.State.Builder!

This builder.

setAdBufferedPositionMs

@CanIgnoreReturnValue
fun setAdBufferedPositionMs(
    adBufferedPositionMsSupplier: SimpleBasePlayer.PositionSupplier!
): SimpleBasePlayer.State.Builder!

Sets the 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: SimpleBasePlayer.PositionSupplier!

The 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
SimpleBasePlayer.State.Builder!

This builder.

setAdPositionMs

@CanIgnoreReturnValue
fun setAdPositionMs(
    adPositionMsSupplier: SimpleBasePlayer.PositionSupplier!
): SimpleBasePlayer.State.Builder!

Sets the 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 getExtrapolating.

This method overrides any other position set via setAdPositionMs.

Parameters
adPositionMsSupplier: SimpleBasePlayer.PositionSupplier!

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

Returns
SimpleBasePlayer.State.Builder!

This builder.

setAdPositionMs

@CanIgnoreReturnValue
fun setAdPositionMs(positionMs: Long): SimpleBasePlayer.State.Builder!

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 PositionSupplier if the overall state indicates an advancing ad playback position.

This method overrides any other PositionSupplier set via setAdPositionMs.

Parameters
positionMs: Long

The current ad playback position in milliseconds.

Returns
SimpleBasePlayer.State.Builder!

This builder.

setAudioAttributes

@CanIgnoreReturnValue
fun setAudioAttributes(audioAttributes: AudioAttributes!): SimpleBasePlayer.State.Builder!

Sets the current AudioAttributes.

Parameters
audioAttributes: AudioAttributes!

The current AudioAttributes.

Returns
SimpleBasePlayer.State.Builder!

This builder.

setAvailableCommands

@CanIgnoreReturnValue
fun setAvailableCommands(availableCommands: Player.Commands!): SimpleBasePlayer.State.Builder!

Sets the available Commands.

Parameters
availableCommands: Player.Commands!

The available Commands.

Returns
SimpleBasePlayer.State.Builder!

This builder.

setContentBufferedPositionMs

@CanIgnoreReturnValue
fun setContentBufferedPositionMs(
    contentBufferedPositionMsSupplier: SimpleBasePlayer.PositionSupplier!
): SimpleBasePlayer.State.Builder!

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

Parameters
contentBufferedPositionMsSupplier: SimpleBasePlayer.PositionSupplier!

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

Returns
SimpleBasePlayer.State.Builder!

This builder.

setContentPositionMs

@CanIgnoreReturnValue
fun setContentPositionMs(
    contentPositionMsSupplier: SimpleBasePlayer.PositionSupplier!
): SimpleBasePlayer.State.Builder!

Sets the 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 getExtrapolating.

This method overrides any other position set via setContentPositionMs.

Parameters
contentPositionMsSupplier: SimpleBasePlayer.PositionSupplier!

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

Returns
SimpleBasePlayer.State.Builder!

This builder.

setContentPositionMs

@CanIgnoreReturnValue
fun setContentPositionMs(positionMs: Long): SimpleBasePlayer.State.Builder!

Sets the current content playback position in milliseconds.

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

This method overrides any other PositionSupplier set via setContentPositionMs.

Parameters
positionMs: Long

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

Returns
SimpleBasePlayer.State.Builder!

This builder.

setCurrentAd

@CanIgnoreReturnValue
fun setCurrentAd(adGroupIndex: Int, adIndexInAdGroup: Int): SimpleBasePlayer.State.Builder!

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

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

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

Parameters
adGroupIndex: Int

The current ad group index, or INDEX_UNSET if no ad is playing.

adIndexInAdGroup: Int

The current ad index in the ad group, or INDEX_UNSET if no ad is playing.

Returns
SimpleBasePlayer.State.Builder!

This builder.

setCurrentCues

@CanIgnoreReturnValue
fun setCurrentCues(currentCues: CueGroup!): SimpleBasePlayer.State.Builder!

Sets the current cues.

Parameters
currentCues: CueGroup!

The current cues.

Returns
SimpleBasePlayer.State.Builder!

This builder.

setCurrentMediaItemIndex

@CanIgnoreReturnValue
fun setCurrentMediaItemIndex(currentMediaItemIndex: Int): SimpleBasePlayer.State.Builder!

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: Int

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

Returns
SimpleBasePlayer.State.Builder!

This builder.

setDeviceInfo

@CanIgnoreReturnValue
fun setDeviceInfo(deviceInfo: DeviceInfo!): SimpleBasePlayer.State.Builder!

Sets the DeviceInfo.

Parameters
deviceInfo: DeviceInfo!

The DeviceInfo.

Returns
SimpleBasePlayer.State.Builder!

This builder.

setDeviceVolume

@CanIgnoreReturnValue
fun setDeviceVolume(deviceVolume: @IntRange(from = 0) Int): SimpleBasePlayer.State.Builder!

Sets the current device volume.

Parameters
deviceVolume: @IntRange(from = 0) Int

The current device volume.

Returns
SimpleBasePlayer.State.Builder!

This builder.

setIsDeviceMuted

@CanIgnoreReturnValue
fun setIsDeviceMuted(isDeviceMuted: Boolean): SimpleBasePlayer.State.Builder!

Sets whether the device is muted.

Parameters
isDeviceMuted: Boolean

Whether the device is muted.

Returns
SimpleBasePlayer.State.Builder!

This builder.

setIsLoading

@CanIgnoreReturnValue
fun setIsLoading(isLoading: Boolean): SimpleBasePlayer.State.Builder!

Sets whether the player is currently loading its source.

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

Parameters
isLoading: Boolean

Whether the player is currently loading its source.

Returns
SimpleBasePlayer.State.Builder!

This builder.

setMaxSeekToPreviousPositionMs

@CanIgnoreReturnValue
fun setMaxSeekToPreviousPositionMs(maxSeekToPreviousPositionMs: Long): SimpleBasePlayer.State.Builder!

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

Parameters
maxSeekToPreviousPositionMs: Long

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

Returns
SimpleBasePlayer.State.Builder!

This builder.

setNewlyRenderedFirstFrame

@CanIgnoreReturnValue
fun setNewlyRenderedFirstFrame(newlyRenderedFirstFrame: Boolean): SimpleBasePlayer.State.Builder!

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 onRenderedFirstFrame event, the flag should only be set for the first State update after the first frame was rendered.

Parameters
newlyRenderedFirstFrame: Boolean

Whether the first frame was newly rendered.

Returns
SimpleBasePlayer.State.Builder!

This builder.

setPlayWhenReady

@CanIgnoreReturnValue
fun setPlayWhenReady(
    playWhenReady: Boolean,
    @Player.PlayWhenReadyChangeReason playWhenReadyChangeReason: Int
): SimpleBasePlayer.State.Builder!

Sets whether playback should proceed when ready and not suppressed.

Parameters
playWhenReady: Boolean

Whether playback should proceed when ready and not suppressed.

@Player.PlayWhenReadyChangeReason playWhenReadyChangeReason: Int

The reason for changing the value.

Returns
SimpleBasePlayer.State.Builder!

This builder.

setPlaybackParameters

@CanIgnoreReturnValue
fun setPlaybackParameters(playbackParameters: PlaybackParameters!): SimpleBasePlayer.State.Builder!

Sets the currently active PlaybackParameters.

Parameters
playbackParameters: PlaybackParameters!

The currently active PlaybackParameters.

Returns
SimpleBasePlayer.State.Builder!

This builder.

setPlaybackState

@CanIgnoreReturnValue
fun setPlaybackState(@Player.State playbackState: Int): SimpleBasePlayer.State.Builder!

Sets the state of the player.

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

Parameters
@Player.State playbackState: Int

The state of the player.

Returns
SimpleBasePlayer.State.Builder!

This builder.

setPlaybackSuppressionReason

@CanIgnoreReturnValue
fun setPlaybackSuppressionReason(
    @Player.PlaybackSuppressionReason playbackSuppressionReason: Int
): SimpleBasePlayer.State.Builder!

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

Parameters
@Player.PlaybackSuppressionReason playbackSuppressionReason: Int

The Player.PlaybackSuppressionReason why playback is suppressed even if getPlayWhenReady is true.

Returns
SimpleBasePlayer.State.Builder!

This builder.

setPlayerError

@CanIgnoreReturnValue
fun setPlayerError(playerError: PlaybackException?): SimpleBasePlayer.State.Builder!

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

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

Parameters
playerError: PlaybackException?

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

Returns
SimpleBasePlayer.State.Builder!

This builder.

setPlaylist

@CanIgnoreReturnValue
fun setPlaylist(playlist: (Mutable)List<SimpleBasePlayer.MediaItemData!>!): SimpleBasePlayer.State.Builder!

Sets the playlist as a list of media items.

All items must have unique UIDs.

This call replaces any previous playlist set via setPlaylist.

Parameters
playlist: (Mutable)List<SimpleBasePlayer.MediaItemData!>!

The list of media items in the playlist.

Returns
SimpleBasePlayer.State.Builder!

This builder.

setPlaylist

@CanIgnoreReturnValue
fun setPlaylist(
    timeline: Timeline!,
    currentTracks: Tracks!,
    currentMetadata: MediaMetadata?
): SimpleBasePlayer.State.Builder!

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

This call replaces any previous playlist set via setPlaylist.

Parameters
timeline: Timeline!

The Timeline containing the playlist data.

currentTracks: Tracks!

The Tracks of the current media item.

currentMetadata: MediaMetadata?

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
SimpleBasePlayer.State.Builder!

This builder.

setPlaylistMetadata

@CanIgnoreReturnValue
fun setPlaylistMetadata(playlistMetadata: MediaMetadata!): SimpleBasePlayer.State.Builder!

Sets the playlist MediaMetadata.

Parameters
playlistMetadata: MediaMetadata!

The playlist MediaMetadata.

Returns
SimpleBasePlayer.State.Builder!

This builder.

setPositionDiscontinuity

@CanIgnoreReturnValue
fun setPositionDiscontinuity(
    @Player.DiscontinuityReason positionDiscontinuityReason: Int,
    discontinuityPositionMs: Long
): SimpleBasePlayer.State.Builder!

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

Parameters
@Player.DiscontinuityReason positionDiscontinuityReason: Int

The reason for the discontinuity.

discontinuityPositionMs: Long

The position, in milliseconds, in the current content or ad from which playback continues after the discontinuity.

Returns
SimpleBasePlayer.State.Builder!

This builder.

setRepeatMode

@CanIgnoreReturnValue
fun setRepeatMode(@Player.RepeatMode repeatMode: Int): SimpleBasePlayer.State.Builder!

Sets the RepeatMode used for playback.

Parameters
@Player.RepeatMode repeatMode: Int

The RepeatMode used for playback.

Returns
SimpleBasePlayer.State.Builder!

This builder.

setSeekBackIncrementMs

@CanIgnoreReturnValue
fun setSeekBackIncrementMs(seekBackIncrementMs: Long): SimpleBasePlayer.State.Builder!

Sets the seekBack increment in milliseconds.

Parameters
seekBackIncrementMs: Long

The seekBack increment in milliseconds.

Returns
SimpleBasePlayer.State.Builder!

This builder.

setSeekForwardIncrementMs

@CanIgnoreReturnValue
fun setSeekForwardIncrementMs(seekForwardIncrementMs: Long): SimpleBasePlayer.State.Builder!

Sets the seekForward increment in milliseconds.

Parameters
seekForwardIncrementMs: Long

The seekForward increment in milliseconds.

Returns
SimpleBasePlayer.State.Builder!

This builder.

setShuffleModeEnabled

@CanIgnoreReturnValue
fun setShuffleModeEnabled(shuffleModeEnabled: Boolean): SimpleBasePlayer.State.Builder!

Sets whether shuffling of media items is enabled.

Parameters
shuffleModeEnabled: Boolean

Whether shuffling of media items is enabled.

Returns
SimpleBasePlayer.State.Builder!

This builder.

setSurfaceSize

@CanIgnoreReturnValue
fun setSurfaceSize(surfaceSize: Size!): SimpleBasePlayer.State.Builder!

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

Parameters
surfaceSize: Size!

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

Returns
SimpleBasePlayer.State.Builder!

This builder.

setTimedMetadata

@CanIgnoreReturnValue
fun setTimedMetadata(timedMetadata: Metadata!): SimpleBasePlayer.State.Builder!

Sets the most recent timed Metadata.

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

Parameters
timedMetadata: Metadata!

The most recent timed Metadata.

Returns
SimpleBasePlayer.State.Builder!

This builder.

setTotalBufferedDurationMs

@CanIgnoreReturnValue
fun setTotalBufferedDurationMs(
    totalBufferedDurationMsSupplier: SimpleBasePlayer.PositionSupplier!
): SimpleBasePlayer.State.Builder!

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

Parameters
totalBufferedDurationMsSupplier: SimpleBasePlayer.PositionSupplier!

The PositionSupplier for the estimated total buffered duration in milliseconds.

Returns
SimpleBasePlayer.State.Builder!

This builder.

setTrackSelectionParameters

@CanIgnoreReturnValue
fun setTrackSelectionParameters(
    trackSelectionParameters: TrackSelectionParameters!
): SimpleBasePlayer.State.Builder!

Sets the currently active TrackSelectionParameters.

Parameters
trackSelectionParameters: TrackSelectionParameters!

The currently active TrackSelectionParameters.

Returns
SimpleBasePlayer.State.Builder!

This builder.

setVideoSize

@CanIgnoreReturnValue
fun setVideoSize(videoSize: VideoSize!): SimpleBasePlayer.State.Builder!

Sets the current video size.

Parameters
videoSize: VideoSize!

The current video size.

Returns
SimpleBasePlayer.State.Builder!

This builder.

setVolume

@CanIgnoreReturnValue
fun setVolume(volume: @FloatRange(from = 0, to = 1.0) Float): SimpleBasePlayer.State.Builder!

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

Parameters
volume: @FloatRange(from = 0, to = 1.0) Float

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

Returns
SimpleBasePlayer.State.Builder!

This builder.