diff --git a/lib/hls/hls_parser.js b/lib/hls/hls_parser.js index 54a26174cf..cf5009821c 100644 --- a/lib/hls/hls_parser.js +++ b/lib/hls/hls_parser.js @@ -534,6 +534,30 @@ shaka.hls.HlsParser = class { } } + // Now that the content has been fit, notify segments. + this.segmentsToNotifyByStream_ = []; + const streamsToNotify = []; + for (const variant of variants) { + for (const stream of [variant.video, variant.audio]) { + if (stream) { + streamsToNotify.push(stream); + } + } + } + await Promise.all(streamsToNotify.map(async (stream) => { + await stream.createSegmentIndex(); + })); + for (const stream of streamsToNotify) { + this.segmentsToNotifyByStream_.push(stream.segmentIndex.references); + } + this.notifySegments_(); + + // This asserts that the live edge is being calculated from segment times. + // For VOD and event streams, this check should still pass. + goog.asserts.assert( + !this.presentationTimeline_.usingPresentationStartTime(), + 'We should not be using the presentation start time in HLS!'); + this.manifest_ = { presentationTimeline: this.presentationTimeline_, variants, @@ -1618,12 +1642,6 @@ shaka.hls.HlsParser = class { } this.notifySegments_(); - - // This asserts that the live edge is being calculated from segment times. - // For VOD and event streams, this check should still pass. - goog.asserts.assert( - !this.presentationTimeline_.usingPresentationStartTime(), - 'We should not be using the presentation start time in HLS!'); } /** @@ -2014,9 +2032,6 @@ shaka.hls.HlsParser = class { } } - this.segmentsToNotifyByStream_.push(references); - this.notifySegments_(); - return references; } diff --git a/test/hls/hls_parser_unit.js b/test/hls/hls_parser_unit.js index 7ee5d21f12..67c000c123 100644 --- a/test/hls/hls_parser_unit.js +++ b/test/hls/hls_parser_unit.js @@ -1309,6 +1309,8 @@ describe('HlsParser', () => { // stream. const timeline = actual.presentationTimeline; expect(timeline.getDuration()).toBe(10); + expect(timeline.getSeekRangeStart()).toBe(0); + expect(timeline.getSeekRangeEnd()).toBe(10); expect(actual.textStreams.length).toBe(1); expect(actual.variants.length).toBe(1);