Skip to content

Commit 55093ec

Browse files
committed
fix: Allow EXT-X-PART with no segment
1 parent 35c651e commit 55093ec

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

stringify.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,8 +363,10 @@ function buildSegment(lines: LineArray, segment: Segment, lastKey: string, lastM
363363
if (hint) {
364364
return [lastKey, lastMap];
365365
}
366-
const duration = version < 3 ? Math.round(segment.duration) : buildDecimalFloatingNumber(segment.duration, getNumberOfDecimalPlaces(segment.duration));
367-
lines.push(`#EXTINF:${duration},${unescape(encodeURIComponent(segment.title || ''))}`);
366+
if (typeof segment.duration === 'number' && !Number.isNaN(segment.duration)) {
367+
const duration = version < 3 ? Math.round(segment.duration) : buildDecimalFloatingNumber(segment.duration, getNumberOfDecimalPlaces(segment.duration));
368+
lines.push(`#EXTINF:${duration},${unescape(encodeURIComponent(segment.title || ''))}`);
369+
}
368370
if (segment.byterange) {
369371
lines.push(`#EXT-X-BYTERANGE:${buildByteRange(segment.byterange)}`);
370372
}

test/spec/Apple-Low-Latency/New_Media_Playlist_Tags_for_Low-Latency_HLS/03_EXT-X-PART.spec.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,3 +216,18 @@ test('#EXT-X-PART_05', t => {
216216
}
217217
}
218218
});
219+
220+
// EXTINF can be ommitted
221+
test('#EXT-X-PART_06', t => {
222+
utils.bothPass(t, `
223+
#EXTM3U
224+
#EXT-X-VERSION:6
225+
#EXT-X-TARGETDURATION:2
226+
#EXT-X-SERVER-CONTROL:CAN-BLOCK-RELOAD=YES,PART-HOLD-BACK=0.6
227+
#EXT-X-PART-INF:PART-TARGET=0.2
228+
#EXTINF:2,
229+
fs240.mp4
230+
#EXT-X-PART:DURATION=0.17,URI="fs241.mp4",BYTERANGE=20000@0
231+
#EXT-X-ENDLIST
232+
`);
233+
});

0 commit comments

Comments
 (0)