hls.js 1.6.0-beta.1.0.canary.10787 → 1.6.0-beta.1.0.canary.10789
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 +10 -6
- package/dist/hls.d.ts +10 -6
- package/dist/hls.js +141 -148
- package/dist/hls.js.d.ts +10 -6
- package/dist/hls.js.map +1 -1
- package/dist/hls.light.js +100 -87
- 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 +97 -84
- 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 +138 -145
- package/dist/hls.mjs.map +1 -1
- package/dist/hls.worker.js +1 -1
- package/package.json +1 -1
- package/src/controller/audio-track-controller.ts +32 -46
- package/src/controller/base-playlist-controller.ts +97 -77
- package/src/controller/base-stream-controller.ts +1 -1
- package/src/controller/level-controller.ts +31 -46
- package/src/controller/subtitle-track-controller.ts +28 -39
- package/src/loader/level-details.ts +1 -0
- package/src/utils/level-helper.ts +9 -7
package/dist/hls.d.mts
CHANGED
@@ -199,6 +199,7 @@ export declare class AudioTrackController extends BasePlaylistController {
|
|
199
199
|
private setAudioTrack;
|
200
200
|
private findTrackId;
|
201
201
|
protected loadPlaylist(hlsUrlParameters?: HlsUrlParameters): void;
|
202
|
+
protected loadingPlaylist(audioTrack: MediaPlaylist, hlsUrlParameters: HlsUrlParameters | undefined): void;
|
202
203
|
}
|
203
204
|
|
204
205
|
export declare interface AudioTrackLoadedData extends TrackLoadedData {
|
@@ -234,19 +235,20 @@ export declare type BaseData = {
|
|
234
235
|
|
235
236
|
export declare class BasePlaylistController extends Logger implements NetworkComponentAPI {
|
236
237
|
protected hls: Hls;
|
237
|
-
|
238
|
-
|
239
|
-
protected canLoad: boolean;
|
238
|
+
private timer;
|
239
|
+
private canLoad;
|
240
240
|
constructor(hls: Hls, logPrefix: string);
|
241
241
|
destroy(): void;
|
242
|
-
|
242
|
+
private clearTimer;
|
243
243
|
startLoad(): void;
|
244
244
|
stopLoad(): void;
|
245
245
|
protected switchParams(playlistUri: string, previous: LevelDetails | undefined, current: LevelDetails | undefined): HlsUrlParameters | undefined;
|
246
246
|
protected loadPlaylist(hlsUrlParameters?: HlsUrlParameters): void;
|
247
|
-
protected
|
248
|
-
protected
|
247
|
+
protected loadingPlaylist(playlist: Level | MediaPlaylist, hlsUrlParameters?: HlsUrlParameters): void;
|
248
|
+
protected shouldLoadPlaylist(playlist: Level | MediaPlaylist | null | undefined): playlist is Level | MediaPlaylist;
|
249
|
+
protected getUrlWithDirectives(uri: string, hlsUrlParameters: HlsUrlParameters | undefined): string;
|
249
250
|
protected playlistLoaded(index: number, data: LevelLoadedData | AudioTrackLoadedData | TrackLoadedData, previousDetails?: LevelDetails): void;
|
251
|
+
protected scheduleLoading(levelOrTrack: Level | MediaPlaylist, deliveryDirectives?: HlsUrlParameters): void;
|
250
252
|
private getDeliveryDirectives;
|
251
253
|
protected checkRetry(errorEvent: ErrorData): boolean;
|
252
254
|
}
|
@@ -2539,6 +2541,7 @@ export declare class LevelDetails {
|
|
2539
2541
|
dateRanges: Record<string, DateRange>;
|
2540
2542
|
dateRangeTagCount: number;
|
2541
2543
|
live: boolean;
|
2544
|
+
requestScheduled: number;
|
2542
2545
|
ageHeader: number;
|
2543
2546
|
advancedDateTime?: number;
|
2544
2547
|
updated: boolean;
|
@@ -3477,6 +3480,7 @@ export declare class SubtitleTrackController extends BasePlaylistController {
|
|
3477
3480
|
set subtitleTrack(newId: number);
|
3478
3481
|
setSubtitleOption(subtitleOption: MediaPlaylist | SubtitleSelectionOption | undefined): MediaPlaylist | null;
|
3479
3482
|
protected loadPlaylist(hlsUrlParameters?: HlsUrlParameters): void;
|
3483
|
+
protected loadingPlaylist(currentTrack: MediaPlaylist, hlsUrlParameters: HlsUrlParameters | undefined): void;
|
3480
3484
|
/**
|
3481
3485
|
* Disables the old subtitleTrack and sets current mode on the next subtitleTrack.
|
3482
3486
|
* This operates on the DOM textTracks.
|
package/dist/hls.d.ts
CHANGED
@@ -199,6 +199,7 @@ export declare class AudioTrackController extends BasePlaylistController {
|
|
199
199
|
private setAudioTrack;
|
200
200
|
private findTrackId;
|
201
201
|
protected loadPlaylist(hlsUrlParameters?: HlsUrlParameters): void;
|
202
|
+
protected loadingPlaylist(audioTrack: MediaPlaylist, hlsUrlParameters: HlsUrlParameters | undefined): void;
|
202
203
|
}
|
203
204
|
|
204
205
|
export declare interface AudioTrackLoadedData extends TrackLoadedData {
|
@@ -234,19 +235,20 @@ export declare type BaseData = {
|
|
234
235
|
|
235
236
|
export declare class BasePlaylistController extends Logger implements NetworkComponentAPI {
|
236
237
|
protected hls: Hls;
|
237
|
-
|
238
|
-
|
239
|
-
protected canLoad: boolean;
|
238
|
+
private timer;
|
239
|
+
private canLoad;
|
240
240
|
constructor(hls: Hls, logPrefix: string);
|
241
241
|
destroy(): void;
|
242
|
-
|
242
|
+
private clearTimer;
|
243
243
|
startLoad(): void;
|
244
244
|
stopLoad(): void;
|
245
245
|
protected switchParams(playlistUri: string, previous: LevelDetails | undefined, current: LevelDetails | undefined): HlsUrlParameters | undefined;
|
246
246
|
protected loadPlaylist(hlsUrlParameters?: HlsUrlParameters): void;
|
247
|
-
protected
|
248
|
-
protected
|
247
|
+
protected loadingPlaylist(playlist: Level | MediaPlaylist, hlsUrlParameters?: HlsUrlParameters): void;
|
248
|
+
protected shouldLoadPlaylist(playlist: Level | MediaPlaylist | null | undefined): playlist is Level | MediaPlaylist;
|
249
|
+
protected getUrlWithDirectives(uri: string, hlsUrlParameters: HlsUrlParameters | undefined): string;
|
249
250
|
protected playlistLoaded(index: number, data: LevelLoadedData | AudioTrackLoadedData | TrackLoadedData, previousDetails?: LevelDetails): void;
|
251
|
+
protected scheduleLoading(levelOrTrack: Level | MediaPlaylist, deliveryDirectives?: HlsUrlParameters): void;
|
250
252
|
private getDeliveryDirectives;
|
251
253
|
protected checkRetry(errorEvent: ErrorData): boolean;
|
252
254
|
}
|
@@ -2539,6 +2541,7 @@ export declare class LevelDetails {
|
|
2539
2541
|
dateRanges: Record<string, DateRange>;
|
2540
2542
|
dateRangeTagCount: number;
|
2541
2543
|
live: boolean;
|
2544
|
+
requestScheduled: number;
|
2542
2545
|
ageHeader: number;
|
2543
2546
|
advancedDateTime?: number;
|
2544
2547
|
updated: boolean;
|
@@ -3477,6 +3480,7 @@ export declare class SubtitleTrackController extends BasePlaylistController {
|
|
3477
3480
|
set subtitleTrack(newId: number);
|
3478
3481
|
setSubtitleOption(subtitleOption: MediaPlaylist | SubtitleSelectionOption | undefined): MediaPlaylist | null;
|
3479
3482
|
protected loadPlaylist(hlsUrlParameters?: HlsUrlParameters): void;
|
3483
|
+
protected loadingPlaylist(currentTrack: MediaPlaylist, hlsUrlParameters: HlsUrlParameters | undefined): void;
|
3480
3484
|
/**
|
3481
3485
|
* Disables the old subtitleTrack and sets current mode on the next subtitleTrack.
|
3482
3486
|
* This operates on the DOM textTracks.
|
package/dist/hls.js
CHANGED
@@ -1057,7 +1057,7 @@
|
|
1057
1057
|
// Some browsers don't allow to use bind on console object anyway
|
1058
1058
|
// fallback to default if needed
|
1059
1059
|
try {
|
1060
|
-
newLogger.log("Debug logs enabled for \"" + context + "\" in hls.js version " + "1.6.0-beta.1.0.canary.
|
1060
|
+
newLogger.log("Debug logs enabled for \"" + context + "\" in hls.js version " + "1.6.0-beta.1.0.canary.10789");
|
1061
1061
|
} catch (e) {
|
1062
1062
|
/* log fn threw an exception. All logger methods are no-ops. */
|
1063
1063
|
return createLogger();
|
@@ -6975,6 +6975,7 @@
|
|
6975
6975
|
this.dateRanges = void 0;
|
6976
6976
|
this.dateRangeTagCount = 0;
|
6977
6977
|
this.live = true;
|
6978
|
+
this.requestScheduled = -1;
|
6978
6979
|
this.ageHeader = 0;
|
6979
6980
|
this.advancedDateTime = void 0;
|
6980
6981
|
this.updated = true;
|
@@ -8426,6 +8427,9 @@
|
|
8426
8427
|
newDetails.driftEnd = oldDetails.driftEnd;
|
8427
8428
|
newDetails.advancedDateTime = oldDetails.advancedDateTime;
|
8428
8429
|
}
|
8430
|
+
if (newDetails.requestScheduled === -1) {
|
8431
|
+
newDetails.requestScheduled = oldDetails.requestScheduled;
|
8432
|
+
}
|
8429
8433
|
}
|
8430
8434
|
function mergeDateRanges(oldDateRanges, newDetails) {
|
8431
8435
|
var deltaDateRanges = newDetails.dateRanges,
|
@@ -8497,12 +8501,14 @@
|
|
8497
8501
|
var sliding = 0;
|
8498
8502
|
if (advancedOrStable && delta < oldFragments.length) {
|
8499
8503
|
sliding = oldFragments[delta].start;
|
8504
|
+
} else if (advancedOrStable && newDetails.startSN === oldDetails.endSN + 1) {
|
8505
|
+
sliding = oldDetails.fragmentEnd;
|
8500
8506
|
} else if (advancedOrStable && matchingStableVariantOrRendition) {
|
8501
|
-
// align
|
8502
|
-
sliding = oldDetails.
|
8503
|
-
} else if (!newDetails.skippedSegments && newDetails.
|
8507
|
+
// align with expected position (updated playlist start sequence is past end sequence of last update)
|
8508
|
+
sliding = oldDetails.fragmentStart + delta * newDetails.levelTargetDuration;
|
8509
|
+
} else if (!newDetails.skippedSegments && newDetails.fragmentStart === 0) {
|
8504
8510
|
// align new start with old (playlist switch has a sequence with no overlap and should not be used for alignment)
|
8505
|
-
sliding = oldDetails.
|
8511
|
+
sliding = oldDetails.fragmentStart;
|
8506
8512
|
} else {
|
8507
8513
|
// new details already has a sliding offset or has skipped segments
|
8508
8514
|
return;
|
@@ -9875,10 +9881,11 @@
|
|
9875
9881
|
this.nextLoadPosition = startPosition;
|
9876
9882
|
};
|
9877
9883
|
_proto.getLoadPosition = function getLoadPosition() {
|
9884
|
+
var _this$hls;
|
9878
9885
|
var media = this.media;
|
9879
9886
|
// if we have not yet loaded any fragment, start loading from start position
|
9880
9887
|
var pos = 0;
|
9881
|
-
if (this.hls.hasEnoughToStart && media) {
|
9888
|
+
if ((_this$hls = this.hls) != null && _this$hls.hasEnoughToStart && media) {
|
9882
9889
|
pos = media.currentTime;
|
9883
9890
|
} else if (this.nextLoadPosition >= 0) {
|
9884
9891
|
pos = this.nextLoadPosition;
|
@@ -16258,7 +16265,7 @@
|
|
16258
16265
|
return !remuxResult.audio && !remuxResult.video && !remuxResult.text && !remuxResult.id3 && !remuxResult.initSegment;
|
16259
16266
|
}
|
16260
16267
|
|
16261
|
-
var version = "1.6.0-beta.1.0.canary.
|
16268
|
+
var version = "1.6.0-beta.1.0.canary.10789";
|
16262
16269
|
|
16263
16270
|
// ensure the worker ends up in the bundle
|
16264
16271
|
// If the worker should not be included this gets aliased to empty.js
|
@@ -17430,7 +17437,6 @@
|
|
17430
17437
|
_this = _Logger.call(this, logPrefix, hls.logger) || this;
|
17431
17438
|
_this.hls = void 0;
|
17432
17439
|
_this.timer = -1;
|
17433
|
-
_this.requestScheduled = -1;
|
17434
17440
|
_this.canLoad = false;
|
17435
17441
|
_this.hls = hls;
|
17436
17442
|
return _this;
|
@@ -17450,7 +17456,6 @@
|
|
17450
17456
|
};
|
17451
17457
|
_proto.startLoad = function startLoad() {
|
17452
17458
|
this.canLoad = true;
|
17453
|
-
this.requestScheduled = -1;
|
17454
17459
|
this.loadPlaylist();
|
17455
17460
|
};
|
17456
17461
|
_proto.stopLoad = function stopLoad() {
|
@@ -17495,19 +17500,27 @@
|
|
17495
17500
|
}
|
17496
17501
|
};
|
17497
17502
|
_proto.loadPlaylist = function loadPlaylist(hlsUrlParameters) {
|
17498
|
-
if (this.requestScheduled === -1) {
|
17499
|
-
this.requestScheduled = self.performance.now();
|
17500
|
-
}
|
17501
17503
|
// Loading is handled by the subclasses
|
17504
|
+
this.clearTimer();
|
17505
|
+
};
|
17506
|
+
_proto.loadingPlaylist = function loadingPlaylist(playlist, hlsUrlParameters) {
|
17507
|
+
// Loading is handled by the subclasses
|
17508
|
+
this.clearTimer();
|
17502
17509
|
};
|
17503
17510
|
_proto.shouldLoadPlaylist = function shouldLoadPlaylist(playlist) {
|
17504
17511
|
return this.canLoad && !!playlist && !!playlist.url && (!playlist.details || playlist.details.live);
|
17505
17512
|
};
|
17506
|
-
_proto.
|
17507
|
-
|
17513
|
+
_proto.getUrlWithDirectives = function getUrlWithDirectives(uri, hlsUrlParameters) {
|
17514
|
+
if (hlsUrlParameters) {
|
17515
|
+
try {
|
17516
|
+
return hlsUrlParameters.addDirectives(uri);
|
17517
|
+
} catch (error) {
|
17518
|
+
this.warn("Could not construct new URL with HLS Delivery Directives: " + error);
|
17519
|
+
}
|
17520
|
+
}
|
17521
|
+
return uri;
|
17508
17522
|
};
|
17509
17523
|
_proto.playlistLoaded = function playlistLoaded(index, data, previousDetails) {
|
17510
|
-
var _this2 = this;
|
17511
17524
|
var details = data.details,
|
17512
17525
|
stats = data.stats;
|
17513
17526
|
|
@@ -17528,10 +17541,9 @@
|
|
17528
17541
|
|
17529
17542
|
// if current playlist is a live playlist, arm a timer to reload it
|
17530
17543
|
if (details.live || previousDetails != null && previousDetails.live) {
|
17544
|
+
var levelOrTrack = 'levelInfo' in data ? data.levelInfo : data.track;
|
17531
17545
|
details.reloaded(previousDetails);
|
17532
|
-
|
17533
|
-
this.log("live playlist " + index + " " + (details.advanced ? 'REFRESHED ' + details.lastPartSn + '-' + details.lastPartIndex : details.updated ? 'UPDATED' : 'MISSED'));
|
17534
|
-
}
|
17546
|
+
this.log("live playlist " + index + " " + (details.advanced ? 'REFRESHED ' + details.lastPartSn + '-' + details.lastPartIndex : details.updated ? 'UPDATED' : 'MISSED'));
|
17535
17547
|
// Merge live playlists to adjust fragment starts and fill in delta playlist skipped segments
|
17536
17548
|
if (previousDetails && details.fragments.length > 0) {
|
17537
17549
|
mergeDetails(previousDetails, details);
|
@@ -17587,52 +17599,67 @@
|
|
17587
17599
|
}
|
17588
17600
|
deliveryDirectives = this.getDeliveryDirectives(details, data.deliveryDirectives, msn, part);
|
17589
17601
|
if (lowLatencyMode || !lastPart) {
|
17590
|
-
this.
|
17602
|
+
this.loadingPlaylist(levelOrTrack, deliveryDirectives);
|
17591
17603
|
return;
|
17592
17604
|
}
|
17593
17605
|
} else if (details.canBlockReload || details.canSkipUntil) {
|
17594
17606
|
deliveryDirectives = this.getDeliveryDirectives(details, data.deliveryDirectives, msn, part);
|
17595
17607
|
}
|
17608
|
+
if (details.requestScheduled === -1) {
|
17609
|
+
details.requestScheduled = stats.loading.start;
|
17610
|
+
}
|
17611
|
+
if (deliveryDirectives && msn !== undefined && details.canBlockReload) {
|
17612
|
+
details.requestScheduled -= details.partTarget * 1000 || 1000;
|
17613
|
+
}
|
17596
17614
|
var bufferInfo = this.hls.mainForwardBufferInfo;
|
17597
17615
|
var position = bufferInfo ? bufferInfo.end - bufferInfo.len : 0;
|
17598
17616
|
var distanceToLiveEdgeMs = (details.edge - position) * 1000;
|
17599
17617
|
var reloadInterval = computeReloadInterval(details, distanceToLiveEdgeMs);
|
17600
|
-
if (details.
|
17601
|
-
|
17602
|
-
}
|
17603
|
-
|
17604
|
-
|
17605
|
-
|
17606
|
-
this.requestScheduled = now;
|
17607
|
-
} else if (this.requestScheduled - now <= 0) {
|
17608
|
-
this.requestScheduled += reloadInterval;
|
17609
|
-
}
|
17610
|
-
var estimatedTimeUntilUpdate = this.requestScheduled - now;
|
17611
|
-
estimatedTimeUntilUpdate = Math.max(0, estimatedTimeUntilUpdate);
|
17612
|
-
this.log("reload live playlist " + index + " in " + Math.round(estimatedTimeUntilUpdate) + " ms");
|
17613
|
-
// this.log(
|
17614
|
-
// `live reload ${details.updated ? 'REFRESHED' : 'MISSED'}
|
17615
|
-
// reload in ${estimatedTimeUntilUpdate / 1000}
|
17616
|
-
// round trip ${(stats.loading.end - stats.loading.start) / 1000}
|
17617
|
-
// diff ${
|
17618
|
-
// (reloadInterval -
|
17619
|
-
// (estimatedTimeUntilUpdate +
|
17620
|
-
// stats.loading.end -
|
17621
|
-
// stats.loading.start)) /
|
17622
|
-
// 1000
|
17623
|
-
// }
|
17624
|
-
// reload interval ${reloadInterval / 1000}
|
17625
|
-
// target duration ${details.targetduration}
|
17626
|
-
// distance to edge ${distanceToLiveEdgeMs / 1000}`
|
17627
|
-
// );
|
17628
|
-
|
17629
|
-
this.timer = self.setTimeout(function () {
|
17630
|
-
return _this2.loadPlaylist(deliveryDirectives);
|
17631
|
-
}, estimatedTimeUntilUpdate);
|
17618
|
+
if (details.requestScheduled + reloadInterval < now) {
|
17619
|
+
details.requestScheduled = now;
|
17620
|
+
} else {
|
17621
|
+
details.requestScheduled += reloadInterval;
|
17622
|
+
}
|
17623
|
+
this.scheduleLoading(levelOrTrack, deliveryDirectives);
|
17632
17624
|
} else {
|
17633
17625
|
this.clearTimer();
|
17634
17626
|
}
|
17635
17627
|
};
|
17628
|
+
_proto.scheduleLoading = function scheduleLoading(levelOrTrack, deliveryDirectives) {
|
17629
|
+
var _this2 = this;
|
17630
|
+
var details = levelOrTrack.details;
|
17631
|
+
if (!details) {
|
17632
|
+
this.loadingPlaylist(levelOrTrack, deliveryDirectives);
|
17633
|
+
return;
|
17634
|
+
}
|
17635
|
+
var now = self.performance.now();
|
17636
|
+
var requestScheduled = details.requestScheduled;
|
17637
|
+
if (now >= requestScheduled) {
|
17638
|
+
this.loadingPlaylist(levelOrTrack, deliveryDirectives);
|
17639
|
+
return;
|
17640
|
+
}
|
17641
|
+
var estimatedTimeUntilUpdate = requestScheduled - now;
|
17642
|
+
this.log("reload live playlist " + (levelOrTrack.name || levelOrTrack.bitrate + 'bps') + " in " + Math.round(estimatedTimeUntilUpdate) + " ms");
|
17643
|
+
// this.log(
|
17644
|
+
// `live reload ${details.updated ? 'REFRESHED' : 'MISSED'}
|
17645
|
+
// reload in ${estimatedTimeUntilUpdate / 1000}
|
17646
|
+
// round trip ${(stats.loading.end - stats.loading.start) / 1000}
|
17647
|
+
// diff ${
|
17648
|
+
// (reloadInterval -
|
17649
|
+
// (estimatedTimeUntilUpdate +
|
17650
|
+
// stats.loading.end -
|
17651
|
+
// stats.loading.start)) /
|
17652
|
+
// 1000
|
17653
|
+
// }
|
17654
|
+
// reload interval ${reloadInterval / 1000}
|
17655
|
+
// target duration ${details.targetduration}
|
17656
|
+
// distance to edge ${distanceToLiveEdgeMs / 1000}`
|
17657
|
+
// );
|
17658
|
+
|
17659
|
+
this.timer = self.setTimeout(function () {
|
17660
|
+
return _this2.loadingPlaylist(levelOrTrack, deliveryDirectives);
|
17661
|
+
}, estimatedTimeUntilUpdate);
|
17662
|
+
};
|
17636
17663
|
_proto.getDeliveryDirectives = function getDeliveryDirectives(details, previousDeliveryDirectives, msn, part) {
|
17637
17664
|
var skip = getSkipValue(details);
|
17638
17665
|
if (previousDeliveryDirectives != null && previousDeliveryDirectives.skip && details.deltaUpdateFailed) {
|
@@ -17655,7 +17682,6 @@
|
|
17655
17682
|
var retry = !!errorAction && !!retryConfig && (action === NetworkErrorAction.RetryRequest || !errorAction.resolved && action === NetworkErrorAction.SendAlternateToPenaltyBox);
|
17656
17683
|
if (retry) {
|
17657
17684
|
var _errorEvent$context;
|
17658
|
-
this.requestScheduled = -1;
|
17659
17685
|
if (retryCount >= retryConfig.maxNumRetry) {
|
17660
17686
|
return false;
|
17661
17687
|
}
|
@@ -17825,9 +17851,6 @@
|
|
17825
17851
|
error: error
|
17826
17852
|
});
|
17827
17853
|
}
|
17828
|
-
} else if (this.shouldReloadPlaylist(currentTrack)) {
|
17829
|
-
// Retry playlist loading if no playlist is or has been loaded yet
|
17830
|
-
this.setAudioTrack(this.trackId);
|
17831
17854
|
}
|
17832
17855
|
};
|
17833
17856
|
_proto.onError = function onError(event, data) {
|
@@ -17835,7 +17858,6 @@
|
|
17835
17858
|
return;
|
17836
17859
|
}
|
17837
17860
|
if (data.context.type === PlaylistContextType.AUDIO_TRACK && data.context.id === this.trackId && (!this.groupIds || this.groupIds.indexOf(data.context.groupId) !== -1)) {
|
17838
|
-
this.requestScheduled = -1;
|
17839
17861
|
this.checkRetry(data);
|
17840
17862
|
}
|
17841
17863
|
};
|
@@ -17891,9 +17913,6 @@
|
|
17891
17913
|
this.warn("Invalid audio track id: " + newId);
|
17892
17914
|
return;
|
17893
17915
|
}
|
17894
|
-
|
17895
|
-
// stopping live reloading timer if any
|
17896
|
-
this.clearTimer();
|
17897
17916
|
this.selectDefaultTrack = false;
|
17898
17917
|
var lastTrack = this.currentTrack;
|
17899
17918
|
var track = tracks[newId];
|
@@ -17960,35 +17979,32 @@
|
|
17960
17979
|
};
|
17961
17980
|
_proto.loadPlaylist = function loadPlaylist(hlsUrlParameters) {
|
17962
17981
|
var _this$hls$levels$this;
|
17982
|
+
_BasePlaylistControll.prototype.loadPlaylist.call(this);
|
17963
17983
|
var audioTrack = this.currentTrack;
|
17964
|
-
if (!audioTrack) {
|
17984
|
+
if (!this.shouldLoadPlaylist(audioTrack)) {
|
17965
17985
|
return;
|
17966
17986
|
}
|
17967
|
-
|
17968
|
-
|
17969
|
-
|
17970
|
-
var id = audioTrack.id;
|
17971
|
-
var groupId = audioTrack.groupId;
|
17972
|
-
if (hlsUrlParameters) {
|
17973
|
-
try {
|
17974
|
-
url = hlsUrlParameters.addDirectives(url);
|
17975
|
-
} catch (error) {
|
17976
|
-
this.warn("Could not construct new URL with HLS Delivery Directives: " + error);
|
17977
|
-
}
|
17978
|
-
}
|
17979
|
-
// track not retrieved yet, or live playlist we need to (re)load it
|
17980
|
-
var details = audioTrack.details;
|
17981
|
-
var age = details == null ? void 0 : details.age;
|
17982
|
-
this.log("Loading audio-track " + id + " \"" + audioTrack.name + "\" lang:" + audioTrack.lang + " group:" + groupId + ((hlsUrlParameters == null ? void 0 : hlsUrlParameters.msn) !== undefined ? ' at sn ' + hlsUrlParameters.msn + ' part ' + hlsUrlParameters.part : '') + (age && details.live ? ' age ' + age.toFixed(1) + (details.type ? ' ' + details.type || '' : '') : '') + " " + url);
|
17983
|
-
this.clearTimer();
|
17984
|
-
this.hls.trigger(Events.AUDIO_TRACK_LOADING, {
|
17985
|
-
url: url,
|
17986
|
-
id: id,
|
17987
|
-
groupId: groupId,
|
17988
|
-
deliveryDirectives: hlsUrlParameters || null,
|
17989
|
-
track: audioTrack
|
17990
|
-
});
|
17987
|
+
if (audioTrack.url === ((_this$hls$levels$this = this.hls.levels[this.hls.loadLevel]) == null ? void 0 : _this$hls$levels$this.uri)) {
|
17988
|
+
// Do not load audio rendition with URI matching main variant URI
|
17989
|
+
return;
|
17991
17990
|
}
|
17991
|
+
this.scheduleLoading(audioTrack, hlsUrlParameters);
|
17992
|
+
};
|
17993
|
+
_proto.loadingPlaylist = function loadingPlaylist(audioTrack, hlsUrlParameters) {
|
17994
|
+
_BasePlaylistControll.prototype.loadingPlaylist.call(this, audioTrack, hlsUrlParameters);
|
17995
|
+
var id = audioTrack.id;
|
17996
|
+
var groupId = audioTrack.groupId;
|
17997
|
+
var url = this.getUrlWithDirectives(audioTrack.url, hlsUrlParameters);
|
17998
|
+
var details = audioTrack.details;
|
17999
|
+
var age = details == null ? void 0 : details.age;
|
18000
|
+
this.log("Loading audio-track " + id + " \"" + audioTrack.name + "\" lang:" + audioTrack.lang + " group:" + groupId + ((hlsUrlParameters == null ? void 0 : hlsUrlParameters.msn) !== undefined ? ' at sn ' + hlsUrlParameters.msn + ' part ' + hlsUrlParameters.part : '') + (age && details.live ? ' age ' + age.toFixed(1) + (details.type ? ' ' + details.type || '' : '') : '') + " " + url);
|
18001
|
+
this.hls.trigger(Events.AUDIO_TRACK_LOADING, {
|
18002
|
+
url: url,
|
18003
|
+
id: id,
|
18004
|
+
groupId: groupId,
|
18005
|
+
deliveryDirectives: hlsUrlParameters || null,
|
18006
|
+
track: audioTrack
|
18007
|
+
});
|
17992
18008
|
};
|
17993
18009
|
return _createClass(AudioTrackController, [{
|
17994
18010
|
key: "allAudioTracks",
|
@@ -26272,9 +26288,6 @@
|
|
26272
26288
|
if (trackId !== -1 && this.trackId === -1) {
|
26273
26289
|
this.setSubtitleTrack(trackId);
|
26274
26290
|
}
|
26275
|
-
} else if (this.shouldReloadPlaylist(currentTrack)) {
|
26276
|
-
// Retry playlist loading if no playlist is or has been loaded yet
|
26277
|
-
this.setSubtitleTrack(this.trackId);
|
26278
26291
|
}
|
26279
26292
|
};
|
26280
26293
|
_proto.findTrackId = function findTrackId(currentTrack) {
|
@@ -26363,29 +26376,25 @@
|
|
26363
26376
|
};
|
26364
26377
|
_proto.loadPlaylist = function loadPlaylist(hlsUrlParameters) {
|
26365
26378
|
_BasePlaylistControll.prototype.loadPlaylist.call(this);
|
26366
|
-
|
26367
|
-
|
26368
|
-
|
26369
|
-
|
26370
|
-
|
26371
|
-
|
26372
|
-
|
26373
|
-
|
26374
|
-
|
26375
|
-
|
26376
|
-
|
26377
|
-
|
26378
|
-
|
26379
|
-
|
26380
|
-
|
26381
|
-
|
26382
|
-
|
26383
|
-
|
26384
|
-
|
26385
|
-
deliveryDirectives: hlsUrlParameters || null,
|
26386
|
-
track: currentTrack
|
26387
|
-
});
|
26388
|
-
}
|
26379
|
+
if (this.shouldLoadPlaylist(this.currentTrack)) {
|
26380
|
+
this.scheduleLoading(this.currentTrack, hlsUrlParameters);
|
26381
|
+
}
|
26382
|
+
};
|
26383
|
+
_proto.loadingPlaylist = function loadingPlaylist(currentTrack, hlsUrlParameters) {
|
26384
|
+
_BasePlaylistControll.prototype.loadingPlaylist.call(this, currentTrack, hlsUrlParameters);
|
26385
|
+
var id = currentTrack.id;
|
26386
|
+
var groupId = currentTrack.groupId;
|
26387
|
+
var url = this.getUrlWithDirectives(currentTrack.url, hlsUrlParameters);
|
26388
|
+
var details = currentTrack.details;
|
26389
|
+
var age = details == null ? void 0 : details.age;
|
26390
|
+
this.log("Loading subtitle " + id + " \"" + currentTrack.name + "\" lang:" + currentTrack.lang + " group:" + groupId + ((hlsUrlParameters == null ? void 0 : hlsUrlParameters.msn) !== undefined ? ' at sn ' + hlsUrlParameters.msn + ' part ' + hlsUrlParameters.part : '') + (age && details.live ? ' age ' + age.toFixed(1) + (details.type ? ' ' + details.type || '' : '') : '') + " " + url);
|
26391
|
+
this.hls.trigger(Events.SUBTITLE_TRACK_LOADING, {
|
26392
|
+
url: url,
|
26393
|
+
id: id,
|
26394
|
+
groupId: groupId,
|
26395
|
+
deliveryDirectives: hlsUrlParameters || null,
|
26396
|
+
track: currentTrack
|
26397
|
+
});
|
26389
26398
|
}
|
26390
26399
|
|
26391
26400
|
/**
|
@@ -26443,9 +26452,6 @@
|
|
26443
26452
|
this.warn("Invalid subtitle track id: " + newId);
|
26444
26453
|
return;
|
26445
26454
|
}
|
26446
|
-
|
26447
|
-
// stopping live reloading timer if any
|
26448
|
-
this.clearTimer();
|
26449
26455
|
this.selectDefaultTrack = false;
|
26450
26456
|
var lastTrack = this.currentTrack;
|
26451
26457
|
var track = tracks[newId] || null;
|
@@ -31330,10 +31336,7 @@
|
|
31330
31336
|
return;
|
31331
31337
|
}
|
31332
31338
|
if (data.context.type === PlaylistContextType.LEVEL && data.context.level === this.level) {
|
31333
|
-
|
31334
|
-
if (!retry) {
|
31335
|
-
this.requestScheduled = -1;
|
31336
|
-
}
|
31339
|
+
this.checkRetry(data);
|
31337
31340
|
}
|
31338
31341
|
}
|
31339
31342
|
|
@@ -31388,36 +31391,28 @@
|
|
31388
31391
|
};
|
31389
31392
|
_proto.loadPlaylist = function loadPlaylist(hlsUrlParameters) {
|
31390
31393
|
_BasePlaylistControll.prototype.loadPlaylist.call(this);
|
31391
|
-
|
31392
|
-
|
31393
|
-
if (currentLevel && this.shouldLoadPlaylist(currentLevel)) {
|
31394
|
-
var url = currentLevel.uri;
|
31395
|
-
if (hlsUrlParameters) {
|
31396
|
-
try {
|
31397
|
-
url = hlsUrlParameters.addDirectives(url);
|
31398
|
-
} catch (error) {
|
31399
|
-
this.warn("Could not construct new URL with HLS Delivery Directives: " + error);
|
31400
|
-
}
|
31401
|
-
}
|
31402
|
-
var pathwayId = currentLevel.attrs['PATHWAY-ID'];
|
31403
|
-
var details = currentLevel.details;
|
31404
|
-
var age = details == null ? void 0 : details.age;
|
31405
|
-
this.log("Loading level index " + currentLevelIndex + ((hlsUrlParameters == null ? void 0 : hlsUrlParameters.msn) !== undefined ? ' at sn ' + hlsUrlParameters.msn + ' part ' + hlsUrlParameters.part : '') + (pathwayId ? ' Pathway ' + pathwayId : '') + (age && details.live ? ' age ' + age.toFixed(1) + (details.type ? ' ' + details.type || '' : '') : '') + " " + url);
|
31406
|
-
|
31407
|
-
// console.log('Current audio track group ID:', this.hls.audioTracks[this.hls.audioTrack].groupId);
|
31408
|
-
// console.log('New video quality level audio group id:', levelObject.attrs.AUDIO, level);
|
31409
|
-
this.clearTimer();
|
31410
|
-
this.hls.trigger(Events.LEVEL_LOADING, {
|
31411
|
-
url: url,
|
31412
|
-
level: currentLevelIndex,
|
31413
|
-
levelInfo: currentLevel,
|
31414
|
-
pathwayId: currentLevel.attrs['PATHWAY-ID'],
|
31415
|
-
id: 0,
|
31416
|
-
// Deprecated Level urlId
|
31417
|
-
deliveryDirectives: hlsUrlParameters || null
|
31418
|
-
});
|
31394
|
+
if (this.shouldLoadPlaylist(this.currentLevel)) {
|
31395
|
+
this.scheduleLoading(this.currentLevel, hlsUrlParameters);
|
31419
31396
|
}
|
31420
31397
|
};
|
31398
|
+
_proto.loadingPlaylist = function loadingPlaylist(currentLevel, hlsUrlParameters) {
|
31399
|
+
_BasePlaylistControll.prototype.loadingPlaylist.call(this, currentLevel, hlsUrlParameters);
|
31400
|
+
var url = this.getUrlWithDirectives(currentLevel.uri, hlsUrlParameters);
|
31401
|
+
var currentLevelIndex = this.currentLevelIndex;
|
31402
|
+
var pathwayId = currentLevel.attrs['PATHWAY-ID'];
|
31403
|
+
var details = currentLevel.details;
|
31404
|
+
var age = details == null ? void 0 : details.age;
|
31405
|
+
this.log("Loading level index " + currentLevelIndex + ((hlsUrlParameters == null ? void 0 : hlsUrlParameters.msn) !== undefined ? ' at sn ' + hlsUrlParameters.msn + ' part ' + hlsUrlParameters.part : '') + (pathwayId ? ' Pathway ' + pathwayId : '') + (age && details.live ? ' age ' + age.toFixed(1) + (details.type ? ' ' + details.type || '' : '') : '') + " " + url);
|
31406
|
+
this.hls.trigger(Events.LEVEL_LOADING, {
|
31407
|
+
url: url,
|
31408
|
+
level: currentLevelIndex,
|
31409
|
+
levelInfo: currentLevel,
|
31410
|
+
pathwayId: currentLevel.attrs['PATHWAY-ID'],
|
31411
|
+
id: 0,
|
31412
|
+
// Deprecated Level urlId
|
31413
|
+
deliveryDirectives: hlsUrlParameters || null
|
31414
|
+
});
|
31415
|
+
};
|
31421
31416
|
_proto.removeLevel = function removeLevel(levelIndex) {
|
31422
31417
|
var _this4 = this,
|
31423
31418
|
_this$currentLevel;
|
@@ -31512,9 +31507,7 @@
|
|
31512
31507
|
this.currentLevelIndex = newLevel;
|
31513
31508
|
this.currentLevel = level;
|
31514
31509
|
if (lastLevelIndex === newLevel && lastLevel && lastPathwayId === pathwayId) {
|
31515
|
-
|
31516
|
-
return;
|
31517
|
-
}
|
31510
|
+
return;
|
31518
31511
|
}
|
31519
31512
|
this.log("Switching to level " + newLevel + " (" + (level.height ? level.height + 'p ' : '') + (level.videoRange ? level.videoRange + ' ' : '') + (level.codecSet ? level.codecSet + ' ' : '') + "@" + level.bitrate + ")" + (pathwayId ? ' with Pathway ' + pathwayId : '') + " from level " + lastLevelIndex + (lastPathwayId ? ' with Pathway ' + lastPathwayId : ''));
|
31520
31513
|
var levelSwitchingData = {
|
package/dist/hls.js.d.ts
CHANGED
@@ -199,6 +199,7 @@ export declare class AudioTrackController extends BasePlaylistController {
|
|
199
199
|
private setAudioTrack;
|
200
200
|
private findTrackId;
|
201
201
|
protected loadPlaylist(hlsUrlParameters?: HlsUrlParameters): void;
|
202
|
+
protected loadingPlaylist(audioTrack: MediaPlaylist, hlsUrlParameters: HlsUrlParameters | undefined): void;
|
202
203
|
}
|
203
204
|
|
204
205
|
export declare interface AudioTrackLoadedData extends TrackLoadedData {
|
@@ -234,19 +235,20 @@ export declare type BaseData = {
|
|
234
235
|
|
235
236
|
export declare class BasePlaylistController extends Logger implements NetworkComponentAPI {
|
236
237
|
protected hls: Hls;
|
237
|
-
|
238
|
-
|
239
|
-
protected canLoad: boolean;
|
238
|
+
private timer;
|
239
|
+
private canLoad;
|
240
240
|
constructor(hls: Hls, logPrefix: string);
|
241
241
|
destroy(): void;
|
242
|
-
|
242
|
+
private clearTimer;
|
243
243
|
startLoad(): void;
|
244
244
|
stopLoad(): void;
|
245
245
|
protected switchParams(playlistUri: string, previous: LevelDetails | undefined, current: LevelDetails | undefined): HlsUrlParameters | undefined;
|
246
246
|
protected loadPlaylist(hlsUrlParameters?: HlsUrlParameters): void;
|
247
|
-
protected
|
248
|
-
protected
|
247
|
+
protected loadingPlaylist(playlist: Level | MediaPlaylist, hlsUrlParameters?: HlsUrlParameters): void;
|
248
|
+
protected shouldLoadPlaylist(playlist: Level | MediaPlaylist | null | undefined): playlist is Level | MediaPlaylist;
|
249
|
+
protected getUrlWithDirectives(uri: string, hlsUrlParameters: HlsUrlParameters | undefined): string;
|
249
250
|
protected playlistLoaded(index: number, data: LevelLoadedData | AudioTrackLoadedData | TrackLoadedData, previousDetails?: LevelDetails): void;
|
251
|
+
protected scheduleLoading(levelOrTrack: Level | MediaPlaylist, deliveryDirectives?: HlsUrlParameters): void;
|
250
252
|
private getDeliveryDirectives;
|
251
253
|
protected checkRetry(errorEvent: ErrorData): boolean;
|
252
254
|
}
|
@@ -2539,6 +2541,7 @@ export declare class LevelDetails {
|
|
2539
2541
|
dateRanges: Record<string, DateRange>;
|
2540
2542
|
dateRangeTagCount: number;
|
2541
2543
|
live: boolean;
|
2544
|
+
requestScheduled: number;
|
2542
2545
|
ageHeader: number;
|
2543
2546
|
advancedDateTime?: number;
|
2544
2547
|
updated: boolean;
|
@@ -3477,6 +3480,7 @@ export declare class SubtitleTrackController extends BasePlaylistController {
|
|
3477
3480
|
set subtitleTrack(newId: number);
|
3478
3481
|
setSubtitleOption(subtitleOption: MediaPlaylist | SubtitleSelectionOption | undefined): MediaPlaylist | null;
|
3479
3482
|
protected loadPlaylist(hlsUrlParameters?: HlsUrlParameters): void;
|
3483
|
+
protected loadingPlaylist(currentTrack: MediaPlaylist, hlsUrlParameters: HlsUrlParameters | undefined): void;
|
3480
3484
|
/**
|
3481
3485
|
* Disables the old subtitleTrack and sets current mode on the next subtitleTrack.
|
3482
3486
|
* This operates on the DOM textTracks.
|