hls.js 1.6.0-rc.1.0.canary.11079 → 1.6.0-rc.1.0.canary.11080
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/hls.d.mts +12 -3
- package/dist/hls.d.ts +12 -3
- package/dist/hls.js +257 -142
- package/dist/hls.js.d.ts +12 -3
- package/dist/hls.js.map +1 -1
- package/dist/hls.light.js +89 -62
- package/dist/hls.light.js.map +1 -1
- package/dist/hls.light.min.js +1 -1
- package/dist/hls.light.min.js.map +1 -1
- package/dist/hls.light.mjs +48 -26
- package/dist/hls.light.mjs.map +1 -1
- package/dist/hls.min.js +1 -1
- package/dist/hls.min.js.map +1 -1
- package/dist/hls.mjs +180 -73
- package/dist/hls.mjs.map +1 -1
- package/dist/hls.worker.js +1 -1
- package/package.json +1 -1
- package/src/controller/audio-stream-controller.ts +7 -7
- package/src/controller/base-stream-controller.ts +44 -11
- package/src/controller/buffer-controller.ts +21 -13
- package/src/controller/interstitial-player.ts +30 -0
- package/src/controller/interstitials-controller.ts +69 -21
- package/src/controller/interstitials-schedule.ts +14 -10
- package/src/controller/stream-controller.ts +9 -8
- package/src/controller/subtitle-stream-controller.ts +4 -5
- package/src/loader/interstitial-asset-list.ts +3 -13
- package/src/loader/interstitial-event.ts +20 -2
package/dist/hls.js
CHANGED
@@ -1073,7 +1073,7 @@
|
|
1073
1073
|
// Some browsers don't allow to use bind on console object anyway
|
1074
1074
|
// fallback to default if needed
|
1075
1075
|
try {
|
1076
|
-
newLogger.log("Debug logs enabled for \"" + context + "\" in hls.js version " + "1.6.0-rc.1.0.canary.
|
1076
|
+
newLogger.log("Debug logs enabled for \"" + context + "\" in hls.js version " + "1.6.0-rc.1.0.canary.11080");
|
1077
1077
|
} catch (e) {
|
1078
1078
|
/* log fn threw an exception. All logger methods are no-ops. */
|
1079
1079
|
return createLogger();
|
@@ -9888,8 +9888,8 @@
|
|
9888
9888
|
var end = this.loadingParts ? levelDetails.partEnd : levelDetails.fragmentEnd;
|
9889
9889
|
frag = this.getFragmentAtPosition(pos, end, levelDetails);
|
9890
9890
|
}
|
9891
|
-
|
9892
|
-
return this.mapToInitFragWhenRequired(
|
9891
|
+
var programFrag = this.filterReplacedPrimary(frag, levelDetails);
|
9892
|
+
return this.mapToInitFragWhenRequired(programFrag);
|
9893
9893
|
};
|
9894
9894
|
_proto.isLoopLoading = function isLoopLoading(frag, targetBufferTime) {
|
9895
9895
|
var trackerState = this.fragmentTracker.getState(frag);
|
@@ -9920,8 +9920,7 @@
|
|
9920
9920
|
if (!frag) {
|
9921
9921
|
return frag;
|
9922
9922
|
}
|
9923
|
-
|
9924
|
-
if (config.interstitialsController && config.enableInterstitialPlayback !== false && frag.type !== PlaylistLevelType.SUBTITLE) {
|
9923
|
+
if (interstitialsEnabled(this.hls.config) && frag.type !== PlaylistLevelType.SUBTITLE) {
|
9925
9924
|
// Do not load fragments outside the buffering schedule segment
|
9926
9925
|
var interstitials = this.hls.interstitialsManager;
|
9927
9926
|
var bufferingItem = interstitials == null ? void 0 : interstitials.bufferingItem;
|
@@ -9941,7 +9940,10 @@
|
|
9941
9940
|
}
|
9942
9941
|
if (frag.start > bufferingItem.end && bufferingItem.nextEvent) {
|
9943
9942
|
// fragment is past schedule item end
|
9944
|
-
|
9943
|
+
// allow some overflow when not appending in place to prevent stalls
|
9944
|
+
if (bufferingItem.nextEvent.appendInPlace || frag.start - bufferingItem.end > 1) {
|
9945
|
+
return null;
|
9946
|
+
}
|
9945
9947
|
}
|
9946
9948
|
}
|
9947
9949
|
}
|
@@ -10117,6 +10119,7 @@
|
|
10117
10119
|
if (startPosition < sliding) {
|
10118
10120
|
startPosition = -1;
|
10119
10121
|
}
|
10122
|
+
var timelineOffset = this.timelineOffset;
|
10120
10123
|
if (startPosition === -1) {
|
10121
10124
|
// Use Playlist EXT-X-START:TIME-OFFSET when set
|
10122
10125
|
// Prioritize Multivariant Playlist offset so that main, audio, and subtitle stream-controller start times match
|
@@ -10140,9 +10143,9 @@
|
|
10140
10143
|
this.log("setting startPosition to 0 by default");
|
10141
10144
|
this.startPosition = startPosition = 0;
|
10142
10145
|
}
|
10143
|
-
this.lastCurrentTime = startPosition;
|
10146
|
+
this.lastCurrentTime = startPosition + timelineOffset;
|
10144
10147
|
}
|
10145
|
-
this.nextLoadPosition = startPosition;
|
10148
|
+
this.nextLoadPosition = startPosition + timelineOffset;
|
10146
10149
|
};
|
10147
10150
|
_proto.getLoadPosition = function getLoadPosition() {
|
10148
10151
|
var _this$hls;
|
@@ -10439,6 +10442,28 @@
|
|
10439
10442
|
state: this.state
|
10440
10443
|
};
|
10441
10444
|
}
|
10445
|
+
}, {
|
10446
|
+
key: "timelineOffset",
|
10447
|
+
get: function get() {
|
10448
|
+
var configuredTimelineOffset = this.config.timelineOffset;
|
10449
|
+
if (configuredTimelineOffset) {
|
10450
|
+
var _this$getLevelDetails;
|
10451
|
+
return ((_this$getLevelDetails = this.getLevelDetails()) == null ? void 0 : _this$getLevelDetails.appliedTimelineOffset) || configuredTimelineOffset;
|
10452
|
+
}
|
10453
|
+
return 0;
|
10454
|
+
}
|
10455
|
+
}, {
|
10456
|
+
key: "primaryPrefetch",
|
10457
|
+
get: function get() {
|
10458
|
+
if (interstitialsEnabled(this.hls.config)) {
|
10459
|
+
var _this$hls$interstitia, _this$hls$interstitia2;
|
10460
|
+
var playingInterstitial = (_this$hls$interstitia = this.hls.interstitialsManager) == null ? void 0 : (_this$hls$interstitia2 = _this$hls$interstitia.playingItem) == null ? void 0 : _this$hls$interstitia2.event;
|
10461
|
+
if (playingInterstitial) {
|
10462
|
+
return true;
|
10463
|
+
}
|
10464
|
+
}
|
10465
|
+
return false;
|
10466
|
+
}
|
10442
10467
|
}, {
|
10443
10468
|
key: "state",
|
10444
10469
|
get: function get() {
|
@@ -10453,6 +10478,9 @@
|
|
10453
10478
|
}
|
10454
10479
|
}]);
|
10455
10480
|
}(TaskLoop);
|
10481
|
+
function interstitialsEnabled(config) {
|
10482
|
+
return !!config.interstitialsController && config.enableInterstitialPlayback !== false;
|
10483
|
+
}
|
10456
10484
|
|
10457
10485
|
var ChunkCache = /*#__PURE__*/function () {
|
10458
10486
|
function ChunkCache() {
|
@@ -16560,7 +16588,7 @@
|
|
16560
16588
|
return !remuxResult.audio && !remuxResult.video && !remuxResult.text && !remuxResult.id3 && !remuxResult.initSegment;
|
16561
16589
|
}
|
16562
16590
|
|
16563
|
-
var version = "1.6.0-rc.1.0.canary.
|
16591
|
+
var version = "1.6.0-rc.1.0.canary.11080";
|
16564
16592
|
|
16565
16593
|
// ensure the worker ends up in the bundle
|
16566
16594
|
// If the worker should not be included this gets aliased to empty.js
|
@@ -17034,7 +17062,7 @@
|
|
17034
17062
|
var cc = mainFrag.cc;
|
17035
17063
|
return findNearestWithCC(trackDetails, cc, mainFrag) || trackDetails && findFragWithCC(trackDetails.fragments, cc) || mainFrag;
|
17036
17064
|
};
|
17037
|
-
_proto.startLoad = function startLoad(startPosition) {
|
17065
|
+
_proto.startLoad = function startLoad(startPosition, skipSeekToStartPosition) {
|
17038
17066
|
if (!this.levels) {
|
17039
17067
|
this.startPosition = startPosition;
|
17040
17068
|
this.state = State.STOPPED;
|
@@ -17050,7 +17078,8 @@
|
|
17050
17078
|
} else {
|
17051
17079
|
this.state = State.WAITING_TRACK;
|
17052
17080
|
}
|
17053
|
-
this.nextLoadPosition = this.
|
17081
|
+
this.nextLoadPosition = this.lastCurrentTime = startPosition + this.timelineOffset;
|
17082
|
+
this.startPosition = skipSeekToStartPosition ? -1 : startPosition;
|
17054
17083
|
this.tick();
|
17055
17084
|
};
|
17056
17085
|
_proto.doTick = function doTick() {
|
@@ -17164,7 +17193,7 @@
|
|
17164
17193
|
// 3. if tracks or track not loaded and selected
|
17165
17194
|
// then exit loop
|
17166
17195
|
// => if media not attached but start frag prefetch is enabled and start frag not requested yet, we will not exit loop
|
17167
|
-
if (!this.buffering || !media && (this.startFragRequested || !config.startFragPrefetch) || !(levels != null && levels[trackId])) {
|
17196
|
+
if (!this.buffering || !media && !this.primaryPrefetch && (this.startFragRequested || !config.startFragPrefetch) || !(levels != null && levels[trackId])) {
|
17168
17197
|
return;
|
17169
17198
|
}
|
17170
17199
|
var levelInfo = levels[trackId];
|
@@ -19381,18 +19410,10 @@
|
|
19381
19410
|
return type && !((_this16$tracks$type = _this16.tracks[type]) != null && _this16$tracks$type.ended);
|
19382
19411
|
});
|
19383
19412
|
if (allTracksEnding) {
|
19384
|
-
|
19385
|
-
|
19386
|
-
|
19387
|
-
|
19388
|
-
if (type !== null) {
|
19389
|
-
var track = _this16.tracks[type];
|
19390
|
-
if (track) {
|
19391
|
-
track.ending = false;
|
19392
|
-
}
|
19393
|
-
}
|
19394
|
-
});
|
19395
|
-
if (allowEndOfStream) {
|
19413
|
+
if (allowEndOfStream) {
|
19414
|
+
this.log("Queueing EOS");
|
19415
|
+
this.blockUntilOpen(function () {
|
19416
|
+
_this16.tracksEnded();
|
19396
19417
|
var mediaSource = _this16.mediaSource;
|
19397
19418
|
if (!mediaSource || mediaSource.readyState !== 'open') {
|
19398
19419
|
if (mediaSource) {
|
@@ -19403,11 +19424,26 @@
|
|
19403
19424
|
_this16.log("Calling mediaSource.endOfStream()");
|
19404
19425
|
// Allow this to throw and be caught by the enqueueing function
|
19405
19426
|
mediaSource.endOfStream();
|
19406
|
-
|
19407
|
-
|
19408
|
-
}
|
19427
|
+
_this16.hls.trigger(Events.BUFFERED_TO_END, undefined);
|
19428
|
+
});
|
19429
|
+
} else {
|
19430
|
+
this.tracksEnded();
|
19431
|
+
this.hls.trigger(Events.BUFFERED_TO_END, undefined);
|
19432
|
+
}
|
19409
19433
|
}
|
19410
19434
|
};
|
19435
|
+
_proto.tracksEnded = function tracksEnded() {
|
19436
|
+
var _this17 = this;
|
19437
|
+
this.sourceBuffers.forEach(function (_ref7) {
|
19438
|
+
var type = _ref7[0];
|
19439
|
+
if (type !== null) {
|
19440
|
+
var track = _this17.tracks[type];
|
19441
|
+
if (track) {
|
19442
|
+
track.ending = false;
|
19443
|
+
}
|
19444
|
+
}
|
19445
|
+
});
|
19446
|
+
};
|
19411
19447
|
_proto.onLevelUpdated = function onLevelUpdated(event, _ref8) {
|
19412
19448
|
var details = _ref8.details;
|
19413
19449
|
if (!details.fragments.length) {
|
@@ -19417,13 +19453,13 @@
|
|
19417
19453
|
this.updateDuration();
|
19418
19454
|
};
|
19419
19455
|
_proto.updateDuration = function updateDuration() {
|
19420
|
-
var
|
19456
|
+
var _this18 = this;
|
19421
19457
|
var durationAndRange = this.getDurationAndRange();
|
19422
19458
|
if (!durationAndRange) {
|
19423
19459
|
return;
|
19424
19460
|
}
|
19425
19461
|
this.blockUntilOpen(function () {
|
19426
|
-
return
|
19462
|
+
return _this18.updateMediaSource(durationAndRange);
|
19427
19463
|
});
|
19428
19464
|
};
|
19429
19465
|
_proto.onError = function onError(event, data) {
|
@@ -19471,7 +19507,7 @@
|
|
19471
19507
|
}
|
19472
19508
|
};
|
19473
19509
|
_proto.flushBackBuffer = function flushBackBuffer(currentTime, targetDuration, targetBackBufferPosition) {
|
19474
|
-
var
|
19510
|
+
var _this19 = this;
|
19475
19511
|
this.sourceBuffers.forEach(function (_ref9) {
|
19476
19512
|
var type = _ref9[0],
|
19477
19513
|
sb = _ref9[1];
|
@@ -19479,22 +19515,22 @@
|
|
19479
19515
|
var buffered = BufferHelper.getBuffered(sb);
|
19480
19516
|
// when target buffer start exceeds actual buffer start
|
19481
19517
|
if (buffered.length > 0 && targetBackBufferPosition > buffered.start(0)) {
|
19482
|
-
var
|
19483
|
-
|
19518
|
+
var _this19$details;
|
19519
|
+
_this19.hls.trigger(Events.BACK_BUFFER_REACHED, {
|
19484
19520
|
bufferEnd: targetBackBufferPosition
|
19485
19521
|
});
|
19486
19522
|
|
19487
19523
|
// Support for deprecated event:
|
19488
|
-
var track =
|
19489
|
-
if ((
|
19490
|
-
|
19524
|
+
var track = _this19.tracks[type];
|
19525
|
+
if ((_this19$details = _this19.details) != null && _this19$details.live) {
|
19526
|
+
_this19.hls.trigger(Events.LIVE_BACK_BUFFER_REACHED, {
|
19491
19527
|
bufferEnd: targetBackBufferPosition
|
19492
19528
|
});
|
19493
19529
|
} else if (track != null && track.ended) {
|
19494
|
-
|
19530
|
+
_this19.log("Cannot flush " + type + " back buffer while SourceBuffer is in ended state");
|
19495
19531
|
return;
|
19496
19532
|
}
|
19497
|
-
|
19533
|
+
_this19.hls.trigger(Events.BUFFER_FLUSHING, {
|
19498
19534
|
startOffset: 0,
|
19499
19535
|
endOffset: targetBackBufferPosition,
|
19500
19536
|
type: type
|
@@ -19504,7 +19540,7 @@
|
|
19504
19540
|
});
|
19505
19541
|
};
|
19506
19542
|
_proto.flushFrontBuffer = function flushFrontBuffer(currentTime, targetDuration, targetFrontBufferPosition) {
|
19507
|
-
var
|
19543
|
+
var _this20 = this;
|
19508
19544
|
this.sourceBuffers.forEach(function (_ref10) {
|
19509
19545
|
var type = _ref10[0],
|
19510
19546
|
sb = _ref10[1];
|
@@ -19521,7 +19557,7 @@
|
|
19521
19557
|
if (targetFrontBufferPosition > bufferStart || currentTime >= bufferStart && currentTime <= bufferEnd) {
|
19522
19558
|
return;
|
19523
19559
|
}
|
19524
|
-
|
19560
|
+
_this20.hls.trigger(Events.BUFFER_FLUSHING, {
|
19525
19561
|
startOffset: bufferStart,
|
19526
19562
|
endOffset: Infinity,
|
19527
19563
|
type: type
|
@@ -19616,14 +19652,14 @@
|
|
19616
19652
|
}
|
19617
19653
|
};
|
19618
19654
|
_proto.bufferCreated = function bufferCreated() {
|
19619
|
-
var
|
19655
|
+
var _this21 = this;
|
19620
19656
|
if (this.sourceBufferCount) {
|
19621
19657
|
var tracks = {};
|
19622
19658
|
this.sourceBuffers.forEach(function (_ref12) {
|
19623
19659
|
var type = _ref12[0],
|
19624
19660
|
buffer = _ref12[1];
|
19625
19661
|
if (type) {
|
19626
|
-
var track =
|
19662
|
+
var track = _this21.tracks[type];
|
19627
19663
|
tracks[type] = {
|
19628
19664
|
buffer: buffer,
|
19629
19665
|
container: track.container,
|
@@ -19641,7 +19677,7 @@
|
|
19641
19677
|
this.log("SourceBuffers created. Running queue: " + this.operationQueue);
|
19642
19678
|
this.sourceBuffers.forEach(function (_ref13) {
|
19643
19679
|
var type = _ref13[0];
|
19644
|
-
|
19680
|
+
_this21.executeNext(type);
|
19645
19681
|
});
|
19646
19682
|
} else {
|
19647
19683
|
var error = new Error('could not create source buffer for media codec(s)');
|
@@ -19715,7 +19751,7 @@
|
|
19715
19751
|
return '';
|
19716
19752
|
};
|
19717
19753
|
_proto.trackSourceBuffer = function trackSourceBuffer(type, track) {
|
19718
|
-
var
|
19754
|
+
var _this22 = this;
|
19719
19755
|
var buffer = track.buffer;
|
19720
19756
|
if (!buffer) {
|
19721
19757
|
return;
|
@@ -19741,7 +19777,7 @@
|
|
19741
19777
|
// If media was ejected check for a change. Added ranges are redundant with changes on 'updateend' event.
|
19742
19778
|
var removedRanges = event.removedRanges;
|
19743
19779
|
if (removedRanges != null && removedRanges.length) {
|
19744
|
-
|
19780
|
+
_this22.hls.trigger(Events.BUFFER_FLUSHED, {
|
19745
19781
|
type: type
|
19746
19782
|
});
|
19747
19783
|
}
|
@@ -19841,10 +19877,10 @@
|
|
19841
19877
|
});
|
19842
19878
|
};
|
19843
19879
|
_proto.isQueued = function isQueued() {
|
19844
|
-
var
|
19880
|
+
var _this23 = this;
|
19845
19881
|
return this.sourceBuffers.some(function (_ref15) {
|
19846
19882
|
var type = _ref15[0];
|
19847
|
-
return type && !!
|
19883
|
+
return type && !!_this23.currentOp(type);
|
19848
19884
|
});
|
19849
19885
|
};
|
19850
19886
|
_proto.isPending = function isPending(track) {
|
@@ -19856,7 +19892,7 @@
|
|
19856
19892
|
// upon completion, since we already do it here
|
19857
19893
|
;
|
19858
19894
|
_proto.blockBuffers = function blockBuffers(onUnblocked, bufferNames) {
|
19859
|
-
var
|
19895
|
+
var _this24 = this;
|
19860
19896
|
if (bufferNames === void 0) {
|
19861
19897
|
bufferNames = this.sourceBufferTypes;
|
19862
19898
|
}
|
@@ -19869,33 +19905,33 @@
|
|
19869
19905
|
|
19870
19906
|
// logger.debug(`[buffer-controller]: Blocking ${buffers} SourceBuffer`);
|
19871
19907
|
var blockingOperations = bufferNames.map(function (type) {
|
19872
|
-
return
|
19908
|
+
return _this24.appendBlocker(type);
|
19873
19909
|
});
|
19874
19910
|
var audioBlocked = bufferNames.length > 1 && !!this.blockedAudioAppend;
|
19875
19911
|
if (audioBlocked) {
|
19876
19912
|
this.unblockAudio();
|
19877
19913
|
}
|
19878
19914
|
Promise.all(blockingOperations).then(function (result) {
|
19879
|
-
if (operationQueue !==
|
19915
|
+
if (operationQueue !== _this24.operationQueue) {
|
19880
19916
|
return;
|
19881
19917
|
}
|
19882
19918
|
// logger.debug(`[buffer-controller]: Blocking operation resolved; unblocking ${buffers} SourceBuffer`);
|
19883
19919
|
onUnblocked();
|
19884
|
-
|
19920
|
+
_this24.stepOperationQueue(bufferNames);
|
19885
19921
|
});
|
19886
19922
|
};
|
19887
19923
|
_proto.stepOperationQueue = function stepOperationQueue(bufferNames) {
|
19888
|
-
var
|
19924
|
+
var _this25 = this;
|
19889
19925
|
bufferNames.forEach(function (type) {
|
19890
|
-
var
|
19891
|
-
var sb = (
|
19926
|
+
var _this25$tracks$type;
|
19927
|
+
var sb = (_this25$tracks$type = _this25.tracks[type]) == null ? void 0 : _this25$tracks$type.buffer;
|
19892
19928
|
// Only cycle the queue if the SB is not updating. There's a bug in Chrome which sets the SB updating flag to
|
19893
19929
|
// true when changing the MediaSource duration (https://bugs.chromium.org/p/chromium/issues/detail?id=959359&can=2&q=mediasource%20duration)
|
19894
19930
|
// While this is a workaround, it's probably useful to have around
|
19895
19931
|
if (!sb || sb.updating) {
|
19896
19932
|
return;
|
19897
19933
|
}
|
19898
|
-
|
19934
|
+
_this25.shiftAndExecuteNext(type);
|
19899
19935
|
});
|
19900
19936
|
};
|
19901
19937
|
_proto.append = function append(operation, type, pending) {
|
@@ -19964,9 +20000,9 @@
|
|
19964
20000
|
}, {
|
19965
20001
|
key: "sourceBufferTracks",
|
19966
20002
|
get: function get() {
|
19967
|
-
var
|
20003
|
+
var _this26 = this;
|
19968
20004
|
return Object.keys(this.tracks).reduce(function (baseTracks, type) {
|
19969
|
-
var track =
|
20005
|
+
var track = _this26.tracks[type];
|
19970
20006
|
baseTracks[type] = {
|
19971
20007
|
id: track.id,
|
19972
20008
|
container: track.container,
|
@@ -19979,11 +20015,11 @@
|
|
19979
20015
|
}, {
|
19980
20016
|
key: "bufferedToEnd",
|
19981
20017
|
get: function get() {
|
19982
|
-
var
|
20018
|
+
var _this27 = this;
|
19983
20019
|
return this.sourceBufferCount > 0 && !this.sourceBuffers.some(function (_ref16) {
|
19984
|
-
var
|
20020
|
+
var _this27$tracks$type, _this27$tracks$type2;
|
19985
20021
|
var type = _ref16[0];
|
19986
|
-
return type && (!((
|
20022
|
+
return type && (!((_this27$tracks$type = _this27.tracks[type]) != null && _this27$tracks$type.ended) || ((_this27$tracks$type2 = _this27.tracks[type]) == null ? void 0 : _this27$tracks$type2.ending));
|
19987
20023
|
});
|
19988
20024
|
}
|
19989
20025
|
}, {
|
@@ -20002,9 +20038,9 @@
|
|
20002
20038
|
}, {
|
20003
20039
|
key: "pendingTrackCount",
|
20004
20040
|
get: function get() {
|
20005
|
-
var
|
20041
|
+
var _this28 = this;
|
20006
20042
|
return Object.keys(this.tracks).reduce(function (acc, type) {
|
20007
|
-
return acc + (
|
20043
|
+
return acc + (_this28.isPending(_this28.tracks[type]) ? 1 : 0);
|
20008
20044
|
}, 0);
|
20009
20045
|
}
|
20010
20046
|
}, {
|
@@ -23112,7 +23148,7 @@
|
|
23112
23148
|
return (hash >>> 0).toString();
|
23113
23149
|
}
|
23114
23150
|
|
23115
|
-
var ALIGNED_END_THRESHOLD_SECONDS = 0.
|
23151
|
+
var ALIGNED_END_THRESHOLD_SECONDS = 0.025;
|
23116
23152
|
var TimelineOccupancy = /*#__PURE__*/function (TimelineOccupancy) {
|
23117
23153
|
TimelineOccupancy[TimelineOccupancy["Point"] = 0] = "Point";
|
23118
23154
|
TimelineOccupancy[TimelineOccupancy["Range"] = 1] = "Range";
|
@@ -23146,6 +23182,7 @@
|
|
23146
23182
|
this.assetListResponse = null;
|
23147
23183
|
this.resumeAnchor = void 0;
|
23148
23184
|
this.error = void 0;
|
23185
|
+
this.resetOnResume = void 0;
|
23149
23186
|
this.base = base;
|
23150
23187
|
this.dateRange = dateRange;
|
23151
23188
|
this.setDateRange(dateRange);
|
@@ -23217,6 +23254,20 @@
|
|
23217
23254
|
get: function get() {
|
23218
23255
|
return this.cue.pre ? 0 : this.startTime;
|
23219
23256
|
}
|
23257
|
+
}, {
|
23258
|
+
key: "startIsAligned",
|
23259
|
+
get: function get() {
|
23260
|
+
if (this.startTime === 0 || this.snapOptions.out) {
|
23261
|
+
return true;
|
23262
|
+
}
|
23263
|
+
var frag = this.dateRange.tagAnchor;
|
23264
|
+
if (frag) {
|
23265
|
+
var startTime = this.dateRange.startTime;
|
23266
|
+
var snappedStart = getSnapToFragmentTime(startTime, frag);
|
23267
|
+
return startTime - snappedStart < 0.1;
|
23268
|
+
}
|
23269
|
+
return false;
|
23270
|
+
}
|
23220
23271
|
}, {
|
23221
23272
|
key: "resumptionOffset",
|
23222
23273
|
get: function get() {
|
@@ -23240,18 +23291,22 @@
|
|
23240
23291
|
}, {
|
23241
23292
|
key: "appendInPlace",
|
23242
23293
|
get: function get() {
|
23294
|
+
if (this.appendInPlaceStarted) {
|
23295
|
+
return true;
|
23296
|
+
}
|
23243
23297
|
if (this.appendInPlaceDisabled) {
|
23244
23298
|
return false;
|
23245
23299
|
}
|
23246
|
-
if (!this.cue.once && !this.cue.pre &&
|
23300
|
+
if (!this.cue.once && !this.cue.pre &&
|
23247
23301
|
// preroll starts at startPosition before startPosition is known (live)
|
23248
|
-
this.
|
23302
|
+
this.startIsAligned && (isNaN(this.playoutLimit) && isNaN(this.resumeOffset) || this.resumeOffset && this.duration && Math.abs(this.resumeOffset - this.duration) < ALIGNED_END_THRESHOLD_SECONDS)) {
|
23249
23303
|
return true;
|
23250
23304
|
}
|
23251
23305
|
return false;
|
23252
23306
|
},
|
23253
23307
|
set: function set(value) {
|
23254
23308
|
if (this.appendInPlaceStarted) {
|
23309
|
+
this.resetOnResume = !value;
|
23255
23310
|
return;
|
23256
23311
|
}
|
23257
23312
|
this.appendInPlaceDisabled = !value;
|
@@ -23363,6 +23418,7 @@
|
|
23363
23418
|
this.hasDetails = false;
|
23364
23419
|
this.mediaAttached = null;
|
23365
23420
|
this._currentTime = void 0;
|
23421
|
+
this._bufferedEosTime = void 0;
|
23366
23422
|
this.checkPlayout = function () {
|
23367
23423
|
var interstitial = _this.interstitial;
|
23368
23424
|
var playoutLimit = interstitial.playoutLimit;
|
@@ -23399,6 +23455,22 @@
|
|
23399
23455
|
});
|
23400
23456
|
}
|
23401
23457
|
var _proto = HlsAssetPlayer.prototype;
|
23458
|
+
_proto.bufferedInPlaceToEnd = function bufferedInPlaceToEnd(media) {
|
23459
|
+
var _this$hls;
|
23460
|
+
if (!this.interstitial.appendInPlace) {
|
23461
|
+
return false;
|
23462
|
+
}
|
23463
|
+
if ((_this$hls = this.hls) != null && _this$hls.bufferedToEnd) {
|
23464
|
+
return true;
|
23465
|
+
}
|
23466
|
+
if (!media || !this._bufferedEosTime) {
|
23467
|
+
return false;
|
23468
|
+
}
|
23469
|
+
var start = this.timelineOffset;
|
23470
|
+
var bufferInfo = BufferHelper.bufferInfo(media, start, 0);
|
23471
|
+
var bufferedEnd = this.getAssetTime(bufferInfo.end);
|
23472
|
+
return bufferedEnd >= this._bufferedEosTime - 0.02;
|
23473
|
+
};
|
23402
23474
|
_proto.getAssetTime = function getAssetTime(time) {
|
23403
23475
|
var timelineOffset = this.timelineOffset;
|
23404
23476
|
var duration = this.duration;
|
@@ -23408,9 +23480,18 @@
|
|
23408
23480
|
var media = this.mediaAttached;
|
23409
23481
|
if (media) {
|
23410
23482
|
this._currentTime = media.currentTime;
|
23483
|
+
this.bufferSnapShot();
|
23411
23484
|
media.removeEventListener('timeupdate', this.checkPlayout);
|
23412
23485
|
}
|
23413
23486
|
};
|
23487
|
+
_proto.bufferSnapShot = function bufferSnapShot() {
|
23488
|
+
if (this.mediaAttached) {
|
23489
|
+
var _this$hls2;
|
23490
|
+
if ((_this$hls2 = this.hls) != null && _this$hls2.bufferedToEnd) {
|
23491
|
+
this._bufferedEosTime = this.bufferedEnd;
|
23492
|
+
}
|
23493
|
+
}
|
23494
|
+
};
|
23414
23495
|
_proto.destroy = function destroy() {
|
23415
23496
|
this.removeMediaListeners();
|
23416
23497
|
this.hls.destroy();
|
@@ -23434,6 +23515,7 @@
|
|
23434
23515
|
this.hls.pauseBuffering();
|
23435
23516
|
};
|
23436
23517
|
_proto.transferMedia = function transferMedia() {
|
23518
|
+
this.bufferSnapShot();
|
23437
23519
|
return this.hls.transferMedia();
|
23438
23520
|
};
|
23439
23521
|
_proto.on = function on(event, listener, context) {
|
@@ -23446,14 +23528,14 @@
|
|
23446
23528
|
this.hls.off(event, listener);
|
23447
23529
|
};
|
23448
23530
|
_proto.toString = function toString() {
|
23449
|
-
var _this$
|
23450
|
-
return "HlsAssetPlayer: " + eventAssetToString(this.assetItem) + " " + ((_this$
|
23531
|
+
var _this$hls3, _this$interstitial;
|
23532
|
+
return "HlsAssetPlayer: " + eventAssetToString(this.assetItem) + " " + ((_this$hls3 = this.hls) == null ? void 0 : _this$hls3.sessionId) + " " + ((_this$interstitial = this.interstitial) != null && _this$interstitial.appendInPlace ? 'append-in-place' : '');
|
23451
23533
|
};
|
23452
23534
|
return _createClass(HlsAssetPlayer, [{
|
23453
23535
|
key: "destroyed",
|
23454
23536
|
get: function get() {
|
23455
|
-
var _this$
|
23456
|
-
return !((_this$
|
23537
|
+
var _this$hls4;
|
23538
|
+
return !((_this$hls4 = this.hls) != null && _this$hls4.userConfig);
|
23457
23539
|
}
|
23458
23540
|
}, {
|
23459
23541
|
key: "assetId",
|
@@ -23468,14 +23550,17 @@
|
|
23468
23550
|
}, {
|
23469
23551
|
key: "media",
|
23470
23552
|
get: function get() {
|
23471
|
-
var _this$
|
23472
|
-
return ((_this$
|
23553
|
+
var _this$hls5;
|
23554
|
+
return ((_this$hls5 = this.hls) == null ? void 0 : _this$hls5.media) || null;
|
23473
23555
|
}
|
23474
23556
|
}, {
|
23475
23557
|
key: "bufferedEnd",
|
23476
23558
|
get: function get() {
|
23477
23559
|
var media = this.media || this.mediaAttached;
|
23478
23560
|
if (!media) {
|
23561
|
+
if (this._bufferedEosTime) {
|
23562
|
+
return this._bufferedEosTime;
|
23563
|
+
}
|
23479
23564
|
return this.currentTime;
|
23480
23565
|
}
|
23481
23566
|
var bufferInfo = BufferHelper.bufferInfo(media, media.currentTime, 0.001);
|
@@ -23516,8 +23601,8 @@
|
|
23516
23601
|
}, {
|
23517
23602
|
key: "timelineOffset",
|
23518
23603
|
get: function get() {
|
23519
|
-
var _this$
|
23520
|
-
return ((_this$
|
23604
|
+
var _this$hls6;
|
23605
|
+
return ((_this$hls6 = this.hls) == null ? void 0 : _this$hls6.config.timelineOffset) || 0;
|
23521
23606
|
},
|
23522
23607
|
set: function set(value) {
|
23523
23608
|
var timelineOffset = this.timelineOffset;
|
@@ -23971,6 +24056,9 @@
|
|
23971
24056
|
var timeBetween = interstitialEvents[i + 1].startTime - interstitialEvents[i].resumeTime;
|
23972
24057
|
if (timeBetween < ABUTTING_THRESHOLD_SECONDS) {
|
23973
24058
|
interstitialEvents[i + 1].appendInPlace = false;
|
24059
|
+
if (interstitialEvents[i + 1].appendInPlace) {
|
24060
|
+
_this3.warn("Could not change append strategy for abutting event " + interstitial);
|
24061
|
+
}
|
23974
24062
|
}
|
23975
24063
|
}
|
23976
24064
|
// Update cumulativeDuration for next abutting interstitial with the same start date
|
@@ -23995,19 +24083,18 @@
|
|
23995
24083
|
var details = mediaSelection[playlistType].details;
|
23996
24084
|
var playlistEnd = details.edge;
|
23997
24085
|
if (resumeTime > playlistEnd) {
|
23998
|
-
|
23999
|
-
|
24000
|
-
|
24001
|
-
}
|
24086
|
+
// Live playback - resumption segments are not yet available
|
24087
|
+
_this4.log("\"" + interstitial.identifier + "\" resumption " + resumeTime + " past " + playlistType + " playlist end " + playlistEnd);
|
24088
|
+
// Assume alignment is possible (or reset can take place)
|
24002
24089
|
return false;
|
24003
24090
|
}
|
24004
24091
|
var startFragment = findFragmentByPTS(null, details.fragments, resumeTime);
|
24005
24092
|
if (!startFragment) {
|
24006
|
-
_this4.log("\"" + interstitial.identifier + "\" resumption " + resumeTime + " does not align with any fragments in " + playlistType + " playlist");
|
24093
|
+
_this4.log("\"" + interstitial.identifier + "\" resumption " + resumeTime + " does not align with any fragments in " + playlistType + " playlist (" + details.fragStart + "-" + details.fragmentEnd + ")");
|
24007
24094
|
return true;
|
24008
24095
|
}
|
24009
|
-
var
|
24010
|
-
var alignedWithSegment = Math.abs(startFragment.start - resumeTime) < ALIGNED_END_THRESHOLD_SECONDS || Math.abs(startFragment.end - resumeTime) < ALIGNED_END_THRESHOLD_SECONDS +
|
24096
|
+
var allowance = playlistType === 'audio' ? 0.175 : 0;
|
24097
|
+
var alignedWithSegment = Math.abs(startFragment.start - resumeTime) < ALIGNED_END_THRESHOLD_SECONDS + allowance || Math.abs(startFragment.end - resumeTime) < ALIGNED_END_THRESHOLD_SECONDS + allowance;
|
24011
24098
|
if (!alignedWithSegment) {
|
24012
24099
|
_this4.log("\"" + interstitial.identifier + "\" resumption " + resumeTime + " not aligned with " + playlistType + " fragment bounds (" + startFragment.start + "-" + startFragment.end + " sn: " + startFragment.sn + " cc: " + startFragment.cc + ")");
|
24013
24100
|
return true;
|
@@ -24084,7 +24171,7 @@
|
|
24084
24171
|
// @ts-ignore
|
24085
24172
|
this.hls = null;
|
24086
24173
|
};
|
24087
|
-
_proto.loadAssetList = function loadAssetList(interstitial,
|
24174
|
+
_proto.loadAssetList = function loadAssetList(interstitial, hlsStartOffset) {
|
24088
24175
|
var _this = this;
|
24089
24176
|
var assetListUrl = interstitial.assetListUrl;
|
24090
24177
|
var url;
|
@@ -24095,11 +24182,8 @@
|
|
24095
24182
|
this.hls.trigger(Events.ERROR, errorData);
|
24096
24183
|
return;
|
24097
24184
|
}
|
24098
|
-
if (
|
24099
|
-
|
24100
|
-
if (startOffset > 0) {
|
24101
|
-
url.searchParams.set('_HLS_start_offset', '' + Math.round(startOffset * 1000) / 1000);
|
24102
|
-
}
|
24185
|
+
if (hlsStartOffset && url.protocol !== 'data:') {
|
24186
|
+
url.searchParams.set('_HLS_start_offset', '' + hlsStartOffset);
|
24103
24187
|
}
|
24104
24188
|
var config = this.hls.config;
|
24105
24189
|
var Loader = config.loader;
|
@@ -24620,6 +24704,9 @@
|
|
24620
24704
|
var interstitial = queuedPlayer.interstitial;
|
24621
24705
|
_this2.clearInterstitial(queuedPlayer.interstitial, null);
|
24622
24706
|
interstitial.appendInPlace = false;
|
24707
|
+
if (interstitial.appendInPlace) {
|
24708
|
+
_this2.warn("Could not change append strategy for queued assets " + interstitial);
|
24709
|
+
}
|
24623
24710
|
}
|
24624
24711
|
});
|
24625
24712
|
}
|
@@ -24797,7 +24884,9 @@
|
|
24797
24884
|
}
|
24798
24885
|
// Ensure Interstitial is enqueued
|
24799
24886
|
var waitingItem = this.waitingItem;
|
24800
|
-
this.
|
24887
|
+
if (!this.assetsBuffered(scheduledItem, media)) {
|
24888
|
+
this.setBufferingItem(scheduledItem);
|
24889
|
+
}
|
24801
24890
|
var player = this.preloadAssets(interstitial, assetListIndex);
|
24802
24891
|
if (!this.eventItemsMatch(scheduledItem, waitingItem || currentItem)) {
|
24803
24892
|
this.waitingItem = scheduledItem;
|
@@ -25148,8 +25237,19 @@
|
|
25148
25237
|
this.bufferedToItem(playingItem);
|
25149
25238
|
}
|
25150
25239
|
};
|
25151
|
-
_proto.
|
25240
|
+
_proto.assetsBuffered = function assetsBuffered(item, media) {
|
25152
25241
|
var _this4 = this;
|
25242
|
+
var assetList = item.event.assetList;
|
25243
|
+
if (assetList.length === 0) {
|
25244
|
+
return false;
|
25245
|
+
}
|
25246
|
+
return !item.event.assetList.some(function (asset) {
|
25247
|
+
var player = _this4.getAssetPlayer(asset.identifier);
|
25248
|
+
return !(player != null && player.bufferedInPlaceToEnd(media));
|
25249
|
+
});
|
25250
|
+
};
|
25251
|
+
_proto.setBufferingItem = function setBufferingItem(item) {
|
25252
|
+
var _this5 = this;
|
25153
25253
|
var bufferingLast = this.bufferingItem;
|
25154
25254
|
var schedule = this.schedule;
|
25155
25255
|
if (!this.itemsMatch(item, bufferingLast)) {
|
@@ -25168,7 +25268,7 @@
|
|
25168
25268
|
if (isInterstitial) {
|
25169
25269
|
// primary fragment loading will exit early in base-stream-controller while `bufferingItem` is set to an Interstitial block
|
25170
25270
|
item.event.assetList.forEach(function (asset) {
|
25171
|
-
var player =
|
25271
|
+
var player = _this5.getAssetPlayer(asset.identifier);
|
25172
25272
|
if (player) {
|
25173
25273
|
player.resumeBuffering();
|
25174
25274
|
}
|
@@ -25247,14 +25347,11 @@
|
|
25247
25347
|
var neverLoaded = assetListLength === 0 && !interstitial.assetListLoader;
|
25248
25348
|
var playOnce = interstitial.cue.once;
|
25249
25349
|
if (neverLoaded) {
|
25250
|
-
this.log("Load interstitial asset " + (assetListIndex + 1) + "/" + (uri ? 1 : assetListLength) + " " + interstitial);
|
25251
25350
|
var timelineStart = interstitial.timelineStart;
|
25252
25351
|
if (interstitial.appendInPlace) {
|
25253
25352
|
this.flushFrontBuffer(timelineStart + 0.25);
|
25254
25353
|
}
|
25255
|
-
|
25256
|
-
return this.createAsset(interstitial, 0, 0, timelineStart, interstitial.duration, uri);
|
25257
|
-
}
|
25354
|
+
var hlsStartOffset;
|
25258
25355
|
var liveStartPosition = 0;
|
25259
25356
|
if (!this.playingItem && this.primaryLive) {
|
25260
25357
|
liveStartPosition = this.hls.startPosition;
|
@@ -25262,7 +25359,17 @@
|
|
25262
25359
|
liveStartPosition = this.hls.liveSyncPosition || 0;
|
25263
25360
|
}
|
25264
25361
|
}
|
25265
|
-
|
25362
|
+
if (liveStartPosition && !(interstitial.cue.pre || interstitial.cue.post)) {
|
25363
|
+
var startOffset = liveStartPosition - timelineStart;
|
25364
|
+
if (startOffset > 0) {
|
25365
|
+
hlsStartOffset = Math.round(startOffset * 1000) / 1000;
|
25366
|
+
}
|
25367
|
+
}
|
25368
|
+
this.log("Load interstitial asset " + (assetListIndex + 1) + "/" + (uri ? 1 : assetListLength) + " " + interstitial + (hlsStartOffset ? " live-start: " + liveStartPosition + " start-offset: " + hlsStartOffset : ''));
|
25369
|
+
if (uri) {
|
25370
|
+
return this.createAsset(interstitial, 0, 0, timelineStart, interstitial.duration, uri);
|
25371
|
+
}
|
25372
|
+
var assetListLoader = this.assetListLoader.loadAssetList(interstitial, hlsStartOffset);
|
25266
25373
|
if (assetListLoader) {
|
25267
25374
|
interstitial.assetListLoader = assetListLoader;
|
25268
25375
|
}
|
@@ -25280,7 +25387,7 @@
|
|
25280
25387
|
return null;
|
25281
25388
|
};
|
25282
25389
|
_proto.flushFrontBuffer = function flushFrontBuffer(startOffset) {
|
25283
|
-
var
|
25390
|
+
var _this6 = this;
|
25284
25391
|
// Force queued flushing of all buffers
|
25285
25392
|
var requiredTracks = this.requiredTracks;
|
25286
25393
|
if (!requiredTracks) {
|
@@ -25288,7 +25395,7 @@
|
|
25288
25395
|
}
|
25289
25396
|
var sourceBufferNames = Object.keys(requiredTracks);
|
25290
25397
|
sourceBufferNames.forEach(function (type) {
|
25291
|
-
|
25398
|
+
_this6.hls.trigger(Events.BUFFER_FLUSHING, {
|
25292
25399
|
startOffset: startOffset,
|
25293
25400
|
endOffset: Infinity,
|
25294
25401
|
type: type
|
@@ -25335,7 +25442,7 @@
|
|
25335
25442
|
return this.createAssetPlayer(interstitial, assetItem, assetListIndex);
|
25336
25443
|
};
|
25337
25444
|
_proto.createAssetPlayer = function createAssetPlayer(interstitial, assetItem, assetListIndex) {
|
25338
|
-
var
|
25445
|
+
var _this7 = this;
|
25339
25446
|
this.log("create HLSAssetPlayer for " + eventAssetToString(assetItem));
|
25340
25447
|
var primary = this.hls;
|
25341
25448
|
var userConfig = primary.userConfig;
|
@@ -25353,7 +25460,7 @@
|
|
25353
25460
|
var selectedAudio = primary.audioTracks[primary.audioTrack];
|
25354
25461
|
var selectedSubtitle = primary.subtitleTracks[primary.subtitleTrack];
|
25355
25462
|
var startPosition = 0;
|
25356
|
-
if (this.primaryLive) {
|
25463
|
+
if (this.primaryLive || interstitial.appendInPlace) {
|
25357
25464
|
var timePastStart = this.timelinePos - assetItem.timelineStart;
|
25358
25465
|
if (timePastStart > 1) {
|
25359
25466
|
var duration = assetItem.duration;
|
@@ -25402,17 +25509,17 @@
|
|
25402
25509
|
details: ErrorDetails.INTERSTITIAL_ASSET_ITEM_ERROR,
|
25403
25510
|
error: error
|
25404
25511
|
};
|
25405
|
-
|
25512
|
+
_this7.handleAssetItemError(errorData, interstitial, _this7.schedule.findEventIndex(interstitial.identifier), assetListIndex, error.message);
|
25406
25513
|
return;
|
25407
25514
|
}
|
25408
25515
|
// Get time at end of last fragment
|
25409
25516
|
var duration = details.edge - details.fragmentStart;
|
25410
25517
|
var currentAssetDuration = assetItem.duration;
|
25411
25518
|
if (currentAssetDuration === null || duration > currentAssetDuration) {
|
25412
|
-
|
25519
|
+
_this7.log("Interstitial asset \"" + assetId + "\" duration change " + currentAssetDuration + " > " + duration);
|
25413
25520
|
assetItem.duration = duration;
|
25414
25521
|
// Update schedule with new event and asset duration
|
25415
|
-
|
25522
|
+
_this7.updateSchedule();
|
25416
25523
|
}
|
25417
25524
|
};
|
25418
25525
|
player.on(Events.LEVEL_UPDATED, function (event, _ref) {
|
@@ -25424,39 +25531,39 @@
|
|
25424
25531
|
return updateAssetPlayerDetails(details);
|
25425
25532
|
});
|
25426
25533
|
var _onBufferCodecs = function onBufferCodecs(event, data) {
|
25427
|
-
var inQueuPlayer =
|
25534
|
+
var inQueuPlayer = _this7.getAssetPlayer(assetId);
|
25428
25535
|
if (inQueuPlayer && data.tracks) {
|
25429
25536
|
inQueuPlayer.off(Events.BUFFER_CODECS, _onBufferCodecs);
|
25430
25537
|
inQueuPlayer.tracks = data.tracks;
|
25431
|
-
var media =
|
25432
|
-
if (
|
25433
|
-
|
25538
|
+
var media = _this7.primaryMedia;
|
25539
|
+
if (_this7.bufferingAsset === inQueuPlayer.assetItem && media && !inQueuPlayer.media) {
|
25540
|
+
_this7.bufferAssetPlayer(inQueuPlayer, media);
|
25434
25541
|
}
|
25435
25542
|
}
|
25436
25543
|
};
|
25437
25544
|
player.on(Events.BUFFER_CODECS, _onBufferCodecs);
|
25438
25545
|
var _bufferedToEnd = function bufferedToEnd(name) {
|
25439
|
-
var
|
25440
|
-
var inQueuPlayer =
|
25441
|
-
|
25546
|
+
var _this7$schedule$items;
|
25547
|
+
var inQueuPlayer = _this7.getAssetPlayer(assetId);
|
25548
|
+
_this7.log("buffered to end of asset " + inQueuPlayer);
|
25442
25549
|
if (!inQueuPlayer) {
|
25443
25550
|
return;
|
25444
25551
|
}
|
25445
25552
|
inQueuPlayer.off(Events.BUFFERED_TO_END, _bufferedToEnd);
|
25446
25553
|
|
25447
25554
|
// Preload at end of asset
|
25448
|
-
var scheduleIndex =
|
25555
|
+
var scheduleIndex = _this7.schedule.findEventIndex(interstitial.identifier);
|
25449
25556
|
var assetListIndex = interstitial.findAssetIndex(assetItem);
|
25450
25557
|
var nextAssetIndex = assetListIndex + 1;
|
25451
|
-
var item = (
|
25452
|
-
if (
|
25558
|
+
var item = (_this7$schedule$items = _this7.schedule.items) == null ? void 0 : _this7$schedule$items[scheduleIndex];
|
25559
|
+
if (_this7.isInterstitial(item)) {
|
25453
25560
|
if (assetListIndex !== -1 && !interstitial.isAssetPastPlayoutLimit(nextAssetIndex) && !interstitial.assetList[nextAssetIndex].error) {
|
25454
|
-
|
25561
|
+
_this7.bufferedToItem(item, assetListIndex + 1);
|
25455
25562
|
} else {
|
25456
|
-
var
|
25457
|
-
var nextItem = (
|
25563
|
+
var _this7$schedule$items2;
|
25564
|
+
var nextItem = (_this7$schedule$items2 = _this7.schedule.items) == null ? void 0 : _this7$schedule$items2[scheduleIndex + 1];
|
25458
25565
|
if (nextItem) {
|
25459
|
-
|
25566
|
+
_this7.bufferedToItem(nextItem);
|
25460
25567
|
}
|
25461
25568
|
}
|
25462
25569
|
}
|
@@ -25464,22 +25571,22 @@
|
|
25464
25571
|
player.on(Events.BUFFERED_TO_END, _bufferedToEnd);
|
25465
25572
|
var endedWithAssetIndex = function endedWithAssetIndex(assetIndex) {
|
25466
25573
|
return function () {
|
25467
|
-
var inQueuPlayer =
|
25574
|
+
var inQueuPlayer = _this7.getAssetPlayer(assetId);
|
25468
25575
|
if (!inQueuPlayer) {
|
25469
25576
|
return;
|
25470
25577
|
}
|
25471
|
-
|
25472
|
-
var scheduleIndex =
|
25473
|
-
|
25578
|
+
_this7.shouldPlay = true;
|
25579
|
+
var scheduleIndex = _this7.schedule.findEventIndex(interstitial.identifier);
|
25580
|
+
_this7.advanceAfterAssetEnded(interstitial, scheduleIndex, assetIndex);
|
25474
25581
|
};
|
25475
25582
|
};
|
25476
25583
|
player.once(Events.MEDIA_ENDED, endedWithAssetIndex(assetListIndex));
|
25477
25584
|
player.once(Events.PLAYOUT_LIMIT_REACHED, endedWithAssetIndex(Infinity));
|
25478
25585
|
player.on(Events.ERROR, function (event, data) {
|
25479
|
-
|
25586
|
+
_this7.handleAssetItemError(data, interstitial, _this7.schedule.findEventIndex(interstitial.identifier), assetListIndex, "Asset player error " + data.error + " " + interstitial);
|
25480
25587
|
});
|
25481
25588
|
player.on(Events.DESTROYING, function () {
|
25482
|
-
var inQueuPlayer =
|
25589
|
+
var inQueuPlayer = _this7.getAssetPlayer(assetId);
|
25483
25590
|
if (!inQueuPlayer) {
|
25484
25591
|
return;
|
25485
25592
|
}
|
@@ -25490,7 +25597,7 @@
|
|
25490
25597
|
details: ErrorDetails.INTERSTITIAL_ASSET_ITEM_ERROR,
|
25491
25598
|
error: error
|
25492
25599
|
};
|
25493
|
-
|
25600
|
+
_this7.handleAssetItemError(errorData, interstitial, _this7.schedule.findEventIndex(interstitial.identifier), assetListIndex, error.message);
|
25494
25601
|
});
|
25495
25602
|
this.hls.trigger(Events.INTERSTITIAL_ASSET_PLAYER_CREATED, {
|
25496
25603
|
asset: assetItem,
|
@@ -25501,9 +25608,9 @@
|
|
25501
25608
|
return player;
|
25502
25609
|
};
|
25503
25610
|
_proto.clearInterstitial = function clearInterstitial(interstitial, toSegment) {
|
25504
|
-
var
|
25611
|
+
var _this8 = this;
|
25505
25612
|
interstitial.assetList.forEach(function (asset) {
|
25506
|
-
|
25613
|
+
_this8.clearAssetPlayer(asset.identifier, toSegment);
|
25507
25614
|
});
|
25508
25615
|
// Remove asset list and resolved duration
|
25509
25616
|
interstitial.reset();
|
@@ -25549,9 +25656,10 @@
|
|
25549
25656
|
player: player
|
25550
25657
|
});
|
25551
25658
|
}
|
25552
|
-
|
25553
|
-
|
25554
|
-
|
25659
|
+
if (!player.bufferedInPlaceToEnd(media)) {
|
25660
|
+
// detach media and attach to interstitial player if it does not have another element attached
|
25661
|
+
this.bufferAssetPlayer(player, media);
|
25662
|
+
}
|
25555
25663
|
};
|
25556
25664
|
_proto.bufferAssetPlayer = function bufferAssetPlayer(player, media) {
|
25557
25665
|
var _this$schedule$items2, _this$detachedData4;
|
@@ -25671,7 +25779,7 @@
|
|
25671
25779
|
// Asset List loading
|
25672
25780
|
;
|
25673
25781
|
_proto.onAssetListLoaded = function onAssetListLoaded(event, data) {
|
25674
|
-
var
|
25782
|
+
var _this9 = this,
|
25675
25783
|
_this$bufferingItem;
|
25676
25784
|
var interstitial = data.event;
|
25677
25785
|
var interstitialId = interstitial.identifier;
|
@@ -25681,13 +25789,15 @@
|
|
25681
25789
|
return;
|
25682
25790
|
}
|
25683
25791
|
var eventStart = interstitial.timelineStart;
|
25792
|
+
var previousDuration = interstitial.duration;
|
25684
25793
|
var sumDuration = 0;
|
25685
25794
|
assets.forEach(function (asset, assetListIndex) {
|
25686
25795
|
var duration = parseFloat(asset.DURATION);
|
25687
|
-
|
25796
|
+
_this9.createAsset(interstitial, assetListIndex, sumDuration, eventStart + sumDuration, duration, asset.URI);
|
25688
25797
|
sumDuration += duration;
|
25689
25798
|
});
|
25690
25799
|
interstitial.duration = sumDuration;
|
25800
|
+
this.log("Loaded asset-list with duration: " + sumDuration + " (was: " + previousDuration + ") " + interstitial);
|
25691
25801
|
var waitingItem = this.waitingItem;
|
25692
25802
|
var waitingForItem = (waitingItem == null ? void 0 : waitingItem.event.identifier) === interstitialId;
|
25693
25803
|
|
@@ -25702,6 +25812,15 @@
|
|
25702
25812
|
var scheduleIndex = this.schedule.findEventIndex(interstitialId);
|
25703
25813
|
var item = (_this$schedule$items3 = this.schedule.items) == null ? void 0 : _this$schedule$items3[scheduleIndex];
|
25704
25814
|
if (item) {
|
25815
|
+
if (!this.playingItem && this.timelinePos > item.end) {
|
25816
|
+
// Abandon if new duration is reduced enough to land playback in primary start
|
25817
|
+
var index = this.schedule.findItemIndexAtTime(this.timelinePos);
|
25818
|
+
if (index !== scheduleIndex) {
|
25819
|
+
interstitial.error = new Error("Interstitial no longer within playback range " + this.timelinePos + " " + interstitial);
|
25820
|
+
this.primaryFallback(interstitial);
|
25821
|
+
return;
|
25822
|
+
}
|
25823
|
+
}
|
25705
25824
|
this.setBufferingItem(item);
|
25706
25825
|
}
|
25707
25826
|
this.setSchedulePosition(scheduleIndex);
|
@@ -25809,7 +25928,7 @@
|
|
25809
25928
|
if (media) {
|
25810
25929
|
var currentTime = timelineType === 'primary' ? media.currentTime : getMappedTime(playingItem, timelineType, c.playingAsset, 'timelinePos', 'currentTime');
|
25811
25930
|
var diff = time - currentTime;
|
25812
|
-
var seekToTime = media.currentTime + diff;
|
25931
|
+
var seekToTime = (appendInPlace ? currentTime : media.currentTime) + diff;
|
25813
25932
|
if (seekToTime >= 0 && (!assetPlayer || appendInPlace || seekToTime <= assetPlayer.duration)) {
|
25814
25933
|
media.currentTime = seekToTime;
|
25815
25934
|
return;
|
@@ -25961,12 +26080,7 @@
|
|
25961
26080
|
return getBufferedEnd();
|
25962
26081
|
},
|
25963
26082
|
get currentTime() {
|
25964
|
-
var _playingItem$event;
|
25965
26083
|
var timelinePos = c.timelinePos;
|
25966
|
-
var playingItem = c.effectivePlayingItem;
|
25967
|
-
if (playingItem != null && (_playingItem$event = playingItem.event) != null && _playingItem$event.appendInPlace) {
|
25968
|
-
return playingItem.start;
|
25969
|
-
}
|
25970
26084
|
return timelinePos > 0 ? timelinePos : 0;
|
25971
26085
|
},
|
25972
26086
|
set currentTime(time) {
|
@@ -26134,11 +26248,12 @@
|
|
26134
26248
|
hls.off(Events.SUBTITLE_FRAG_PROCESSED, this.onSubtitleFragProcessed, this);
|
26135
26249
|
hls.off(Events.BUFFER_FLUSHING, this.onBufferFlushing, this);
|
26136
26250
|
};
|
26137
|
-
_proto.startLoad = function startLoad(startPosition) {
|
26251
|
+
_proto.startLoad = function startLoad(startPosition, skipSeekToStartPosition) {
|
26138
26252
|
this.stopLoad();
|
26139
26253
|
this.state = State.IDLE;
|
26140
26254
|
this.setInterval(TICK_INTERVAL$2);
|
26141
|
-
this.nextLoadPosition = this.
|
26255
|
+
this.nextLoadPosition = this.lastCurrentTime = startPosition + this.timelineOffset;
|
26256
|
+
this.startPosition = skipSeekToStartPosition ? -1 : startPosition;
|
26142
26257
|
this.tick();
|
26143
26258
|
};
|
26144
26259
|
_proto.onManifestLoading = function onManifestLoading() {
|
@@ -32946,7 +33061,7 @@
|
|
32946
33061
|
startPosition = lastCurrentTime;
|
32947
33062
|
}
|
32948
33063
|
this.state = State.IDLE;
|
32949
|
-
this.nextLoadPosition = this.lastCurrentTime = startPosition;
|
33064
|
+
this.nextLoadPosition = this.lastCurrentTime = startPosition + this.timelineOffset;
|
32950
33065
|
this.startPosition = skipSeekToStartPosition ? -1 : startPosition;
|
32951
33066
|
this.tick();
|
32952
33067
|
} else {
|
@@ -33016,7 +33131,7 @@
|
|
33016
33131
|
// if start level not parsed yet OR
|
33017
33132
|
// if video not attached AND start fragment already requested OR start frag prefetch not enabled
|
33018
33133
|
// exit loop, as we either need more info (level not parsed) or we need media to be attached to load new fragment
|
33019
|
-
if (levelLastLoaded === null || !media && (this.startFragRequested || !hls.config.startFragPrefetch)) {
|
33134
|
+
if (levelLastLoaded === null || !media && !this.primaryPrefetch && (this.startFragRequested || !hls.config.startFragPrefetch)) {
|
33020
33135
|
return;
|
33021
33136
|
}
|
33022
33137
|
|
@@ -33625,11 +33740,11 @@
|
|
33625
33740
|
}
|
33626
33741
|
|
33627
33742
|
// Offset start position by timeline offset
|
33628
|
-
var
|
33629
|
-
|
33630
|
-
|
33631
|
-
startPosition += (details == null ? void 0 : details.appliedTimelineOffset) || configuredTimelineOffset;
|
33743
|
+
var timelineOffset = this.timelineOffset;
|
33744
|
+
if (timelineOffset && startPosition) {
|
33745
|
+
startPosition += timelineOffset;
|
33632
33746
|
}
|
33747
|
+
var details = this.getLevelDetails();
|
33633
33748
|
var buffered = BufferHelper.getBuffered(media);
|
33634
33749
|
var bufferStart = buffered.length ? buffered.start(0) : 0;
|
33635
33750
|
var delta = bufferStart - startPosition;
|