diff --git a/lib/hls/hls_parser.js b/lib/hls/hls_parser.js index df281b505b..c84d9277f0 100644 --- a/lib/hls/hls_parser.js +++ b/lib/hls/hls_parser.js @@ -2438,21 +2438,11 @@ shaka.hls.HlsParser = class { this.setFullTypeForStream_(stream); } - const redirectUris = []; - const getUris = () => { - if (this.contentSteeringManager_ && - verbatimMediaPlaylistUris.length > 1) { - return this.contentSteeringManager_.getLocations(streamId); - } - return redirectUris.concat(shaka.hls.Utils.constructUris( - [this.masterPlaylistUri_], verbatimMediaPlaylistUris, - this.globalVariables_)); - }; const streamInfo = { stream, type, - redirectUris, - getUris, + redirectUris: [], + getUris: () => {}, // These values are filled out or updated after lazy-loading: minTimestamp: 0, maxTimestamp: 0, @@ -2466,12 +2456,23 @@ shaka.hls.HlsParser = class { loadedOnce: false, }; + const getUris = () => { + if (this.contentSteeringManager_ && + verbatimMediaPlaylistUris.length > 1) { + return this.contentSteeringManager_.getLocations(streamId); + } + return streamInfo.redirectUris.concat(shaka.hls.Utils.constructUris( + [this.masterPlaylistUri_], verbatimMediaPlaylistUris, + this.globalVariables_)); + }; + + streamInfo.getUris = getUris; + /** @param {!shaka.net.NetworkingEngine.PendingRequest} pendingRequest */ const downloadSegmentIndex = async (pendingRequest) => { const ContentType = shaka.util.ManifestParserUtils.ContentType; try { - const uris = streamInfo.getUris(); // Download the actual manifest. const response = await pendingRequest.promise; if (pendingRequest.aborted) { @@ -2480,9 +2481,11 @@ shaka.hls.HlsParser = class { // Record the final URI after redirects. const responseUri = response.uri; - if (responseUri != response.originalUri && - !uris.includes(responseUri)) { - redirectUris.push(responseUri); + if (responseUri != response.originalUri) { + const uris = streamInfo.getUris(); + if (!uris.includes(responseUri)) { + streamInfo.redirectUris.push(responseUri); + } } // Record the redirected, final URI of this media playlist when we parse