From 2f8779baff9cf139d3993903301eb6c288f2b969 Mon Sep 17 00:00:00 2001 From: Steve Mayhew Date: Thu, 2 Sep 2021 11:30:31 -0700 Subject: [PATCH] TrackSelection does not jump to live with HlsMediaPeriod This is a fix for issue #9347 Once the MaskingMediaPeriod completes `prepare()` (when the masked HlsMediaPeriod reports the first real Timeline with a duration and window start position) and the `preparePositionUs` is used by the player in the `onPrepared()` callback to set the render position it should not use it again. The bug is a track selection causes a jump to live if you are at position 0 in the timeline, even after playback was started from the live point (the prepare position override). --- .../google/android/exoplayer2/source/MaskingMediaPeriod.java | 4 ---- .../google/android/exoplayer2/source/MaskingMediaSource.java | 5 ----- 2 files changed, 9 deletions(-) diff --git a/library/core/src/main/java/com/google/android/exoplayer2/source/MaskingMediaPeriod.java b/library/core/src/main/java/com/google/android/exoplayer2/source/MaskingMediaPeriod.java index 7c60a379c7f..40bbb786f69 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/source/MaskingMediaPeriod.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/source/MaskingMediaPeriod.java @@ -178,10 +178,6 @@ public long selectTracks( @NullableType SampleStream[] streams, boolean[] streamResetFlags, long positionUs) { - if (preparePositionOverrideUs != C.TIME_UNSET && positionUs == preparePositionUs) { - positionUs = preparePositionOverrideUs; - preparePositionOverrideUs = C.TIME_UNSET; - } return castNonNull(mediaPeriod) .selectTracks(selections, mayRetainStreamFlags, streams, streamResetFlags, positionUs); } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/source/MaskingMediaSource.java b/library/core/src/main/java/com/google/android/exoplayer2/source/MaskingMediaSource.java index c1744ed57a6..d787af15438 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/source/MaskingMediaSource.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/source/MaskingMediaSource.java @@ -140,11 +140,6 @@ protected void onChildSourceInfoRefreshed( @Nullable MediaPeriodId idForMaskingPeriodPreparation = null; if (isPrepared) { timeline = timeline.cloneWithUpdatedTimeline(newTimeline); - if (unpreparedMaskingMediaPeriod != null) { - // Reset override in case the duration changed and we need to update our override. - setPreparePositionOverrideToUnpreparedMaskingPeriod( - unpreparedMaskingMediaPeriod.getPreparePositionOverrideUs()); - } } else if (newTimeline.isEmpty()) { timeline = hasRealTimeline