Propagate playback position through LoadControl shouldContinueLoading.
PiperOrigin-RevId: 304420177
This commit is contained in:
parent
6438e1cdbc
commit
fb0330d4db
@ -3,6 +3,7 @@
|
||||
### dev-v2 (not yet released) ###
|
||||
|
||||
* Core library:
|
||||
* Add playbackPositionUs parameter to 'LoadControl.shouldContinueLoading'.
|
||||
* The `DefaultLoadControl` default minimum buffer is set to 50 seconds,
|
||||
equal to the default maximum buffer. `DefaultLoadControl` applies the
|
||||
same behavior for audio and video.
|
||||
|
@ -1945,9 +1945,16 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||
if (!isLoadingPossible()) {
|
||||
return false;
|
||||
}
|
||||
MediaPeriodHolder loadingPeriodHolder = queue.getLoadingPeriod();
|
||||
long bufferedDurationUs =
|
||||
getTotalBufferedDurationUs(queue.getLoadingPeriod().getNextLoadPositionUs());
|
||||
return loadControl.shouldContinueLoading(bufferedDurationUs, mediaClock.getPlaybackSpeed());
|
||||
getTotalBufferedDurationUs(loadingPeriodHolder.getNextLoadPositionUs());
|
||||
long playbackPositionUs =
|
||||
loadingPeriodHolder == queue.getPlayingPeriod()
|
||||
? loadingPeriodHolder.toPeriodTime(rendererPositionUs)
|
||||
: loadingPeriodHolder.toPeriodTime(rendererPositionUs)
|
||||
- loadingPeriodHolder.info.startPositionUs;
|
||||
return loadControl.shouldContinueLoading(
|
||||
playbackPositionUs, bufferedDurationUs, mediaClock.getPlaybackSpeed());
|
||||
}
|
||||
|
||||
private boolean isLoadingPossible() {
|
||||
|
@ -87,14 +87,28 @@ public interface LoadControl {
|
||||
*/
|
||||
boolean retainBackBufferFromKeyframe();
|
||||
|
||||
/** @deprecated Use {@link LoadControl#shouldContinueLoading(long, long, float)}. */
|
||||
@Deprecated
|
||||
default boolean shouldContinueLoading(long bufferedDurationUs, float playbackSpeed) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by the player to determine whether it should continue to load the source.
|
||||
*
|
||||
* @param playbackPositionUs The current playback position in microseconds, relative to the start
|
||||
* of the {@link Timeline.Period period} that will continue to be loaded if this method
|
||||
* returns {@code true}. If the playback for this period has not yet started, the value will
|
||||
* negative and equal in magnitude to the duration of any media in previous periods still to
|
||||
* be played.
|
||||
* @param bufferedDurationUs The duration of media that's currently buffered.
|
||||
* @param playbackSpeed The current playback speed.
|
||||
* @return Whether the loading should continue.
|
||||
*/
|
||||
boolean shouldContinueLoading(long bufferedDurationUs, float playbackSpeed);
|
||||
default boolean shouldContinueLoading(
|
||||
long playbackPositionUs, long bufferedDurationUs, float playbackSpeed) {
|
||||
return shouldContinueLoading(bufferedDurationUs, playbackSpeed);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called repeatedly by the player when it's loading the source, has yet to start playback, and
|
||||
|
Loading…
x
Reference in New Issue
Block a user