diff --git a/lib/dash/segment_list.js b/lib/dash/segment_list.js index 81dd7fe56f..9412f4d8e6 100644 --- a/lib/dash/segment_list.js +++ b/lib/dash/segment_list.js @@ -223,9 +223,6 @@ shaka.dash.SegmentList = class { let prevEndTime = info.startTime; for (let i = 0; i < max; i++) { const segment = info.mediaSegments[i]; - const mediaUri = ManifestParserUtils.resolveUris( - baseUris, [segment.mediaUri]); - const startTime = prevEndTime; let endTime; @@ -243,7 +240,13 @@ shaka.dash.SegmentList = class { endTime = startTime + periodDuration; } - const getUris = () => mediaUri; + let uris = null; + const getUris = () => { + if (uris == null) { + uris = ManifestParserUtils.resolveUris(baseUris, [segment.mediaUri]); + } + return uris; + }; references.push( new shaka.media.SegmentReference( periodStart + startTime, diff --git a/lib/hls/hls_parser.js b/lib/hls/hls_parser.js index 035dc988ea..d3c1245104 100644 --- a/lib/hls/hls_parser.js +++ b/lib/hls/hls_parser.js @@ -2669,8 +2669,6 @@ shaka.hls.HlsParser = class { variables, absoluteMediaPlaylistUri, type, timestampOffset, hlsAes128Key) { const tags = hlsSegment.tags; - const absoluteSegmentUri = this.variableSubstitution_( - hlsSegment.absoluteUri, variables); const extinfTag = shaka.hls.Utils.getFirstTagWithName(tags, 'EXTINF'); @@ -2754,18 +2752,26 @@ shaka.hls.HlsParser = class { if (!pUri) { continue; } - const pAbsoluteUri = shaka.hls.Utils.constructAbsoluteUri( - absoluteMediaPlaylistUri, pUri); let partialStatus = shaka.media.SegmentReference.Status.AVAILABLE; if (item.getAttributeValue('GAP') == 'YES') { partialStatus = shaka.media.SegmentReference.Status.MISSING; } + let pAbsoluteUri = null; + const getPartialUris = () => { + if (pAbsoluteUri == null) { + goog.asserts.assert(pUri, 'Partial uri should be defined!'); + pAbsoluteUri = shaka.hls.Utils.constructAbsoluteUri( + absoluteMediaPlaylistUri, pUri); + } + return [pAbsoluteUri]; + }; + const partial = new shaka.media.SegmentReference( pStartTime, pEndTime, - () => [pAbsoluteUri], + getPartialUris, pStartByte, pEndByte, initSegmentReference, @@ -2829,10 +2835,19 @@ shaka.hls.HlsParser = class { } } + let absoluteSegmentUri = null; + const getUris = () => { + if (absoluteSegmentUri == null) { + absoluteSegmentUri = this.variableSubstitution_( + hlsSegment.absoluteUri, variables); + } + return absoluteSegmentUri.length ? [absoluteSegmentUri] : []; + }; + return new shaka.media.SegmentReference( startTime, endTime, - () => absoluteSegmentUri.length ? [absoluteSegmentUri] : [], + getUris, startByte, endByte, initSegmentReference,