Skip to content

Commit

Permalink
fix: Allow EXT-X-PART with no segment
Browse files Browse the repository at this point in the history
  • Loading branch information
kuu committed Dec 17, 2024
1 parent 35c651e commit 55093ec
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
6 changes: 4 additions & 2 deletions stringify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -363,8 +363,10 @@ function buildSegment(lines: LineArray, segment: Segment, lastKey: string, lastM
if (hint) {
return [lastKey, lastMap];
}
const duration = version < 3 ? Math.round(segment.duration) : buildDecimalFloatingNumber(segment.duration, getNumberOfDecimalPlaces(segment.duration));
lines.push(`#EXTINF:${duration},${unescape(encodeURIComponent(segment.title || ''))}`);
if (typeof segment.duration === 'number' && !Number.isNaN(segment.duration)) {
const duration = version < 3 ? Math.round(segment.duration) : buildDecimalFloatingNumber(segment.duration, getNumberOfDecimalPlaces(segment.duration));
lines.push(`#EXTINF:${duration},${unescape(encodeURIComponent(segment.title || ''))}`);
}
if (segment.byterange) {
lines.push(`#EXT-X-BYTERANGE:${buildByteRange(segment.byterange)}`);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,3 +216,18 @@ test('#EXT-X-PART_05', t => {
}
}
});

// EXTINF can be ommitted
test('#EXT-X-PART_06', t => {
utils.bothPass(t, `
#EXTM3U
#EXT-X-VERSION:6
#EXT-X-TARGETDURATION:2
#EXT-X-SERVER-CONTROL:CAN-BLOCK-RELOAD=YES,PART-HOLD-BACK=0.6
#EXT-X-PART-INF:PART-TARGET=0.2
#EXTINF:2,
fs240.mp4
#EXT-X-PART:DURATION=0.17,URI="fs241.mp4",BYTERANGE=20000@0
#EXT-X-ENDLIST
`);
});

0 comments on commit 55093ec

Please sign in to comment.