mirror of
https://github.com/samsonjs/media.git
synced 2026-04-05 11:15:46 +00:00
Add SequencableLoader.isLoading
This method allows the player to figure out whether we still have an ongoing load even if LoadControl.shouldContinueLoading returns false. PiperOrigin-RevId: 272445577
This commit is contained in:
parent
9f78187678
commit
4f640bc62e
19 changed files with 90 additions and 0 deletions
|
|
@ -91,6 +91,7 @@
|
|||
([#6476](https://github.com/google/ExoPlayer/issues/6476)).
|
||||
* Fail more explicitly when local-file Uris contain invalid parts (e.g.
|
||||
fragment) ([#6470](https://github.com/google/ExoPlayer/issues/6470)).
|
||||
* Add `MediaPeriod.isLoading` to improve `Player.isLoading` state.
|
||||
|
||||
### 2.10.5 (2019-09-20) ###
|
||||
|
||||
|
|
|
|||
|
|
@ -211,6 +211,11 @@ public final class ClippingMediaPeriod implements MediaPeriod, MediaPeriod.Callb
|
|||
return mediaPeriod.continueLoading(positionUs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLoading() {
|
||||
return mediaPeriod.isLoading();
|
||||
}
|
||||
|
||||
// MediaPeriod.Callback implementation.
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -83,4 +83,13 @@ public class CompositeSequenceableLoader implements SequenceableLoader {
|
|||
return madeProgress;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLoading() {
|
||||
for (SequenceableLoader loader : loaders) {
|
||||
if (loader.isLoading()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -211,6 +211,11 @@ public final class MaskingMediaPeriod implements MediaPeriod, MediaPeriod.Callba
|
|||
return mediaPeriod != null && mediaPeriod.continueLoading(positionUs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLoading() {
|
||||
return mediaPeriod != null && mediaPeriod.isLoading();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onContinueLoadingRequested(MediaPeriod source) {
|
||||
castNonNull(callback).onContinueLoadingRequested(this);
|
||||
|
|
|
|||
|
|
@ -231,6 +231,9 @@ public interface MediaPeriod extends SequenceableLoader {
|
|||
@Override
|
||||
boolean continueLoading(long positionUs);
|
||||
|
||||
/** Returns whether the media period is currently loading. */
|
||||
boolean isLoading();
|
||||
|
||||
/**
|
||||
* Re-evaluates the buffer given the playback position.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -169,6 +169,11 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLoading() {
|
||||
return compositeSequenceableLoader.isLoading();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getNextLoadPositionUs() {
|
||||
return compositeSequenceableLoader.getNextLoadPositionUs();
|
||||
|
|
|
|||
|
|
@ -358,6 +358,11 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
|
|||
return continuedLoading;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLoading() {
|
||||
return loader.isLoading() && loadCondition.isOpen();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getNextLoadPositionUs() {
|
||||
return enabledTrackCount == 0 ? C.TIME_END_OF_SOURCE : getBufferedPositionUs();
|
||||
|
|
|
|||
|
|
@ -60,6 +60,9 @@ public interface SequenceableLoader {
|
|||
*/
|
||||
boolean continueLoading(long positionUs);
|
||||
|
||||
/** Returns whether the loader is currently loading. */
|
||||
boolean isLoading();
|
||||
|
||||
/**
|
||||
* Re-evaluates the buffer given the playback position.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -172,6 +172,11 @@ public final class SilenceMediaSource extends BaseMediaSource {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLoading() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reevaluateBuffer(long positionUs) {}
|
||||
|
||||
|
|
|
|||
|
|
@ -172,6 +172,11 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLoading() {
|
||||
return loader.isLoading();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long readDiscontinuity() {
|
||||
if (!notifiedReadingStarted) {
|
||||
|
|
|
|||
|
|
@ -577,6 +577,11 @@ public class ChunkSampleStream<T extends ChunkSource> implements SampleStream, S
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLoading() {
|
||||
return loader.isLoading();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getNextLoadPositionUs() {
|
||||
if (isPendingReset()) {
|
||||
|
|
|
|||
|
|
@ -76,4 +76,8 @@ public final class ConditionVariable {
|
|||
return isOpen;
|
||||
}
|
||||
|
||||
/** Returns whether the condition is opened. */
|
||||
public synchronized boolean isOpen() {
|
||||
return isOpen;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -261,6 +261,11 @@ public final class CompositeSequenceableLoaderTest {
|
|||
return loaded;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLoading() {
|
||||
return nextChunkDurationUs != 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reevaluateBuffer(long positionUs) {
|
||||
// Do nothing.
|
||||
|
|
|
|||
|
|
@ -297,6 +297,11 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
|
|||
return compositeSequenceableLoader.continueLoading(positionUs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLoading() {
|
||||
return compositeSequenceableLoader.isLoading();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getNextLoadPositionUs() {
|
||||
return compositeSequenceableLoader.getNextLoadPositionUs();
|
||||
|
|
|
|||
|
|
@ -359,6 +359,11 @@ public final class HlsMediaPeriod implements MediaPeriod, HlsSampleStreamWrapper
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLoading() {
|
||||
return compositeSequenceableLoader.isLoading();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getNextLoadPositionUs() {
|
||||
return compositeSequenceableLoader.getNextLoadPositionUs();
|
||||
|
|
|
|||
|
|
@ -663,6 +663,11 @@ import java.util.Set;
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLoading() {
|
||||
return loader.isLoading();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reevaluateBuffer(long positionUs) {
|
||||
// Do nothing.
|
||||
|
|
|
|||
|
|
@ -184,6 +184,11 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
|
|||
return compositeSequenceableLoader.continueLoading(positionUs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLoading() {
|
||||
return compositeSequenceableLoader.isLoading();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getNextLoadPositionUs() {
|
||||
return compositeSequenceableLoader.getNextLoadPositionUs();
|
||||
|
|
|
|||
|
|
@ -138,6 +138,11 @@ public class FakeAdaptiveMediaPeriod extends FakeMediaPeriod
|
|||
return sequenceableLoader.continueLoading(positionUs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLoading() {
|
||||
return sequenceableLoader.isLoading();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SampleStream createSampleStream(TrackSelection trackSelection) {
|
||||
FakeChunkSource chunkSource =
|
||||
|
|
|
|||
|
|
@ -217,6 +217,11 @@ public class FakeMediaPeriod implements MediaPeriod {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLoading() {
|
||||
return false;
|
||||
}
|
||||
|
||||
protected SampleStream createSampleStream(TrackSelection selection) {
|
||||
return new FakeSampleStream(
|
||||
selection.getSelectedFormat(), eventDispatcher, /* shouldOutputSample= */ true);
|
||||
|
|
|
|||
Loading…
Reference in a new issue