mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +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
fc3ed0bf31
commit
a6360ab6c0
3 changed files with 32 additions and 5 deletions
|
|
@ -676,6 +676,7 @@ import java.io.IOException;
|
||||||
standaloneMediaClock.stop();
|
standaloneMediaClock.stop();
|
||||||
rendererMediaClock = null;
|
rendererMediaClock = null;
|
||||||
rendererMediaClockSource = null;
|
rendererMediaClockSource = null;
|
||||||
|
rendererPositionUs = RENDERER_TIMESTAMP_OFFSET_US;
|
||||||
for (Renderer renderer : enabledRenderers) {
|
for (Renderer renderer : enabledRenderers) {
|
||||||
try {
|
try {
|
||||||
ensureStopped(renderer);
|
ensureStopped(renderer);
|
||||||
|
|
@ -823,9 +824,6 @@ import java.io.IOException;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean haveSufficientBuffer(boolean rebuffering) {
|
private boolean haveSufficientBuffer(boolean rebuffering) {
|
||||||
if (loadingPeriodHolder == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
long loadingPeriodBufferedPositionUs = !loadingPeriodHolder.prepared
|
long loadingPeriodBufferedPositionUs = !loadingPeriodHolder.prepared
|
||||||
? loadingPeriodHolder.startPositionUs
|
? loadingPeriodHolder.startPositionUs
|
||||||
: loadingPeriodHolder.mediaPeriod.getBufferedPositionUs();
|
: loadingPeriodHolder.mediaPeriod.getBufferedPositionUs();
|
||||||
|
|
@ -1287,7 +1285,8 @@ import java.io.IOException;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void maybeContinueLoading() {
|
private void maybeContinueLoading() {
|
||||||
long nextLoadPositionUs = loadingPeriodHolder.mediaPeriod.getNextLoadPositionUs();
|
long nextLoadPositionUs = !loadingPeriodHolder.prepared ? 0
|
||||||
|
: loadingPeriodHolder.mediaPeriod.getNextLoadPositionUs();
|
||||||
if (nextLoadPositionUs == C.TIME_END_OF_SOURCE) {
|
if (nextLoadPositionUs == C.TIME_END_OF_SOURCE) {
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -244,7 +244,7 @@ import java.io.IOException;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getNextLoadPositionUs() {
|
public long getNextLoadPositionUs() {
|
||||||
return getBufferedPositionUs();
|
return enabledTrackCount == 0 ? C.TIME_END_OF_SOURCE : getBufferedPositionUs();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -133,4 +133,32 @@ public interface MediaPeriod extends SequenceableLoader {
|
||||||
*/
|
*/
|
||||||
long seekToUs(long positionUs);
|
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