mirror of
https://github.com/samsonjs/media.git
synced 2026-04-01 10:35:48 +00:00
Fix playback of media with >1MB preparation data
Also clarify when getNextLoadPositionUs and continueLoading can be called. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=142124497
This commit is contained in:
parent
37317520f4
commit
2c3ce7fee3
3 changed files with 32 additions and 5 deletions
|
|
@ -676,6 +676,7 @@ import java.io.IOException;
|
|||
standaloneMediaClock.stop();
|
||||
rendererMediaClock = null;
|
||||
rendererMediaClockSource = null;
|
||||
rendererPositionUs = RENDERER_TIMESTAMP_OFFSET_US;
|
||||
for (Renderer renderer : enabledRenderers) {
|
||||
try {
|
||||
ensureStopped(renderer);
|
||||
|
|
@ -823,9 +824,6 @@ import java.io.IOException;
|
|||
}
|
||||
|
||||
private boolean haveSufficientBuffer(boolean rebuffering) {
|
||||
if (loadingPeriodHolder == null) {
|
||||
return false;
|
||||
}
|
||||
long loadingPeriodBufferedPositionUs = !loadingPeriodHolder.prepared
|
||||
? loadingPeriodHolder.startPositionUs
|
||||
: loadingPeriodHolder.mediaPeriod.getBufferedPositionUs();
|
||||
|
|
@ -1287,7 +1285,8 @@ import java.io.IOException;
|
|||
}
|
||||
|
||||
private void maybeContinueLoading() {
|
||||
long nextLoadPositionUs = loadingPeriodHolder.mediaPeriod.getNextLoadPositionUs();
|
||||
long nextLoadPositionUs = !loadingPeriodHolder.prepared ? 0
|
||||
: loadingPeriodHolder.mediaPeriod.getNextLoadPositionUs();
|
||||
if (nextLoadPositionUs == C.TIME_END_OF_SOURCE) {
|
||||
setIsLoading(false);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -244,7 +244,7 @@ import java.io.IOException;
|
|||
|
||||
@Override
|
||||
public long getNextLoadPositionUs() {
|
||||
return getBufferedPositionUs();
|
||||
return enabledTrackCount == 0 ? C.TIME_END_OF_SOURCE : getBufferedPositionUs();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -133,4 +133,32 @@ public interface MediaPeriod extends SequenceableLoader {
|
|||
*/
|
||||
long seekToUs(long positionUs);
|
||||
|
||||
// SequenceableLoader interface. Overridden to provide more specific documentation.
|
||||
|
||||
/**
|
||||
* Returns the next load time, or {@link C#TIME_END_OF_SOURCE} if loading has finished.
|
||||
* <p>
|
||||
* This method should only be called after the period has been prepared. It may be called when no
|
||||
* tracks are selected.
|
||||
*/
|
||||
@Override
|
||||
long getNextLoadPositionUs();
|
||||
|
||||
/**
|
||||
* Attempts to continue loading.
|
||||
* <p>
|
||||
* This method may be called both during and after the period has been prepared.
|
||||
* <p>
|
||||
* A period may call {@link Callback#onContinueLoadingRequested(SequenceableLoader)} on the
|
||||
* {@link Callback} passed to {@link #prepare(Callback)} to request that this method be called
|
||||
* when the period is permitted to continue loading data. A period may do this both during and
|
||||
* after preparation.
|
||||
*
|
||||
* @param positionUs The current playback position.
|
||||
* @return True if progress was made, meaning that {@link #getNextLoadPositionUs()} will return
|
||||
* a different value than prior to the call. False otherwise.
|
||||
*/
|
||||
@Override
|
||||
boolean continueLoading(long positionUs);
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue