ClippingMediaSource.Builder


class ClippingMediaSource.Builder


A builder for ClippingMediaSource.

Summary

Public constructors

Builder(mediaSource: MediaSource!)

Creates the builder.

Public functions

ClippingMediaSource!

Builds the ClippingMediaSource.

ClippingMediaSource.Builder!

Sets whether the clipping of active media periods moves with a live window.

ClippingMediaSource.Builder!

Sets whether clipping to a non-zero start position in unseekable media is allowed.

ClippingMediaSource.Builder!

Sets whether to enable the initial discontinuity.

ClippingMediaSource.Builder!

Sets the clip end position.

ClippingMediaSource.Builder!

Sets the clip end position.

ClippingMediaSource.Builder!

Sets whether the start and end position are relative to the default position of the wrapped source's Timeline.Window.

ClippingMediaSource.Builder!

Sets the clip start position.

ClippingMediaSource.Builder!

Sets the clip start position.

Public constructors

Builder

Builder(mediaSource: MediaSource!)

Creates the builder.

Parameters
mediaSource: MediaSource!

The MediaSource to clip.

Public functions

build

fun build(): ClippingMediaSource!

Builds the ClippingMediaSource.

setAllowDynamicClippingUpdates

@CanIgnoreReturnValue
fun setAllowDynamicClippingUpdates(allowDynamicClippingUpdates: Boolean): ClippingMediaSource.Builder!

Sets whether the clipping of active media periods moves with a live window.

If false, playback ends when it reaches endPositionUs in the last reported live window at the time a media period was created.

The default value is false.

Parameters
allowDynamicClippingUpdates: Boolean

Whether to allow dynamic clipping updates.

Returns
ClippingMediaSource.Builder!

This builder.

setAllowUnseekableMedia

@CanIgnoreReturnValue
fun setAllowUnseekableMedia(allowUnseekableMedia: Boolean): ClippingMediaSource.Builder!

Sets whether clipping to a non-zero start position in unseekable media is allowed.

Note that this is inefficient because the player needs to read and decode all samples from the beginning of the file and it should only be used if the seek start position is small and the entire data before the start position fits into memory.

The default value is false.

Parameters
allowUnseekableMedia: Boolean

Whether a non-zero start position in unseekable media is allowed.

Returns
ClippingMediaSource.Builder!

This builder.

setEnableInitialDiscontinuity

@CanIgnoreReturnValue
fun setEnableInitialDiscontinuity(enableInitialDiscontinuity: Boolean): ClippingMediaSource.Builder!

Sets whether to enable the initial discontinuity.

This discontinuity is needed to handle pre-rolling samples from a previous keyframe if the start position doesn't fall onto a keyframe.

When starting from the beginning of the stream or when clipping a format that is guaranteed to have keyframes only, the discontinuity won't be applied even if enabled.

The default value is true.

Parameters
enableInitialDiscontinuity: Boolean

Whether to enable the initial discontinuity.

Returns
ClippingMediaSource.Builder!

This builder.

setEndPositionMs

@CanIgnoreReturnValue
fun setEndPositionMs(endPositionMs: Long): ClippingMediaSource.Builder!

Sets the clip end position.

The end position is relative to the wrapped source's Timeline.Window, unless setRelativeToDefaultPosition is set to true.

Specify TIME_END_OF_SOURCE to provide samples up to the end of the source. Specifying a position that exceeds the wrapped source's duration will also result in the end of the source not being clipped.

Parameters
endPositionMs: Long

The clip end position in milliseconds, or TIME_END_OF_SOURCE.

Returns
ClippingMediaSource.Builder!

This builder.

setEndPositionUs

@CanIgnoreReturnValue
fun setEndPositionUs(endPositionUs: Long): ClippingMediaSource.Builder!

Sets the clip end position.

The end position is relative to the wrapped source's Timeline.Window, unless setRelativeToDefaultPosition is set to true.

Specify TIME_END_OF_SOURCE to provide samples up to the end of the source. Specifying a position that exceeds the wrapped source's duration will also result in the end of the source not being clipped.

Parameters
endPositionUs: Long

The clip end position in microseconds, or TIME_END_OF_SOURCE.

Returns
ClippingMediaSource.Builder!

This builder.

setRelativeToDefaultPosition

@CanIgnoreReturnValue
fun setRelativeToDefaultPosition(relativeToDefaultPosition: Boolean): ClippingMediaSource.Builder!

Sets whether the start and end position are relative to the default position of the wrapped source's Timeline.Window.

The default value is false.

Parameters
relativeToDefaultPosition: Boolean

Whether the start and end positions are relative to the default position of the wrapped source's Timeline.Window.

Returns
ClippingMediaSource.Builder!

This builder.

setStartPositionMs

@CanIgnoreReturnValue
fun setStartPositionMs(startPositionMs: Long): ClippingMediaSource.Builder!

Sets the clip start position.

The start position is relative to the wrapped source's Timeline.Window, unless setRelativeToDefaultPosition is set to true.

Parameters
startPositionMs: Long

The clip start position in milliseconds.

Returns
ClippingMediaSource.Builder!

This builder.

setStartPositionUs

@CanIgnoreReturnValue
fun setStartPositionUs(startPositionUs: Long): ClippingMediaSource.Builder!

Sets the clip start position.

The start position is relative to the wrapped source's Timeline.Window, unless setRelativeToDefaultPosition is set to true.

Parameters
startPositionUs: Long

The clip start position in microseconds.

Returns
ClippingMediaSource.Builder!

This builder.