hls.js 1.6.0-beta.1.0.canary.10788 → 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 +135 -144
- package/dist/hls.js.d.ts +10 -6
- package/dist/hls.js.map +1 -1
- package/dist/hls.light.js +94 -83
- 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 +91 -80
- 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 +132 -141
- 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 +3 -0
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,
|
@@ -9877,10 +9881,11 @@
|
|
9877
9881
|
this.nextLoadPosition = startPosition;
|
9878
9882
|
};
|
9879
9883
|
_proto.getLoadPosition = function getLoadPosition() {
|
9884
|
+
var _this$hls;
|
9880
9885
|
var media = this.media;
|
9881
9886
|
// if we have not yet loaded any fragment, start loading from start position
|
9882
9887
|
var pos = 0;
|
9883
|
-
if (this.hls.hasEnoughToStart && media) {
|
9888
|
+
if ((_this$hls = this.hls) != null && _this$hls.hasEnoughToStart && media) {
|
9884
9889
|
pos = media.currentTime;
|
9885
9890
|
} else if (this.nextLoadPosition >= 0) {
|
9886
9891
|
pos = this.nextLoadPosition;
|
@@ -16260,7 +16265,7 @@
|
|
16260
16265
|
return !remuxResult.audio && !remuxResult.video && !remuxResult.text && !remuxResult.id3 && !remuxResult.initSegment;
|
16261
16266
|
}
|
16262
16267
|
|
16263
|
-
var version = "1.6.0-beta.1.0.canary.
|
16268
|
+
var version = "1.6.0-beta.1.0.canary.10789";
|
16264
16269
|
|
16265
16270
|
// ensure the worker ends up in the bundle
|
16266
16271
|
// If the worker should not be included this gets aliased to empty.js
|
@@ -17432,7 +17437,6 @@
|
|
17432
17437
|
_this = _Logger.call(this, logPrefix, hls.logger) || this;
|
17433
17438
|
_this.hls = void 0;
|
17434
17439
|
_this.timer = -1;
|
17435
|
-
_this.requestScheduled = -1;
|
17436
17440
|
_this.canLoad = false;
|
17437
17441
|
_this.hls = hls;
|
17438
17442
|
return _this;
|
@@ -17452,7 +17456,6 @@
|
|
17452
17456
|
};
|
17453
17457
|
_proto.startLoad = function startLoad() {
|
17454
17458
|
this.canLoad = true;
|
17455
|
-
this.requestScheduled = -1;
|
17456
17459
|
this.loadPlaylist();
|
17457
17460
|
};
|
17458
17461
|
_proto.stopLoad = function stopLoad() {
|
@@ -17497,19 +17500,27 @@
|
|
17497
17500
|
}
|
17498
17501
|
};
|
17499
17502
|
_proto.loadPlaylist = function loadPlaylist(hlsUrlParameters) {
|
17500
|
-
if (this.requestScheduled === -1) {
|
17501
|
-
this.requestScheduled = self.performance.now();
|
17502
|
-
}
|
17503
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();
|
17504
17509
|
};
|
17505
17510
|
_proto.shouldLoadPlaylist = function shouldLoadPlaylist(playlist) {
|
17506
17511
|
return this.canLoad && !!playlist && !!playlist.url && (!playlist.details || playlist.details.live);
|
17507
17512
|
};
|
17508
|
-
_proto.
|
17509
|
-
|
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;
|
17510
17522
|
};
|
17511
17523
|
_proto.playlistLoaded = function playlistLoaded(index, data, previousDetails) {
|
17512
|
-
var _this2 = this;
|
17513
17524
|
var details = data.details,
|
17514
17525
|
stats = data.stats;
|
17515
17526
|
|
@@ -17530,10 +17541,9 @@
|
|
17530
17541
|
|
17531
17542
|
// if current playlist is a live playlist, arm a timer to reload it
|
17532
17543
|
if (details.live || previousDetails != null && previousDetails.live) {
|
17544
|
+
var levelOrTrack = 'levelInfo' in data ? data.levelInfo : data.track;
|
17533
17545
|
details.reloaded(previousDetails);
|
17534
|
-
|
17535
|
-
this.log("live playlist " + index + " " + (details.advanced ? 'REFRESHED ' + details.lastPartSn + '-' + details.lastPartIndex : details.updated ? 'UPDATED' : 'MISSED'));
|
17536
|
-
}
|
17546
|
+
this.log("live playlist " + index + " " + (details.advanced ? 'REFRESHED ' + details.lastPartSn + '-' + details.lastPartIndex : details.updated ? 'UPDATED' : 'MISSED'));
|
17537
17547
|
// Merge live playlists to adjust fragment starts and fill in delta playlist skipped segments
|
17538
17548
|
if (previousDetails && details.fragments.length > 0) {
|
17539
17549
|
mergeDetails(previousDetails, details);
|
@@ -17589,52 +17599,67 @@
|
|
17589
17599
|
}
|
17590
17600
|
deliveryDirectives = this.getDeliveryDirectives(details, data.deliveryDirectives, msn, part);
|
17591
17601
|
if (lowLatencyMode || !lastPart) {
|
17592
|
-
this.
|
17602
|
+
this.loadingPlaylist(levelOrTrack, deliveryDirectives);
|
17593
17603
|
return;
|
17594
17604
|
}
|
17595
17605
|
} else if (details.canBlockReload || details.canSkipUntil) {
|
17596
17606
|
deliveryDirectives = this.getDeliveryDirectives(details, data.deliveryDirectives, msn, part);
|
17597
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
|
+
}
|
17598
17614
|
var bufferInfo = this.hls.mainForwardBufferInfo;
|
17599
17615
|
var position = bufferInfo ? bufferInfo.end - bufferInfo.len : 0;
|
17600
17616
|
var distanceToLiveEdgeMs = (details.edge - position) * 1000;
|
17601
17617
|
var reloadInterval = computeReloadInterval(details, distanceToLiveEdgeMs);
|
17602
|
-
if (details.
|
17603
|
-
|
17604
|
-
}
|
17605
|
-
|
17606
|
-
|
17607
|
-
|
17608
|
-
this.requestScheduled = now;
|
17609
|
-
} else if (this.requestScheduled - now <= 0) {
|
17610
|
-
this.requestScheduled += reloadInterval;
|
17611
|
-
}
|
17612
|
-
var estimatedTimeUntilUpdate = this.requestScheduled - now;
|
17613
|
-
estimatedTimeUntilUpdate = Math.max(0, estimatedTimeUntilUpdate);
|
17614
|
-
this.log("reload live playlist " + index + " in " + Math.round(estimatedTimeUntilUpdate) + " ms");
|
17615
|
-
// this.log(
|
17616
|
-
// `live reload ${details.updated ? 'REFRESHED' : 'MISSED'}
|
17617
|
-
// reload in ${estimatedTimeUntilUpdate / 1000}
|
17618
|
-
// round trip ${(stats.loading.end - stats.loading.start) / 1000}
|
17619
|
-
// diff ${
|
17620
|
-
// (reloadInterval -
|
17621
|
-
// (estimatedTimeUntilUpdate +
|
17622
|
-
// stats.loading.end -
|
17623
|
-
// stats.loading.start)) /
|
17624
|
-
// 1000
|
17625
|
-
// }
|
17626
|
-
// reload interval ${reloadInterval / 1000}
|
17627
|
-
// target duration ${details.targetduration}
|
17628
|
-
// distance to edge ${distanceToLiveEdgeMs / 1000}`
|
17629
|
-
// );
|
17630
|
-
|
17631
|
-
this.timer = self.setTimeout(function () {
|
17632
|
-
return _this2.loadPlaylist(deliveryDirectives);
|
17633
|
-
}, estimatedTimeUntilUpdate);
|
17618
|
+
if (details.requestScheduled + reloadInterval < now) {
|
17619
|
+
details.requestScheduled = now;
|
17620
|
+
} else {
|
17621
|
+
details.requestScheduled += reloadInterval;
|
17622
|
+
}
|
17623
|
+
this.scheduleLoading(levelOrTrack, deliveryDirectives);
|
17634
17624
|
} else {
|
17635
17625
|
this.clearTimer();
|
17636
17626
|
}
|
17637
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
|
+
};
|
17638
17663
|
_proto.getDeliveryDirectives = function getDeliveryDirectives(details, previousDeliveryDirectives, msn, part) {
|
17639
17664
|
var skip = getSkipValue(details);
|
17640
17665
|
if (previousDeliveryDirectives != null && previousDeliveryDirectives.skip && details.deltaUpdateFailed) {
|
@@ -17657,7 +17682,6 @@
|
|
17657
17682
|
var retry = !!errorAction && !!retryConfig && (action === NetworkErrorAction.RetryRequest || !errorAction.resolved && action === NetworkErrorAction.SendAlternateToPenaltyBox);
|
17658
17683
|
if (retry) {
|
17659
17684
|
var _errorEvent$context;
|
17660
|
-
this.requestScheduled = -1;
|
17661
17685
|
if (retryCount >= retryConfig.maxNumRetry) {
|
17662
17686
|
return false;
|
17663
17687
|
}
|
@@ -17827,9 +17851,6 @@
|
|
17827
17851
|
error: error
|
17828
17852
|
});
|
17829
17853
|
}
|
17830
|
-
} else if (this.shouldReloadPlaylist(currentTrack)) {
|
17831
|
-
// Retry playlist loading if no playlist is or has been loaded yet
|
17832
|
-
this.setAudioTrack(this.trackId);
|
17833
17854
|
}
|
17834
17855
|
};
|
17835
17856
|
_proto.onError = function onError(event, data) {
|
@@ -17837,7 +17858,6 @@
|
|
17837
17858
|
return;
|
17838
17859
|
}
|
17839
17860
|
if (data.context.type === PlaylistContextType.AUDIO_TRACK && data.context.id === this.trackId && (!this.groupIds || this.groupIds.indexOf(data.context.groupId) !== -1)) {
|
17840
|
-
this.requestScheduled = -1;
|
17841
17861
|
this.checkRetry(data);
|
17842
17862
|
}
|
17843
17863
|
};
|
@@ -17893,9 +17913,6 @@
|
|
17893
17913
|
this.warn("Invalid audio track id: " + newId);
|
17894
17914
|
return;
|
17895
17915
|
}
|
17896
|
-
|
17897
|
-
// stopping live reloading timer if any
|
17898
|
-
this.clearTimer();
|
17899
17916
|
this.selectDefaultTrack = false;
|
17900
17917
|
var lastTrack = this.currentTrack;
|
17901
17918
|
var track = tracks[newId];
|
@@ -17962,35 +17979,32 @@
|
|
17962
17979
|
};
|
17963
17980
|
_proto.loadPlaylist = function loadPlaylist(hlsUrlParameters) {
|
17964
17981
|
var _this$hls$levels$this;
|
17982
|
+
_BasePlaylistControll.prototype.loadPlaylist.call(this);
|
17965
17983
|
var audioTrack = this.currentTrack;
|
17966
|
-
if (!audioTrack) {
|
17984
|
+
if (!this.shouldLoadPlaylist(audioTrack)) {
|
17967
17985
|
return;
|
17968
17986
|
}
|
17969
|
-
|
17970
|
-
|
17971
|
-
|
17972
|
-
var id = audioTrack.id;
|
17973
|
-
var groupId = audioTrack.groupId;
|
17974
|
-
if (hlsUrlParameters) {
|
17975
|
-
try {
|
17976
|
-
url = hlsUrlParameters.addDirectives(url);
|
17977
|
-
} catch (error) {
|
17978
|
-
this.warn("Could not construct new URL with HLS Delivery Directives: " + error);
|
17979
|
-
}
|
17980
|
-
}
|
17981
|
-
// track not retrieved yet, or live playlist we need to (re)load it
|
17982
|
-
var details = audioTrack.details;
|
17983
|
-
var age = details == null ? void 0 : details.age;
|
17984
|
-
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);
|
17985
|
-
this.clearTimer();
|
17986
|
-
this.hls.trigger(Events.AUDIO_TRACK_LOADING, {
|
17987
|
-
url: url,
|
17988
|
-
id: id,
|
17989
|
-
groupId: groupId,
|
17990
|
-
deliveryDirectives: hlsUrlParameters || null,
|
17991
|
-
track: audioTrack
|
17992
|
-
});
|
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;
|
17993
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
|
+
});
|
17994
18008
|
};
|
17995
18009
|
return _createClass(AudioTrackController, [{
|
17996
18010
|
key: "allAudioTracks",
|
@@ -26274,9 +26288,6 @@
|
|
26274
26288
|
if (trackId !== -1 && this.trackId === -1) {
|
26275
26289
|
this.setSubtitleTrack(trackId);
|
26276
26290
|
}
|
26277
|
-
} else if (this.shouldReloadPlaylist(currentTrack)) {
|
26278
|
-
// Retry playlist loading if no playlist is or has been loaded yet
|
26279
|
-
this.setSubtitleTrack(this.trackId);
|
26280
26291
|
}
|
26281
26292
|
};
|
26282
26293
|
_proto.findTrackId = function findTrackId(currentTrack) {
|
@@ -26365,29 +26376,25 @@
|
|
26365
26376
|
};
|
26366
26377
|
_proto.loadPlaylist = function loadPlaylist(hlsUrlParameters) {
|
26367
26378
|
_BasePlaylistControll.prototype.loadPlaylist.call(this);
|
26368
|
-
|
26369
|
-
|
26370
|
-
|
26371
|
-
|
26372
|
-
|
26373
|
-
|
26374
|
-
|
26375
|
-
|
26376
|
-
|
26377
|
-
|
26378
|
-
|
26379
|
-
|
26380
|
-
|
26381
|
-
|
26382
|
-
|
26383
|
-
|
26384
|
-
|
26385
|
-
|
26386
|
-
|
26387
|
-
deliveryDirectives: hlsUrlParameters || null,
|
26388
|
-
track: currentTrack
|
26389
|
-
});
|
26390
|
-
}
|
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
|
+
});
|
26391
26398
|
}
|
26392
26399
|
|
26393
26400
|
/**
|
@@ -26445,9 +26452,6 @@
|
|
26445
26452
|
this.warn("Invalid subtitle track id: " + newId);
|
26446
26453
|
return;
|
26447
26454
|
}
|
26448
|
-
|
26449
|
-
// stopping live reloading timer if any
|
26450
|
-
this.clearTimer();
|
26451
26455
|
this.selectDefaultTrack = false;
|
26452
26456
|
var lastTrack = this.currentTrack;
|
26453
26457
|
var track = tracks[newId] || null;
|
@@ -31332,10 +31336,7 @@
|
|
31332
31336
|
return;
|
31333
31337
|
}
|
31334
31338
|
if (data.context.type === PlaylistContextType.LEVEL && data.context.level === this.level) {
|
31335
|
-
|
31336
|
-
if (!retry) {
|
31337
|
-
this.requestScheduled = -1;
|
31338
|
-
}
|
31339
|
+
this.checkRetry(data);
|
31339
31340
|
}
|
31340
31341
|
}
|
31341
31342
|
|
@@ -31390,36 +31391,28 @@
|
|
31390
31391
|
};
|
31391
31392
|
_proto.loadPlaylist = function loadPlaylist(hlsUrlParameters) {
|
31392
31393
|
_BasePlaylistControll.prototype.loadPlaylist.call(this);
|
31393
|
-
|
31394
|
-
|
31395
|
-
if (currentLevel && this.shouldLoadPlaylist(currentLevel)) {
|
31396
|
-
var url = currentLevel.uri;
|
31397
|
-
if (hlsUrlParameters) {
|
31398
|
-
try {
|
31399
|
-
url = hlsUrlParameters.addDirectives(url);
|
31400
|
-
} catch (error) {
|
31401
|
-
this.warn("Could not construct new URL with HLS Delivery Directives: " + error);
|
31402
|
-
}
|
31403
|
-
}
|
31404
|
-
var pathwayId = currentLevel.attrs['PATHWAY-ID'];
|
31405
|
-
var details = currentLevel.details;
|
31406
|
-
var age = details == null ? void 0 : details.age;
|
31407
|
-
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);
|
31408
|
-
|
31409
|
-
// console.log('Current audio track group ID:', this.hls.audioTracks[this.hls.audioTrack].groupId);
|
31410
|
-
// console.log('New video quality level audio group id:', levelObject.attrs.AUDIO, level);
|
31411
|
-
this.clearTimer();
|
31412
|
-
this.hls.trigger(Events.LEVEL_LOADING, {
|
31413
|
-
url: url,
|
31414
|
-
level: currentLevelIndex,
|
31415
|
-
levelInfo: currentLevel,
|
31416
|
-
pathwayId: currentLevel.attrs['PATHWAY-ID'],
|
31417
|
-
id: 0,
|
31418
|
-
// Deprecated Level urlId
|
31419
|
-
deliveryDirectives: hlsUrlParameters || null
|
31420
|
-
});
|
31394
|
+
if (this.shouldLoadPlaylist(this.currentLevel)) {
|
31395
|
+
this.scheduleLoading(this.currentLevel, hlsUrlParameters);
|
31421
31396
|
}
|
31422
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
|
+
};
|
31423
31416
|
_proto.removeLevel = function removeLevel(levelIndex) {
|
31424
31417
|
var _this4 = this,
|
31425
31418
|
_this$currentLevel;
|
@@ -31514,9 +31507,7 @@
|
|
31514
31507
|
this.currentLevelIndex = newLevel;
|
31515
31508
|
this.currentLevel = level;
|
31516
31509
|
if (lastLevelIndex === newLevel && lastLevel && lastPathwayId === pathwayId) {
|
31517
|
-
|
31518
|
-
return;
|
31519
|
-
}
|
31510
|
+
return;
|
31520
31511
|
}
|
31521
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 : ''));
|
31522
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.
|