ClippingMediaSource.Builder


public final class ClippingMediaSource.Builder


A builder for ClippingMediaSource.

Summary

Public constructors

Builder(MediaSource mediaSource)

Creates the builder.

Public methods

ClippingMediaSource

Builds the ClippingMediaSource.

ClippingMediaSource.Builder
@CanIgnoreReturnValue
setAllowDynamicClippingUpdates(boolean allowDynamicClippingUpdates)

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

ClippingMediaSource.Builder
@CanIgnoreReturnValue
setAllowUnseekableMedia(boolean allowUnseekableMedia)

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

ClippingMediaSource.Builder
@CanIgnoreReturnValue
setEnableInitialDiscontinuity(boolean enableInitialDiscontinuity)

Sets whether to enable the initial discontinuity.

ClippingMediaSource.Builder

Sets the clip end position.

ClippingMediaSource.Builder

Sets the clip end position.

ClippingMediaSource.Builder
@CanIgnoreReturnValue
setRelativeToDefaultPosition(boolean relativeToDefaultPosition)

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

public Builder(MediaSource mediaSource)

Creates the builder.

Parameters
MediaSource mediaSource

The MediaSource to clip.

Public methods

build

public ClippingMediaSource build()

Builds the ClippingMediaSource.

setAllowDynamicClippingUpdates

@CanIgnoreReturnValue
public ClippingMediaSource.Builder setAllowDynamicClippingUpdates(boolean allowDynamicClippingUpdates)

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
boolean allowDynamicClippingUpdates

Whether to allow dynamic clipping updates.

Returns
ClippingMediaSource.Builder

This builder.

setAllowUnseekableMedia

@CanIgnoreReturnValue
public ClippingMediaSource.Builder setAllowUnseekableMedia(boolean allowUnseekableMedia)

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
boolean allowUnseekableMedia

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

Returns
ClippingMediaSource.Builder

This builder.

setEnableInitialDiscontinuity

@CanIgnoreReturnValue
public ClippingMediaSource.Builder setEnableInitialDiscontinuity(boolean enableInitialDiscontinuity)

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
boolean enableInitialDiscontinuity

Whether to enable the initial discontinuity.

Returns
ClippingMediaSource.Builder

This builder.

setEndPositionMs

@CanIgnoreReturnValue
public ClippingMediaSource.Builder setEndPositionMs(long endPositionMs)

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
long endPositionMs

The clip end position in milliseconds, or TIME_END_OF_SOURCE.

Returns
ClippingMediaSource.Builder

This builder.

setEndPositionUs

@CanIgnoreReturnValue
public ClippingMediaSource.Builder setEndPositionUs(long endPositionUs)

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
long endPositionUs

The clip end position in microseconds, or TIME_END_OF_SOURCE.

Returns
ClippingMediaSource.Builder

This builder.

setRelativeToDefaultPosition

@CanIgnoreReturnValue
public ClippingMediaSource.Builder setRelativeToDefaultPosition(boolean relativeToDefaultPosition)

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
boolean relativeToDefaultPosition

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
public ClippingMediaSource.Builder setStartPositionMs(long startPositionMs)

Sets the clip start position.

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

Parameters
long startPositionMs

The clip start position in milliseconds.

Returns
ClippingMediaSource.Builder

This builder.

setStartPositionUs

@CanIgnoreReturnValue
public ClippingMediaSource.Builder setStartPositionUs(long startPositionUs)

Sets the clip start position.

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

Parameters
long startPositionUs

The clip start position in microseconds.

Returns
ClippingMediaSource.Builder

This builder.