Skip to content

Commit

Permalink
fix: Prevent error and incorrect duration
Browse files Browse the repository at this point in the history
Only check active stream:
  1. Not loaded stream maxTimestamp initialized to 0
    which the following setDuration does not allowed
  2. Inactive stream maxTimestamp always smaller
    when the user changed the resolution,
    the maxTimestamp value fell out of sync.
  • Loading branch information
cuyl committed Feb 14, 2023
1 parent ac963a9 commit 75edbce
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/hls/hls_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,13 @@ shaka.hls.HlsParser = class {
const PresentationType = shaka.hls.HlsParser.PresentationType_;
this.setPresentationType_(PresentationType.VOD);

const maxTimestamps = streamInfos.map((s) => s.maxTimestamp);
// Only check active stream:
// 1. Not loaded stream maxTimestamp initialized to 0
// which the following setDuration does not allowed
// 2. Inactive stream maxTimestamp always smaller
// when the user changed the resolution,
// the maxTimestamp value fell out of sync.
const maxTimestamps = activeStreamInfos.map((s) => s.maxTimestamp);
// The duration is the minimum of the end times of all streams.
this.presentationTimeline_.setDuration(Math.min(...maxTimestamps));
this.playerInterface_.updateDuration();
Expand Down

0 comments on commit 75edbce

Please sign in to comment.