@byteplus/veplayer-plugin 2.10.3-rc.0 → 2.10.3
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/esm/ad.d.ts +3 -0
- package/esm/hlsjs.d.ts +3 -0
- package/esm/index.development.js +531 -244
- package/esm/index.production.js +1 -1
- package/esm/time-shift.d.ts +3 -0
- package/esm/veplayer.plugin.abr.development.js +1 -1
- package/esm/veplayer.plugin.abr.production.js +1 -1
- package/esm/veplayer.plugin.drm.development.js +1 -1
- package/esm/veplayer.plugin.drm.production.js +1 -1
- package/esm/veplayer.plugin.flv.development.js +1 -1
- package/esm/veplayer.plugin.flv.production.js +1 -1
- package/esm/veplayer.plugin.hls.development.js +1 -1
- package/esm/veplayer.plugin.hls.production.js +1 -1
- package/esm/veplayer.plugin.hlsjs.development.js +496 -218
- package/esm/veplayer.plugin.hlsjs.production.js +1 -1
- package/esm/veplayer.plugin.rtm.development.js +37 -28
- package/esm/veplayer.plugin.rtm.production.js +1 -1
- package/esm/veplayer.plugin.time.shift.development.js +13 -16
- package/esm/veplayer.plugin.time.shift.production.js +1 -1
- package/esm/veplayer.plugin.xgvideo.development.js +1 -1
- package/esm/veplayer.plugin.xgvideo.production.js +1 -1
- package/esm/veplayer.strategy.base.development.js +1 -1
- package/esm/veplayer.strategy.base.production.js +1 -1
- package/esm/veplayer.strategy.rtm.adaptive.buffer.development.js +1 -1
- package/esm/veplayer.strategy.rtm.adaptive.buffer.production.js +1 -1
- package/package.json +106 -2
- package/umd/ad.d.ts +3 -0
- package/umd/hlsjs.d.ts +3 -0
- package/umd/time-shift.d.ts +3 -0
- package/umd/veplayer.plugin.hlsjs.development.js +495 -217
- package/umd/veplayer.plugin.hlsjs.production.js +1 -1
- package/umd/veplayer.plugin.rtm.development.js +36 -27
- package/umd/veplayer.plugin.rtm.production.js +1 -1
package/esm/index.development.js
CHANGED
|
@@ -33132,6 +33132,9 @@ function isHeyTapBrowser() {
|
|
|
33132
33132
|
function isVivoBrowser() {
|
|
33133
33133
|
return /(VivoBrowser)/i.test(navigator.userAgent);
|
|
33134
33134
|
}
|
|
33135
|
+
function isPositiveNumber(num) {
|
|
33136
|
+
return typeof num === "number" && num > 0;
|
|
33137
|
+
}
|
|
33135
33138
|
var VideoFrameRecvCallback = /* @__PURE__ */ function() {
|
|
33136
33139
|
function VideoFrameRecvCallback2() {
|
|
33137
33140
|
var _this = this;
|
|
@@ -33222,7 +33225,8 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
|
|
|
33222
33225
|
clearTimeout(_this._checkStatsErrorTimer);
|
|
33223
33226
|
}
|
|
33224
33227
|
_this._checkStatsErrorTimer = setTimeout(/* @__PURE__ */ _asyncToGenerator$a(/* @__PURE__ */ _regeneratorRuntime$a().mark(function _callee() {
|
|
33225
|
-
var
|
|
33228
|
+
var _stats$video, _stats$audio, _stats$video2, _stats$video3;
|
|
33229
|
+
var stats;
|
|
33226
33230
|
return _regeneratorRuntime$a().wrap(function _callee$(_context) {
|
|
33227
33231
|
while (1)
|
|
33228
33232
|
switch (_context.prev = _context.next) {
|
|
@@ -33231,19 +33235,17 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
|
|
|
33231
33235
|
return _this.getStatsSnapshoot();
|
|
33232
33236
|
case 2:
|
|
33233
33237
|
stats = _context.sent;
|
|
33234
|
-
if (stats.video) {
|
|
33235
|
-
|
|
33236
|
-
|
|
33237
|
-
|
|
33238
|
-
message: "rts receive empty"
|
|
33239
|
-
}));
|
|
33240
|
-
} else if (!framesDecoded) {
|
|
33241
|
-
_this._emitError(StreamingError$2.create(ERR$2.MEDIA, ERR$2.SUB_TYPES.MEDIA_ERR_DECODE, {
|
|
33242
|
-
message: "rts decode error"
|
|
33243
|
-
}));
|
|
33244
|
-
}
|
|
33238
|
+
if (!isPositiveNumber((_stats$video = stats.video) === null || _stats$video === void 0 ? void 0 : _stats$video.bytesReceived) && !isPositiveNumber((_stats$audio = stats.audio) === null || _stats$audio === void 0 ? void 0 : _stats$audio.bytesReceived)) {
|
|
33239
|
+
_this._emitError(StreamingError$2.create(ERR$2.MEDIA, ERR$2.SUB_TYPES.MEDIA_ERR_DECODE, {
|
|
33240
|
+
message: "rts receive empty"
|
|
33241
|
+
}));
|
|
33245
33242
|
}
|
|
33246
|
-
|
|
33243
|
+
if (isPositiveNumber((_stats$video2 = stats.video) === null || _stats$video2 === void 0 ? void 0 : _stats$video2.bytesReceived) && !isPositiveNumber((_stats$video3 = stats.video) === null || _stats$video3 === void 0 ? void 0 : _stats$video3.framesDecoded)) {
|
|
33244
|
+
_this._emitError(StreamingError$2.create(ERR$2.MEDIA, ERR$2.SUB_TYPES.MEDIA_ERR_DECODE, {
|
|
33245
|
+
message: "rts decode error"
|
|
33246
|
+
}));
|
|
33247
|
+
}
|
|
33248
|
+
case 5:
|
|
33247
33249
|
case "end":
|
|
33248
33250
|
return _context.stop();
|
|
33249
33251
|
}
|
|
@@ -33661,6 +33663,7 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
|
|
|
33661
33663
|
value: function _bindRTCEvents(pc) {
|
|
33662
33664
|
var _this3 = this;
|
|
33663
33665
|
pc.addEventListener("track", this._onTrack);
|
|
33666
|
+
var firstConnect = true;
|
|
33664
33667
|
pc.addEventListener("connectionstatechange", function() {
|
|
33665
33668
|
logger$b.warn("onconnectionstatechange:", pc.connectionState);
|
|
33666
33669
|
_this3._clearPeerStateTimeout();
|
|
@@ -33668,26 +33671,31 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
|
|
|
33668
33671
|
state: pc.connectionState,
|
|
33669
33672
|
url: _this3._url
|
|
33670
33673
|
});
|
|
33671
|
-
if (pc.connectionState === "disconnected" || pc.connectionState === "failed") {
|
|
33672
|
-
_this3.emit("waiting");
|
|
33673
|
-
_this3._stopRtcReport();
|
|
33674
|
-
}
|
|
33675
33674
|
if (pc.connectionState === "failed") {
|
|
33675
|
+
var _this3$_preAudioStats, _this3$_preVideoStats;
|
|
33676
|
+
var reason = isPositiveNumber((_this3$_preAudioStats = _this3._preAudioStats) === null || _this3$_preAudioStats === void 0 ? void 0 : _this3$_preAudioStats.bytesReceived) && !isPositiveNumber((_this3$_preVideoStats = _this3._preVideoStats) === null || _this3$_preVideoStats === void 0 ? void 0 : _this3$_preVideoStats.bytesReceived) ? "rtc connect failed(only audio)" : "rtc connect failed";
|
|
33676
33677
|
if (_this3._retry === 0) {
|
|
33677
|
-
_this3._emitError(StreamingError$2.network(new Error(
|
|
33678
|
+
_this3._emitError(StreamingError$2.network(new Error(reason)));
|
|
33678
33679
|
return;
|
|
33679
33680
|
}
|
|
33680
33681
|
_this3._retry--;
|
|
33681
|
-
_this3.load(_this3._url,
|
|
33682
|
+
_this3.load(_this3._url, reason);
|
|
33683
|
+
}
|
|
33684
|
+
if (pc.connectionState === "disconnected" || pc.connectionState === "failed") {
|
|
33685
|
+
_this3.emit("waiting");
|
|
33686
|
+
_this3._stopRtcReport();
|
|
33682
33687
|
}
|
|
33683
33688
|
if (pc.connectionState === "connected") {
|
|
33684
|
-
|
|
33685
|
-
|
|
33686
|
-
|
|
33687
|
-
|
|
33688
|
-
|
|
33689
|
-
|
|
33690
|
-
|
|
33689
|
+
if (firstConnect) {
|
|
33690
|
+
firstConnect = false;
|
|
33691
|
+
_this3._handleMediaStream();
|
|
33692
|
+
_this3.emit(EVENT$2.TTFB, {
|
|
33693
|
+
url: _this3._url,
|
|
33694
|
+
responseUrl: _this3._url,
|
|
33695
|
+
elapsed: Date.now() - _this3._rctConnectStartTs
|
|
33696
|
+
});
|
|
33697
|
+
_this3._checkStatsError();
|
|
33698
|
+
}
|
|
33691
33699
|
_this3._startRtcReport();
|
|
33692
33700
|
}
|
|
33693
33701
|
});
|
|
@@ -34258,6 +34266,7 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
|
|
|
34258
34266
|
this._firstFrameObserver.reset();
|
|
34259
34267
|
this.emit(EVENT$2.ERROR, error);
|
|
34260
34268
|
clearTimeout(this._checkStatsErrorTimer);
|
|
34269
|
+
this._stopRtcReport();
|
|
34261
34270
|
this._clearPeerStateTimeout();
|
|
34262
34271
|
if (this._pc) {
|
|
34263
34272
|
this._pc.close();
|
|
@@ -34517,7 +34526,7 @@ var RtsPlugin = /* @__PURE__ */ function(_BasePlugin) {
|
|
|
34517
34526
|
}, {
|
|
34518
34527
|
key: "version",
|
|
34519
34528
|
get: function get4() {
|
|
34520
|
-
return "0.2.1-alpha.
|
|
34529
|
+
return "0.2.1-alpha.57";
|
|
34521
34530
|
}
|
|
34522
34531
|
}, {
|
|
34523
34532
|
key: "beforePlayerInit",
|
|
@@ -80224,7 +80233,7 @@ class Hls {
|
|
|
80224
80233
|
}
|
|
80225
80234
|
}
|
|
80226
80235
|
Hls.defaultConfig = void 0;
|
|
80227
|
-
const
|
|
80236
|
+
const OPTIONS_MAP = {
|
|
80228
80237
|
liveSyncDuration: {
|
|
80229
80238
|
key: "targetLatency",
|
|
80230
80239
|
val: 10
|
|
@@ -80241,20 +80250,40 @@ const optionsMap = {
|
|
|
80241
80250
|
key: "minSegmentsStartPlay",
|
|
80242
80251
|
val: 3
|
|
80243
80252
|
},
|
|
80244
|
-
preferManagedMediaSource:
|
|
80245
|
-
|
|
80246
|
-
|
|
80247
|
-
|
|
80253
|
+
preferManagedMediaSource: [
|
|
80254
|
+
{
|
|
80255
|
+
key: "preferMMS",
|
|
80256
|
+
val: false
|
|
80257
|
+
},
|
|
80258
|
+
{
|
|
80259
|
+
key: "preferMMSStreaming",
|
|
80260
|
+
val: false
|
|
80261
|
+
}
|
|
80262
|
+
],
|
|
80248
80263
|
lowLatencyMode: {
|
|
80249
80264
|
key: "useLowLatency",
|
|
80250
80265
|
val: true
|
|
80266
|
+
},
|
|
80267
|
+
startPosition: {
|
|
80268
|
+
key: "startTime",
|
|
80269
|
+
val: 0
|
|
80270
|
+
},
|
|
80271
|
+
interstitialLiveLookAhead: {
|
|
80272
|
+
key: "preloadTime",
|
|
80273
|
+
val: 30
|
|
80251
80274
|
}
|
|
80252
80275
|
};
|
|
80253
|
-
function getHlsConfig(config2
|
|
80276
|
+
function getHlsConfig(config2) {
|
|
80254
80277
|
const hlsConfig = {};
|
|
80255
|
-
Object.keys(
|
|
80256
|
-
const tmp =
|
|
80257
|
-
|
|
80278
|
+
Object.keys(OPTIONS_MAP).forEach((keyStr) => {
|
|
80279
|
+
const tmp = OPTIONS_MAP[keyStr];
|
|
80280
|
+
if (tmp instanceof Array) {
|
|
80281
|
+
tmp.forEach((item) => {
|
|
80282
|
+
hlsConfig[keyStr] = item.val;
|
|
80283
|
+
});
|
|
80284
|
+
} else {
|
|
80285
|
+
hlsConfig[keyStr] = config2[tmp.key] || tmp.val;
|
|
80286
|
+
}
|
|
80258
80287
|
});
|
|
80259
80288
|
const maxNumRetry = typeof config2.retryCount === "number" ? config2.retryCount : 3;
|
|
80260
80289
|
const retryDelayMs = typeof config2.retryDelay === "number" ? config2.retryDelay : 1e3;
|
|
@@ -80305,11 +80334,434 @@ function getHlsConfig(config2, playerConfig) {
|
|
|
80305
80334
|
...config2
|
|
80306
80335
|
};
|
|
80307
80336
|
}
|
|
80337
|
+
function initHlsEvents(hls, player) {
|
|
80338
|
+
hls.on(Hls.Events.SUBTITLE_FRAG_PROCESSED, (_, { frag }) => {
|
|
80339
|
+
player.emit("core_event", {
|
|
80340
|
+
eventName: "core.subtitlesegments",
|
|
80341
|
+
list: frag
|
|
80342
|
+
});
|
|
80343
|
+
});
|
|
80344
|
+
hls.on(Hls.Events.MANIFEST_PARSED, (_, { levels }) => {
|
|
80345
|
+
player.emit("core_event", {
|
|
80346
|
+
eventName: "core.subtitleplaylist",
|
|
80347
|
+
list: levels
|
|
80348
|
+
});
|
|
80349
|
+
});
|
|
80350
|
+
hls.on(Hls.Events.MANIFEST_LOADING, (_, { url: url2 }) => {
|
|
80351
|
+
player.emit("core_event", {
|
|
80352
|
+
eventName: "core.loadstart",
|
|
80353
|
+
url: url2
|
|
80354
|
+
});
|
|
80355
|
+
});
|
|
80356
|
+
hls.on(Hls.Events.LEVEL_LOADING, (_, { url: url2 }) => {
|
|
80357
|
+
player.emit("core_event", {
|
|
80358
|
+
eventName: "core.loadstart",
|
|
80359
|
+
url: url2
|
|
80360
|
+
});
|
|
80361
|
+
});
|
|
80362
|
+
hls.on(Hls.Events.FRAG_LOADING, (_, { frag }) => {
|
|
80363
|
+
player.emit("core_event", {
|
|
80364
|
+
eventName: "core.loadstart",
|
|
80365
|
+
url: frag.url
|
|
80366
|
+
});
|
|
80367
|
+
});
|
|
80368
|
+
hls.on(Hls.Events.MANIFEST_LOADED, (_, data2) => {
|
|
80369
|
+
const { url: url2 } = data2;
|
|
80370
|
+
player.emit("core_event", {
|
|
80371
|
+
eventName: "core.loadcomplete",
|
|
80372
|
+
url: url2
|
|
80373
|
+
});
|
|
80374
|
+
});
|
|
80375
|
+
hls.on(Hls.Events.LEVEL_LOADED, (_, data2) => {
|
|
80376
|
+
const { details, stats } = data2;
|
|
80377
|
+
player.emit("core_event", {
|
|
80378
|
+
eventName: "core.loadcomplete",
|
|
80379
|
+
...stats,
|
|
80380
|
+
url: details == null ? void 0 : details.url
|
|
80381
|
+
});
|
|
80382
|
+
});
|
|
80383
|
+
hls.on(Hls.Events.FRAG_LOADED, (_, data2) => {
|
|
80384
|
+
const { frag } = data2;
|
|
80385
|
+
player.emit("core_event", {
|
|
80386
|
+
eventName: "core.loadcomplete",
|
|
80387
|
+
url: frag.url
|
|
80388
|
+
});
|
|
80389
|
+
});
|
|
80390
|
+
hls.on(Hls.Events.FRAG_PARSING_USERDATA, (_, { samples }) => {
|
|
80391
|
+
player.emit("core_event", {
|
|
80392
|
+
eventName: "core.sei",
|
|
80393
|
+
sei: samples
|
|
80394
|
+
});
|
|
80395
|
+
});
|
|
80396
|
+
hls.on(Hls.Events.MANIFEST_LOADED, (_, { levels, networkDetails }) => {
|
|
80397
|
+
player.emit("core_event", {
|
|
80398
|
+
eventName: "core.hlsmanifestloaded",
|
|
80399
|
+
playlist: levels
|
|
80400
|
+
});
|
|
80401
|
+
player.emit("core_event", {
|
|
80402
|
+
eventName: "core.loadresponseheaders",
|
|
80403
|
+
headers: networkDetails.headers
|
|
80404
|
+
});
|
|
80405
|
+
});
|
|
80406
|
+
hls.on(Hls.Events.LEVEL_LOADED, (_, { details }) => {
|
|
80407
|
+
const dateRanges = {};
|
|
80408
|
+
Object.keys(details.dateRanges).forEach((key2) => {
|
|
80409
|
+
dateRanges[key2] = details.dateRanges[key2].attr["START-DATE"];
|
|
80410
|
+
});
|
|
80411
|
+
player.emit("core_event", {
|
|
80412
|
+
eventName: "core.hlslevelloaded",
|
|
80413
|
+
playlist: {
|
|
80414
|
+
...details,
|
|
80415
|
+
segments: details.fragments,
|
|
80416
|
+
dateRanges
|
|
80417
|
+
}
|
|
80418
|
+
});
|
|
80419
|
+
});
|
|
80420
|
+
hls.on(Hls.Events.ERROR, (_, data2) => {
|
|
80421
|
+
const { details, fatal, type, response, reason, error } = data2;
|
|
80422
|
+
if (!fatal) {
|
|
80423
|
+
return;
|
|
80424
|
+
}
|
|
80425
|
+
let errorCode;
|
|
80426
|
+
let errorType;
|
|
80427
|
+
switch (type) {
|
|
80428
|
+
case Hls.ErrorTypes.NETWORK_ERROR:
|
|
80429
|
+
errorCode = 2100;
|
|
80430
|
+
if (details.includes("TimeOut")) {
|
|
80431
|
+
errorCode = 2101;
|
|
80432
|
+
} else if ((response == null ? void 0 : response.code) === 403) {
|
|
80433
|
+
errorCode = 2103;
|
|
80434
|
+
} else if ((response == null ? void 0 : response.code) === 404) {
|
|
80435
|
+
errorCode = 2104;
|
|
80436
|
+
}
|
|
80437
|
+
player.emit("error", {
|
|
80438
|
+
errorType: "network",
|
|
80439
|
+
errorCode,
|
|
80440
|
+
message: (error == null ? void 0 : error.message) || details,
|
|
80441
|
+
originError: data2
|
|
80442
|
+
});
|
|
80443
|
+
break;
|
|
80444
|
+
case Hls.ErrorTypes.MEDIA_ERROR:
|
|
80445
|
+
errorType = "media";
|
|
80446
|
+
if (details === Hls.ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR) {
|
|
80447
|
+
errorCode = 5104;
|
|
80448
|
+
} else if (details === Hls.ErrorDetails.FRAG_DECRYPT_ERROR) {
|
|
80449
|
+
errorCode = 5105;
|
|
80450
|
+
} else if (details === Hls.ErrorDetails.FRAG_PARSING_ERROR) {
|
|
80451
|
+
errorCode = 1100;
|
|
80452
|
+
errorType = "manifest";
|
|
80453
|
+
} else if (details === Hls.ErrorDetails.FRAG_GAP) {
|
|
80454
|
+
errorCode = 5104;
|
|
80455
|
+
} else if (details === Hls.ErrorDetails.BUFFER_ADD_CODEC_ERROR) {
|
|
80456
|
+
errorCode = 5200;
|
|
80457
|
+
} else if (details === Hls.ErrorDetails.BUFFER_INCOMPATIBLE_CODECS_ERROR) {
|
|
80458
|
+
errorCode = 5104;
|
|
80459
|
+
} else if (details === Hls.ErrorDetails.BUFFER_APPEND_ERROR) {
|
|
80460
|
+
errorCode = 5201;
|
|
80461
|
+
} else if (details === Hls.ErrorDetails.BUFFER_APPENDING_ERROR) {
|
|
80462
|
+
errorCode = 5201;
|
|
80463
|
+
} else if (details === Hls.ErrorDetails.BUFFER_STALLED_ERROR) {
|
|
80464
|
+
errorCode = 5203;
|
|
80465
|
+
} else if (details === Hls.ErrorDetails.BUFFER_FULL_ERROR) {
|
|
80466
|
+
errorCode = 5203;
|
|
80467
|
+
} else if (details === Hls.ErrorDetails.BUFFER_SEEK_OVER_HOLE) {
|
|
80468
|
+
errorCode = 5202;
|
|
80469
|
+
} else if (details === Hls.ErrorDetails.BUFFER_NUDGE_ON_STALL) {
|
|
80470
|
+
errorCode = 5202;
|
|
80471
|
+
}
|
|
80472
|
+
player.emit("error", {
|
|
80473
|
+
errorType: errorType || type,
|
|
80474
|
+
errorCode,
|
|
80475
|
+
message: (error == null ? void 0 : error.message) || details,
|
|
80476
|
+
originError: data2
|
|
80477
|
+
});
|
|
80478
|
+
break;
|
|
80479
|
+
case Hls.ErrorTypes.MUX_ERROR:
|
|
80480
|
+
errorCode = 4100;
|
|
80481
|
+
player.emit("error", {
|
|
80482
|
+
errorType: "remux",
|
|
80483
|
+
errorCode,
|
|
80484
|
+
message: (error == null ? void 0 : error.message) || details,
|
|
80485
|
+
originError: data2
|
|
80486
|
+
});
|
|
80487
|
+
break;
|
|
80488
|
+
case Hls.ErrorTypes.KEY_SYSTEM_ERROR:
|
|
80489
|
+
errorCode = 7111;
|
|
80490
|
+
if (details === Hls.ErrorDetails.KEY_SYSTEM_NO_KEYS) {
|
|
80491
|
+
errorCode = 7103;
|
|
80492
|
+
} else if (details === Hls.ErrorDetails.KEY_SYSTEM_NO_ACCESS) {
|
|
80493
|
+
errorCode = 7101;
|
|
80494
|
+
} else if (details === Hls.ErrorDetails.KEY_SYSTEM_NO_SESSION) {
|
|
80495
|
+
errorCode = 7104;
|
|
80496
|
+
} else if (details === Hls.ErrorDetails.KEY_SYSTEM_NO_CONFIGURED_LICENSE) {
|
|
80497
|
+
errorCode = 7107;
|
|
80498
|
+
} else if (details === Hls.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED) {
|
|
80499
|
+
errorCode = 7108;
|
|
80500
|
+
} else if (details === Hls.ErrorDetails.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED) {
|
|
80501
|
+
errorCode = 7110;
|
|
80502
|
+
} else if (details === Hls.ErrorDetails.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED) {
|
|
80503
|
+
errorCode = 7110;
|
|
80504
|
+
} else if (details === Hls.ErrorDetails.KEY_SYSTEM_SESSION_UPDATE_FAILED) {
|
|
80505
|
+
errorCode = 7104;
|
|
80506
|
+
} else if (details === Hls.ErrorDetails.KEY_SYSTEM_STATUS_INTERNAL_ERROR) {
|
|
80507
|
+
errorCode = 7111;
|
|
80508
|
+
}
|
|
80509
|
+
player.emit("error", {
|
|
80510
|
+
errorType: "drm",
|
|
80511
|
+
errorCode,
|
|
80512
|
+
message: (error == null ? void 0 : error.message) || reason || details,
|
|
80513
|
+
originError: data2
|
|
80514
|
+
});
|
|
80515
|
+
break;
|
|
80516
|
+
default:
|
|
80517
|
+
if (details === Hls.ErrorDetails.LEVEL_SWITCH_ERROR) {
|
|
80518
|
+
errorCode = 2100;
|
|
80519
|
+
errorType = "network";
|
|
80520
|
+
}
|
|
80521
|
+
player.emit("error", {
|
|
80522
|
+
errorType: errorType || "other",
|
|
80523
|
+
errorCode,
|
|
80524
|
+
message: (error == null ? void 0 : error.message) || reason || details,
|
|
80525
|
+
originError: data2
|
|
80526
|
+
});
|
|
80527
|
+
break;
|
|
80528
|
+
}
|
|
80529
|
+
try {
|
|
80530
|
+
hls.stopLoad();
|
|
80531
|
+
player.pause();
|
|
80532
|
+
} catch (error2) {
|
|
80533
|
+
}
|
|
80534
|
+
});
|
|
80535
|
+
hls.on(Hls.Events.MEDIA_ATTACHED, () => {
|
|
80536
|
+
player.emit("sourceopen");
|
|
80537
|
+
});
|
|
80538
|
+
hls.on(Hls.Events.BUFFER_APPENDED, () => {
|
|
80539
|
+
player.emit("bufferappend");
|
|
80540
|
+
});
|
|
80541
|
+
hls.on(Hls.Events.AUDIO_TRACKS_UPDATED, (_, { audioTracks }) => {
|
|
80542
|
+
player.emit("core_event", {
|
|
80543
|
+
eventName: "core.audiotracksupdate",
|
|
80544
|
+
audioTracks
|
|
80545
|
+
});
|
|
80546
|
+
});
|
|
80547
|
+
hls.on(Hls.Events.AUDIO_TRACK_SWITCHING, (_, data2) => {
|
|
80548
|
+
player.emit("core_event", {
|
|
80549
|
+
eventName: "core.audiotrackswitching",
|
|
80550
|
+
...data2
|
|
80551
|
+
});
|
|
80552
|
+
});
|
|
80553
|
+
hls.on(Hls.Events.AUDIO_TRACK_SWITCHED, (_, data2) => {
|
|
80554
|
+
player.emit("core_event", {
|
|
80555
|
+
eventName: "core.audiotrackswitched",
|
|
80556
|
+
...data2
|
|
80557
|
+
});
|
|
80558
|
+
});
|
|
80559
|
+
hls.on(Hls.Events.SUBTITLE_TRACKS_UPDATED, (_, { subtitleTracks }) => {
|
|
80560
|
+
player.emit("core_event", {
|
|
80561
|
+
eventName: "core.subtitletracksupdate",
|
|
80562
|
+
subtitleTracks
|
|
80563
|
+
});
|
|
80564
|
+
});
|
|
80565
|
+
hls.on(Hls.Events.SUBTITLE_TRACKS_CLEARED, () => {
|
|
80566
|
+
player.emit("core_event", {
|
|
80567
|
+
eventName: "core.subtitletracksclear"
|
|
80568
|
+
});
|
|
80569
|
+
});
|
|
80570
|
+
hls.on(Hls.Events.SUBTITLE_TRACK_SWITCH, (_, data2) => {
|
|
80571
|
+
player.emit("core_event", {
|
|
80572
|
+
eventName: "core.subtitletrackswitch",
|
|
80573
|
+
...data2
|
|
80574
|
+
});
|
|
80575
|
+
});
|
|
80576
|
+
hls.on(Hls.Events.SUBTITLE_TRACK_LOADING, (_, data2) => {
|
|
80577
|
+
player.emit("core_event", {
|
|
80578
|
+
eventName: "core.subtitletrackloading",
|
|
80579
|
+
...data2
|
|
80580
|
+
});
|
|
80581
|
+
});
|
|
80582
|
+
hls.on(Hls.Events.SUBTITLE_TRACK_LOADED, (_, data2) => {
|
|
80583
|
+
player.emit("core_event", {
|
|
80584
|
+
eventName: "core.subtitletrackloaded",
|
|
80585
|
+
...data2
|
|
80586
|
+
});
|
|
80587
|
+
});
|
|
80588
|
+
}
|
|
80589
|
+
class TrackManager {
|
|
80590
|
+
constructor(hls, player) {
|
|
80591
|
+
this.hls = hls;
|
|
80592
|
+
this.player = player;
|
|
80593
|
+
}
|
|
80594
|
+
// Audio Track Methods
|
|
80595
|
+
getAudioTracks() {
|
|
80596
|
+
if (!this.hls) {
|
|
80597
|
+
console.warn("HLS instance not initialized");
|
|
80598
|
+
return [];
|
|
80599
|
+
}
|
|
80600
|
+
try {
|
|
80601
|
+
return this.hls.audioTracks || [];
|
|
80602
|
+
} catch (error) {
|
|
80603
|
+
console.error("Failed to get audio tracks:", error);
|
|
80604
|
+
return [];
|
|
80605
|
+
}
|
|
80606
|
+
}
|
|
80607
|
+
getCurrentAudioTrack() {
|
|
80608
|
+
if (!this.hls) {
|
|
80609
|
+
console.warn("HLS instance not initialized");
|
|
80610
|
+
return -1;
|
|
80611
|
+
}
|
|
80612
|
+
try {
|
|
80613
|
+
return this.hls.audioTrack;
|
|
80614
|
+
} catch (error) {
|
|
80615
|
+
console.error("Failed to get current audio track:", error);
|
|
80616
|
+
return -1;
|
|
80617
|
+
}
|
|
80618
|
+
}
|
|
80619
|
+
switchAudioTrack(trackId) {
|
|
80620
|
+
if (!this.hls) {
|
|
80621
|
+
console.warn("HLS instance not initialized");
|
|
80622
|
+
return false;
|
|
80623
|
+
}
|
|
80624
|
+
const audioTracks = this.getAudioTracks();
|
|
80625
|
+
if (audioTracks.length === 0) {
|
|
80626
|
+
console.warn("No audio tracks available");
|
|
80627
|
+
return false;
|
|
80628
|
+
}
|
|
80629
|
+
const trackExists = audioTracks.some((_, index2) => index2 === trackId);
|
|
80630
|
+
if (!trackExists) {
|
|
80631
|
+
console.warn(`Audio track with ID ${trackId} not found`);
|
|
80632
|
+
return false;
|
|
80633
|
+
}
|
|
80634
|
+
try {
|
|
80635
|
+
this.hls.audioTrack = trackId;
|
|
80636
|
+
this.player.emit("core_event", {
|
|
80637
|
+
eventName: "core.audiotrackchange",
|
|
80638
|
+
trackId,
|
|
80639
|
+
trackInfo: audioTracks[trackId] || null
|
|
80640
|
+
});
|
|
80641
|
+
return true;
|
|
80642
|
+
} catch (error) {
|
|
80643
|
+
console.error("Failed to switch audio track:", error);
|
|
80644
|
+
return false;
|
|
80645
|
+
}
|
|
80646
|
+
}
|
|
80647
|
+
// Subtitle Track Methods
|
|
80648
|
+
getSubtitleTracks() {
|
|
80649
|
+
if (!this.hls) {
|
|
80650
|
+
console.warn("HLS instance not initialized");
|
|
80651
|
+
return [];
|
|
80652
|
+
}
|
|
80653
|
+
try {
|
|
80654
|
+
return this.hls.subtitleTracks || [];
|
|
80655
|
+
} catch (error) {
|
|
80656
|
+
console.error("Failed to get subtitle tracks:", error);
|
|
80657
|
+
return [];
|
|
80658
|
+
}
|
|
80659
|
+
}
|
|
80660
|
+
getAllSubtitleTracks() {
|
|
80661
|
+
if (!this.hls) {
|
|
80662
|
+
console.warn("HLS instance not initialized");
|
|
80663
|
+
return [];
|
|
80664
|
+
}
|
|
80665
|
+
try {
|
|
80666
|
+
return this.hls.allSubtitleTracks || [];
|
|
80667
|
+
} catch (error) {
|
|
80668
|
+
console.error("Failed to get all subtitle tracks:", error);
|
|
80669
|
+
return [];
|
|
80670
|
+
}
|
|
80671
|
+
}
|
|
80672
|
+
getCurrentSubtitleTrack() {
|
|
80673
|
+
if (!this.hls) {
|
|
80674
|
+
console.warn("HLS instance not initialized");
|
|
80675
|
+
return -1;
|
|
80676
|
+
}
|
|
80677
|
+
try {
|
|
80678
|
+
return this.hls.subtitleTrack;
|
|
80679
|
+
} catch (error) {
|
|
80680
|
+
console.error("Failed to get current subtitle track:", error);
|
|
80681
|
+
return -1;
|
|
80682
|
+
}
|
|
80683
|
+
}
|
|
80684
|
+
switchSubtitleTrack(trackId) {
|
|
80685
|
+
if (!this.hls) {
|
|
80686
|
+
console.warn("HLS instance not initialized");
|
|
80687
|
+
return false;
|
|
80688
|
+
}
|
|
80689
|
+
const subtitleTracks = this.getSubtitleTracks();
|
|
80690
|
+
if (trackId === -1) {
|
|
80691
|
+
try {
|
|
80692
|
+
this.hls.subtitleTrack = -1;
|
|
80693
|
+
this.player.emit("core_event", {
|
|
80694
|
+
eventName: "core.subtitletrackchange",
|
|
80695
|
+
trackId: -1,
|
|
80696
|
+
trackInfo: null
|
|
80697
|
+
});
|
|
80698
|
+
return true;
|
|
80699
|
+
} catch (error) {
|
|
80700
|
+
console.error("Failed to disable subtitle track:", error);
|
|
80701
|
+
return false;
|
|
80702
|
+
}
|
|
80703
|
+
}
|
|
80704
|
+
if (subtitleTracks.length === 0) {
|
|
80705
|
+
console.warn("No subtitle tracks available");
|
|
80706
|
+
return false;
|
|
80707
|
+
}
|
|
80708
|
+
const trackExists = subtitleTracks.some((_, index2) => index2 === trackId);
|
|
80709
|
+
if (!trackExists) {
|
|
80710
|
+
console.warn(`Subtitle track with ID ${trackId} not found`);
|
|
80711
|
+
return false;
|
|
80712
|
+
}
|
|
80713
|
+
try {
|
|
80714
|
+
this.hls.subtitleTrack = trackId;
|
|
80715
|
+
this.player.emit("core_event", {
|
|
80716
|
+
eventName: "core.subtitletrackchange",
|
|
80717
|
+
trackId,
|
|
80718
|
+
trackInfo: subtitleTracks[trackId] || null
|
|
80719
|
+
});
|
|
80720
|
+
return true;
|
|
80721
|
+
} catch (error) {
|
|
80722
|
+
console.error("Failed to switch subtitle track:", error);
|
|
80723
|
+
return false;
|
|
80724
|
+
}
|
|
80725
|
+
}
|
|
80726
|
+
getSubtitleDisplay() {
|
|
80727
|
+
if (!this.hls) {
|
|
80728
|
+
console.warn("HLS instance not initialized");
|
|
80729
|
+
return false;
|
|
80730
|
+
}
|
|
80731
|
+
try {
|
|
80732
|
+
return this.hls.subtitleDisplay;
|
|
80733
|
+
} catch (error) {
|
|
80734
|
+
console.error("Failed to get subtitle display status:", error);
|
|
80735
|
+
return false;
|
|
80736
|
+
}
|
|
80737
|
+
}
|
|
80738
|
+
setSubtitleDisplay(enabled) {
|
|
80739
|
+
if (!this.hls) {
|
|
80740
|
+
console.warn("HLS instance not initialized");
|
|
80741
|
+
return false;
|
|
80742
|
+
}
|
|
80743
|
+
try {
|
|
80744
|
+
this.hls.subtitleDisplay = enabled;
|
|
80745
|
+
this.player.emit("core_event", {
|
|
80746
|
+
eventName: "core.subtitledisplaychange",
|
|
80747
|
+
enabled
|
|
80748
|
+
});
|
|
80749
|
+
return true;
|
|
80750
|
+
} catch (error) {
|
|
80751
|
+
console.error("Failed to set subtitle display:", error);
|
|
80752
|
+
return false;
|
|
80753
|
+
}
|
|
80754
|
+
}
|
|
80755
|
+
}
|
|
80308
80756
|
const MAX_HOLE = 0.1;
|
|
80309
80757
|
class XgHls extends BasePlugin$1 {
|
|
80310
80758
|
constructor(options) {
|
|
80311
|
-
super(
|
|
80759
|
+
super({
|
|
80760
|
+
...options,
|
|
80761
|
+
pluginName: XgHls.pluginName
|
|
80762
|
+
});
|
|
80312
80763
|
this._tickInterval = 500;
|
|
80764
|
+
this._currentIndex = 0;
|
|
80313
80765
|
this._onPlay = () => {
|
|
80314
80766
|
this.hls.startLoad();
|
|
80315
80767
|
};
|
|
@@ -80347,8 +80799,7 @@ class XgHls extends BasePlugin$1 {
|
|
|
80347
80799
|
var _a;
|
|
80348
80800
|
(_a = this.hls) == null ? void 0 : _a.on(eventName, func);
|
|
80349
80801
|
};
|
|
80350
|
-
|
|
80351
|
-
this.config = config2;
|
|
80802
|
+
this.config = options.config || {};
|
|
80352
80803
|
this.player.handleSource = false;
|
|
80353
80804
|
}
|
|
80354
80805
|
static get pluginName() {
|
|
@@ -80358,209 +80809,7 @@ class XgHls extends BasePlugin$1 {
|
|
|
80358
80809
|
this.register(this.player.config.url);
|
|
80359
80810
|
}
|
|
80360
80811
|
initEvt() {
|
|
80361
|
-
this.hls
|
|
80362
|
-
this.player.emit("core_event", {
|
|
80363
|
-
eventName: "core.subtitlesegments",
|
|
80364
|
-
list: frag
|
|
80365
|
-
});
|
|
80366
|
-
});
|
|
80367
|
-
this.hls.on(Hls.Events.MANIFEST_PARSED, (_, { levels }) => {
|
|
80368
|
-
this.player.emit("core_event", {
|
|
80369
|
-
eventName: "core.subtitleplaylist",
|
|
80370
|
-
list: levels
|
|
80371
|
-
});
|
|
80372
|
-
});
|
|
80373
|
-
this.hls.on(Hls.Events.MANIFEST_LOADING, (_, { url: url2 }) => {
|
|
80374
|
-
this.player.emit("core_event", {
|
|
80375
|
-
eventName: "core.loadstart",
|
|
80376
|
-
url: url2
|
|
80377
|
-
});
|
|
80378
|
-
});
|
|
80379
|
-
this.hls.on(Hls.Events.LEVEL_LOADING, (_, { url: url2 }) => {
|
|
80380
|
-
this.player.emit("core_event", {
|
|
80381
|
-
eventName: "core.loadstart",
|
|
80382
|
-
url: url2
|
|
80383
|
-
});
|
|
80384
|
-
});
|
|
80385
|
-
this.hls.on(Hls.Events.FRAG_LOADING, (_, { frag }) => {
|
|
80386
|
-
this.player.emit("core_event", {
|
|
80387
|
-
eventName: "core.loadstart",
|
|
80388
|
-
url: frag.url
|
|
80389
|
-
});
|
|
80390
|
-
});
|
|
80391
|
-
this.hls.on(Hls.Events.MANIFEST_LOADED, (_, data2) => {
|
|
80392
|
-
const { url: url2 } = data2;
|
|
80393
|
-
this.player.emit("core_event", {
|
|
80394
|
-
eventName: "core.loadcomplete",
|
|
80395
|
-
url: url2
|
|
80396
|
-
});
|
|
80397
|
-
});
|
|
80398
|
-
this.hls.on(Hls.Events.LEVEL_LOADED, (_, data2) => {
|
|
80399
|
-
const { details, stats } = data2;
|
|
80400
|
-
this.player.emit("core_event", {
|
|
80401
|
-
eventName: "core.loadcomplete",
|
|
80402
|
-
...stats,
|
|
80403
|
-
url: details == null ? void 0 : details.url
|
|
80404
|
-
});
|
|
80405
|
-
});
|
|
80406
|
-
this.hls.on(Hls.Events.FRAG_LOADED, (_, data2) => {
|
|
80407
|
-
const { frag } = data2;
|
|
80408
|
-
this.player.emit("core_event", {
|
|
80409
|
-
eventName: "core.loadcomplete",
|
|
80410
|
-
url: frag.url
|
|
80411
|
-
});
|
|
80412
|
-
});
|
|
80413
|
-
this.hls.on(Hls.Events.FRAG_PARSING_USERDATA, (_, { samples }) => {
|
|
80414
|
-
this.player.emit("core_event", {
|
|
80415
|
-
eventName: "core.sei",
|
|
80416
|
-
sei: samples
|
|
80417
|
-
});
|
|
80418
|
-
});
|
|
80419
|
-
this.hls.on(Hls.Events.MANIFEST_LOADED, (_, { levels, networkDetails }) => {
|
|
80420
|
-
this.player.emit("core_event", {
|
|
80421
|
-
eventName: "core.hlsmanifestloaded",
|
|
80422
|
-
playlist: levels
|
|
80423
|
-
});
|
|
80424
|
-
this.player.emit("core_event", {
|
|
80425
|
-
eventName: "core.loadresponseheaders",
|
|
80426
|
-
headers: networkDetails.headers
|
|
80427
|
-
});
|
|
80428
|
-
});
|
|
80429
|
-
this.hls.on(Hls.Events.LEVEL_LOADED, (_, { details }) => {
|
|
80430
|
-
const dateRanges = {};
|
|
80431
|
-
Object.keys(details.dateRanges).forEach((key2) => {
|
|
80432
|
-
dateRanges[key2] = details.dateRanges[key2].attr["START-DATE"];
|
|
80433
|
-
});
|
|
80434
|
-
this.player.emit("core_event", {
|
|
80435
|
-
eventName: "core.hlslevelloaded",
|
|
80436
|
-
playlist: {
|
|
80437
|
-
...details,
|
|
80438
|
-
segments: details.fragments,
|
|
80439
|
-
dateRanges
|
|
80440
|
-
}
|
|
80441
|
-
});
|
|
80442
|
-
});
|
|
80443
|
-
this.hls.on(Hls.Events.ERROR, (_, data2) => {
|
|
80444
|
-
const { details, fatal, type, response, reason, error } = data2;
|
|
80445
|
-
if (!fatal) {
|
|
80446
|
-
return;
|
|
80447
|
-
}
|
|
80448
|
-
let errorCode;
|
|
80449
|
-
let errorType;
|
|
80450
|
-
switch (type) {
|
|
80451
|
-
case Hls.ErrorTypes.NETWORK_ERROR:
|
|
80452
|
-
errorCode = 2100;
|
|
80453
|
-
if (details.includes("TimeOut")) {
|
|
80454
|
-
errorCode = 2101;
|
|
80455
|
-
} else if ((response == null ? void 0 : response.code) === 403) {
|
|
80456
|
-
errorCode = 2103;
|
|
80457
|
-
} else if ((response == null ? void 0 : response.code) === 404) {
|
|
80458
|
-
errorCode = 2104;
|
|
80459
|
-
}
|
|
80460
|
-
this.player.emit("error", {
|
|
80461
|
-
errorType: "network",
|
|
80462
|
-
errorCode,
|
|
80463
|
-
message: (error == null ? void 0 : error.message) || details,
|
|
80464
|
-
originError: data2
|
|
80465
|
-
});
|
|
80466
|
-
break;
|
|
80467
|
-
case Hls.ErrorTypes.MEDIA_ERROR:
|
|
80468
|
-
errorType = "media";
|
|
80469
|
-
if (details === Hls.ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR) {
|
|
80470
|
-
errorCode = 5104;
|
|
80471
|
-
} else if (details === Hls.ErrorDetails.FRAG_DECRYPT_ERROR) {
|
|
80472
|
-
errorCode = 5105;
|
|
80473
|
-
} else if (details === Hls.ErrorDetails.FRAG_PARSING_ERROR) {
|
|
80474
|
-
errorCode = 1100;
|
|
80475
|
-
errorType = "manifest";
|
|
80476
|
-
} else if (details === Hls.ErrorDetails.FRAG_GAP) {
|
|
80477
|
-
errorCode = 5104;
|
|
80478
|
-
} else if (details === Hls.ErrorDetails.BUFFER_ADD_CODEC_ERROR) {
|
|
80479
|
-
errorCode = 5200;
|
|
80480
|
-
} else if (details === Hls.ErrorDetails.BUFFER_INCOMPATIBLE_CODECS_ERROR) {
|
|
80481
|
-
errorCode = 5104;
|
|
80482
|
-
} else if (details === Hls.ErrorDetails.BUFFER_APPEND_ERROR) {
|
|
80483
|
-
errorCode = 5201;
|
|
80484
|
-
} else if (details === Hls.ErrorDetails.BUFFER_APPENDING_ERROR) {
|
|
80485
|
-
errorCode = 5201;
|
|
80486
|
-
} else if (details === Hls.ErrorDetails.BUFFER_STALLED_ERROR) {
|
|
80487
|
-
errorCode = 5203;
|
|
80488
|
-
} else if (details === Hls.ErrorDetails.BUFFER_FULL_ERROR) {
|
|
80489
|
-
errorCode = 5203;
|
|
80490
|
-
} else if (details === Hls.ErrorDetails.BUFFER_SEEK_OVER_HOLE) {
|
|
80491
|
-
errorCode = 5202;
|
|
80492
|
-
} else if (details === Hls.ErrorDetails.BUFFER_NUDGE_ON_STALL) {
|
|
80493
|
-
errorCode = 5202;
|
|
80494
|
-
}
|
|
80495
|
-
this.player.emit("error", {
|
|
80496
|
-
errorType: errorType || type,
|
|
80497
|
-
errorCode,
|
|
80498
|
-
message: (error == null ? void 0 : error.message) || details,
|
|
80499
|
-
originError: data2
|
|
80500
|
-
});
|
|
80501
|
-
break;
|
|
80502
|
-
case Hls.ErrorTypes.MUX_ERROR:
|
|
80503
|
-
errorCode = 4100;
|
|
80504
|
-
this.player.emit("error", {
|
|
80505
|
-
errorType: "remux",
|
|
80506
|
-
errorCode,
|
|
80507
|
-
message: (error == null ? void 0 : error.message) || details,
|
|
80508
|
-
originError: data2
|
|
80509
|
-
});
|
|
80510
|
-
break;
|
|
80511
|
-
case Hls.ErrorTypes.KEY_SYSTEM_ERROR:
|
|
80512
|
-
errorCode = 7111;
|
|
80513
|
-
if (details === Hls.ErrorDetails.KEY_SYSTEM_NO_KEYS) {
|
|
80514
|
-
errorCode = 7103;
|
|
80515
|
-
} else if (details === Hls.ErrorDetails.KEY_SYSTEM_NO_ACCESS) {
|
|
80516
|
-
errorCode = 7101;
|
|
80517
|
-
} else if (details === Hls.ErrorDetails.KEY_SYSTEM_NO_SESSION) {
|
|
80518
|
-
errorCode = 7104;
|
|
80519
|
-
} else if (details === Hls.ErrorDetails.KEY_SYSTEM_NO_CONFIGURED_LICENSE) {
|
|
80520
|
-
errorCode = 7107;
|
|
80521
|
-
} else if (details === Hls.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED) {
|
|
80522
|
-
errorCode = 7108;
|
|
80523
|
-
} else if (details === Hls.ErrorDetails.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED) {
|
|
80524
|
-
errorCode = 7110;
|
|
80525
|
-
} else if (details === Hls.ErrorDetails.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED) {
|
|
80526
|
-
errorCode = 7110;
|
|
80527
|
-
} else if (details === Hls.ErrorDetails.KEY_SYSTEM_SESSION_UPDATE_FAILED) {
|
|
80528
|
-
errorCode = 7104;
|
|
80529
|
-
} else if (details === Hls.ErrorDetails.KEY_SYSTEM_STATUS_INTERNAL_ERROR) {
|
|
80530
|
-
errorCode = 7111;
|
|
80531
|
-
}
|
|
80532
|
-
this.player.emit("error", {
|
|
80533
|
-
errorType: "drm",
|
|
80534
|
-
errorCode,
|
|
80535
|
-
message: (error == null ? void 0 : error.message) || reason || details,
|
|
80536
|
-
originError: data2
|
|
80537
|
-
});
|
|
80538
|
-
break;
|
|
80539
|
-
default:
|
|
80540
|
-
if (details === Hls.ErrorDetails.LEVEL_SWITCH_ERROR) {
|
|
80541
|
-
errorCode = 2100;
|
|
80542
|
-
errorType = "network";
|
|
80543
|
-
}
|
|
80544
|
-
this.player.emit("error", {
|
|
80545
|
-
errorType: errorType || "other",
|
|
80546
|
-
errorCode,
|
|
80547
|
-
message: (error == null ? void 0 : error.message) || reason || details,
|
|
80548
|
-
originError: data2
|
|
80549
|
-
});
|
|
80550
|
-
break;
|
|
80551
|
-
}
|
|
80552
|
-
try {
|
|
80553
|
-
this.hls.stopLoad();
|
|
80554
|
-
this.player.pause();
|
|
80555
|
-
} catch (error2) {
|
|
80556
|
-
}
|
|
80557
|
-
});
|
|
80558
|
-
this.hls.on(Hls.Events.MEDIA_ATTACHED, () => {
|
|
80559
|
-
this.player.emit("sourceopen");
|
|
80560
|
-
});
|
|
80561
|
-
this.hls.on(Hls.Events.BUFFER_APPENDED, () => {
|
|
80562
|
-
this.player.emit("bufferappend");
|
|
80563
|
-
});
|
|
80812
|
+
initHlsEvents(this.hls, this.player);
|
|
80564
80813
|
}
|
|
80565
80814
|
afterCreate() {
|
|
80566
80815
|
const media = this.player.media;
|
|
@@ -80586,8 +80835,9 @@ class XgHls extends BasePlugin$1 {
|
|
|
80586
80835
|
if (this.hls) {
|
|
80587
80836
|
this.hls.destroy();
|
|
80588
80837
|
}
|
|
80589
|
-
const hlsConfig = getHlsConfig(this.config
|
|
80838
|
+
const hlsConfig = getHlsConfig(this.config);
|
|
80590
80839
|
this.hls = new Hls(hlsConfig);
|
|
80840
|
+
this._trackManager = new TrackManager(this.hls, this.player);
|
|
80591
80841
|
this.initEvt();
|
|
80592
80842
|
if (player.config.preProcessUrl) {
|
|
80593
80843
|
const { url: newUrl } = player.config.preProcessUrl(url2);
|
|
@@ -80601,10 +80851,47 @@ class XgHls extends BasePlugin$1 {
|
|
|
80601
80851
|
media.removeEventListener("play", this._onPlay);
|
|
80602
80852
|
media.addEventListener("play", this._onPlay);
|
|
80603
80853
|
}
|
|
80854
|
+
switchUrl(url2, { startTime, bitrate, seamless }) {
|
|
80855
|
+
this.hls.loadSource(url2);
|
|
80856
|
+
if (startTime !== void 0) {
|
|
80857
|
+
const media = this.player.media;
|
|
80858
|
+
media.currentTime = startTime;
|
|
80859
|
+
}
|
|
80860
|
+
}
|
|
80861
|
+
// Audio Track Methods
|
|
80862
|
+
getAudioTracks() {
|
|
80863
|
+
return this._trackManager.getAudioTracks();
|
|
80864
|
+
}
|
|
80865
|
+
getCurrentAudioTrack() {
|
|
80866
|
+
return this._trackManager.getCurrentAudioTrack();
|
|
80867
|
+
}
|
|
80868
|
+
switchAudioTrack(trackId) {
|
|
80869
|
+
return this._trackManager.switchAudioTrack(trackId);
|
|
80870
|
+
}
|
|
80871
|
+
// Subtitle Track Methods
|
|
80872
|
+
getSubtitleTracks() {
|
|
80873
|
+
return this._trackManager.getSubtitleTracks();
|
|
80874
|
+
}
|
|
80875
|
+
getAllSubtitleTracks() {
|
|
80876
|
+
return this._trackManager.getAllSubtitleTracks();
|
|
80877
|
+
}
|
|
80878
|
+
getCurrentSubtitleTrack() {
|
|
80879
|
+
return this._trackManager.getCurrentSubtitleTrack();
|
|
80880
|
+
}
|
|
80881
|
+
switchSubtitleTrack(trackId) {
|
|
80882
|
+
return this._trackManager.switchSubtitleTrack(trackId);
|
|
80883
|
+
}
|
|
80884
|
+
getSubtitleDisplay() {
|
|
80885
|
+
return this._trackManager.getSubtitleDisplay();
|
|
80886
|
+
}
|
|
80887
|
+
setSubtitleDisplay(enabled) {
|
|
80888
|
+
return this._trackManager.setSubtitleDisplay(enabled);
|
|
80889
|
+
}
|
|
80604
80890
|
destroy() {
|
|
80891
|
+
var _a;
|
|
80605
80892
|
clearTimeout(this._tickTimer);
|
|
80606
80893
|
this.player.off(URL_CHANGE, this.onUrlChange);
|
|
80607
|
-
this.hls.destroy();
|
|
80894
|
+
(_a = this.hls) == null ? void 0 : _a.destroy();
|
|
80608
80895
|
}
|
|
80609
80896
|
}
|
|
80610
80897
|
class HlsPlugin extends XgHls {
|