diff --git a/lib/hls/hls_parser.js b/lib/hls/hls_parser.js index 277f7e8615..35451eb4d1 100644 --- a/lib/hls/hls_parser.js +++ b/lib/hls/hls_parser.js @@ -2360,6 +2360,9 @@ shaka.hls.HlsParser = class { const partialReferences = lastSegment.partialReferences; if (!lastSegment.partialReferences.length) { nextMediaSequence++; + if (lastSegment.hasByterangeOptimization()) { + nextPart = 0; + } return { nextMediaSequence, nextPart, @@ -2844,6 +2847,7 @@ shaka.hls.HlsParser = class { let segmentWithByteRangeOptimization = false; let getUrisOptimization = null; let somePartialSegmentWithGap = false; + let isPreloadSegment = false; if (this.lowLatencyMode_ && hlsSegment.partialSegments.length) { const byterangeOptimizationSupport = (mimeType == 'video/mp4' || @@ -2937,6 +2941,7 @@ shaka.hls.HlsParser = class { hlsAes128Key); if (item.name == 'EXT-X-PRELOAD-HINT') { partial.markAsPreload(); + isPreloadSegment = true; } // The spec doesn't say that we can assume INDEPENDENT=YES for the // first partial segment. It does call the flag "optional", though, and @@ -3043,6 +3048,10 @@ shaka.hls.HlsParser = class { if (segmentWithByteRangeOptimization) { reference.markAsByterangeOptimization(); + + if (isPreloadSegment) { + reference.markAsPreload(); + } } return reference; diff --git a/test/hls/hls_live_unit.js b/test/hls/hls_live_unit.js index 7e867ec33b..de6279371c 100644 --- a/test/hls/hls_live_unit.js +++ b/test/hls/hls_live_unit.js @@ -722,6 +722,7 @@ describe('HlsParser live', () => { /* baseUri= */ '', /* startByte= */ 0, /* endByte= */ null, /* timestampOffset= */ 0); ref2.markAsByterangeOptimization(); + ref2.markAsPreload(); await testInitialManifest(master, mediaWithPartialSegments, [ref, ref2]);