Fix seeking in live HLS streams

Issue:#4187

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=194829857
This commit is contained in:
aquilescanta 2018-04-30 12:50:08 -07:00 committed by Oliver Woodman
parent c8ec77ef96
commit d412dc97dc
2 changed files with 5 additions and 1 deletions

View File

@ -81,6 +81,8 @@
([#4016](https://github.com/google/ExoPlayer/issues/4016)).
* Add support for multiple #EXT-X-MAP tags in a media playlist
([#4164](https://github.com/google/ExoPlayer/issues/4182)).
* Fix seeking in live streams
([#4187](https://github.com/google/ExoPlayer/issues/4187)).
* Fix ClearKey decryption error if the key contains a forward slash
([#4075](https://github.com/google/ExoPlayer/issues/4075)).
* Fix crash when switching surface on Huawei P9 Lite

View File

@ -261,10 +261,12 @@ import java.util.List;
// If the playlist is too old to contain the chunk, we need to refresh it.
chunkMediaSequence = mediaPlaylist.mediaSequence + mediaPlaylist.segments.size();
} else {
// The playlist start time is subtracted from the target position because the segment start
// times are relative to the start of the playlist, but the target position is not.
chunkMediaSequence =
Util.binarySearchFloor(
mediaPlaylist.segments,
targetPositionUs,
/* value= */ targetPositionUs - mediaPlaylist.startTimeUs,
/* inclusive= */ true,
/* stayInBounds= */ !playlistTracker.isLive() || previous == null)
+ mediaPlaylist.mediaSequence;