diff --git a/lib/hls/hls_parser.js b/lib/hls/hls_parser.js index 1aa536f1e2..6836518115 100644 --- a/lib/hls/hls_parser.js +++ b/lib/hls/hls_parser.js @@ -1061,19 +1061,6 @@ shaka.hls.HlsParser = class { } this.playerInterface_.makeTextStreamsForClosedCaptions(this.manifest_); - - if (variants.length == 1) { - const createSegmentIndexPromises = []; - const variant = variants[0]; - for (const stream of [variant.video, variant.audio]) { - if (stream && !stream.segmentIndex) { - createSegmentIndexPromises.push(stream.createSegmentIndex()); - } - } - if (createSegmentIndexPromises.length > 0) { - await Promise.all(createSegmentIndexPromises); - } - } } /** diff --git a/lib/media/preload_manager.js b/lib/media/preload_manager.js index c400a0f662..95844efbd1 100644 --- a/lib/media/preload_manager.js +++ b/lib/media/preload_manager.js @@ -512,6 +512,19 @@ shaka.media.PreloadManager = class extends shaka.util.FakeEventTarget { if (!this.manifest_) { this.manifest_ = await this.parser_.start( this.assetUri_, this.manifestPlayerInterface_); + + if (this.manifest_.variants.length == 1) { + const createSegmentIndexPromises = []; + const variant = this.manifest_.variants[0]; + for (const stream of [variant.video, variant.audio]) { + if (stream && !stream.segmentIndex) { + createSegmentIndexPromises.push(stream.createSegmentIndex()); + } + } + if (createSegmentIndexPromises.length > 0) { + await Promise.all(createSegmentIndexPromises); + } + } } this.manifestPromise_.resolve();