LoadControl
@UnstableApi
public interface LoadControl
DefaultLoadControl |
The default |
Controls buffering of media.
Summary
Nested types |
|---|
public final class LoadControl.ParametersInformation about the current playback context and the |
Constants |
|
|---|---|
default static final MediaSource.MediaPeriodId |
This field is deprecated. Used as a placeholder when MediaPeriodId is unknown. |
Public methods |
|
|---|---|
abstract Allocator |
getAllocator(PlayerId playerId)Returns the |
default long |
This method is deprecated. Implements |
default long |
getBackBufferDurationUs(PlayerId playerId)Returns the duration of media to retain in the buffer prior to the current playback position, for fast backward seeking. |
default void |
This method is deprecated. Use |
default void |
onPrepared(PlayerId playerId)Called by the player when prepared with a new source. |
default void |
This method is deprecated. Implement |
default void |
onReleased(PlayerId playerId)Called by the player when released. |
default void |
This method is deprecated. Implement |
default void |
Called by the player when stopped. |
default void |
onTracksSelected(Called by the player when a track selection occurs. |
default void |
This method is deprecated. Implement |
default void |
This method is deprecated. Implement |
default void |
This method is deprecated. Implement |
default boolean |
This method is deprecated. Implements |
default boolean |
retainBackBufferFromKeyframe(PlayerId playerId)Returns whether media should be retained from the keyframe before the current playback position minus |
default boolean |
shouldContinueLoading(LoadControl.Parameters parameters)Called by the player to determine whether it should continue to load the source. |
default boolean |
This method is deprecated. Implement |
default boolean |
shouldContinuePreloading(Called to determine whether preloading should be continued. |
default boolean |
shouldStartPlayback(LoadControl.Parameters parameters)Called repeatedly by the player when it's loading the source, has yet to start playback, and has the minimum amount of data necessary for playback to be started. |
default boolean |
This method is deprecated. Implement |
default boolean |
This method is deprecated. Implement |
Constants
Public methods
getAllocator
abstract Allocator getAllocator(PlayerId playerId)
Returns the Allocator that should be used to obtain media buffer allocations for the specified PlayerId.
getBackBufferDurationUs
default long getBackBufferDurationUs(PlayerId playerId)
Returns the duration of media to retain in the buffer prior to the current playback position, for fast backward seeking.
Note: If retainBackBufferFromKeyframe is false then seeking in the back-buffer will only be fast if the back-buffer contains a keyframe prior to the seek position.
Note: Implementations should return a single value. Dynamic changes to the back-buffer are not currently supported.
| Parameters | |
|---|---|
PlayerId playerId |
The |
| Returns | |
|---|---|
long |
The duration of media to retain in the buffer prior to the current playback position, in microseconds. |
onPrepared
default void onPrepared(PlayerId playerId)
Called by the player when prepared with a new source.
| Parameters | |
|---|---|
PlayerId playerId |
The |
onReleased
default void onReleased(PlayerId playerId)
Called by the player when released.
| Parameters | |
|---|---|
PlayerId playerId |
The |
onStopped
default void onStopped(PlayerId playerId)
Called by the player when stopped.
| Parameters | |
|---|---|
PlayerId playerId |
The |
onTracksSelected
default void onTracksSelected(
LoadControl.Parameters parameters,
TrackGroupArray trackGroups,
@NullableType ExoTrackSelection[] trackSelections
)
Called by the player when a track selection occurs.
| Parameters | |
|---|---|
LoadControl.Parameters parameters |
containing the |
TrackGroupArray trackGroups |
The |
@NullableType ExoTrackSelection[] trackSelections |
The track selections that were made. |
onTracksSelected
default voidonTracksSelected(
Renderer[] renderers,
TrackGroupArray trackGroups,
@NullableType ExoTrackSelection[] trackSelections
)
onTracksSelected
default voidonTracksSelected(
Timeline timeline,
MediaSource.MediaPeriodId mediaPeriodId,
Renderer[] renderers,
TrackGroupArray trackGroups,
@NullableType ExoTrackSelection[] trackSelections
)
onTracksSelected
default voidonTracksSelected(
PlayerId playerId,
Timeline timeline,
MediaSource.MediaPeriodId mediaPeriodId,
Renderer[] renderers,
TrackGroupArray trackGroups,
@NullableType ExoTrackSelection[] trackSelections
)
retainBackBufferFromKeyframe
default boolean retainBackBufferFromKeyframe(PlayerId playerId)
Returns whether media should be retained from the keyframe before the current playback position minus getBackBufferDurationUs, rather than any sample before or at that position.
Warning: Returning true will cause the back-buffer size to depend on the spacing of keyframes in the media being played. Returning true is not recommended unless you control the media and are comfortable with the back-buffer size exceeding getBackBufferDurationUs by as much as the maximum duration between adjacent keyframes in the media.
Note: Implementations should return a single value. Dynamic changes to the back-buffer are not currently supported.
| Parameters | |
|---|---|
PlayerId playerId |
The |
| Returns | |
|---|---|
boolean |
Whether media should be retained from the keyframe before the current playback position minus |
shouldContinueLoading
default boolean shouldContinueLoading(LoadControl.Parameters parameters)
Called by the player to determine whether it should continue to load the source. If this method returns true, the MediaPeriod identified in the most recent onTracksSelected call will continue being loaded.
| Parameters | |
|---|---|
LoadControl.Parameters parameters |
Information about the playback context and the |
| Returns | |
|---|---|
boolean |
Whether the loading should continue. |
shouldContinueLoading
default booleanshouldContinueLoading(
long playbackPositionUs,
long bufferedDurationUs,
float playbackSpeed
)
shouldContinuePreloading
default boolean shouldContinuePreloading(
PlayerId playerId,
Timeline timeline,
MediaSource.MediaPeriodId mediaPeriodId,
long bufferedDurationUs
)
Called to determine whether preloading should be continued. If this method returns true, the presented period will continue to load media.
| Parameters | |
|---|---|
PlayerId playerId |
The |
Timeline timeline |
The Timeline containing the preload period that can be looked up with MediaPeriodId.periodUid. |
MediaSource.MediaPeriodId mediaPeriodId |
The MediaPeriodId of the preloading period. |
long bufferedDurationUs |
The duration of media currently buffered by the preload period. |
| Returns | |
|---|---|
boolean |
Whether the preloading should continue for the given period. |
shouldStartPlayback
default boolean shouldStartPlayback(LoadControl.Parameters parameters)
Called repeatedly by the player when it's loading the source, has yet to start playback, and has the minimum amount of data necessary for playback to be started. The value returned determines whether playback is actually started. The load control may opt to return
false until some condition has been met (e.g. a certain amount of media is buffered).
| Parameters | |
|---|---|
LoadControl.Parameters parameters |
Information about the playback context and the |
| Returns | |
|---|---|
boolean |
Whether playback should be allowed to start or resume. |
shouldStartPlayback
default booleanshouldStartPlayback(
long bufferedDurationUs,
float playbackSpeed,
boolean rebuffering,
long targetLiveOffsetUs
)
shouldStartPlayback
default booleanshouldStartPlayback(
Timeline timeline,
MediaSource.MediaPeriodId mediaPeriodId,
long bufferedDurationUs,
float playbackSpeed,
boolean rebuffering,
long targetLiveOffsetUs
)