Skip to content

Commit

Permalink
fix: Fix duration error when HLS goes from LIVE to VOD (shaka-project…
Browse files Browse the repository at this point in the history
…#5001)

The duration is the minimum of the end times of all active streams.
Non-active streams are not guaranteed to have useful maxTimestamp
values, due to the lazy-loading system, so they are ignored.
  • Loading branch information
cuyl committed Feb 16, 2023
1 parent ac963a9 commit 1aee989
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/hls/hls_parser.js
Expand Up @@ -308,7 +308,10 @@ shaka.hls.HlsParser = class {
const PresentationType = shaka.hls.HlsParser.PresentationType_;
this.setPresentationType_(PresentationType.VOD);

const maxTimestamps = streamInfos.map((s) => s.maxTimestamp);
// The duration is the minimum of the end times of all active streams.
// Non-active streams are not guaranteed to have useful maxTimestamp
// values, due to the lazy-loading system, so they are ignored.
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 1aee989

Please sign in to comment.