diff --git a/lib/hls/hls_parser.js b/lib/hls/hls_parser.js index 2c07ae7316..f6cba67cfc 100644 --- a/lib/hls/hls_parser.js +++ b/lib/hls/hls_parser.js @@ -2846,6 +2846,11 @@ shaka.hls.HlsParser = class { // A preload hinted partial segment may have byterange start info. const pByterangeStart = item.getAttributeValue('BYTERANGE-START'); pStartByte = pByterangeStart ? Number(pByterangeStart) : 0; + // A preload hinted partial segment may have byterange length info. + const pByterangeLength = item.getAttributeValue('BYTERANGE-LENGTH'); + if (pByterangeLength) { + pEndByte = pStartByte + Number(pByterangeLength) - 1; + } } else { const pByterange = item.getAttributeValue('BYTERANGE'); [pStartByte, pEndByte] = diff --git a/test/hls/hls_live_unit.js b/test/hls/hls_live_unit.js index ecd249766b..d923d7aa7b 100644 --- a/test/hls/hls_live_unit.js +++ b/test/hls/hls_live_unit.js @@ -643,7 +643,8 @@ describe('HlsParser live', () => { // partialRef3 '#EXT-X-PART:DURATION=2,URI="partial.mp4",BYTERANGE=210@0\n', // preloadRef - '#EXT-X-PRELOAD-HINT:TYPE=PART,URI="partial.mp4",BYTERANGE-START=210\n', + '#EXT-X-PRELOAD-HINT:TYPE=PART,URI="partial.mp4",BYTERANGE-START=210,', + 'BYTERANGE-LENGTH=210\n', ].join(''); const partialRef = makeReference( @@ -665,13 +666,13 @@ describe('HlsParser live', () => { const preloadRef = makeReference( 'test:/partial.mp4', 6, 7.5, /* syncTime= */ null, - /* baseUri= */ '', /* startByte= */ 210, /* endByte= */ null); + /* baseUri= */ '', /* startByte= */ 210, /* endByte= */ 419); preloadRef.markAsPreload(); // ref2 is not fully published yet, so it doesn't have a segment uri. const ref2 = makeReference( '', 4, 7.5, /* syncTime= */ null, - /* baseUri= */ '', /* startByte= */ 0, /* endByte= */ null, + /* baseUri= */ '', /* startByte= */ 0, /* endByte= */ 419, /* timestampOffset= */ 0, [partialRef3, preloadRef]); await testInitialManifest(master, mediaWithPartialSegments, [ref, ref2]);