DefaultLoadControl.Builder


public final class DefaultLoadControl.Builder


Builder for DefaultLoadControl.

Summary

Public constructors

Constructs a new instance.

Public methods

DefaultLoadControl

Creates a DefaultLoadControl.

DefaultLoadControl.Builder

Sets the DefaultAllocator used by the loader.

DefaultLoadControl.Builder
@CanIgnoreReturnValue
setBackBuffer(
    int backBufferDurationMs,
    boolean retainBackBufferFromKeyframe
)

Sets the back buffer duration, and whether the back buffer is retained from the previous keyframe.

DefaultLoadControl.Builder
@CanIgnoreReturnValue
setBufferDurationsMs(
    int minBufferMs,
    int maxBufferMs,
    int bufferForPlaybackMs,
    int bufferForPlaybackAfterRebufferMs
)

Sets the buffer duration parameters for both streaming and local on-device playback.

DefaultLoadControl.Builder
@CanIgnoreReturnValue
setBufferDurationsMsForLocalPlayback(
    int minBufferMs,
    int maxBufferMs,
    int bufferForPlaybackMs,
    int bufferForPlaybackAfterRebufferMs
)

Sets the buffer duration parameters for local on-device playback.

DefaultLoadControl.Builder
@CanIgnoreReturnValue
setBufferDurationsMsForStreaming(
    int minBufferMs,
    int maxBufferMs,
    int bufferForPlaybackMs,
    int bufferForPlaybackAfterRebufferMs
)

Sets the buffer duration parameters for streaming playback.

DefaultLoadControl.Builder
@CanIgnoreReturnValue
setPlayerTargetBufferBytes(
    String playerName,
    int playerTargetBufferBytes
)

Sets the target buffer size in bytes for a player with the specified playerName.

DefaultLoadControl.Builder
@CanIgnoreReturnValue
setPrioritizeTimeOverSizeThresholds(
    boolean prioritizeTimeOverSizeThresholds
)

Sets whether the load control prioritizes buffer time constraints over buffer size constraints for streaming and local on-device playback.

DefaultLoadControl.Builder
@CanIgnoreReturnValue
setPrioritizeTimeOverSizeThresholdsForLocalPlayback(
    boolean prioritizeTimeOverSizeThresholds
)

Sets whether the load control prioritizes buffer time constraints over buffer size constraints for local on-device playback.

DefaultLoadControl.Builder
@CanIgnoreReturnValue
setPrioritizeTimeOverSizeThresholdsForStreaming(
    boolean prioritizeTimeOverSizeThresholds
)

Sets whether the load control prioritizes buffer time constraints over buffer size constraints for streaming playback.

DefaultLoadControl.Builder

Sets the target buffer size in bytes for each player.

Public constructors

Builder

public Builder()

Constructs a new instance.

Public methods

build

public DefaultLoadControl build()

Creates a DefaultLoadControl.

setAllocator

@CanIgnoreReturnValue
public DefaultLoadControl.Builder setAllocator(DefaultAllocator allocator)

Sets the DefaultAllocator used by the loader.

Parameters
DefaultAllocator allocator

The DefaultAllocator.

Returns
DefaultLoadControl.Builder

This builder, for convenience.

Throws
java.lang.IllegalStateException

If build has already been called.

setBackBuffer

@CanIgnoreReturnValue
public DefaultLoadControl.Builder setBackBuffer(
    int backBufferDurationMs,
    boolean retainBackBufferFromKeyframe
)

Sets the back buffer duration, and whether the back buffer is retained from the previous keyframe.

Parameters
int backBufferDurationMs

The back buffer duration in milliseconds.

boolean retainBackBufferFromKeyframe

Whether the back buffer is retained from the previous keyframe.

Returns
DefaultLoadControl.Builder

This builder, for convenience.

Throws
java.lang.IllegalStateException

If build has already been called.

setBufferDurationsMs

@CanIgnoreReturnValue
public DefaultLoadControl.Builder setBufferDurationsMs(
    int minBufferMs,
    int maxBufferMs,
    int bufferForPlaybackMs,
    int bufferForPlaybackAfterRebufferMs
)

Sets the buffer duration parameters for both streaming and local on-device playback.

Use setBufferDurationsMsForStreaming or setBufferDurationsMsForLocalPlayback to set them separately for each use case.

Parameters
int minBufferMs

The minimum duration of media that the player will attempt to ensure is buffered at all times, in milliseconds.

int maxBufferMs

The maximum duration of media that the player will attempt to buffer, in milliseconds.

int bufferForPlaybackMs

The duration of media that must be buffered for playback to start or resume following a user action such as a seek, in milliseconds.

int bufferForPlaybackAfterRebufferMs

The default duration of media that must be buffered for playback to resume after a rebuffer, in milliseconds. A rebuffer is defined to be caused by buffer depletion rather than a user action.

Returns
DefaultLoadControl.Builder

This builder, for convenience.

Throws
java.lang.IllegalStateException

If build has already been called.

setBufferDurationsMsForLocalPlayback

@CanIgnoreReturnValue
public DefaultLoadControl.Builder setBufferDurationsMsForLocalPlayback(
    int minBufferMs,
    int maxBufferMs,
    int bufferForPlaybackMs,
    int bufferForPlaybackAfterRebufferMs
)

Sets the buffer duration parameters for local on-device playback.

Playbacks are considered to be on-device if the uri has an empty scheme or one of the schemes in LOCAL_PLAYBACK_SCHEMES.

Parameters
int minBufferMs

The minimum duration of media that the player will attempt to ensure is buffered at all times, in milliseconds.

