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
This commit is contained in:
aquilescanta 2016-10-18 11:55:47 -07:00 committed by Oliver Woodman
parent 1cfc432bb8
commit aecbbdd36c

View File

@ -440,6 +440,10 @@ import java.util.Locale;
} }
HlsMediaPlaylist oldMediaPlaylist = variantPlaylists[oldVariantIndex]; HlsMediaPlaylist oldMediaPlaylist = variantPlaylists[oldVariantIndex];
HlsMediaPlaylist newMediaPlaylist = variantPlaylists[newVariantIndex]; HlsMediaPlaylist newMediaPlaylist = variantPlaylists[newVariantIndex];
if (previousChunkIndex < oldMediaPlaylist.mediaSequence) {
// We have fallen behind the live window.
return newMediaPlaylist.mediaSequence - 1;
}
double offsetToLiveInstantSecs = 0; double offsetToLiveInstantSecs = 0;
for (int i = previousChunkIndex - oldMediaPlaylist.mediaSequence; for (int i = previousChunkIndex - oldMediaPlaylist.mediaSequence;
i < oldMediaPlaylist.segments.size(); i++) { i < oldMediaPlaylist.segments.size(); i++) {