public final class DefaultLoadControl extends Object implements LoadControl
LoadControl
implementation.Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_BUFFER_FOR_PLAYBACK_AFTER_REBUFFER_MS
The default duration of media that must be buffered for playback to resume after a rebuffer,
in milliseconds.
|
static int |
DEFAULT_BUFFER_FOR_PLAYBACK_MS
The default duration of media that must be buffered for playback to start or resume following a
user action such as a seek, in milliseconds.
|
static int |
DEFAULT_MAX_BUFFER_MS
The default maximum duration of media that the player will attempt to buffer, in milliseconds.
|
static int |
DEFAULT_MIN_BUFFER_MS
The default minimum duration of media that the player will attempt to ensure is buffered at all
times, in milliseconds.
|
Constructor and Description |
---|
DefaultLoadControl()
Constructs a new instance, using the
DEFAULT_* constants defined in this class. |
DefaultLoadControl(DefaultAllocator allocator)
Constructs a new instance, using the
DEFAULT_* constants defined in this class. |
DefaultLoadControl(DefaultAllocator allocator,
int minBufferMs,
int maxBufferMs,
long bufferForPlaybackMs,
long bufferForPlaybackAfterRebufferMs)
Constructs a new instance.
|
Modifier and Type | Method and Description |
---|---|
Allocator |
getAllocator()
Returns the
Allocator that should be used to obtain media buffer allocations. |
void |
onPrepared()
Called by the player when prepared with a new source.
|
void |
onReleased()
Called by the player when released.
|
void |
onStopped()
Called by the player when stopped.
|
void |
onTracksSelected(Renderer[] renderers,
TrackGroupArray trackGroups,
TrackSelections<?> trackSelections)
Called by the player when a track selection occurs.
|
boolean |
shouldContinueLoading(long bufferedDurationUs)
Called by the player to determine whether it should continue to load the source.
|
boolean |
shouldStartPlayback(long bufferedDurationUs,
boolean rebuffering)
Called by the player to determine whether sufficient media is buffered for playback to be
started or resumed.
|
public static final int DEFAULT_MIN_BUFFER_MS
public static final int DEFAULT_MAX_BUFFER_MS
public static final int DEFAULT_BUFFER_FOR_PLAYBACK_MS
public static final int DEFAULT_BUFFER_FOR_PLAYBACK_AFTER_REBUFFER_MS
public DefaultLoadControl()
DEFAULT_*
constants defined in this class.public DefaultLoadControl(DefaultAllocator allocator)
DEFAULT_*
constants defined in this class.allocator
- The DefaultAllocator
used by the loader.public DefaultLoadControl(DefaultAllocator allocator, int minBufferMs, int maxBufferMs, long bufferForPlaybackMs, long bufferForPlaybackAfterRebufferMs)
allocator
- The DefaultAllocator
used by the loader.minBufferMs
- The minimum duration of media that the player will attempt to ensure is
buffered at all times, in milliseconds.maxBufferMs
- The maximum duration of media that the player will attempt buffer, in
milliseconds.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.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.public void onPrepared()
LoadControl
onPrepared
in interface LoadControl
public void onTracksSelected(Renderer[] renderers, TrackGroupArray trackGroups, TrackSelections<?> trackSelections)
LoadControl
onTracksSelected
in interface LoadControl
renderers
- The renderers.trackGroups
- The TrackGroup
s from which the selection was made.trackSelections
- The track selections that were made.public void onStopped()
LoadControl
onStopped
in interface LoadControl
public void onReleased()
LoadControl
onReleased
in interface LoadControl
public Allocator getAllocator()
LoadControl
Allocator
that should be used to obtain media buffer allocations.getAllocator
in interface LoadControl
public boolean shouldStartPlayback(long bufferedDurationUs, boolean rebuffering)
LoadControl
shouldStartPlayback
in interface LoadControl
bufferedDurationUs
- The duration of media that's currently buffered.rebuffering
- Whether the player is rebuffering. A rebuffer is defined to be caused by
buffer depletion rather than a user action. Hence this parameter is false during initial
buffering and when buffering as a result of a seek operation.public boolean shouldContinueLoading(long bufferedDurationUs)
LoadControl
shouldContinueLoading
in interface LoadControl
bufferedDurationUs
- The duration of media that's currently buffered.