mirror of
https://github.com/samsonjs/media.git
synced 2026-04-17 13:15:47 +00:00
Correct comment on track selection during seek
The comment "all should be same" is not correct, it is extremely likely they will be the same but not assured. In either case the seek position will work, it just may not land exactly on a sync point in every variant.
This commit is contained in:
parent
d3bba3b0e6
commit
530dd3f733
1 changed files with 7 additions and 2 deletions
|
|
@ -257,8 +257,13 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
|||
mediaPlaylist = playlistTracker.getPlaylistSnapshot(playlistUrls[selectedIndex], /* isForPlayback= */ true);
|
||||
}
|
||||
|
||||
// Resolve to a segment boundary, current track is fine (all should be same).
|
||||
// and, segments must start with sync (EXT-X-INDEPENDENT-SEGMENTS must be present)
|
||||
// If segments must start with sync (EXT-X-INDEPENDENT-SEGMENTS is set) and the playlist is not empty
|
||||
// resolve using the nearest segment start and the next segment (if any) start as the first and second
|
||||
// sync points.
|
||||
// Note, the position returned is normalized to the period, so it will work if a track selection changes
|
||||
// variants before the seek is executed. It is possible it may not land exactly on a segment sync point in the rare
|
||||
// case the segment boundaries do not align across variants.
|
||||
//
|
||||
if (mediaPlaylist != null && mediaPlaylist.hasIndependentSegments && !mediaPlaylist.segments.isEmpty()) {
|
||||
long startOfPlaylistInPeriodUs = mediaPlaylist.startTimeUs - playlistTracker.getInitialStartTimeUs();
|
||||
long targetPositionInPlaylistUs = positionUs - startOfPlaylistInPeriodUs;
|
||||
|
|
|
|||
Loading…
Reference in a new issue