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) ###
|
### dev-v2 (not yet released) ###
|
||||||
|
|
||||||
* Core library:
|
* Core library:
|
||||||
|
* Add playbackPositionUs parameter to 'LoadControl.shouldContinueLoading'.
|
||||||
* The `DefaultLoadControl` default minimum buffer is set to 50 seconds,
|
* The `DefaultLoadControl` default minimum buffer is set to 50 seconds,
|
||||||
equal to the default maximum buffer. `DefaultLoadControl` applies the
|
equal to the default maximum buffer. `DefaultLoadControl` applies the
|
||||||
same behavior for audio and video.
|
same behavior for audio and video.
|
||||||
|
@ -1945,9 +1945,16 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
|||||||
if (!isLoadingPossible()) {
|
if (!isLoadingPossible()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
MediaPeriodHolder loadingPeriodHolder = queue.getLoadingPeriod();
|
||||||
long bufferedDurationUs =
|
long bufferedDurationUs =
|
||||||
getTotalBufferedDurationUs(queue.getLoadingPeriod().getNextLoadPositionUs());
|
getTotalBufferedDurationUs(loadingPeriodHolder.getNextLoadPositionUs());
|
||||||
return loadControl.shouldContinueLoading(bufferedDurationUs, mediaClock.getPlaybackSpeed());
|
long playbackPositionUs =
|
||||||
|
loadingPeriodHolder == queue.getPlayingPeriod()
|
||||||
|
? loadingPeriodHolder.toPeriodTime(rendererPositionUs)
|
||||||
|
: loadingPeriodHolder.toPeriodTime(rendererPositionUs)
|
||||||
|
- loadingPeriodHolder.info.startPositionUs;
|
||||||
|
return loadControl.shouldContinueLoading(
|
||||||
|
playbackPositionUs, bufferedDurationUs, mediaClock.getPlaybackSpeed());
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isLoadingPossible() {
|
private boolean isLoadingPossible() {
|
||||||
|
@ -87,14 +87,28 @@ public interface LoadControl {
|
|||||||
*/
|
*/
|
||||||
boolean retainBackBufferFromKeyframe();
|
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.
|
* 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 bufferedDurationUs The duration of media that's currently buffered.
|
||||||
* @param playbackSpeed The current playback speed.
|
* @param playbackSpeed The current playback speed.
|
||||||
* @return Whether the loading should continue.
|
* @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
|
* 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