From aecbbdd36c669f1c98facac91b92eb07850bf38c Mon Sep 17 00:00:00 2001 From: aquilescanta Date: Tue, 18 Oct 2016 11:55:47 -0700 Subject: [PATCH] Replace IndexOutOfBounds Exception for BehindLiveWindowException This is a problem when two invocations of getNextChunk that retrieve chunks (i.e. not playlists) occur too apart in time. In that case the last loaded chunk has a media sequence that is behind the current playlist. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=136501291 --- .../google/android/exoplayer2/source/hls/HlsChunkSource.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/library/src/main/java/com/google/android/exoplayer2/source/hls/HlsChunkSource.java b/library/src/main/java/com/google/android/exoplayer2/source/hls/HlsChunkSource.java index 53d9e70d76..a23ab3bae7 100644 --- a/library/src/main/java/com/google/android/exoplayer2/source/hls/HlsChunkSource.java +++ b/library/src/main/java/com/google/android/exoplayer2/source/hls/HlsChunkSource.java @@ -440,6 +440,10 @@ import java.util.Locale; } HlsMediaPlaylist oldMediaPlaylist = variantPlaylists[oldVariantIndex]; HlsMediaPlaylist newMediaPlaylist = variantPlaylists[newVariantIndex]; + if (previousChunkIndex < oldMediaPlaylist.mediaSequence) { + // We have fallen behind the live window. + return newMediaPlaylist.mediaSequence - 1; + } double offsetToLiveInstantSecs = 0; for (int i = previousChunkIndex - oldMediaPlaylist.mediaSequence; i < oldMediaPlaylist.segments.size(); i++) {