hls.js 1.6.0-beta.2.0.canary.10939 → 1.6.0-beta.2.0.canary.10942
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 +1 -1
- package/dist/hls.d.ts +1 -1
- package/dist/hls.js +68 -45
- package/dist/hls.js.d.ts +1 -1
- package/dist/hls.js.map +1 -1
- package/dist/hls.light.js +15 -10
- 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 +15 -10
- 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 +68 -45
- package/dist/hls.mjs.map +1 -1
- package/dist/hls.worker.js +1 -1
- package/package.json +2 -2
- package/src/controller/audio-stream-controller.ts +22 -19
- package/src/controller/base-stream-controller.ts +15 -1
- package/src/controller/gap-controller.ts +5 -2
- package/src/controller/interstitial-player.ts +2 -2
- package/src/controller/interstitials-controller.ts +14 -14
- package/src/controller/interstitials-schedule.ts +11 -5
- package/src/controller/stream-controller.ts +14 -4
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.2.0.canary.
|
405
|
+
newLogger.log(`Debug logs enabled for "${context}" in hls.js version ${"1.6.0-beta.2.0.canary.10942"}`);
|
406
406
|
} catch (e) {
|
407
407
|
/* log fn threw an exception. All logger methods are no-ops. */
|
408
408
|
return createLogger();
|
@@ -8364,6 +8364,16 @@ class BaseStreamController extends TaskLoop {
|
|
8364
8364
|
}
|
8365
8365
|
}
|
8366
8366
|
}
|
8367
|
+
// Skip loading of fragments that overlap completely with appendInPlace interstitals
|
8368
|
+
const playerQueue = interstitials == null ? undefined : interstitials.playerQueue;
|
8369
|
+
if (playerQueue) {
|
8370
|
+
for (let i = playerQueue.length; i--;) {
|
8371
|
+
const interstitial = playerQueue[i].interstitial;
|
8372
|
+
if (interstitial.appendInPlace && frag.start >= interstitial.startTime && frag.end <= interstitial.resumeTime) {
|
8373
|
+
return;
|
8374
|
+
}
|
8375
|
+
}
|
8376
|
+
}
|
8367
8377
|
}
|
8368
8378
|
this.startFragRequested = true;
|
8369
8379
|
this._loadFragForPlayback(frag, level, targetBufferTime);
|
@@ -9873,7 +9883,7 @@ var eventemitter3 = {exports: {}};
|
|
9873
9883
|
var eventemitter3Exports = eventemitter3.exports;
|
9874
9884
|
var EventEmitter = /*@__PURE__*/getDefaultExportFromCjs(eventemitter3Exports);
|
9875
9885
|
|
9876
|
-
const version = "1.6.0-beta.2.0.canary.
|
9886
|
+
const version = "1.6.0-beta.2.0.canary.10942";
|
9877
9887
|
|
9878
9888
|
// ensure the worker ends up in the bundle
|
9879
9889
|
// If the worker should not be included this gets aliased to empty.js
|
@@ -16423,23 +16433,27 @@ class AudioStreamController extends BaseStreamController {
|
|
16423
16433
|
}
|
16424
16434
|
|
16425
16435
|
// Request audio segments up to one fragment ahead of main stream-controller
|
16426
|
-
|
16427
|
-
if (!this.audioOnly && this.startFragRequested && mainFragLoading && isMediaFragment(
|
16428
|
-
|
16429
|
-
|
16430
|
-
|
16431
|
-
|
16432
|
-
if (
|
16433
|
-
|
16434
|
-
this.
|
16435
|
-
|
16436
|
-
|
16437
|
-
|
16436
|
+
let mainFragLoading = ((_this$mainFragLoading = this.mainFragLoading) == null ? undefined : _this$mainFragLoading.frag) || null;
|
16437
|
+
if (!this.audioOnly && this.startFragRequested && mainFragLoading && isMediaFragment(frag) && !frag.endList && (!trackDetails.live || !this.loadingParts && targetBufferTime < this.hls.liveSyncPosition)) {
|
16438
|
+
if (this.fragmentTracker.getState(mainFragLoading) === FragmentState.OK) {
|
16439
|
+
this.mainFragLoading = mainFragLoading = null;
|
16440
|
+
}
|
16441
|
+
if (mainFragLoading && isMediaFragment(mainFragLoading)) {
|
16442
|
+
if (frag.start > mainFragLoading.end) {
|
16443
|
+
// Get buffered frag at target position from tracker (loaded out of sequence)
|
16444
|
+
const mainFragAtPos = this.fragmentTracker.getFragAtPos(targetBufferTime, PlaylistLevelType.MAIN);
|
16445
|
+
if (mainFragAtPos && mainFragAtPos.end > mainFragLoading.end) {
|
16446
|
+
mainFragLoading = mainFragAtPos;
|
16447
|
+
this.mainFragLoading = {
|
16448
|
+
frag: mainFragAtPos,
|
16449
|
+
targetBufferTime: null
|
16450
|
+
};
|
16451
|
+
}
|
16452
|
+
}
|
16453
|
+
const atBufferSyncLimit = frag.start > mainFragLoading.end;
|
16454
|
+
if (atBufferSyncLimit) {
|
16455
|
+
return;
|
16438
16456
|
}
|
16439
|
-
}
|
16440
|
-
const atBufferSyncLimit = frag.start > mainFrag.end;
|
16441
|
-
if (atBufferSyncLimit) {
|
16442
|
-
return;
|
16443
16457
|
}
|
16444
16458
|
}
|
16445
16459
|
this.loadFragment(frag, levelInfo, targetBufferTime);
|
@@ -22953,7 +22967,8 @@ class HlsAssetPlayer {
|
|
22953
22967
|
return this.assetItem.parentIdentifier;
|
22954
22968
|
}
|
22955
22969
|
get media() {
|
22956
|
-
|
22970
|
+
var _this$hls2;
|
22971
|
+
return ((_this$hls2 = this.hls) == null ? undefined : _this$hls2.media) || null;
|
22957
22972
|
}
|
22958
22973
|
get bufferedEnd() {
|
22959
22974
|
const media = this.media || this.mediaAttached;
|
@@ -22986,7 +23001,8 @@ class HlsAssetPlayer {
|
|
22986
23001
|
return Math.max(0, duration - this.currentTime);
|
22987
23002
|
}
|
22988
23003
|
get timelineOffset() {
|
22989
|
-
|
23004
|
+
var _this$hls3;
|
23005
|
+
return ((_this$hls3 = this.hls) == null ? undefined : _this$hls3.config.timelineOffset) || 0;
|
22990
23006
|
}
|
22991
23007
|
set timelineOffset(value) {
|
22992
23008
|
const timelineOffset = this.timelineOffset;
|
@@ -23113,6 +23129,8 @@ class InterstitialsSchedule extends Logger {
|
|
23113
23129
|
// Only return index of a Primary Item
|
23114
23130
|
while (index >= 0 && (_items$index = items[index]) != null && _items$index.event) {
|
23115
23131
|
var _items$index;
|
23132
|
+
// If index found is an interstitial it is not a valid result as it should have been matched up top
|
23133
|
+
// decrement until result is negative (not found) or a primary segment
|
23116
23134
|
index--;
|
23117
23135
|
}
|
23118
23136
|
}
|
@@ -23495,12 +23513,16 @@ class InterstitialsSchedule extends Logger {
|
|
23495
23513
|
this.log(`"${interstitial.identifier}" resumption ${resumeTime} can not be aligned with media (none selected)`);
|
23496
23514
|
return false;
|
23497
23515
|
}
|
23498
|
-
|
23516
|
+
const playlists = Object.keys(mediaSelection);
|
23517
|
+
return !playlists.some(playlistType => {
|
23499
23518
|
const details = mediaSelection[playlistType].details;
|
23500
23519
|
const playlistEnd = details.edge;
|
23501
23520
|
if (resumeTime > playlistEnd) {
|
23502
|
-
|
23503
|
-
|
23521
|
+
if (playlists.length > 1) {
|
23522
|
+
this.log(`"${interstitial.identifier}" resumption ${resumeTime} past ${playlistType} playlist end ${playlistEnd}`);
|
23523
|
+
return true;
|
23524
|
+
}
|
23525
|
+
return false;
|
23504
23526
|
}
|
23505
23527
|
const startFragment = findFragmentByPTS(null, details.fragments, resumeTime);
|
23506
23528
|
if (!startFragment) {
|
@@ -24236,11 +24258,11 @@ Schedule: ${scheduleItems.map(seg => segmentToString(seg))}`);
|
|
24236
24258
|
get playingLastItem() {
|
24237
24259
|
var _this$schedule;
|
24238
24260
|
const playingItem = this.playingItem;
|
24239
|
-
|
24261
|
+
const items = (_this$schedule = this.schedule) == null ? undefined : _this$schedule.items;
|
24262
|
+
if (!this.playbackStarted || !playingItem || !items) {
|
24240
24263
|
return false;
|
24241
24264
|
}
|
24242
|
-
|
24243
|
-
return this.itemsMatch(playingItem, items ? items[items.length - 1] : null);
|
24265
|
+
return this.findItemIndex(playingItem) === items.length - 1;
|
24244
24266
|
}
|
24245
24267
|
get playbackStarted() {
|
24246
24268
|
return this.playingItem !== null;
|
@@ -24286,6 +24308,7 @@ Schedule: ${scheduleItems.map(seg => segmentToString(seg))}`);
|
|
24286
24308
|
const appendInPlace = player.interstitial.appendInPlace;
|
24287
24309
|
const playerMedia = player.media;
|
24288
24310
|
if (appendInPlace && playerMedia === this.primaryMedia) {
|
24311
|
+
this.bufferingAsset = null;
|
24289
24312
|
if (!toSegment || this.isInterstitial(toSegment) && !toSegment.event.appendInPlace) {
|
24290
24313
|
// MediaSource cannot be transfered back to an Interstitial that requires a source reset
|
24291
24314
|
// no-op when toSegment is undefined
|
@@ -24293,12 +24316,11 @@ Schedule: ${scheduleItems.map(seg => segmentToString(seg))}`);
|
|
24293
24316
|
this.detachedData = {
|
24294
24317
|
media: playerMedia
|
24295
24318
|
};
|
24319
|
+
return;
|
24296
24320
|
}
|
24297
|
-
return;
|
24298
24321
|
}
|
24299
24322
|
const attachMediaSourceData = player.transferMedia();
|
24300
24323
|
this.log(`transfer MediaSource from ${player} ${JSON.stringify(attachMediaSourceData)}`);
|
24301
|
-
this.bufferingAsset = null;
|
24302
24324
|
this.detachedData = attachMediaSourceData;
|
24303
24325
|
} else if (toSegment && playerMedia) {
|
24304
24326
|
this.shouldPlay || (this.shouldPlay = !playerMedia.paused);
|
@@ -24348,7 +24370,7 @@ MediaSource ${JSON.stringify(attachMediaSourceData)} from ${logFromSource}`);
|
|
24348
24370
|
dataToAttach.overrides = {
|
24349
24371
|
duration: this.schedule.duration,
|
24350
24372
|
endOfStream: !isAssetPlayer || isAssetAtEndOfSchedule,
|
24351
|
-
cueRemoval:
|
24373
|
+
cueRemoval: !isAssetPlayer
|
24352
24374
|
};
|
24353
24375
|
}
|
24354
24376
|
player.attachMedia(dataToAttach);
|
@@ -24748,7 +24770,7 @@ MediaSource ${JSON.stringify(attachMediaSourceData)} from ${logFromSource}`);
|
|
24748
24770
|
if (playingItem && !this.itemsMatch(playingItem, this.bufferingItem) && !this.isInterstitial(playingItem)) {
|
24749
24771
|
const timelinePos = this.timelinePos;
|
24750
24772
|
this.bufferedPos = timelinePos;
|
24751
|
-
this.
|
24773
|
+
this.checkBuffer();
|
24752
24774
|
}
|
24753
24775
|
}
|
24754
24776
|
onBufferedToEnd(event) {
|
@@ -24787,8 +24809,7 @@ MediaSource ${JSON.stringify(attachMediaSourceData)} from ${logFromSource}`);
|
|
24787
24809
|
return null;
|
24788
24810
|
}
|
24789
24811
|
itemsMatch(a, b) {
|
24790
|
-
|
24791
|
-
return !!b && (a === b || a.event && b.event && this.eventItemsMatch(a, b) || !a.event && !b.event && ((_a$nextEvent = a.nextEvent) == null ? undefined : _a$nextEvent.identifier) === ((_b$nextEvent = b.nextEvent) == null ? undefined : _b$nextEvent.identifier));
|
24812
|
+
return !!b && (a === b || a.event && b.event && this.eventItemsMatch(a, b) || !a.event && !b.event && this.findItemIndex(a) === this.findItemIndex(b));
|
24792
24813
|
}
|
24793
24814
|
eventItemsMatch(a, b) {
|
24794
24815
|
var _b$event;
|
@@ -24829,11 +24850,11 @@ MediaSource ${JSON.stringify(attachMediaSourceData)} from ${logFromSource}`);
|
|
24829
24850
|
const playingIndex = this.findItemIndex(playingItem);
|
24830
24851
|
let bufferEndIndex = schedule.findItemIndexAtTime(bufferEnd);
|
24831
24852
|
if (this.bufferedPos < bufferEnd) {
|
24832
|
-
var _bufferingItem$event;
|
24853
|
+
var _nextItemToBuffer$eve, _bufferingItem$event;
|
24833
24854
|
const bufferingIndex = this.findItemIndex(bufferingItem);
|
24834
24855
|
const nextToBufferIndex = Math.min(bufferingIndex + 1, items.length - 1);
|
24835
24856
|
const nextItemToBuffer = items[nextToBufferIndex];
|
24836
|
-
if (bufferEndIndex === -1 && bufferingItem && bufferEnd >= bufferingItem.end) {
|
24857
|
+
if (bufferEndIndex === -1 && bufferingItem && bufferEnd >= bufferingItem.end || (_nextItemToBuffer$eve = nextItemToBuffer.event) != null && _nextItemToBuffer$eve.appendInPlace && bufferEnd + 0.01 >= nextItemToBuffer.start) {
|
24837
24858
|
bufferEndIndex = nextToBufferIndex;
|
24838
24859
|
}
|
24839
24860
|
if (nextToBufferIndex - playingIndex > 1 && (bufferingItem == null ? undefined : (_bufferingItem$event = bufferingItem.event) == null ? undefined : _bufferingItem$event.appendInPlace) === false) {
|
@@ -25201,9 +25222,6 @@ MediaSource ${JSON.stringify(attachMediaSourceData)} from ${logFromSource}`);
|
|
25201
25222
|
interstitial.appendInPlaceStarted = false;
|
25202
25223
|
}
|
25203
25224
|
clearAssetPlayer(assetId, toSegment) {
|
25204
|
-
if (toSegment === null) {
|
25205
|
-
return;
|
25206
|
-
}
|
25207
25225
|
const playerIndex = this.getAssetPlayerQueueIndex(assetId);
|
25208
25226
|
if (playerIndex !== -1) {
|
25209
25227
|
this.log(`clearAssetPlayer "${assetId}" toSegment: ${toSegment ? segmentToString(toSegment) : toSegment}`);
|
@@ -30040,7 +30058,7 @@ class GapController extends TaskLoop {
|
|
30040
30058
|
* @private
|
30041
30059
|
*/
|
30042
30060
|
_tryFixBufferStall(bufferInfo, stalledDurationMs) {
|
30043
|
-
var _this$hls3;
|
30061
|
+
var _this$hls3, _this$hls4;
|
30044
30062
|
const {
|
30045
30063
|
fragmentTracker,
|
30046
30064
|
media
|
@@ -30050,8 +30068,9 @@ class GapController extends TaskLoop {
|
|
30050
30068
|
return;
|
30051
30069
|
}
|
30052
30070
|
const currentTime = media.currentTime;
|
30071
|
+
const levelDetails = (_this$hls4 = this.hls) == null ? undefined : _this$hls4.latestLevelDetails;
|
30053
30072
|
const partial = fragmentTracker.getPartialFragment(currentTime);
|
30054
|
-
if (partial) {
|
30073
|
+
if (partial || levelDetails != null && levelDetails.live && currentTime < levelDetails.fragmentStart) {
|
30055
30074
|
// Try to skip over the buffer hole caused by a partial fragment
|
30056
30075
|
// This method isn't limited by the size of the gap between buffered ranges
|
30057
30076
|
const targetTime = this._trySkipBufferHole(partial);
|
@@ -30112,12 +30131,12 @@ class GapController extends TaskLoop {
|
|
30112
30131
|
* @private
|
30113
30132
|
*/
|
30114
30133
|
_trySkipBufferHole(partial) {
|
30115
|
-
var _this$
|
30134
|
+
var _this$hls5;
|
30116
30135
|
const {
|
30117
30136
|
fragmentTracker,
|
30118
30137
|
media
|
30119
30138
|
} = this;
|
30120
|
-
const config = (_this$
|
30139
|
+
const config = (_this$hls5 = this.hls) == null ? undefined : _this$hls5.config;
|
30121
30140
|
if (!media || !fragmentTracker || !config) {
|
30122
30141
|
return 0;
|
30123
30142
|
}
|
@@ -31477,14 +31496,18 @@ class StreamController extends BaseStreamController {
|
|
31477
31496
|
this.onMediaSeeked = () => {
|
31478
31497
|
const media = this.media;
|
31479
31498
|
const currentTime = media ? media.currentTime : null;
|
31480
|
-
if (isFiniteNumber(currentTime)) {
|
31481
|
-
|
31499
|
+
if (currentTime === null || !isFiniteNumber(currentTime)) {
|
31500
|
+
return;
|
31482
31501
|
}
|
31502
|
+
this.log(`Media seeked to ${currentTime.toFixed(3)}`);
|
31483
31503
|
|
31484
31504
|
// If seeked was issued before buffer was appended do not tick immediately
|
31485
|
-
|
31505
|
+
if (!this.getBufferedFrag(currentTime)) {
|
31506
|
+
return;
|
31507
|
+
}
|
31508
|
+
const bufferInfo = this.getFwdBufferInfoAtPos(media, currentTime, PlaylistLevelType.MAIN, 0);
|
31486
31509
|
if (bufferInfo === null || bufferInfo.len === 0) {
|
31487
|
-
this.warn(`Main forward buffer length on "seeked" event ${bufferInfo ? bufferInfo.len : 'empty'})`);
|
31510
|
+
this.warn(`Main forward buffer length at ${currentTime} on "seeked" event ${bufferInfo ? bufferInfo.len : 'empty'})`);
|
31488
31511
|
return;
|
31489
31512
|
}
|
31490
31513
|
|