diff --git a/library/core/src/main/java/com/google/android/exoplayer2/extractor/DefaultTrackOutput.java b/library/core/src/main/java/com/google/android/exoplayer2/extractor/DefaultTrackOutput.java index 8aff8858a1f..d57b55bfd2b 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/extractor/DefaultTrackOutput.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/extractor/DefaultTrackOutput.java @@ -227,20 +227,6 @@ public long getLargestQueuedTimestampUs() { return infoQueue.getLargestQueuedTimestampUs(); } - /** - * Attempts to skip to the keyframe before or at the specified time. Succeeds only if the buffer - * contains a keyframe with a timestamp of {@code timeUs} or earlier, and if {@code timeUs} falls - * within the currently buffered media. - *
- * This method is equivalent to {@code skipToKeyframeBefore(timeUs, false)}. - * - * @param timeUs The seek time. - * @return Whether the skip was successful. - */ - public boolean skipToKeyframeBefore(long timeUs) { - return skipToKeyframeBefore(timeUs, false); - } - /** * Attempts to skip to the keyframe before or at the specified time. Succeeds only if the buffer * contains a keyframe with a timestamp of {@code timeUs} or earlier. If diff --git a/library/core/src/main/java/com/google/android/exoplayer2/source/ExtractorMediaPeriod.java b/library/core/src/main/java/com/google/android/exoplayer2/source/ExtractorMediaPeriod.java index d843943710e..d54e8811830 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/source/ExtractorMediaPeriod.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/source/ExtractorMediaPeriod.java @@ -301,7 +301,7 @@ public long seekToUs(long positionUs) { boolean seekInsideBuffer = !isPendingReset(); for (int i = 0; seekInsideBuffer && i < trackCount; i++) { if (trackEnabledStates[i]) { - seekInsideBuffer = sampleQueues.valueAt(i).skipToKeyframeBefore(positionUs); + seekInsideBuffer = sampleQueues.valueAt(i).skipToKeyframeBefore(positionUs, false); } } // If we failed to seek within the sample queues, we need to restart. @@ -340,6 +340,10 @@ public long seekToUs(long positionUs) { loadingFinished, lastSeekPositionUs); } + /* package */ void skipToKeyframeBefore(int track, long timeUs) { + sampleQueues.valueAt(track).skipToKeyframeBefore(timeUs, true); + } + // Loader.Callback implementation. @Override @@ -566,7 +570,7 @@ public int readData(FormatHolder formatHolder, DecoderInputBuffer buffer, @Override public void skipToKeyframeBefore(long timeUs) { - sampleQueues.valueAt(track).skipToKeyframeBefore(timeUs); + ExtractorMediaPeriod.this.skipToKeyframeBefore(track, timeUs); } } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/ChunkSampleStream.java b/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/ChunkSampleStream.java index 93d86a8de19..6a62afe2fb5 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/ChunkSampleStream.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/ChunkSampleStream.java @@ -193,7 +193,7 @@ public void seekToUs(long positionUs) { // TODO: For this to work correctly, the embedded streams must not discard anything from their // sample queues beyond the current read position of the primary stream. for (DefaultTrackOutput embeddedSampleQueue : embeddedSampleQueues) { - embeddedSampleQueue.skipToKeyframeBefore(positionUs); + embeddedSampleQueue.skipToKeyframeBefore(positionUs, true); } } else { // We failed, and need to restart. @@ -252,7 +252,7 @@ public int readData(FormatHolder formatHolder, DecoderInputBuffer buffer, @Override public void skipToKeyframeBefore(long timeUs) { - primarySampleQueue.skipToKeyframeBefore(timeUs); + primarySampleQueue.skipToKeyframeBefore(timeUs, true); } // Loader.Callback implementation. @@ -449,7 +449,7 @@ public boolean isReady() { @Override public void skipToKeyframeBefore(long timeUs) { - sampleQueue.skipToKeyframeBefore(timeUs); + sampleQueue.skipToKeyframeBefore(timeUs, true); } @Override diff --git a/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/HlsSampleStreamWrapper.java b/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/HlsSampleStreamWrapper.java index 8bd966f1779..f2cf7d2ddb6 100644 --- a/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/HlsSampleStreamWrapper.java +++ b/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/HlsSampleStreamWrapper.java @@ -313,7 +313,7 @@ public void onPlaylistBlacklisted(HlsUrl url, long blacklistMs) { } /* package */ void skipToKeyframeBefore(int group, long timeUs) { - sampleQueues.valueAt(group).skipToKeyframeBefore(timeUs); + sampleQueues.valueAt(group).skipToKeyframeBefore(timeUs, true); } private boolean finishedReadingChunk(HlsMediaChunk chunk) {