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.mjs
CHANGED
@@ -402,7 +402,7 @@ function enableLogs(debugConfig, context, id) {
|
|
402
402
|
// Some browsers don't allow to use bind on console object anyway
|
403
403
|
// fallback to default if needed
|
404
404
|
try {
|
405
|
-
newLogger.log(`Debug logs enabled for "${context}" in hls.js version ${"1.6.0-beta.3.0.canary.
|
405
|
+
newLogger.log(`Debug logs enabled for "${context}" in hls.js version ${"1.6.0-beta.3.0.canary.10984"}`);
|
406
406
|
} catch (e) {
|
407
407
|
/* log fn threw an exception. All logger methods are no-ops. */
|
408
408
|
return createLogger();
|
@@ -8419,7 +8419,7 @@ class BaseStreamController extends TaskLoop {
|
|
8419
8419
|
}
|
8420
8420
|
}
|
8421
8421
|
}
|
8422
|
-
// Skip loading of fragments that overlap completely with appendInPlace
|
8422
|
+
// Skip loading of fragments that overlap completely with appendInPlace interstitials
|
8423
8423
|
const playerQueue = interstitials == null ? void 0 : interstitials.playerQueue;
|
8424
8424
|
if (playerQueue) {
|
8425
8425
|
for (let i = playerQueue.length; i--;) {
|
@@ -9938,7 +9938,7 @@ var eventemitter3 = {exports: {}};
|
|
9938
9938
|
var eventemitter3Exports = eventemitter3.exports;
|
9939
9939
|
var EventEmitter = /*@__PURE__*/getDefaultExportFromCjs(eventemitter3Exports);
|
9940
9940
|
|
9941
|
-
const version = "1.6.0-beta.3.0.canary.
|
9941
|
+
const version = "1.6.0-beta.3.0.canary.10984";
|
9942
9942
|
|
9943
9943
|
// ensure the worker ends up in the bundle
|
9944
9944
|
// If the worker should not be included this gets aliased to empty.js
|
@@ -22998,11 +22998,11 @@ class HlsAssetPlayer {
|
|
22998
22998
|
this.tracks = null;
|
22999
22999
|
this.hasDetails = false;
|
23000
23000
|
this.mediaAttached = null;
|
23001
|
-
this.playoutOffset = 0;
|
23002
23001
|
this.checkPlayout = () => {
|
23003
23002
|
const interstitial = this.interstitial;
|
23004
23003
|
const playoutLimit = interstitial.playoutLimit;
|
23005
|
-
|
23004
|
+
const currentTime = this.currentTime;
|
23005
|
+
if (this.startOffset + currentTime >= playoutLimit) {
|
23006
23006
|
this.hls.trigger(Events.PLAYOUT_LIMIT_REACHED, {});
|
23007
23007
|
}
|
23008
23008
|
};
|
@@ -23030,8 +23030,6 @@ class HlsAssetPlayer {
|
|
23030
23030
|
this.mediaAttached = media;
|
23031
23031
|
const event = this.interstitial;
|
23032
23032
|
if (event.playoutLimit) {
|
23033
|
-
var _event$assetList$even;
|
23034
|
-
this.playoutOffset = ((_event$assetList$even = event.assetList[event.assetList.indexOf(assetItem)]) == null ? void 0 : _event$assetList$even.startOffset) || 0;
|
23035
23033
|
media.addEventListener('timeupdate', this.checkPlayout);
|
23036
23034
|
}
|
23037
23035
|
});
|
@@ -23066,8 +23064,7 @@ class HlsAssetPlayer {
|
|
23066
23064
|
return this.getAssetTime(media.currentTime);
|
23067
23065
|
}
|
23068
23066
|
get duration() {
|
23069
|
-
|
23070
|
-
const duration = (_this$assetItem = this.assetItem) == null ? void 0 : _this$assetItem.duration;
|
23067
|
+
const duration = this.assetItem.duration;
|
23071
23068
|
if (!duration) {
|
23072
23069
|
return 0;
|
23073
23070
|
}
|
@@ -23080,6 +23077,9 @@ class HlsAssetPlayer {
|
|
23080
23077
|
}
|
23081
23078
|
return Math.max(0, duration - this.currentTime);
|
23082
23079
|
}
|
23080
|
+
get startOffset() {
|
23081
|
+
return this.assetItem.startOffset;
|
23082
|
+
}
|
23083
23083
|
get timelineOffset() {
|
23084
23084
|
var _this$hls3;
|
23085
23085
|
return ((_this$hls3 = this.hls) == null ? void 0 : _this$hls3.config.timelineOffset) || 0;
|
@@ -23776,7 +23776,9 @@ class InterstitialsController extends Logger {
|
|
23776
23776
|
this.playingItem = null;
|
23777
23777
|
this.bufferingItem = null;
|
23778
23778
|
this.waitingItem = null;
|
23779
|
+
this.endedItem = null;
|
23779
23780
|
this.playingAsset = null;
|
23781
|
+
this.endedAsset = null;
|
23780
23782
|
this.bufferingAsset = null;
|
23781
23783
|
this.shouldPlay = false;
|
23782
23784
|
this.onPlay = () => {
|
@@ -23832,6 +23834,7 @@ class InterstitialsController extends Logger {
|
|
23832
23834
|
if (this.playingLastItem && this.isInterstitial(playingItem)) {
|
23833
23835
|
const restartAsset = playingItem.event.assetList[0];
|
23834
23836
|
if (restartAsset) {
|
23837
|
+
this.endedItem = this.playingItem;
|
23835
23838
|
this.playingItem = null;
|
23836
23839
|
this.setScheduleToAssetAtTime(currentTime, restartAsset);
|
23837
23840
|
}
|
@@ -23922,7 +23925,12 @@ Schedule: ${scheduleItems.map(seg => segmentToString(seg))}`);
|
|
23922
23925
|
const updatedPlayingItem = this.updateItem(playingItem, this.timelinePos);
|
23923
23926
|
if (this.itemsMatch(playingItem, updatedPlayingItem)) {
|
23924
23927
|
this.playingItem = updatedPlayingItem;
|
23928
|
+
this.waitingItem = this.endedItem = null;
|
23925
23929
|
}
|
23930
|
+
} else {
|
23931
|
+
// Clear waitingItem if it has been removed from the schedule
|
23932
|
+
this.waitingItem = this.updateItem(this.waitingItem);
|
23933
|
+
this.endedItem = this.updateItem(this.endedItem);
|
23926
23934
|
}
|
23927
23935
|
// Do not replace Interstitial bufferingItem without a match - used for transfering media element or source
|
23928
23936
|
const bufferingItem = this.bufferingItem;
|
@@ -23936,8 +23944,6 @@ Schedule: ${scheduleItems.map(seg => segmentToString(seg))}`);
|
|
23936
23944
|
this.clearInterstitial(bufferingItem.event, null);
|
23937
23945
|
}
|
23938
23946
|
}
|
23939
|
-
// Clear waitingItem if it has been removed from the schedule
|
23940
|
-
this.waitingItem = this.updateItem(this.waitingItem);
|
23941
23947
|
removedInterstitials.forEach(interstitial => {
|
23942
23948
|
interstitial.assetList.forEach(asset => {
|
23943
23949
|
this.clearAssetPlayer(asset.identifier, null);
|
@@ -24066,7 +24072,7 @@ Schedule: ${scheduleItems.map(seg => segmentToString(seg))}`);
|
|
24066
24072
|
addEventListener(media, 'pause', this.onPause);
|
24067
24073
|
}
|
24068
24074
|
onMediaAttached(event, data) {
|
24069
|
-
const playingItem = this.
|
24075
|
+
const playingItem = this.effectivePlayingItem;
|
24070
24076
|
const detachedMedia = this.detachedData;
|
24071
24077
|
this.detachedData = null;
|
24072
24078
|
if (playingItem === null) {
|
@@ -24079,7 +24085,7 @@ Schedule: ${scheduleItems.map(seg => segmentToString(seg))}`);
|
|
24079
24085
|
}
|
24080
24086
|
}
|
24081
24087
|
clearScheduleState() {
|
24082
|
-
this.playingItem = this.bufferingItem = this.waitingItem = this.playingAsset = this.bufferingAsset = null;
|
24088
|
+
this.playingItem = this.bufferingItem = this.waitingItem = this.endedItem = this.playingAsset = this.endedAsset = this.bufferingAsset = null;
|
24083
24089
|
}
|
24084
24090
|
onMediaDetaching(event, data) {
|
24085
24091
|
const transferringMedia = !!data.transferMedia;
|
@@ -24095,11 +24101,7 @@ Schedule: ${scheduleItems.map(seg => segmentToString(seg))}`);
|
|
24095
24101
|
if (this.detachedData) {
|
24096
24102
|
const player = this.getBufferingPlayer();
|
24097
24103
|
if (player) {
|
24098
|
-
this.playingAsset = null;
|
24099
|
-
this.bufferingAsset = null;
|
24100
|
-
this.bufferingItem = null;
|
24101
|
-
this.waitingItem = null;
|
24102
|
-
this.detachedData = null;
|
24104
|
+
this.playingAsset = this.endedAsset = this.bufferingAsset = this.bufferingItem = this.waitingItem = this.detachedData = null;
|
24103
24105
|
player.detachMedia();
|
24104
24106
|
}
|
24105
24107
|
this.shouldPlay = false;
|
@@ -24107,12 +24109,11 @@ Schedule: ${scheduleItems.map(seg => segmentToString(seg))}`);
|
|
24107
24109
|
}
|
24108
24110
|
get interstitialsManager() {
|
24109
24111
|
if (!this.manager) {
|
24110
|
-
if (!this.hls
|
24112
|
+
if (!this.hls) {
|
24111
24113
|
return null;
|
24112
24114
|
}
|
24113
24115
|
const c = this;
|
24114
24116
|
const effectiveBufferingItem = () => c.bufferingItem || c.waitingItem;
|
24115
|
-
const effectivePlayingItem = () => c.playingItem || c.waitingItem;
|
24116
24117
|
const getAssetPlayer = asset => asset ? c.getAssetPlayer(asset.identifier) : asset;
|
24117
24118
|
const getMappedTime = (item, timelineType, asset, controllerField, assetPlayerField) => {
|
24118
24119
|
if (item) {
|
@@ -24150,7 +24151,7 @@ Schedule: ${scheduleItems.map(seg => segmentToString(seg))}`);
|
|
24150
24151
|
if (value === Number.MAX_VALUE) {
|
24151
24152
|
return getMappedDuration('primary');
|
24152
24153
|
}
|
24153
|
-
return value;
|
24154
|
+
return Math.max(value, 0);
|
24154
24155
|
};
|
24155
24156
|
const getMappedDuration = timelineType => {
|
24156
24157
|
var _c$primaryDetails;
|
@@ -24162,12 +24163,12 @@ Schedule: ${scheduleItems.map(seg => segmentToString(seg))}`);
|
|
24162
24163
|
};
|
24163
24164
|
const seekTo = (time, timelineType) => {
|
24164
24165
|
var _item$event, _c$schedule$items2;
|
24165
|
-
const item = effectivePlayingItem
|
24166
|
+
const item = c.effectivePlayingItem;
|
24166
24167
|
if (item != null && (_item$event = item.event) != null && _item$event.restrictions.skip) {
|
24167
24168
|
return;
|
24168
24169
|
}
|
24169
24170
|
c.log(`seek to ${time} "${timelineType}"`);
|
24170
|
-
const playingItem = effectivePlayingItem
|
24171
|
+
const playingItem = c.effectivePlayingItem;
|
24171
24172
|
const targetIndex = c.schedule.findItemIndexAtTime(time, timelineType);
|
24172
24173
|
const targetItem = (_c$schedule$items2 = c.schedule.items) == null ? void 0 : _c$schedule$items2[targetIndex];
|
24173
24174
|
const playingInterstitial = playingItem == null ? void 0 : playingItem.event;
|
@@ -24176,7 +24177,7 @@ Schedule: ${scheduleItems.map(seg => segmentToString(seg))}`);
|
|
24176
24177
|
if (playingItem && (appendInPlace || seekInItem)) {
|
24177
24178
|
// seek in asset player or primary media (appendInPlace)
|
24178
24179
|
const assetPlayer = getAssetPlayer(c.playingAsset);
|
24179
|
-
const media = (assetPlayer == null ? void 0 : assetPlayer.media) || c.
|
24180
|
+
const media = (assetPlayer == null ? void 0 : assetPlayer.media) || c.primaryMedia;
|
24180
24181
|
if (media) {
|
24181
24182
|
const currentTime = timelineType === 'primary' ? media.currentTime : getMappedTime(playingItem, timelineType, c.playingAsset, 'timelinePos', 'currentTime');
|
24182
24183
|
const diff = time - currentTime;
|
@@ -24232,6 +24233,60 @@ Schedule: ${scheduleItems.map(seg => segmentToString(seg))}`);
|
|
24232
24233
|
}
|
24233
24234
|
}
|
24234
24235
|
};
|
24236
|
+
const getActiveInterstitial = () => {
|
24237
|
+
const playingItem = c.effectivePlayingItem;
|
24238
|
+
if (c.isInterstitial(playingItem)) {
|
24239
|
+
return playingItem;
|
24240
|
+
}
|
24241
|
+
const bufferingItem = effectiveBufferingItem();
|
24242
|
+
if (c.isInterstitial(bufferingItem)) {
|
24243
|
+
return bufferingItem;
|
24244
|
+
}
|
24245
|
+
return null;
|
24246
|
+
};
|
24247
|
+
const interstitialPlayer = {
|
24248
|
+
get currentTime() {
|
24249
|
+
const interstitialItem = getActiveInterstitial();
|
24250
|
+
const playingItem = c.effectivePlayingItem;
|
24251
|
+
if (playingItem && playingItem === interstitialItem) {
|
24252
|
+
return getMappedTime(playingItem, 'playout', c.effectivePlayingAsset, 'timelinePos', 'currentTime') - playingItem.playout.start;
|
24253
|
+
}
|
24254
|
+
return 0;
|
24255
|
+
},
|
24256
|
+
set currentTime(time) {
|
24257
|
+
const interstitialItem = getActiveInterstitial();
|
24258
|
+
const playingItem = c.effectivePlayingItem;
|
24259
|
+
if (playingItem && playingItem === interstitialItem) {
|
24260
|
+
seekTo(time + playingItem.playout.start, 'playout');
|
24261
|
+
}
|
24262
|
+
},
|
24263
|
+
get duration() {
|
24264
|
+
const interstitialItem = getActiveInterstitial();
|
24265
|
+
if (interstitialItem) {
|
24266
|
+
return interstitialItem.playout.end - interstitialItem.playout.start;
|
24267
|
+
}
|
24268
|
+
return 0;
|
24269
|
+
},
|
24270
|
+
get assetPlayers() {
|
24271
|
+
var _getActiveInterstitia;
|
24272
|
+
const assetList = (_getActiveInterstitia = getActiveInterstitial()) == null ? void 0 : _getActiveInterstitia.event.assetList;
|
24273
|
+
if (assetList) {
|
24274
|
+
return assetList.map(asset => c.getAssetPlayer(asset.identifier));
|
24275
|
+
}
|
24276
|
+
return [];
|
24277
|
+
},
|
24278
|
+
get playingIndex() {
|
24279
|
+
var _getActiveInterstitia2;
|
24280
|
+
const interstitial = (_getActiveInterstitia2 = getActiveInterstitial()) == null ? void 0 : _getActiveInterstitia2.event;
|
24281
|
+
if (interstitial && c.effectivePlayingAsset) {
|
24282
|
+
return interstitial.findAssetIndex(c.effectivePlayingAsset);
|
24283
|
+
}
|
24284
|
+
return -1;
|
24285
|
+
},
|
24286
|
+
get scheduleItem() {
|
24287
|
+
return getActiveInterstitial();
|
24288
|
+
}
|
24289
|
+
};
|
24235
24290
|
this.manager = {
|
24236
24291
|
get events() {
|
24237
24292
|
var _c$schedule, _c$schedule$events;
|
@@ -24241,86 +24296,79 @@ Schedule: ${scheduleItems.map(seg => segmentToString(seg))}`);
|
|
24241
24296
|
var _c$schedule2, _c$schedule2$items;
|
24242
24297
|
return ((_c$schedule2 = c.schedule) == null ? void 0 : (_c$schedule2$items = _c$schedule2.items) == null ? void 0 : _c$schedule2$items.slice(0)) || [];
|
24243
24298
|
},
|
24299
|
+
get interstitialPlayer() {
|
24300
|
+
if (getActiveInterstitial()) {
|
24301
|
+
return interstitialPlayer;
|
24302
|
+
}
|
24303
|
+
return null;
|
24304
|
+
},
|
24244
24305
|
get playerQueue() {
|
24245
24306
|
return c.playerQueue.slice(0);
|
24246
24307
|
},
|
24247
|
-
get bufferingPlayer() {
|
24248
|
-
return c.getBufferingPlayer();
|
24249
|
-
},
|
24250
24308
|
get bufferingAsset() {
|
24251
24309
|
return c.bufferingAsset;
|
24252
24310
|
},
|
24253
24311
|
get bufferingItem() {
|
24254
|
-
return
|
24255
|
-
},
|
24256
|
-
get playingAsset() {
|
24257
|
-
return c.playingAsset;
|
24258
|
-
},
|
24259
|
-
get playingItem() {
|
24260
|
-
return c.playingItem;
|
24312
|
+
return effectiveBufferingItem();
|
24261
24313
|
},
|
24262
24314
|
get bufferingIndex() {
|
24263
24315
|
const item = effectiveBufferingItem();
|
24264
24316
|
return c.findItemIndex(item);
|
24265
24317
|
},
|
24318
|
+
get playingAsset() {
|
24319
|
+
return c.effectivePlayingAsset;
|
24320
|
+
},
|
24321
|
+
get playingItem() {
|
24322
|
+
return c.effectivePlayingItem;
|
24323
|
+
},
|
24266
24324
|
get playingIndex() {
|
24267
|
-
const item = effectivePlayingItem
|
24325
|
+
const item = c.effectivePlayingItem;
|
24268
24326
|
return c.findItemIndex(item);
|
24269
24327
|
},
|
24270
|
-
get waitingIndex() {
|
24271
|
-
return c.findItemIndex(c.waitingItem);
|
24272
|
-
},
|
24273
24328
|
primary: {
|
24274
24329
|
get bufferedEnd() {
|
24275
24330
|
return getBufferedEnd();
|
24276
24331
|
},
|
24277
24332
|
get currentTime() {
|
24333
|
+
var _playingItem$event;
|
24278
24334
|
const timelinePos = c.timelinePos;
|
24335
|
+
const playingItem = c.effectivePlayingItem;
|
24336
|
+
if (playingItem != null && (_playingItem$event = playingItem.event) != null && _playingItem$event.appendInPlace) {
|
24337
|
+
return playingItem.start;
|
24338
|
+
}
|
24279
24339
|
return timelinePos > 0 ? timelinePos : 0;
|
24280
24340
|
},
|
24341
|
+
set currentTime(time) {
|
24342
|
+
seekTo(time, 'primary');
|
24343
|
+
},
|
24281
24344
|
get duration() {
|
24282
24345
|
return getMappedDuration('primary');
|
24283
24346
|
},
|
24284
24347
|
get seekableStart() {
|
24285
24348
|
var _c$primaryDetails2;
|
24286
24349
|
return ((_c$primaryDetails2 = c.primaryDetails) == null ? void 0 : _c$primaryDetails2.fragmentStart) || 0;
|
24287
|
-
}
|
24288
|
-
seekTo: time => seekTo(time, 'primary')
|
24289
|
-
},
|
24290
|
-
playout: {
|
24291
|
-
get bufferedEnd() {
|
24292
|
-
return getMappedTime(effectiveBufferingItem(), 'playout', c.bufferingAsset, 'bufferedPos', 'bufferedEnd');
|
24293
|
-
},
|
24294
|
-
get currentTime() {
|
24295
|
-
return getMappedTime(effectivePlayingItem(), 'playout', c.playingAsset, 'timelinePos', 'currentTime');
|
24296
|
-
},
|
24297
|
-
get duration() {
|
24298
|
-
return getMappedDuration('playout');
|
24299
|
-
},
|
24300
|
-
get seekableStart() {
|
24301
|
-
var _c$primaryDetails3;
|
24302
|
-
return findMappedTime(((_c$primaryDetails3 = c.primaryDetails) == null ? void 0 : _c$primaryDetails3.fragmentStart) || 0, 'playout');
|
24303
|
-
},
|
24304
|
-
seekTo: time => seekTo(time, 'playout')
|
24350
|
+
}
|
24305
24351
|
},
|
24306
24352
|
integrated: {
|
24307
24353
|
get bufferedEnd() {
|
24308
24354
|
return getMappedTime(effectiveBufferingItem(), 'integrated', c.bufferingAsset, 'bufferedPos', 'bufferedEnd');
|
24309
24355
|
},
|
24310
24356
|
get currentTime() {
|
24311
|
-
return getMappedTime(effectivePlayingItem
|
24357
|
+
return getMappedTime(c.effectivePlayingItem, 'integrated', c.effectivePlayingAsset, 'timelinePos', 'currentTime');
|
24358
|
+
},
|
24359
|
+
set currentTime(time) {
|
24360
|
+
seekTo(time, 'integrated');
|
24312
24361
|
},
|
24313
24362
|
get duration() {
|
24314
24363
|
return getMappedDuration('integrated');
|
24315
24364
|
},
|
24316
24365
|
get seekableStart() {
|
24317
|
-
var _c$
|
24318
|
-
return findMappedTime(((_c$
|
24319
|
-
}
|
24320
|
-
seekTo: time => seekTo(time, 'integrated')
|
24366
|
+
var _c$primaryDetails3;
|
24367
|
+
return findMappedTime(((_c$primaryDetails3 = c.primaryDetails) == null ? void 0 : _c$primaryDetails3.fragmentStart) || 0, 'integrated');
|
24368
|
+
}
|
24321
24369
|
},
|
24322
24370
|
skip: () => {
|
24323
|
-
const item = effectivePlayingItem
|
24371
|
+
const item = c.effectivePlayingItem;
|
24324
24372
|
const event = item == null ? void 0 : item.event;
|
24325
24373
|
if (event && !event.restrictions.skip) {
|
24326
24374
|
const index = c.findItemIndex(item);
|
@@ -24338,6 +24386,12 @@ Schedule: ${scheduleItems.map(seg => segmentToString(seg))}`);
|
|
24338
24386
|
}
|
24339
24387
|
|
24340
24388
|
// Schedule getters
|
24389
|
+
get effectivePlayingItem() {
|
24390
|
+
return this.waitingItem || this.playingItem || this.endedItem;
|
24391
|
+
}
|
24392
|
+
get effectivePlayingAsset() {
|
24393
|
+
return this.playingAsset || this.endedAsset;
|
24394
|
+
}
|
24341
24395
|
get playingLastItem() {
|
24342
24396
|
var _this$schedule;
|
24343
24397
|
const playingItem = this.playingItem;
|
@@ -24348,7 +24402,7 @@ Schedule: ${scheduleItems.map(seg => segmentToString(seg))}`);
|
|
24348
24402
|
return this.findItemIndex(playingItem) === items.length - 1;
|
24349
24403
|
}
|
24350
24404
|
get playbackStarted() {
|
24351
|
-
return this.
|
24405
|
+
return this.effectivePlayingItem !== null;
|
24352
24406
|
}
|
24353
24407
|
|
24354
24408
|
// Media getters and event callbacks
|
@@ -24474,7 +24528,7 @@ MediaSource ${stringify(attachMediaSourceData)} from ${logFromSource}`);
|
|
24474
24528
|
}
|
24475
24529
|
// Start stepping through schedule when playback begins for the first time and we have a pre-roll
|
24476
24530
|
const timelinePos = this.timelinePos;
|
24477
|
-
const
|
24531
|
+
const effectivePlayingItem = this.effectivePlayingItem;
|
24478
24532
|
if (timelinePos === -1) {
|
24479
24533
|
const startPosition = this.hls.startPosition;
|
24480
24534
|
this.timelinePos = startPosition;
|
@@ -24486,8 +24540,8 @@ MediaSource ${stringify(attachMediaSourceData)} from ${logFromSource}`);
|
|
24486
24540
|
const index = schedule.findItemIndexAtTime(start);
|
24487
24541
|
this.setSchedulePosition(index);
|
24488
24542
|
}
|
24489
|
-
} else if (
|
24490
|
-
const index = schedule.findItemIndex(
|
24543
|
+
} else if (effectivePlayingItem && !this.playingItem) {
|
24544
|
+
const index = schedule.findItemIndex(effectivePlayingItem);
|
24491
24545
|
this.setSchedulePosition(index);
|
24492
24546
|
}
|
24493
24547
|
}
|
@@ -24542,9 +24596,10 @@ MediaSource ${stringify(attachMediaSourceData)} from ${logFromSource}`);
|
|
24542
24596
|
const assetId = playingAsset == null ? void 0 : playingAsset.identifier;
|
24543
24597
|
const player = assetId ? this.getAssetPlayer(assetId) : null;
|
24544
24598
|
if (player && assetId && (!this.eventItemsMatch(currentItem, scheduledItem) || assetListIndex !== undefined && assetId !== ((_interstitial$assetLi = interstitial.assetList) == null ? void 0 : _interstitial$assetLi[assetListIndex].identifier))) {
|
24545
|
-
this.playingAsset = null;
|
24546
24599
|
const _assetListIndex = interstitial.findAssetIndex(playingAsset);
|
24547
24600
|
this.log(`INTERSTITIAL_ASSET_ENDED ${_assetListIndex + 1}/${interstitial.assetList.length} ${eventAssetToString(playingAsset)}`);
|
24601
|
+
this.endedAsset = playingAsset;
|
24602
|
+
this.playingAsset = null;
|
24548
24603
|
this.hls.trigger(Events.INTERSTITIAL_ASSET_ENDED, {
|
24549
24604
|
asset: playingAsset,
|
24550
24605
|
assetListIndex: _assetListIndex,
|
@@ -24557,9 +24612,9 @@ MediaSource ${stringify(attachMediaSourceData)} from ${logFromSource}`);
|
|
24557
24612
|
if (player.media && !this.detachedData) {
|
24558
24613
|
player.detachMedia();
|
24559
24614
|
}
|
24560
|
-
this.clearAssetPlayer(assetId, scheduledItem);
|
24561
24615
|
}
|
24562
24616
|
if (!this.eventItemsMatch(currentItem, scheduledItem)) {
|
24617
|
+
this.endedItem = currentItem;
|
24563
24618
|
this.playingItem = null;
|
24564
24619
|
this.log(`INTERSTITIAL_ENDED ${interstitial} ${segmentToString(currentItem)}`);
|
24565
24620
|
interstitial.hasPlayed = true;
|
@@ -24611,7 +24666,7 @@ MediaSource ${stringify(attachMediaSourceData)} from ${logFromSource}`);
|
|
24611
24666
|
const waitingItem = this.waitingItem;
|
24612
24667
|
this.setBufferingItem(scheduledItem);
|
24613
24668
|
let player = this.preloadAssets(interstitial, assetListIndex);
|
24614
|
-
if (!this.eventItemsMatch(scheduledItem,
|
24669
|
+
if (!this.eventItemsMatch(scheduledItem, waitingItem || currentItem)) {
|
24615
24670
|
this.waitingItem = scheduledItem;
|
24616
24671
|
this.log(`INTERSTITIAL_STARTED ${segmentToString(scheduledItem)} ${interstitial.appendInPlace ? 'append in place' : ''}`);
|
24617
24672
|
this.hls.trigger(Events.INTERSTITIAL_STARTED, {
|
@@ -24635,7 +24690,7 @@ MediaSource ${stringify(attachMediaSourceData)} from ${logFromSource}`);
|
|
24635
24690
|
return;
|
24636
24691
|
}
|
24637
24692
|
// Update schedule and asset list position now that it can start
|
24638
|
-
this.waitingItem = null;
|
24693
|
+
this.waitingItem = this.endedItem = null;
|
24639
24694
|
this.playingItem = scheduledItem;
|
24640
24695
|
|
24641
24696
|
// If asset-list is empty or missing asset index, advance to next item
|
@@ -24676,6 +24731,7 @@ MediaSource ${stringify(attachMediaSourceData)} from ${logFromSource}`);
|
|
24676
24731
|
} else if (playedLastItem && this.isInterstitial(currentItem)) {
|
24677
24732
|
// Maintain playingItem state at end of schedule (setSchedulePosition(-1) called to end program)
|
24678
24733
|
// this allows onSeeking handler to update schedule position
|
24734
|
+
this.endedItem = null;
|
24679
24735
|
this.playingItem = currentItem;
|
24680
24736
|
if (!currentItem.event.appendInPlace) {
|
24681
24737
|
// Media must be re-attached to resume primary schedule if not sharing source
|
@@ -24697,8 +24753,8 @@ MediaSource ${stringify(attachMediaSourceData)} from ${logFromSource}`);
|
|
24697
24753
|
resumePrimary(scheduledItem, index, fromItem) {
|
24698
24754
|
var _this$detachedData3;
|
24699
24755
|
this.playingItem = scheduledItem;
|
24700
|
-
this.playingAsset = null;
|
24701
|
-
this.waitingItem = null;
|
24756
|
+
this.playingAsset = this.endedAsset = null;
|
24757
|
+
this.waitingItem = this.endedItem = null;
|
24702
24758
|
this.bufferedToItem(scheduledItem);
|
24703
24759
|
this.log(`resuming ${segmentToString(scheduledItem)}`);
|
24704
24760
|
if (!((_this$detachedData3 = this.detachedData) != null && _this$detachedData3.mediaSource)) {
|
@@ -24802,7 +24858,7 @@ MediaSource ${stringify(attachMediaSourceData)} from ${logFromSource}`);
|
|
24802
24858
|
});
|
24803
24859
|
this.mediaSelection = currentSelection;
|
24804
24860
|
this.schedule.parseInterstitialDateRanges(currentSelection);
|
24805
|
-
if (!this.
|
24861
|
+
if (!this.effectivePlayingItem && this.schedule.items) {
|
24806
24862
|
this.checkStart();
|
24807
24863
|
}
|
24808
24864
|
}
|
@@ -24852,9 +24908,7 @@ MediaSource ${stringify(attachMediaSourceData)} from ${logFromSource}`);
|
|
24852
24908
|
this.checkBuffer();
|
24853
24909
|
}
|
24854
24910
|
onBufferFlushed(event, data) {
|
24855
|
-
const
|
24856
|
-
playingItem
|
24857
|
-
} = this;
|
24911
|
+
const playingItem = this.playingItem;
|
24858
24912
|
if (playingItem && !this.itemsMatch(playingItem, this.bufferingItem) && !this.isInterstitial(playingItem)) {
|
24859
24913
|
const timelinePos = this.timelinePos;
|
24860
24914
|
this.bufferedPos = timelinePos;
|
@@ -24983,7 +25037,12 @@ MediaSource ${stringify(attachMediaSourceData)} from ${logFromSource}`);
|
|
24983
25037
|
if (!this.playbackDisabled) {
|
24984
25038
|
if (isInterstitial) {
|
24985
25039
|
// primary fragment loading will exit early in base-stream-controller while `bufferingItem` is set to an Interstitial block
|
24986
|
-
|
25040
|
+
item.event.assetList.forEach(asset => {
|
25041
|
+
const player = this.getAssetPlayer(asset.identifier);
|
25042
|
+
if (player) {
|
25043
|
+
player.resumeBuffering();
|
25044
|
+
}
|
25045
|
+
});
|
24987
25046
|
} else {
|
24988
25047
|
this.hls.resumeBuffering();
|
24989
25048
|
this.playerQueue.forEach(player => player.pauseBuffering());
|
@@ -25055,7 +25114,7 @@ MediaSource ${stringify(attachMediaSourceData)} from ${logFromSource}`);
|
|
25055
25114
|
this.log(`Load interstitial asset ${assetListIndex + 1}/${assetListLength} ${interstitial}`);
|
25056
25115
|
const timelineStart = interstitial.timelineStart;
|
25057
25116
|
if (interstitial.appendInPlace) {
|
25058
|
-
this.flushFrontBuffer(timelineStart);
|
25117
|
+
this.flushFrontBuffer(timelineStart + 0.25);
|
25059
25118
|
}
|
25060
25119
|
const uri = interstitial.assetUrl;
|
25061
25120
|
if (uri) {
|
@@ -25335,6 +25394,7 @@ MediaSource ${stringify(attachMediaSourceData)} from ${logFromSource}`);
|
|
25335
25394
|
} = player;
|
25336
25395
|
const assetListLength = interstitial.assetList.length;
|
25337
25396
|
const playingAsset = this.playingAsset;
|
25397
|
+
this.endedAsset = null;
|
25338
25398
|
this.playingAsset = assetItem;
|
25339
25399
|
if (!playingAsset || playingAsset.identifier !== assetId) {
|
25340
25400
|
if (playingAsset) {
|
@@ -25343,7 +25403,6 @@ MediaSource ${stringify(attachMediaSourceData)} from ${logFromSource}`);
|
|
25343
25403
|
delete playingAsset.error;
|
25344
25404
|
}
|
25345
25405
|
this.log(`INTERSTITIAL_ASSET_STARTED ${assetListIndex + 1}/${assetListLength} ${player}`);
|
25346
|
-
// player.resumeBuffering();
|
25347
25406
|
this.hls.trigger(Events.INTERSTITIAL_ASSET_STARTED, {
|
25348
25407
|
asset: assetItem,
|
25349
25408
|
assetListIndex,
|
@@ -25444,7 +25503,7 @@ MediaSource ${stringify(attachMediaSourceData)} from ${logFromSource}`);
|
|
25444
25503
|
primaryFallback(interstitial) {
|
25445
25504
|
// Fallback to Primary by on current or future events by updating schedule to skip errored interstitials/assets
|
25446
25505
|
const flushStart = interstitial.timelineStart;
|
25447
|
-
const playingItem = this.
|
25506
|
+
const playingItem = this.effectivePlayingItem;
|
25448
25507
|
// Update schedule now that interstitial/assets are flagged with `error` for fallback
|
25449
25508
|
this.updateSchedule();
|
25450
25509
|
if (playingItem) {
|
@@ -31681,7 +31740,7 @@ class StreamController extends BaseStreamController {
|
|
31681
31740
|
// hls.nextLoadLevel remains until it is set to a new value or until a new frag is successfully loaded
|
31682
31741
|
hls.nextLoadLevel = startLevel;
|
31683
31742
|
this.level = hls.loadLevel;
|
31684
|
-
this._hasEnoughToStart =
|
31743
|
+
this._hasEnoughToStart = !!skipSeekToStartPosition;
|
31685
31744
|
}
|
31686
31745
|
// if startPosition undefined but lastCurrentTime set, set startPosition to last currentTime
|
31687
31746
|
if (lastCurrentTime > 0 && startPosition === -1 && !skipSeekToStartPosition) {
|
@@ -32285,7 +32344,7 @@ class StreamController extends BaseStreamController {
|
|
32285
32344
|
if (!media) {
|
32286
32345
|
return;
|
32287
32346
|
}
|
32288
|
-
if (!this._hasEnoughToStart && media.
|
32347
|
+
if (!this._hasEnoughToStart && BufferHelper.getBuffered(media).length) {
|
32289
32348
|
this._hasEnoughToStart = true;
|
32290
32349
|
this.seekToStartPos();
|
32291
32350
|
}
|
@@ -32718,7 +32777,9 @@ class StreamController extends BaseStreamController {
|
|
32718
32777
|
this.tickImmediate();
|
32719
32778
|
}
|
32720
32779
|
getMainFwdBufferInfo() {
|
32721
|
-
|
32780
|
+
// Observe video SourceBuffer (this.mediaBuffer) only when alt-audio is used, otherwise observe combined media buffer
|
32781
|
+
const bufferOutput = this.mediaBuffer && this.altAudio === 2 ? this.mediaBuffer : this.media;
|
32782
|
+
return this.getFwdBufferInfo(bufferOutput, PlaylistLevelType.MAIN);
|
32722
32783
|
}
|
32723
32784
|
get maxBufferLength() {
|
32724
32785
|
const {
|