hls.js 1.6.0-beta.3.0.canary.10981 → 1.6.0-beta.3.0.canary.10984
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 +15 -6
- package/dist/hls.d.ts +15 -6
- package/dist/hls.js +182 -120
- package/dist/hls.js.d.ts +15 -6
- package/dist/hls.js.map +1 -1
- package/dist/hls.light.js +7 -5
- 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 +7 -5
- 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 +144 -83
- package/dist/hls.mjs.map +1 -1
- package/dist/hls.worker.js +1 -1
- package/package.json +2 -2
- package/src/config.ts +4 -4
- package/src/controller/base-stream-controller.ts +2 -2
- package/src/controller/id3-track-controller.ts +1 -1
- package/src/controller/interstitial-player.ts +15 -5
- package/src/controller/interstitials-controller.ts +146 -84
- package/src/controller/stream-controller.ts +8 -6
- package/src/define-plugin.d.ts +1 -1
- package/src/hls.ts +4 -1
- package/src/loader/interstitial-event.ts +2 -2
package/dist/hls.js
CHANGED
@@ -1059,7 +1059,7 @@
|
|
1059
1059
|
// Some browsers don't allow to use bind on console object anyway
|
1060
1060
|
// fallback to default if needed
|
1061
1061
|
try {
|
1062
|
-
newLogger.log("Debug logs enabled for \"" + context + "\" in hls.js version " + "1.6.0-beta.3.0.canary.
|
1062
|
+
newLogger.log("Debug logs enabled for \"" + context + "\" in hls.js version " + "1.6.0-beta.3.0.canary.10984");
|
1063
1063
|
} catch (e) {
|
1064
1064
|
/* log fn threw an exception. All logger methods are no-ops. */
|
1065
1065
|
return createLogger();
|
@@ -9154,7 +9154,7 @@
|
|
9154
9154
|
}
|
9155
9155
|
}
|
9156
9156
|
}
|
9157
|
-
// Skip loading of fragments that overlap completely with appendInPlace
|
9157
|
+
// Skip loading of fragments that overlap completely with appendInPlace interstitials
|
9158
9158
|
var playerQueue = interstitials == null ? void 0 : interstitials.playerQueue;
|
9159
9159
|
if (playerQueue) {
|
9160
9160
|
for (var i = playerQueue.length; i--;) {
|
@@ -16413,7 +16413,7 @@
|
|
16413
16413
|
return !remuxResult.audio && !remuxResult.video && !remuxResult.text && !remuxResult.id3 && !remuxResult.initSegment;
|
16414
16414
|
}
|
16415
16415
|
|
16416
|
-
var version = "1.6.0-beta.3.0.canary.
|
16416
|
+
var version = "1.6.0-beta.3.0.canary.10984";
|
16417
16417
|
|
16418
16418
|
// ensure the worker ends up in the bundle
|
16419
16419
|
// If the worker should not be included this gets aliased to empty.js
|
@@ -23175,11 +23175,11 @@
|
|
23175
23175
|
this.tracks = null;
|
23176
23176
|
this.hasDetails = false;
|
23177
23177
|
this.mediaAttached = null;
|
23178
|
-
this.playoutOffset = 0;
|
23179
23178
|
this.checkPlayout = function () {
|
23180
23179
|
var interstitial = _this.interstitial;
|
23181
23180
|
var playoutLimit = interstitial.playoutLimit;
|
23182
|
-
|
23181
|
+
var currentTime = _this.currentTime;
|
23182
|
+
if (_this.startOffset + currentTime >= playoutLimit) {
|
23183
23183
|
_this.hls.trigger(Events.PLAYOUT_LIMIT_REACHED, {});
|
23184
23184
|
}
|
23185
23185
|
};
|
@@ -23206,8 +23206,6 @@
|
|
23206
23206
|
_this.mediaAttached = media;
|
23207
23207
|
var event = _this.interstitial;
|
23208
23208
|
if (event.playoutLimit) {
|
23209
|
-
var _event$assetList$even;
|
23210
|
-
_this.playoutOffset = ((_event$assetList$even = event.assetList[event.assetList.indexOf(assetItem)]) == null ? void 0 : _event$assetList$even.startOffset) || 0;
|
23211
23209
|
media.addEventListener('timeupdate', _this.checkPlayout);
|
23212
23210
|
}
|
23213
23211
|
});
|
@@ -23304,8 +23302,7 @@
|
|
23304
23302
|
}, {
|
23305
23303
|
key: "duration",
|
23306
23304
|
get: function get() {
|
23307
|
-
var
|
23308
|
-
var duration = (_this$assetItem = this.assetItem) == null ? void 0 : _this$assetItem.duration;
|
23305
|
+
var duration = this.assetItem.duration;
|
23309
23306
|
if (!duration) {
|
23310
23307
|
return 0;
|
23311
23308
|
}
|
@@ -23320,6 +23317,11 @@
|
|
23320
23317
|
}
|
23321
23318
|
return Math.max(0, duration - this.currentTime);
|
23322
23319
|
}
|
23320
|
+
}, {
|
23321
|
+
key: "startOffset",
|
23322
|
+
get: function get() {
|
23323
|
+
return this.assetItem.startOffset;
|
23324
|
+
}
|
23323
23325
|
}, {
|
23324
23326
|
key: "timelineOffset",
|
23325
23327
|
get: function get() {
|
@@ -23997,7 +23999,9 @@
|
|
23997
23999
|
_this.playingItem = null;
|
23998
24000
|
_this.bufferingItem = null;
|
23999
24001
|
_this.waitingItem = null;
|
24002
|
+
_this.endedItem = null;
|
24000
24003
|
_this.playingAsset = null;
|
24004
|
+
_this.endedAsset = null;
|
24001
24005
|
_this.bufferingAsset = null;
|
24002
24006
|
_this.shouldPlay = false;
|
24003
24007
|
_this.onPlay = function () {
|
@@ -24053,6 +24057,7 @@
|
|
24053
24057
|
if (_this.playingLastItem && _this.isInterstitial(playingItem)) {
|
24054
24058
|
var restartAsset = playingItem.event.assetList[0];
|
24055
24059
|
if (restartAsset) {
|
24060
|
+
_this.endedItem = _this.playingItem;
|
24056
24061
|
_this.playingItem = null;
|
24057
24062
|
_this.setScheduleToAssetAtTime(currentTime, restartAsset);
|
24058
24063
|
}
|
@@ -24148,7 +24153,12 @@
|
|
24148
24153
|
var updatedPlayingItem = _this.updateItem(playingItem, _this.timelinePos);
|
24149
24154
|
if (_this.itemsMatch(playingItem, updatedPlayingItem)) {
|
24150
24155
|
_this.playingItem = updatedPlayingItem;
|
24156
|
+
_this.waitingItem = _this.endedItem = null;
|
24151
24157
|
}
|
24158
|
+
} else {
|
24159
|
+
// Clear waitingItem if it has been removed from the schedule
|
24160
|
+
_this.waitingItem = _this.updateItem(_this.waitingItem);
|
24161
|
+
_this.endedItem = _this.updateItem(_this.endedItem);
|
24152
24162
|
}
|
24153
24163
|
// Do not replace Interstitial bufferingItem without a match - used for transfering media element or source
|
24154
24164
|
var bufferingItem = _this.bufferingItem;
|
@@ -24162,8 +24172,6 @@
|
|
24162
24172
|
_this.clearInterstitial(bufferingItem.event, null);
|
24163
24173
|
}
|
24164
24174
|
}
|
24165
|
-
// Clear waitingItem if it has been removed from the schedule
|
24166
|
-
_this.waitingItem = _this.updateItem(_this.waitingItem);
|
24167
24175
|
removedInterstitials.forEach(function (interstitial) {
|
24168
24176
|
interstitial.assetList.forEach(function (asset) {
|
24169
24177
|
_this.clearAssetPlayer(asset.identifier, null);
|
@@ -24299,7 +24307,7 @@
|
|
24299
24307
|
addEventListener(media, 'pause', this.onPause);
|
24300
24308
|
};
|
24301
24309
|
_proto.onMediaAttached = function onMediaAttached(event, data) {
|
24302
|
-
var playingItem = this.
|
24310
|
+
var playingItem = this.effectivePlayingItem;
|
24303
24311
|
var detachedMedia = this.detachedData;
|
24304
24312
|
this.detachedData = null;
|
24305
24313
|
if (playingItem === null) {
|
@@ -24312,7 +24320,7 @@
|
|
24312
24320
|
}
|
24313
24321
|
};
|
24314
24322
|
_proto.clearScheduleState = function clearScheduleState() {
|
24315
|
-
this.playingItem = this.bufferingItem = this.waitingItem = this.playingAsset = this.bufferingAsset = null;
|
24323
|
+
this.playingItem = this.bufferingItem = this.waitingItem = this.endedItem = this.playingAsset = this.endedAsset = this.bufferingAsset = null;
|
24316
24324
|
};
|
24317
24325
|
_proto.onMediaDetaching = function onMediaDetaching(event, data) {
|
24318
24326
|
var transferringMedia = !!data.transferMedia;
|
@@ -24328,11 +24336,7 @@
|
|
24328
24336
|
if (this.detachedData) {
|
24329
24337
|
var player = this.getBufferingPlayer();
|
24330
24338
|
if (player) {
|
24331
|
-
this.playingAsset = null;
|
24332
|
-
this.bufferingAsset = null;
|
24333
|
-
this.bufferingItem = null;
|
24334
|
-
this.waitingItem = null;
|
24335
|
-
this.detachedData = null;
|
24339
|
+
this.playingAsset = this.endedAsset = this.bufferingAsset = this.bufferingItem = this.waitingItem = this.detachedData = null;
|
24336
24340
|
player.detachMedia();
|
24337
24341
|
}
|
24338
24342
|
this.shouldPlay = false;
|
@@ -24433,7 +24437,7 @@
|
|
24433
24437
|
}
|
24434
24438
|
// Start stepping through schedule when playback begins for the first time and we have a pre-roll
|
24435
24439
|
var timelinePos = this.timelinePos;
|
24436
|
-
var
|
24440
|
+
var effectivePlayingItem = this.effectivePlayingItem;
|
24437
24441
|
if (timelinePos === -1) {
|
24438
24442
|
var startPosition = this.hls.startPosition;
|
24439
24443
|
this.timelinePos = startPosition;
|
@@ -24445,8 +24449,8 @@
|
|
24445
24449
|
var _index = schedule.findItemIndexAtTime(start);
|
24446
24450
|
this.setSchedulePosition(_index);
|
24447
24451
|
}
|
24448
|
-
} else if (
|
24449
|
-
var _index2 = schedule.findItemIndex(
|
24452
|
+
} else if (effectivePlayingItem && !this.playingItem) {
|
24453
|
+
var _index2 = schedule.findItemIndex(effectivePlayingItem);
|
24450
24454
|
this.setSchedulePosition(_index2);
|
24451
24455
|
}
|
24452
24456
|
};
|
@@ -24501,9 +24505,10 @@
|
|
24501
24505
|
var assetId = playingAsset == null ? void 0 : playingAsset.identifier;
|
24502
24506
|
var player = assetId ? this.getAssetPlayer(assetId) : null;
|
24503
24507
|
if (player && assetId && (!this.eventItemsMatch(currentItem, scheduledItem) || assetListIndex !== undefined && assetId !== ((_interstitial$assetLi = interstitial.assetList) == null ? void 0 : _interstitial$assetLi[assetListIndex].identifier))) {
|
24504
|
-
this.playingAsset = null;
|
24505
24508
|
var _assetListIndex = interstitial.findAssetIndex(playingAsset);
|
24506
24509
|
this.log("INTERSTITIAL_ASSET_ENDED " + (_assetListIndex + 1) + "/" + interstitial.assetList.length + " " + eventAssetToString(playingAsset));
|
24510
|
+
this.endedAsset = playingAsset;
|
24511
|
+
this.playingAsset = null;
|
24507
24512
|
this.hls.trigger(Events.INTERSTITIAL_ASSET_ENDED, {
|
24508
24513
|
asset: playingAsset,
|
24509
24514
|
assetListIndex: _assetListIndex,
|
@@ -24516,9 +24521,9 @@
|
|
24516
24521
|
if (player.media && !this.detachedData) {
|
24517
24522
|
player.detachMedia();
|
24518
24523
|
}
|
24519
|
-
this.clearAssetPlayer(assetId, scheduledItem);
|
24520
24524
|
}
|
24521
24525
|
if (!this.eventItemsMatch(currentItem, scheduledItem)) {
|
24526
|
+
this.endedItem = currentItem;
|
24522
24527
|
this.playingItem = null;
|
24523
24528
|
this.log("INTERSTITIAL_ENDED " + interstitial + " " + segmentToString(currentItem));
|
24524
24529
|
interstitial.hasPlayed = true;
|
@@ -24571,7 +24576,7 @@
|
|
24571
24576
|
var waitingItem = this.waitingItem;
|
24572
24577
|
this.setBufferingItem(scheduledItem);
|
24573
24578
|
var player = this.preloadAssets(interstitial, assetListIndex);
|
24574
|
-
if (!this.eventItemsMatch(scheduledItem,
|
24579
|
+
if (!this.eventItemsMatch(scheduledItem, waitingItem || currentItem)) {
|
24575
24580
|
this.waitingItem = scheduledItem;
|
24576
24581
|
this.log("INTERSTITIAL_STARTED " + segmentToString(scheduledItem) + " " + (interstitial.appendInPlace ? 'append in place' : ''));
|
24577
24582
|
this.hls.trigger(Events.INTERSTITIAL_STARTED, {
|
@@ -24595,7 +24600,7 @@
|
|
24595
24600
|
return;
|
24596
24601
|
}
|
24597
24602
|
// Update schedule and asset list position now that it can start
|
24598
|
-
this.waitingItem = null;
|
24603
|
+
this.waitingItem = this.endedItem = null;
|
24599
24604
|
this.playingItem = scheduledItem;
|
24600
24605
|
|
24601
24606
|
// If asset-list is empty or missing asset index, advance to next item
|
@@ -24636,6 +24641,7 @@
|
|
24636
24641
|
} else if (playedLastItem && this.isInterstitial(currentItem)) {
|
24637
24642
|
// Maintain playingItem state at end of schedule (setSchedulePosition(-1) called to end program)
|
24638
24643
|
// this allows onSeeking handler to update schedule position
|
24644
|
+
this.endedItem = null;
|
24639
24645
|
this.playingItem = currentItem;
|
24640
24646
|
if (!currentItem.event.appendInPlace) {
|
24641
24647
|
// Media must be re-attached to resume primary schedule if not sharing source
|
@@ -24646,8 +24652,8 @@
|
|
24646
24652
|
_proto.resumePrimary = function resumePrimary(scheduledItem, index, fromItem) {
|
24647
24653
|
var _this$detachedData2;
|
24648
24654
|
this.playingItem = scheduledItem;
|
24649
|
-
this.playingAsset = null;
|
24650
|
-
this.waitingItem = null;
|
24655
|
+
this.playingAsset = this.endedAsset = null;
|
24656
|
+
this.waitingItem = this.endedItem = null;
|
24651
24657
|
this.bufferedToItem(scheduledItem);
|
24652
24658
|
this.log("resuming " + segmentToString(scheduledItem));
|
24653
24659
|
if (!((_this$detachedData2 = this.detachedData) != null && _this$detachedData2.mediaSource)) {
|
@@ -24752,7 +24758,7 @@
|
|
24752
24758
|
});
|
24753
24759
|
this.mediaSelection = currentSelection;
|
24754
24760
|
this.schedule.parseInterstitialDateRanges(currentSelection);
|
24755
|
-
if (!this.
|
24761
|
+
if (!this.effectivePlayingItem && this.schedule.items) {
|
24756
24762
|
this.checkStart();
|
24757
24763
|
}
|
24758
24764
|
};
|
@@ -24917,6 +24923,7 @@
|
|
24917
24923
|
}
|
24918
24924
|
};
|
24919
24925
|
_proto.setBufferingItem = function setBufferingItem(item) {
|
24926
|
+
var _this3 = this;
|
24920
24927
|
var bufferingLast = this.bufferingItem;
|
24921
24928
|
var schedule = this.schedule;
|
24922
24929
|
if (!this.itemsMatch(item, bufferingLast)) {
|
@@ -24934,8 +24941,11 @@
|
|
24934
24941
|
if (!this.playbackDisabled) {
|
24935
24942
|
if (isInterstitial) {
|
24936
24943
|
// primary fragment loading will exit early in base-stream-controller while `bufferingItem` is set to an Interstitial block
|
24937
|
-
|
24938
|
-
|
24944
|
+
item.event.assetList.forEach(function (asset) {
|
24945
|
+
var player = _this3.getAssetPlayer(asset.identifier);
|
24946
|
+
if (player) {
|
24947
|
+
player.resumeBuffering();
|
24948
|
+
}
|
24939
24949
|
});
|
24940
24950
|
} else {
|
24941
24951
|
this.hls.resumeBuffering();
|
@@ -25013,7 +25023,7 @@
|
|
25013
25023
|
this.log("Load interstitial asset " + (assetListIndex + 1) + "/" + assetListLength + " " + interstitial);
|
25014
25024
|
var timelineStart = interstitial.timelineStart;
|
25015
25025
|
if (interstitial.appendInPlace) {
|
25016
|
-
this.flushFrontBuffer(timelineStart);
|
25026
|
+
this.flushFrontBuffer(timelineStart + 0.25);
|
25017
25027
|
}
|
25018
25028
|
var uri = interstitial.assetUrl;
|
25019
25029
|
if (uri) {
|
@@ -25045,7 +25055,7 @@
|
|
25045
25055
|
return null;
|
25046
25056
|
};
|
25047
25057
|
_proto.flushFrontBuffer = function flushFrontBuffer(startOffset) {
|
25048
|
-
var
|
25058
|
+
var _this4 = this;
|
25049
25059
|
// Force queued flushing of all buffers
|
25050
25060
|
var requiredTracks = this.requiredTracks;
|
25051
25061
|
if (!requiredTracks) {
|
@@ -25053,7 +25063,7 @@
|
|
25053
25063
|
}
|
25054
25064
|
var sourceBufferNames = Object.keys(requiredTracks);
|
25055
25065
|
sourceBufferNames.forEach(function (type) {
|
25056
|
-
|
25066
|
+
_this4.hls.trigger(Events.BUFFER_FLUSHING, {
|
25057
25067
|
startOffset: startOffset,
|
25058
25068
|
endOffset: Infinity,
|
25059
25069
|
type: type
|
@@ -25100,7 +25110,7 @@
|
|
25100
25110
|
return this.createAssetPlayer(interstitial, assetItem, assetListIndex);
|
25101
25111
|
};
|
25102
25112
|
_proto.createAssetPlayer = function createAssetPlayer(interstitial, assetItem, assetListIndex) {
|
25103
|
-
var
|
25113
|
+
var _this5 = this;
|
25104
25114
|
this.log("create HLSAssetPlayer for " + eventAssetToString(assetItem));
|
25105
25115
|
var primary = this.hls;
|
25106
25116
|
var userConfig = primary.userConfig;
|
@@ -25167,17 +25177,17 @@
|
|
25167
25177
|
details: ErrorDetails.INTERSTITIAL_ASSET_ITEM_ERROR,
|
25168
25178
|
error: error
|
25169
25179
|
};
|
25170
|
-
|
25180
|
+
_this5.handleAssetItemError(errorData, interstitial, _this5.schedule.findEventIndex(interstitial.identifier), assetListIndex, error.message);
|
25171
25181
|
return;
|
25172
25182
|
}
|
25173
25183
|
// Get time at end of last fragment
|
25174
25184
|
var duration = details.edge - details.fragmentStart;
|
25175
25185
|
var currentAssetDuration = assetItem.duration;
|
25176
25186
|
if (currentAssetDuration === null || duration > currentAssetDuration) {
|
25177
|
-
|
25187
|
+
_this5.log("Interstitial asset \"" + assetId + "\" duration change " + currentAssetDuration + " > " + duration);
|
25178
25188
|
assetItem.duration = duration;
|
25179
25189
|
// Update schedule with new event and asset duration
|
25180
|
-
|
25190
|
+
_this5.updateSchedule();
|
25181
25191
|
}
|
25182
25192
|
};
|
25183
25193
|
player.on(Events.LEVEL_UPDATED, function (event, _ref) {
|
@@ -25189,39 +25199,39 @@
|
|
25189
25199
|
return updateAssetPlayerDetails(details);
|
25190
25200
|
});
|
25191
25201
|
var _onBufferCodecs = function onBufferCodecs(event, data) {
|
25192
|
-
var inQueuPlayer =
|
25202
|
+
var inQueuPlayer = _this5.getAssetPlayer(assetId);
|
25193
25203
|
if (inQueuPlayer && data.tracks) {
|
25194
25204
|
inQueuPlayer.off(Events.BUFFER_CODECS, _onBufferCodecs);
|
25195
25205
|
inQueuPlayer.tracks = data.tracks;
|
25196
|
-
var media =
|
25197
|
-
if (
|
25198
|
-
|
25206
|
+
var media = _this5.primaryMedia;
|
25207
|
+
if (_this5.bufferingAsset === inQueuPlayer.assetItem && media && !inQueuPlayer.media) {
|
25208
|
+
_this5.bufferAssetPlayer(inQueuPlayer, media);
|
25199
25209
|
}
|
25200
25210
|
}
|
25201
25211
|
};
|
25202
25212
|
player.on(Events.BUFFER_CODECS, _onBufferCodecs);
|
25203
25213
|
var _bufferedToEnd = function bufferedToEnd(name) {
|
25204
|
-
var
|
25205
|
-
var inQueuPlayer =
|
25206
|
-
|
25214
|
+
var _this5$schedule$items;
|
25215
|
+
var inQueuPlayer = _this5.getAssetPlayer(assetId);
|
25216
|
+
_this5.log("buffered to end of asset " + inQueuPlayer);
|
25207
25217
|
if (!inQueuPlayer) {
|
25208
25218
|
return;
|
25209
25219
|
}
|
25210
25220
|
inQueuPlayer.off(Events.BUFFERED_TO_END, _bufferedToEnd);
|
25211
25221
|
|
25212
25222
|
// Preload at end of asset
|
25213
|
-
var scheduleIndex =
|
25223
|
+
var scheduleIndex = _this5.schedule.findEventIndex(interstitial.identifier);
|
25214
25224
|
var assetListIndex = interstitial.findAssetIndex(assetItem);
|
25215
25225
|
var nextAssetIndex = assetListIndex + 1;
|
25216
|
-
var item = (
|
25217
|
-
if (
|
25226
|
+
var item = (_this5$schedule$items = _this5.schedule.items) == null ? void 0 : _this5$schedule$items[scheduleIndex];
|
25227
|
+
if (_this5.isInterstitial(item)) {
|
25218
25228
|
if (assetListIndex !== -1 && !interstitial.isAssetPastPlayoutLimit(nextAssetIndex) && !interstitial.assetList[nextAssetIndex].error) {
|
25219
|
-
|
25229
|
+
_this5.bufferedToItem(item, assetListIndex + 1);
|
25220
25230
|
} else {
|
25221
|
-
var
|
25222
|
-
var nextItem = (
|
25231
|
+
var _this5$schedule$items2;
|
25232
|
+
var nextItem = (_this5$schedule$items2 = _this5.schedule.items) == null ? void 0 : _this5$schedule$items2[scheduleIndex + 1];
|
25223
25233
|
if (nextItem) {
|
25224
|
-
|
25234
|
+
_this5.bufferedToItem(nextItem);
|
25225
25235
|
}
|
25226
25236
|
}
|
25227
25237
|
}
|
@@ -25229,22 +25239,22 @@
|
|
25229
25239
|
player.on(Events.BUFFERED_TO_END, _bufferedToEnd);
|
25230
25240
|
var endedWithAssetIndex = function endedWithAssetIndex(assetIndex) {
|
25231
25241
|
return function () {
|
25232
|
-
var inQueuPlayer =
|
25242
|
+
var inQueuPlayer = _this5.getAssetPlayer(assetId);
|
25233
25243
|
if (!inQueuPlayer) {
|
25234
25244
|
return;
|
25235
25245
|
}
|
25236
|
-
|
25237
|
-
var scheduleIndex =
|
25238
|
-
|
25246
|
+
_this5.shouldPlay = true;
|
25247
|
+
var scheduleIndex = _this5.schedule.findEventIndex(interstitial.identifier);
|
25248
|
+
_this5.advanceAfterAssetEnded(interstitial, scheduleIndex, assetIndex);
|
25239
25249
|
};
|
25240
25250
|
};
|
25241
25251
|
player.once(Events.MEDIA_ENDED, endedWithAssetIndex(assetListIndex));
|
25242
25252
|
player.once(Events.PLAYOUT_LIMIT_REACHED, endedWithAssetIndex(Infinity));
|
25243
25253
|
player.on(Events.ERROR, function (event, data) {
|
25244
|
-
|
25254
|
+
_this5.handleAssetItemError(data, interstitial, _this5.schedule.findEventIndex(interstitial.identifier), assetListIndex, "Asset player error " + data.error + " " + interstitial);
|
25245
25255
|
});
|
25246
25256
|
player.on(Events.DESTROYING, function () {
|
25247
|
-
var inQueuPlayer =
|
25257
|
+
var inQueuPlayer = _this5.getAssetPlayer(assetId);
|
25248
25258
|
if (!inQueuPlayer) {
|
25249
25259
|
return;
|
25250
25260
|
}
|
@@ -25255,7 +25265,7 @@
|
|
25255
25265
|
details: ErrorDetails.INTERSTITIAL_ASSET_ITEM_ERROR,
|
25256
25266
|
error: error
|
25257
25267
|
};
|
25258
|
-
|
25268
|
+
_this5.handleAssetItemError(errorData, interstitial, _this5.schedule.findEventIndex(interstitial.identifier), assetListIndex, error.message);
|
25259
25269
|
});
|
25260
25270
|
this.hls.trigger(Events.INTERSTITIAL_ASSET_PLAYER_CREATED, {
|
25261
25271
|
asset: assetItem,
|
@@ -25266,9 +25276,9 @@
|
|
25266
25276
|
return player;
|
25267
25277
|
};
|
25268
25278
|
_proto.clearInterstitial = function clearInterstitial(interstitial, toSegment) {
|
25269
|
-
var
|
25279
|
+
var _this6 = this;
|
25270
25280
|
interstitial.assetList.forEach(function (asset) {
|
25271
|
-
|
25281
|
+
_this6.clearAssetPlayer(asset.identifier, toSegment);
|
25272
25282
|
});
|
25273
25283
|
interstitial.appendInPlaceStarted = false;
|
25274
25284
|
};
|
@@ -25295,6 +25305,7 @@
|
|
25295
25305
|
assetId = player.assetId;
|
25296
25306
|
var assetListLength = interstitial.assetList.length;
|
25297
25307
|
var playingAsset = this.playingAsset;
|
25308
|
+
this.endedAsset = null;
|
25298
25309
|
this.playingAsset = assetItem;
|
25299
25310
|
if (!playingAsset || playingAsset.identifier !== assetId) {
|
25300
25311
|
if (playingAsset) {
|
@@ -25303,7 +25314,6 @@
|
|
25303
25314
|
delete playingAsset.error;
|
25304
25315
|
}
|
25305
25316
|
this.log("INTERSTITIAL_ASSET_STARTED " + (assetListIndex + 1) + "/" + assetListLength + " " + player);
|
25306
|
-
// player.resumeBuffering();
|
25307
25317
|
this.hls.trigger(Events.INTERSTITIAL_ASSET_STARTED, {
|
25308
25318
|
asset: assetItem,
|
25309
25319
|
assetListIndex: assetListIndex,
|
@@ -25404,7 +25414,7 @@
|
|
25404
25414
|
_proto.primaryFallback = function primaryFallback(interstitial) {
|
25405
25415
|
// Fallback to Primary by on current or future events by updating schedule to skip errored interstitials/assets
|
25406
25416
|
var flushStart = interstitial.timelineStart;
|
25407
|
-
var playingItem = this.
|
25417
|
+
var playingItem = this.effectivePlayingItem;
|
25408
25418
|
// Update schedule now that interstitial/assets are flagged with `error` for fallback
|
25409
25419
|
this.updateSchedule();
|
25410
25420
|
if (playingItem) {
|
@@ -25431,7 +25441,7 @@
|
|
25431
25441
|
// Asset List loading
|
25432
25442
|
;
|
25433
25443
|
_proto.onAssetListLoaded = function onAssetListLoaded(event, data) {
|
25434
|
-
var
|
25444
|
+
var _this7 = this,
|
25435
25445
|
_this$bufferingItem;
|
25436
25446
|
var interstitial = data.event;
|
25437
25447
|
var interstitialId = interstitial.identifier;
|
@@ -25444,7 +25454,7 @@
|
|
25444
25454
|
var sumDuration = 0;
|
25445
25455
|
assets.forEach(function (asset, assetListIndex) {
|
25446
25456
|
var duration = parseFloat(asset.DURATION);
|
25447
|
-
|
25457
|
+
_this7.createAsset(interstitial, assetListIndex, sumDuration, eventStart + sumDuration, duration, asset.URI);
|
25448
25458
|
sumDuration += duration;
|
25449
25459
|
});
|
25450
25460
|
interstitial.duration = sumDuration;
|
@@ -25492,16 +25502,13 @@
|
|
25492
25502
|
key: "interstitialsManager",
|
25493
25503
|
get: function get() {
|
25494
25504
|
if (!this.manager) {
|
25495
|
-
if (!this.hls
|
25505
|
+
if (!this.hls) {
|
25496
25506
|
return null;
|
25497
25507
|
}
|
25498
25508
|
var c = this;
|
25499
25509
|
var effectiveBufferingItem = function effectiveBufferingItem() {
|
25500
25510
|
return c.bufferingItem || c.waitingItem;
|
25501
25511
|
};
|
25502
|
-
var effectivePlayingItem = function effectivePlayingItem() {
|
25503
|
-
return c.playingItem || c.waitingItem;
|
25504
|
-
};
|
25505
25512
|
var getAssetPlayer = function getAssetPlayer(asset) {
|
25506
25513
|
return asset ? c.getAssetPlayer(asset.identifier) : asset;
|
25507
25514
|
};
|
@@ -25541,7 +25548,7 @@
|
|
25541
25548
|
if (value === Number.MAX_VALUE) {
|
25542
25549
|
return getMappedDuration('primary');
|
25543
25550
|
}
|
25544
|
-
return value;
|
25551
|
+
return Math.max(value, 0);
|
25545
25552
|
};
|
25546
25553
|
var getMappedDuration = function getMappedDuration(timelineType) {
|
25547
25554
|
var _c$primaryDetails;
|
@@ -25551,14 +25558,14 @@
|
|
25551
25558
|
}
|
25552
25559
|
return c.schedule.durations[timelineType];
|
25553
25560
|
};
|
25554
|
-
var
|
25561
|
+
var seekTo = function seekTo(time, timelineType) {
|
25555
25562
|
var _item$event, _c$schedule$items2;
|
25556
|
-
var item = effectivePlayingItem
|
25563
|
+
var item = c.effectivePlayingItem;
|
25557
25564
|
if (item != null && (_item$event = item.event) != null && _item$event.restrictions.skip) {
|
25558
25565
|
return;
|
25559
25566
|
}
|
25560
25567
|
c.log("seek to " + time + " \"" + timelineType + "\"");
|
25561
|
-
var playingItem = effectivePlayingItem
|
25568
|
+
var playingItem = c.effectivePlayingItem;
|
25562
25569
|
var targetIndex = c.schedule.findItemIndexAtTime(time, timelineType);
|
25563
25570
|
var targetItem = (_c$schedule$items2 = c.schedule.items) == null ? void 0 : _c$schedule$items2[targetIndex];
|
25564
25571
|
var playingInterstitial = playingItem == null ? void 0 : playingItem.event;
|
@@ -25567,7 +25574,7 @@
|
|
25567
25574
|
if (playingItem && (appendInPlace || seekInItem)) {
|
25568
25575
|
// seek in asset player or primary media (appendInPlace)
|
25569
25576
|
var assetPlayer = getAssetPlayer(c.playingAsset);
|
25570
|
-
var media = (assetPlayer == null ? void 0 : assetPlayer.media) || c.
|
25577
|
+
var media = (assetPlayer == null ? void 0 : assetPlayer.media) || c.primaryMedia;
|
25571
25578
|
if (media) {
|
25572
25579
|
var currentTime = timelineType === 'primary' ? media.currentTime : getMappedTime(playingItem, timelineType, c.playingAsset, 'timelinePos', 'currentTime');
|
25573
25580
|
var diff = time - currentTime;
|
@@ -25623,6 +25630,62 @@
|
|
25623
25630
|
}
|
25624
25631
|
}
|
25625
25632
|
};
|
25633
|
+
var getActiveInterstitial = function getActiveInterstitial() {
|
25634
|
+
var playingItem = c.effectivePlayingItem;
|
25635
|
+
if (c.isInterstitial(playingItem)) {
|
25636
|
+
return playingItem;
|
25637
|
+
}
|
25638
|
+
var bufferingItem = effectiveBufferingItem();
|
25639
|
+
if (c.isInterstitial(bufferingItem)) {
|
25640
|
+
return bufferingItem;
|
25641
|
+
}
|
25642
|
+
return null;
|
25643
|
+
};
|
25644
|
+
var interstitialPlayer = {
|
25645
|
+
get currentTime() {
|
25646
|
+
var interstitialItem = getActiveInterstitial();
|
25647
|
+
var playingItem = c.effectivePlayingItem;
|
25648
|
+
if (playingItem && playingItem === interstitialItem) {
|
25649
|
+
return getMappedTime(playingItem, 'playout', c.effectivePlayingAsset, 'timelinePos', 'currentTime') - playingItem.playout.start;
|
25650
|
+
}
|
25651
|
+
return 0;
|
25652
|
+
},
|
25653
|
+
set currentTime(time) {
|
25654
|
+
var interstitialItem = getActiveInterstitial();
|
25655
|
+
var playingItem = c.effectivePlayingItem;
|
25656
|
+
if (playingItem && playingItem === interstitialItem) {
|
25657
|
+
seekTo(time + playingItem.playout.start, 'playout');
|
25658
|
+
}
|
25659
|
+
},
|
25660
|
+
get duration() {
|
25661
|
+
var interstitialItem = getActiveInterstitial();
|
25662
|
+
if (interstitialItem) {
|
25663
|
+
return interstitialItem.playout.end - interstitialItem.playout.start;
|
25664
|
+
}
|
25665
|
+
return 0;
|
25666
|
+
},
|
25667
|
+
get assetPlayers() {
|
25668
|
+
var _getActiveInterstitia;
|
25669
|
+
var assetList = (_getActiveInterstitia = getActiveInterstitial()) == null ? void 0 : _getActiveInterstitia.event.assetList;
|
25670
|
+
if (assetList) {
|
25671
|
+
return assetList.map(function (asset) {
|
25672
|
+
return c.getAssetPlayer(asset.identifier);
|
25673
|
+
});
|
25674
|
+
}
|
25675
|
+
return [];
|
25676
|
+
},
|
25677
|
+
get playingIndex() {
|
25678
|
+
var _getActiveInterstitia2;
|
25679
|
+
var interstitial = (_getActiveInterstitia2 = getActiveInterstitial()) == null ? void 0 : _getActiveInterstitia2.event;
|
25680
|
+
if (interstitial && c.effectivePlayingAsset) {
|
25681
|
+
return interstitial.findAssetIndex(c.effectivePlayingAsset);
|
25682
|
+
}
|
25683
|
+
return -1;
|
25684
|
+
},
|
25685
|
+
get scheduleItem() {
|
25686
|
+
return getActiveInterstitial();
|
25687
|
+
}
|
25688
|
+
};
|
25626
25689
|
this.manager = {
|
25627
25690
|
get events() {
|
25628
25691
|
var _c$schedule, _c$schedule$events;
|
@@ -25632,70 +25695,57 @@
|
|
25632
25695
|
var _c$schedule2, _c$schedule2$items;
|
25633
25696
|
return ((_c$schedule2 = c.schedule) == null ? void 0 : (_c$schedule2$items = _c$schedule2.items) == null ? void 0 : _c$schedule2$items.slice(0)) || [];
|
25634
25697
|
},
|
25698
|
+
get interstitialPlayer() {
|
25699
|
+
if (getActiveInterstitial()) {
|
25700
|
+
return interstitialPlayer;
|
25701
|
+
}
|
25702
|
+
return null;
|
25703
|
+
},
|
25635
25704
|
get playerQueue() {
|
25636
25705
|
return c.playerQueue.slice(0);
|
25637
25706
|
},
|
25638
|
-
get bufferingPlayer() {
|
25639
|
-
return c.getBufferingPlayer();
|
25640
|
-
},
|
25641
25707
|
get bufferingAsset() {
|
25642
25708
|
return c.bufferingAsset;
|
25643
25709
|
},
|
25644
25710
|
get bufferingItem() {
|
25645
|
-
return
|
25646
|
-
},
|
25647
|
-
get playingAsset() {
|
25648
|
-
return c.playingAsset;
|
25649
|
-
},
|
25650
|
-
get playingItem() {
|
25651
|
-
return c.playingItem;
|
25711
|
+
return effectiveBufferingItem();
|
25652
25712
|
},
|
25653
25713
|
get bufferingIndex() {
|
25654
25714
|
var item = effectiveBufferingItem();
|
25655
25715
|
return c.findItemIndex(item);
|
25656
25716
|
},
|
25717
|
+
get playingAsset() {
|
25718
|
+
return c.effectivePlayingAsset;
|
25719
|
+
},
|
25720
|
+
get playingItem() {
|
25721
|
+
return c.effectivePlayingItem;
|
25722
|
+
},
|
25657
25723
|
get playingIndex() {
|
25658
|
-
var item = effectivePlayingItem
|
25724
|
+
var item = c.effectivePlayingItem;
|
25659
25725
|
return c.findItemIndex(item);
|
25660
25726
|
},
|
25661
|
-
get waitingIndex() {
|
25662
|
-
return c.findItemIndex(c.waitingItem);
|
25663
|
-
},
|
25664
25727
|
primary: {
|
25665
25728
|
get bufferedEnd() {
|
25666
25729
|
return getBufferedEnd();
|
25667
25730
|
},
|
25668
25731
|
get currentTime() {
|
25732
|
+
var _playingItem$event;
|
25669
25733
|
var timelinePos = c.timelinePos;
|
25734
|
+
var playingItem = c.effectivePlayingItem;
|
25735
|
+
if (playingItem != null && (_playingItem$event = playingItem.event) != null && _playingItem$event.appendInPlace) {
|
25736
|
+
return playingItem.start;
|
25737
|
+
}
|
25670
25738
|
return timelinePos > 0 ? timelinePos : 0;
|
25671
25739
|
},
|
25740
|
+
set currentTime(time) {
|
25741
|
+
seekTo(time, 'primary');
|
25742
|
+
},
|
25672
25743
|
get duration() {
|
25673
25744
|
return getMappedDuration('primary');
|
25674
25745
|
},
|
25675
25746
|
get seekableStart() {
|
25676
25747
|
var _c$primaryDetails2;
|
25677
25748
|
return ((_c$primaryDetails2 = c.primaryDetails) == null ? void 0 : _c$primaryDetails2.fragmentStart) || 0;
|
25678
|
-
},
|
25679
|
-
seekTo: function seekTo(time) {
|
25680
|
-
return _seekTo(time, 'primary');
|
25681
|
-
}
|
25682
|
-
},
|
25683
|
-
playout: {
|
25684
|
-
get bufferedEnd() {
|
25685
|
-
return getMappedTime(effectiveBufferingItem(), 'playout', c.bufferingAsset, 'bufferedPos', 'bufferedEnd');
|
25686
|
-
},
|
25687
|
-
get currentTime() {
|
25688
|
-
return getMappedTime(effectivePlayingItem(), 'playout', c.playingAsset, 'timelinePos', 'currentTime');
|
25689
|
-
},
|
25690
|
-
get duration() {
|
25691
|
-
return getMappedDuration('playout');
|
25692
|
-
},
|
25693
|
-
get seekableStart() {
|
25694
|
-
var _c$primaryDetails3;
|
25695
|
-
return findMappedTime(((_c$primaryDetails3 = c.primaryDetails) == null ? void 0 : _c$primaryDetails3.fragmentStart) || 0, 'playout');
|
25696
|
-
},
|
25697
|
-
seekTo: function seekTo(time) {
|
25698
|
-
return _seekTo(time, 'playout');
|
25699
25749
|
}
|
25700
25750
|
},
|
25701
25751
|
integrated: {
|
@@ -25703,27 +25753,27 @@
|
|
25703
25753
|
return getMappedTime(effectiveBufferingItem(), 'integrated', c.bufferingAsset, 'bufferedPos', 'bufferedEnd');
|
25704
25754
|
},
|
25705
25755
|
get currentTime() {
|
25706
|
-
return getMappedTime(effectivePlayingItem
|
25756
|
+
return getMappedTime(c.effectivePlayingItem, 'integrated', c.effectivePlayingAsset, 'timelinePos', 'currentTime');
|
25757
|
+
},
|
25758
|
+
set currentTime(time) {
|
25759
|
+
seekTo(time, 'integrated');
|
25707
25760
|
},
|
25708
25761
|
get duration() {
|
25709
25762
|
return getMappedDuration('integrated');
|
25710
25763
|
},
|
25711
25764
|
get seekableStart() {
|
25712
|
-
var _c$
|
25713
|
-
return findMappedTime(((_c$
|
25714
|
-
},
|
25715
|
-
seekTo: function seekTo(time) {
|
25716
|
-
return _seekTo(time, 'integrated');
|
25765
|
+
var _c$primaryDetails3;
|
25766
|
+
return findMappedTime(((_c$primaryDetails3 = c.primaryDetails) == null ? void 0 : _c$primaryDetails3.fragmentStart) || 0, 'integrated');
|
25717
25767
|
}
|
25718
25768
|
},
|
25719
25769
|
skip: function skip() {
|
25720
|
-
var item = effectivePlayingItem
|
25770
|
+
var item = c.effectivePlayingItem;
|
25721
25771
|
var event = item == null ? void 0 : item.event;
|
25722
25772
|
if (event && !event.restrictions.skip) {
|
25723
25773
|
var index = c.findItemIndex(item);
|
25724
25774
|
if (event.appendInPlace) {
|
25725
25775
|
var time = item.playout.start + item.event.duration;
|
25726
|
-
|
25776
|
+
seekTo(time + 0.001, 'playout');
|
25727
25777
|
} else {
|
25728
25778
|
c.advanceAfterAssetEnded(event, index, Infinity);
|
25729
25779
|
}
|
@@ -25735,6 +25785,16 @@
|
|
25735
25785
|
}
|
25736
25786
|
|
25737
25787
|
// Schedule getters
|
25788
|
+
}, {
|
25789
|
+
key: "effectivePlayingItem",
|
25790
|
+
get: function get() {
|
25791
|
+
return this.waitingItem || this.playingItem || this.endedItem;
|
25792
|
+
}
|
25793
|
+
}, {
|
25794
|
+
key: "effectivePlayingAsset",
|
25795
|
+
get: function get() {
|
25796
|
+
return this.playingAsset || this.endedAsset;
|
25797
|
+
}
|
25738
25798
|
}, {
|
25739
25799
|
key: "playingLastItem",
|
25740
25800
|
get: function get() {
|
@@ -25749,7 +25809,7 @@
|
|
25749
25809
|
}, {
|
25750
25810
|
key: "playbackStarted",
|
25751
25811
|
get: function get() {
|
25752
|
-
return this.
|
25812
|
+
return this.effectivePlayingItem !== null;
|
25753
25813
|
}
|
25754
25814
|
|
25755
25815
|
// Media getters and event callbacks
|
@@ -32616,7 +32676,7 @@
|
|
32616
32676
|
// hls.nextLoadLevel remains until it is set to a new value or until a new frag is successfully loaded
|
32617
32677
|
hls.nextLoadLevel = startLevel;
|
32618
32678
|
this.level = hls.loadLevel;
|
32619
|
-
this._hasEnoughToStart =
|
32679
|
+
this._hasEnoughToStart = !!skipSeekToStartPosition;
|
32620
32680
|
}
|
32621
32681
|
// if startPosition undefined but lastCurrentTime set, set startPosition to last currentTime
|
32622
32682
|
if (lastCurrentTime > 0 && startPosition === -1 && !skipSeekToStartPosition) {
|
@@ -33199,7 +33259,7 @@
|
|
33199
33259
|
if (!media) {
|
33200
33260
|
return;
|
33201
33261
|
}
|
33202
|
-
if (!this._hasEnoughToStart && media.
|
33262
|
+
if (!this._hasEnoughToStart && BufferHelper.getBuffered(media).length) {
|
33203
33263
|
this._hasEnoughToStart = true;
|
33204
33264
|
this.seekToStartPos();
|
33205
33265
|
}
|
@@ -33610,7 +33670,9 @@
|
|
33610
33670
|
this.tickImmediate();
|
33611
33671
|
};
|
33612
33672
|
_proto.getMainFwdBufferInfo = function getMainFwdBufferInfo() {
|
33613
|
-
|
33673
|
+
// Observe video SourceBuffer (this.mediaBuffer) only when alt-audio is used, otherwise observe combined media buffer
|
33674
|
+
var bufferOutput = this.mediaBuffer && this.altAudio === 2 ? this.mediaBuffer : this.media;
|
33675
|
+
return this.getFwdBufferInfo(bufferOutput, PlaylistLevelType.MAIN);
|
33614
33676
|
};
|
33615
33677
|
_proto.backtrack = function backtrack(frag) {
|
33616
33678
|
this.couldBacktrack = true;
|