int maxBufferMs

The maximum duration of media that the player will attempt to buffer, in milliseconds.

int bufferForPlaybackMs

The duration of media that must be buffered for playback to start or resume following a user action such as a seek, in milliseconds.

int bufferForPlaybackAfterRebufferMs

The default duration of media that must be buffered for playback to resume after a rebuffer, in milliseconds. A rebuffer is defined to be caused by buffer depletion rather than a user action.

Returns
DefaultLoadControl.Builder

This builder, for convenience.

Throws
java.lang.IllegalStateException

If build has already been called.

setBufferDurationsMsForStreaming

@CanIgnoreReturnValue
public DefaultLoadControl.Builder setBufferDurationsMsForStreaming(
    int minBufferMs,
    int maxBufferMs,
    int bufferForPlaybackMs,
    int bufferForPlaybackAfterRebufferMs
)

Sets the buffer duration parameters for streaming playback.

Playbacks are considered to be streaming if the uri is none of the schemes in LOCAL_PLAYBACK_SCHEMES.

Parameters
int minBufferMs

The minimum duration of media that the player will attempt to ensure is buffered at all times, in milliseconds.

int maxBufferMs

The maximum duration of media that the player will attempt to buffer, in milliseconds.

int bufferForPlaybackMs

The duration of media that must be buffered for playback to start or resume following a user action such as a seek, in milliseconds.

int bufferForPlaybackAfterRebufferMs

The default duration of media that must be buffered for playback to resume after a rebuffer, in milliseconds. A rebuffer is defined to be caused by buffer depletion rather than a user action.

Returns
DefaultLoadControl.Builder

This builder, for convenience.

Throws
java.lang.IllegalStateException

If build has already been called.

setPlayerTargetBufferBytes

@CanIgnoreReturnValue
public DefaultLoadControl.Builder setPlayerTargetBufferBytes(
    String playerName,
    int playerTargetBufferBytes
)

Sets the target buffer size in bytes for a player with the specified playerName. When not set or set to LENGTH_UNSET, the target buffer size of a player will be the value set via setTargetBufferBytes if it is not LENGTH_UNSET, otherwise it will be calculated based on the selected tracks of the player.

For the PRELOAD with PlayerId.PRELOAD.name, the default target buffer bytes is DEFAULT_TARGET_BUFFER_BYTES_FOR_PRELOAD.

Parameters
String playerName

The name of the player. The same name must be set to the player via setName in order to be effective at the created DefaultLoadControl.

int playerTargetBufferBytes

The target buffer size in bytes for the specified player.

Returns
DefaultLoadControl.Builder

This builder, for convenience.

Throws
java.lang.IllegalStateException

If build has already been called.

setPrioritizeTimeOverSizeThresholds

@CanIgnoreReturnValue
public DefaultLoadControl.Builder setPrioritizeTimeOverSizeThresholds(
    boolean prioritizeTimeOverSizeThresholds
)

Sets whether the load control prioritizes buffer time constraints over buffer size constraints for streaming and local on-device playback.

Use setPrioritizeTimeOverSizeThresholdsForStreaming or setPrioritizeTimeOverSizeThresholdsForLocalPlayback to set them separately for each use case.

Parameters
boolean prioritizeTimeOverSizeThresholds

Whether the load control prioritizes buffer time constraints over buffer size constraints.

Returns
DefaultLoadControl.Builder

This builder, for convenience.

Throws
java.lang.IllegalStateException

If build has already been called.

setPrioritizeTimeOverSizeThresholdsForLocalPlayback

@CanIgnoreReturnValue
public DefaultLoadControl.Builder setPrioritizeTimeOverSizeThresholdsForLocalPlayback(
    boolean prioritizeTimeOverSizeThresholds
)

Sets whether the load control prioritizes buffer time constraints over buffer size constraints for local on-device playback.

Playbacks are considered to be on-device if the uri has an empty scheme or one of the schemes in LOCAL_PLAYBACK_SCHEMES.

Parameters
boolean prioritizeTimeOverSizeThresholds

Whether the load control prioritizes buffer time constraints over buffer size constraints.

Returns
DefaultLoadControl.Builder

This builder, for convenience.

Throws
java.lang.IllegalStateException

If build has already been called.

setPrioritizeTimeOverSizeThresholdsForStreaming

@CanIgnoreReturnValue
public DefaultLoadControl.Builder setPrioritizeTimeOverSizeThresholdsForStreaming(
    boolean prioritizeTimeOverSizeThresholds
)

Sets whether the load control prioritizes buffer time constraints over buffer size constraints for streaming playback.

Playbacks are considered to be streaming if the uri is none of the schemes in LOCAL_PLAYBACK_SCHEMES.

Parameters
boolean prioritizeTimeOverSizeThresholds

Whether the load control prioritizes buffer time constraints over buffer size constraints.

Returns
DefaultLoadControl.Builder

This builder, for convenience.

Throws
java.lang.IllegalStateException

If build has already been called.

setTargetBufferBytes

@CanIgnoreReturnValue
public DefaultLoadControl.Builder setTargetBufferBytes(int targetBufferBytes)

Sets the target buffer size in bytes for each player. If set to LENGTH_UNSET, the target buffer size of a player will be calculated based on the selected tracks of the player.

This value will be ignored for the players with a playerName that has target buffer size set via setPlayerTargetBufferBytes.

Parameters
int targetBufferBytes

The target buffer size in bytes.

Returns
DefaultLoadControl.Builder

This builder, for convenience.

Throws
java.lang.IllegalStateException

If build has already been called.