Skip to content

Commit

Permalink
fix(HLS): Fix live playlist update when using no LL in a LL stream (s…
Browse files Browse the repository at this point in the history
…haka-project#5282)

This happens because the last segment in an LL stream may not be
complete and may not have EXTINF
  • Loading branch information
avelad committed Jun 12, 2023
1 parent fe43ed3 commit ad2eef6
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions lib/hls/hls_parser.js
Expand Up @@ -2647,14 +2647,19 @@ shaka.hls.HlsParser = class {
let lastTargetDuration = Infinity;
const segments = playlist.segments;
if (segments.length) {
const lastSegment = segments[segments.length - 1];
const extinfTag =
shaka.hls.Utils.getFirstTagWithName(lastSegment.tags, 'EXTINF');
if (extinfTag) {
// The EXTINF tag format is '#EXTINF:<duration>,[<title>]'.
// We're interested in the duration part.
const extinfValues = extinfTag.value.split(',');
lastTargetDuration = Number(extinfValues[0]);
let segmentIndex = segments.length - 1;
while (segmentIndex >= 0) {
const segment = segments[segmentIndex];
const extinfTag =
shaka.hls.Utils.getFirstTagWithName(segment.tags, 'EXTINF');
if (extinfTag) {
// The EXTINF tag format is '#EXTINF:<duration>,[<title>]'.
// We're interested in the duration part.
const extinfValues = extinfTag.value.split(',');
lastTargetDuration = Number(extinfValues[0]);
break;
}
segmentIndex--;
}
}
this.lastTargetDuration_ = Math.min(
Expand Down

0 comments on commit ad2eef6

Please sign in to comment.