@byteplus/veplayer-plugin 2.11.0-rc.0 → 2.11.0-rc.1
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
|
@@ -33346,6 +33346,9 @@ function isHeyTapBrowser() {
|
|
|
33346
33346
|
function isVivoBrowser() {
|
|
33347
33347
|
return /(VivoBrowser)/i.test(navigator.userAgent);
|
|
33348
33348
|
}
|
|
33349
|
+
function isPositiveNumber(num) {
|
|
33350
|
+
return typeof num === "number" && num > 0;
|
|
33351
|
+
}
|
|
33349
33352
|
var VideoFrameRecvCallback = /* @__PURE__ */ function() {
|
|
33350
33353
|
function VideoFrameRecvCallback2() {
|
|
33351
33354
|
var _this = this;
|
|
@@ -33436,7 +33439,8 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
|
|
|
33436
33439
|
clearTimeout(_this._checkStatsErrorTimer);
|
|
33437
33440
|
}
|
|
33438
33441
|
_this._checkStatsErrorTimer = setTimeout(/* @__PURE__ */ _asyncToGenerator$a(/* @__PURE__ */ _regeneratorRuntime$a().mark(function _callee() {
|
|
33439
|
-
var
|
|
33442
|
+
var _stats$video, _stats$audio, _stats$video2, _stats$video3;
|
|
33443
|
+
var stats;
|
|
33440
33444
|
return _regeneratorRuntime$a().wrap(function _callee$(_context) {
|
|
33441
33445
|
while (1)
|
|
33442
33446
|
switch (_context.prev = _context.next) {
|
|
@@ -33445,19 +33449,17 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
|
|
|
33445
33449
|
return _this.getStatsSnapshoot();
|
|
33446
33450
|
case 2:
|
|
33447
33451
|
stats = _context.sent;
|
|
33448
|
-
if (stats.video) {
|
|
33449
|
-
|
|
33450
|
-
|
|
33451
|
-
|
|
33452
|
-
message: "rts receive empty"
|
|
33453
|
-
}));
|
|
33454
|
-
} else if (!framesDecoded) {
|
|
33455
|
-
_this._emitError(StreamingError$2.create(ERR$2.MEDIA, ERR$2.SUB_TYPES.MEDIA_ERR_DECODE, {
|
|
33456
|
-
message: "rts decode error"
|
|
33457
|
-
}));
|
|
33458
|
-
}
|
|
33452
|
+
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)) {
|
|
33453
|
+
_this._emitError(StreamingError$2.create(ERR$2.MEDIA, ERR$2.SUB_TYPES.MEDIA_ERR_DECODE, {
|
|
33454
|
+
message: "rts receive empty"
|
|
33455
|
+
}));
|
|
33459
33456
|
}
|
|
33460
|
-
|
|
33457
|
+
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)) {
|
|
33458
|
+
_this._emitError(StreamingError$2.create(ERR$2.MEDIA, ERR$2.SUB_TYPES.MEDIA_ERR_DECODE, {
|
|
33459
|
+
message: "rts decode error"
|
|
33460
|
+
}));
|
|
33461
|
+
}
|
|
33462
|
+
case 5:
|
|
33461
33463
|
case "end":
|
|
33462
33464
|
return _context.stop();
|
|
33463
33465
|
}
|
|
@@ -33875,6 +33877,7 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
|
|
|
33875
33877
|
value: function _bindRTCEvents(pc) {
|
|
33876
33878
|
var _this3 = this;
|
|
33877
33879
|
pc.addEventListener("track", this._onTrack);
|
|
33880
|
+
var firstConnect = true;
|
|
33878
33881
|
pc.addEventListener("connectionstatechange", function() {
|
|
33879
33882
|
logger$b.warn("onconnectionstatechange:", pc.connectionState);
|
|
33880
33883
|
_this3._clearPeerStateTimeout();
|
|
@@ -33882,26 +33885,31 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
|
|
|
33882
33885
|
state: pc.connectionState,
|
|
33883
33886
|
url: _this3._url
|
|
33884
33887
|
});
|
|
33885
|
-
if (pc.connectionState === "disconnected" || pc.connectionState === "failed") {
|
|
33886
|
-
_this3.emit("waiting");
|
|
33887
|
-
_this3._stopRtcReport();
|
|
33888
|
-
}
|
|
33889
33888
|
if (pc.connectionState === "failed") {
|
|
33889
|
+
var _this3$_preAudioStats, _this3$_preVideoStats;
|
|
33890
|
+
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";
|
|
33890
33891
|
if (_this3._retry === 0) {
|
|
33891
|
-
_this3._emitError(StreamingError$2.network(new Error(
|
|
33892
|
+
_this3._emitError(StreamingError$2.network(new Error(reason)));
|
|
33892
33893
|
return;
|
|
33893
33894
|
}
|
|
33894
33895
|
_this3._retry--;
|
|
33895
|
-
_this3.load(_this3._url,
|
|
33896
|
+
_this3.load(_this3._url, reason);
|
|
33897
|
+
}
|
|
33898
|
+
if (pc.connectionState === "disconnected" || pc.connectionState === "failed") {
|
|
33899
|
+
_this3.emit("waiting");
|
|
33900
|
+
_this3._stopRtcReport();
|
|
33896
33901
|
}
|
|
33897
33902
|
if (pc.connectionState === "connected") {
|
|
33898
|
-
|
|
33899
|
-
|
|
33900
|
-
|
|
33901
|
-
|
|
33902
|
-
|
|
33903
|
-
|
|
33904
|
-
|
|
33903
|
+
if (firstConnect) {
|
|
33904
|
+
firstConnect = false;
|
|
33905
|
+
_this3._handleMediaStream();
|
|
33906
|
+
_this3.emit(EVENT$2.TTFB, {
|
|
33907
|
+
url: _this3._url,
|
|
33908
|
+
responseUrl: _this3._url,
|
|
33909
|
+
elapsed: Date.now() - _this3._rctConnectStartTs
|
|
33910
|
+
});
|
|
33911
|
+
_this3._checkStatsError();
|
|
33912
|
+
}
|
|
33905
33913
|
_this3._startRtcReport();
|
|
33906
33914
|
}
|
|
33907
33915
|
});
|
|
@@ -34472,6 +34480,7 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
|
|
|
34472
34480
|
this._firstFrameObserver.reset();
|
|
34473
34481
|
this.emit(EVENT$2.ERROR, error);
|
|
34474
34482
|
clearTimeout(this._checkStatsErrorTimer);
|
|
34483
|
+
this._stopRtcReport();
|
|
34475
34484
|
this._clearPeerStateTimeout();
|
|
34476
34485
|
if (this._pc) {
|
|
34477
34486
|
this._pc.close();
|
|
@@ -34731,7 +34740,7 @@ var RtsPlugin = /* @__PURE__ */ function(_BasePlugin) {
|
|
|
34731
34740
|
}, {
|
|
34732
34741
|
key: "version",
|
|
34733
34742
|
get: function get4() {
|
|
34734
|
-
return "0.2.1-alpha.
|
|
34743
|
+
return "0.2.1-alpha.57";
|
|
34735
34744
|
}
|
|
34736
34745
|
}, {
|
|
34737
34746
|
key: "beforePlayerInit",
|
|
@@ -80438,7 +80447,7 @@ class Hls {
|
|
|
80438
80447
|
}
|
|
80439
80448
|
}
|
|
80440
80449
|
Hls.defaultConfig = void 0;
|
|
80441
|
-
const
|
|
80450
|
+
const OPTIONS_MAP = {
|
|
80442
80451
|
liveSyncDuration: {
|
|
80443
80452
|
key: "targetLatency",
|
|
80444
80453
|
val: 10
|
|
@@ -80455,20 +80464,40 @@ const optionsMap = {
|
|
|
80455
80464
|
key: "minSegmentsStartPlay",
|
|
80456
80465
|
val: 3
|
|
80457
80466
|
},
|
|
80458
|
-
preferManagedMediaSource:
|
|
80459
|
-
|
|
80460
|
-
|
|
80461
|
-
|
|
80467
|
+
preferManagedMediaSource: [
|
|
80468
|
+
{
|
|
80469
|
+
key: "preferMMS",
|
|
80470
|
+
val: false
|
|
80471
|
+
},
|
|
80472
|
+
{
|
|
80473
|
+
key: "preferMMSStreaming",
|
|
80474
|
+
val: false
|
|
80475
|
+
}
|
|
80476
|
+
],
|
|
80462
80477
|
lowLatencyMode: {
|
|
80463
80478
|
key: "useLowLatency",
|
|
80464
80479
|
val: true
|
|
80480
|
+
},
|
|
80481
|
+
startPosition: {
|
|
80482
|
+
key: "startTime",
|
|
80483
|
+
val: 0
|
|
80484
|
+
},
|
|
80485
|
+
interstitialLiveLookAhead: {
|
|
80486
|
+
key: "preloadTime",
|
|
80487
|
+
val: 30
|
|
80465
80488
|
}
|
|
80466
80489
|
};
|
|
80467
|
-
function getHlsConfig(config2
|
|
80490
|
+
function getHlsConfig(config2) {
|
|
80468
80491
|
const hlsConfig = {};
|
|
80469
|
-
Object.keys(
|
|
80470
|
-
const tmp =
|
|
80471
|
-
|
|
80492
|
+
Object.keys(OPTIONS_MAP).forEach((keyStr) => {
|
|
80493
|
+
const tmp = OPTIONS_MAP[keyStr];
|
|
80494
|
+
if (tmp instanceof Array) {
|
|
80495
|
+
tmp.forEach((item) => {
|
|
80496
|
+
hlsConfig[keyStr] = item.val;
|
|
80497
|
+
});
|
|
80498
|
+
} else {
|
|
80499
|
+
hlsConfig[keyStr] = config2[tmp.key] || tmp.val;
|
|
80500
|
+
}
|
|
80472
80501
|
});
|
|
80473
80502
|
const maxNumRetry = typeof config2.retryCount === "number" ? config2.retryCount : 3;
|
|
80474
80503
|
const retryDelayMs = typeof config2.retryDelay === "number" ? config2.retryDelay : 1e3;
|
|
@@ -80519,11 +80548,434 @@ function getHlsConfig(config2, playerConfig) {
|
|
|
80519
80548
|
...config2
|
|
80520
80549
|
};
|
|
80521
80550
|
}
|
|
80551
|
+
function initHlsEvents(hls, player) {
|
|
80552
|
+
hls.on(Hls.Events.SUBTITLE_FRAG_PROCESSED, (_, { frag }) => {
|
|
80553
|
+
player.emit("core_event", {
|
|
80554
|
+
eventName: "core.subtitlesegments",
|
|
80555
|
+
list: frag
|
|
80556
|
+
});
|
|
80557
|
+
});
|
|
80558
|
+
hls.on(Hls.Events.MANIFEST_PARSED, (_, { levels }) => {
|
|
80559
|
+
player.emit("core_event", {
|
|
80560
|
+
eventName: "core.subtitleplaylist",
|
|
80561
|
+
list: levels
|
|
80562
|
+
});
|
|
80563
|
+
});
|
|
80564
|
+
hls.on(Hls.Events.MANIFEST_LOADING, (_, { url: url2 }) => {
|
|
80565
|
+
player.emit("core_event", {
|
|
80566
|
+
eventName: "core.loadstart",
|
|
80567
|
+
url: url2
|
|
80568
|
+
});
|
|
80569
|
+
});
|
|
80570
|
+
hls.on(Hls.Events.LEVEL_LOADING, (_, { url: url2 }) => {
|
|
80571
|
+
player.emit("core_event", {
|
|
80572
|
+
eventName: "core.loadstart",
|
|
80573
|
+
url: url2
|
|
80574
|
+
});
|
|
80575
|
+
});
|
|
80576
|
+
hls.on(Hls.Events.FRAG_LOADING, (_, { frag }) => {
|
|
80577
|
+
player.emit("core_event", {
|
|
80578
|
+
eventName: "core.loadstart",
|
|
80579
|
+
url: frag.url
|
|
80580
|
+
});
|
|
80581
|
+
});
|
|
80582
|
+
hls.on(Hls.Events.MANIFEST_LOADED, (_, data2) => {
|
|
80583
|
+
const { url: url2 } = data2;
|
|
80584
|
+
player.emit("core_event", {
|
|
80585
|
+
eventName: "core.loadcomplete",
|
|
80586
|
+
url: url2
|
|
80587
|
+
});
|
|
80588
|
+
});
|
|
80589
|
+
hls.on(Hls.Events.LEVEL_LOADED, (_, data2) => {
|
|
80590
|
+
const { details, stats } = data2;
|
|
80591
|
+
player.emit("core_event", {
|
|
80592
|
+
eventName: "core.loadcomplete",
|
|
80593
|
+
...stats,
|
|
80594
|
+
url: details == null ? void 0 : details.url
|
|
80595
|
+
});
|
|
80596
|
+
});
|
|
80597
|
+
hls.on(Hls.Events.FRAG_LOADED, (_, data2) => {
|
|
80598
|
+
const { frag } = data2;
|
|
80599
|
+
player.emit("core_event", {
|
|
80600
|
+
eventName: "core.loadcomplete",
|
|
80601
|
+
url: frag.url
|
|
80602
|
+
});
|
|
80603
|
+
});
|
|
80604
|
+
hls.on(Hls.Events.FRAG_PARSING_USERDATA, (_, { samples }) => {
|
|
80605
|
+
player.emit("core_event", {
|
|
80606
|
+
eventName: "core.sei",
|
|
80607
|
+
sei: samples
|
|
80608
|
+
});
|
|
80609
|
+
});
|
|
80610
|
+
hls.on(Hls.Events.MANIFEST_LOADED, (_, { levels, networkDetails }) => {
|
|
80611
|
+
player.emit("core_event", {
|
|
80612
|
+
eventName: "core.hlsmanifestloaded",
|
|
80613
|
+
playlist: levels
|
|
80614
|
+
});
|
|
80615
|
+
player.emit("core_event", {
|
|
80616
|
+
eventName: "core.loadresponseheaders",
|
|
80617
|
+
headers: networkDetails.headers
|
|
80618
|
+
});
|
|
80619
|
+
});
|
|
80620
|
+
hls.on(Hls.Events.LEVEL_LOADED, (_, { details }) => {
|
|
80621
|
+
const dateRanges = {};
|
|
80622
|
+
Object.keys(details.dateRanges).forEach((key2) => {
|
|
80623
|
+
dateRanges[key2] = details.dateRanges[key2].attr["START-DATE"];
|
|
80624
|
+
});
|
|
80625
|
+
player.emit("core_event", {
|
|
80626
|
+
eventName: "core.hlslevelloaded",
|
|
80627
|
+
playlist: {
|
|
80628
|
+
...details,
|
|
80629
|
+
segments: details.fragments,
|
|
80630
|
+
dateRanges
|
|
80631
|
+
}
|
|
80632
|
+
});
|
|
80633
|
+
});
|
|
80634
|
+
hls.on(Hls.Events.ERROR, (_, data2) => {
|
|
80635
|
+
const { details, fatal, type, response, reason, error } = data2;
|
|
80636
|
+
if (!fatal) {
|
|
80637
|
+
return;
|
|
80638
|
+
}
|
|
80639
|
+
let errorCode;
|
|
80640
|
+
let errorType;
|
|
80641
|
+
switch (type) {
|
|
80642
|
+
case Hls.ErrorTypes.NETWORK_ERROR:
|
|
80643
|
+
errorCode = 2100;
|
|
80644
|
+
if (details.includes("TimeOut")) {
|
|
80645
|
+
errorCode = 2101;
|
|
80646
|
+
} else if ((response == null ? void 0 : response.code) === 403) {
|
|
80647
|
+
errorCode = 2103;
|
|
80648
|
+
} else if ((response == null ? void 0 : response.code) === 404) {
|
|
80649
|
+
errorCode = 2104;
|
|
80650
|
+
}
|
|
80651
|
+
player.emit("error", {
|
|
80652
|
+
errorType: "network",
|
|
80653
|
+
errorCode,
|
|
80654
|
+
message: (error == null ? void 0 : error.message) || details,
|
|
80655
|
+
originError: data2
|
|
80656
|
+
});
|
|
80657
|
+
break;
|
|
80658
|
+
case Hls.ErrorTypes.MEDIA_ERROR:
|
|
80659
|
+
errorType = "media";
|
|
80660
|
+
if (details === Hls.ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR) {
|
|
80661
|
+
errorCode = 5104;
|
|
80662
|
+
} else if (details === Hls.ErrorDetails.FRAG_DECRYPT_ERROR) {
|
|
80663
|
+
errorCode = 5105;
|
|
80664
|
+
} else if (details === Hls.ErrorDetails.FRAG_PARSING_ERROR) {
|
|
80665
|
+
errorCode = 1100;
|
|
80666
|
+
errorType = "manifest";
|
|
80667
|
+
} else if (details === Hls.ErrorDetails.FRAG_GAP) {
|
|
80668
|
+
errorCode = 5104;
|
|
80669
|
+
} else if (details === Hls.ErrorDetails.BUFFER_ADD_CODEC_ERROR) {
|
|
80670
|
+
errorCode = 5200;
|
|
80671
|
+
} else if (details === Hls.ErrorDetails.BUFFER_INCOMPATIBLE_CODECS_ERROR) {
|
|
80672
|
+
errorCode = 5104;
|
|
80673
|
+
} else if (details === Hls.ErrorDetails.BUFFER_APPEND_ERROR) {
|
|
80674
|
+
errorCode = 5201;
|
|
80675
|
+
} else if (details === Hls.ErrorDetails.BUFFER_APPENDING_ERROR) {
|
|
80676
|
+
errorCode = 5201;
|
|
80677
|
+
} else if (details === Hls.ErrorDetails.BUFFER_STALLED_ERROR) {
|
|
80678
|
+
errorCode = 5203;
|
|
80679
|
+
} else if (details === Hls.ErrorDetails.BUFFER_FULL_ERROR) {
|
|
80680
|
+
errorCode = 5203;
|
|
80681
|
+
} else if (details === Hls.ErrorDetails.BUFFER_SEEK_OVER_HOLE) {
|
|
80682
|
+
errorCode = 5202;
|
|
80683
|
+
} else if (details === Hls.ErrorDetails.BUFFER_NUDGE_ON_STALL) {
|
|
80684
|
+
errorCode = 5202;
|
|
80685
|
+
}
|
|
80686
|
+
player.emit("error", {
|
|
80687
|
+
errorType: errorType || type,
|
|
80688
|
+
errorCode,
|
|
80689
|
+
message: (error == null ? void 0 : error.message) || details,
|
|
80690
|
+
originError: data2
|
|
80691
|
+
});
|
|
80692
|
+
break;
|
|
80693
|
+
case Hls.ErrorTypes.MUX_ERROR:
|
|
80694
|
+
errorCode = 4100;
|
|
80695
|
+
player.emit("error", {
|
|
80696
|
+
errorType: "remux",
|
|
80697
|
+
errorCode,
|
|
80698
|
+
message: (error == null ? void 0 : error.message) || details,
|
|
80699
|
+
originError: data2
|
|
80700
|
+
});
|
|
80701
|
+
break;
|
|
80702
|
+
case Hls.ErrorTypes.KEY_SYSTEM_ERROR:
|
|
80703
|
+
errorCode = 7111;
|
|
80704
|
+
if (details === Hls.ErrorDetails.KEY_SYSTEM_NO_KEYS) {
|
|
80705
|
+
errorCode = 7103;
|
|
80706
|
+
} else if (details === Hls.ErrorDetails.KEY_SYSTEM_NO_ACCESS) {
|
|
80707
|
+
errorCode = 7101;
|
|
80708
|
+
} else if (details === Hls.ErrorDetails.KEY_SYSTEM_NO_SESSION) {
|
|
80709
|
+
errorCode = 7104;
|
|
80710
|
+
} else if (details === Hls.ErrorDetails.KEY_SYSTEM_NO_CONFIGURED_LICENSE) {
|
|
80711
|
+
errorCode = 7107;
|
|
80712
|
+
} else if (details === Hls.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED) {
|
|
80713
|
+
errorCode = 7108;
|
|
80714
|
+
} else if (details === Hls.ErrorDetails.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED) {
|
|
80715
|
+
errorCode = 7110;
|
|
80716
|
+
} else if (details === Hls.ErrorDetails.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED) {
|
|
80717
|
+
errorCode = 7110;
|
|
80718
|
+
} else if (details === Hls.ErrorDetails.KEY_SYSTEM_SESSION_UPDATE_FAILED) {
|
|
80719
|
+
errorCode = 7104;
|
|
80720
|
+
} else if (details === Hls.ErrorDetails.KEY_SYSTEM_STATUS_INTERNAL_ERROR) {
|
|
80721
|
+
errorCode = 7111;
|
|
80722
|
+
}
|
|
80723
|
+
player.emit("error", {
|
|
80724
|
+
errorType: "drm",
|
|
80725
|
+
errorCode,
|
|
80726
|
+
message: (error == null ? void 0 : error.message) || reason || details,
|
|
80727
|
+
originError: data2
|
|
80728
|
+
});
|
|
80729
|
+
break;
|
|
80730
|
+
default:
|
|
80731
|
+
if (details === Hls.ErrorDetails.LEVEL_SWITCH_ERROR) {
|
|
80732
|
+
errorCode = 2100;
|
|
80733
|
+
errorType = "network";
|
|
80734
|
+
}
|
|
80735
|
+
player.emit("error", {
|
|
80736
|
+
errorType: errorType || "other",
|
|
80737
|
+
errorCode,
|
|
80738
|
+
message: (error == null ? void 0 : error.message) || reason || details,
|
|
80739
|
+
originError: data2
|
|
80740
|
+
});
|
|
80741
|
+
break;
|
|
80742
|
+
}
|
|
80743
|
+
try {
|
|
80744
|
+
hls.stopLoad();
|
|
80745
|
+
player.pause();
|
|
80746
|
+
} catch (error2) {
|
|
80747
|
+
}
|
|
80748
|
+
});
|
|
80749
|
+
hls.on(Hls.Events.MEDIA_ATTACHED, () => {
|
|
80750
|
+
player.emit("sourceopen");
|
|
80751
|
+
});
|
|
80752
|
+
hls.on(Hls.Events.BUFFER_APPENDED, () => {
|
|
80753
|
+
player.emit("bufferappend");
|
|
80754
|
+
});
|
|
80755
|
+
hls.on(Hls.Events.AUDIO_TRACKS_UPDATED, (_, { audioTracks }) => {
|
|
80756
|
+
player.emit("core_event", {
|
|
80757
|
+
eventName: "core.audiotracksupdate",
|
|
80758
|
+
audioTracks
|
|
80759
|
+
});
|
|
80760
|
+
});
|
|
80761
|
+
hls.on(Hls.Events.AUDIO_TRACK_SWITCHING, (_, data2) => {
|
|
80762
|
+
player.emit("core_event", {
|
|
80763
|
+
eventName: "core.audiotrackswitching",
|
|
80764
|
+
...data2
|
|
80765
|
+
});
|
|
80766
|
+
});
|
|
80767
|
+
hls.on(Hls.Events.AUDIO_TRACK_SWITCHED, (_, data2) => {
|
|
80768
|
+
player.emit("core_event", {
|
|
80769
|
+
eventName: "core.audiotrackswitched",
|
|
80770
|
+
...data2
|
|
80771
|
+
});
|
|
80772
|
+
});
|
|
80773
|
+
hls.on(Hls.Events.SUBTITLE_TRACKS_UPDATED, (_, { subtitleTracks }) => {
|
|
80774
|
+
player.emit("core_event", {
|
|
80775
|
+
eventName: "core.subtitletracksupdate",
|
|
80776
|
+
subtitleTracks
|
|
80777
|
+
});
|
|
80778
|
+
});
|
|
80779
|
+
hls.on(Hls.Events.SUBTITLE_TRACKS_CLEARED, () => {
|
|
80780
|
+
player.emit("core_event", {
|
|
80781
|
+
eventName: "core.subtitletracksclear"
|
|
80782
|
+
});
|
|
80783
|
+
});
|
|
80784
|
+
hls.on(Hls.Events.SUBTITLE_TRACK_SWITCH, (_, data2) => {
|
|
80785
|
+
player.emit("core_event", {
|
|
80786
|
+
eventName: "core.subtitletrackswitch",
|
|
80787
|
+
...data2
|
|
80788
|
+
});
|
|
80789
|
+
});
|
|
80790
|
+
hls.on(Hls.Events.SUBTITLE_TRACK_LOADING, (_, data2) => {
|
|
80791
|
+
player.emit("core_event", {
|
|
80792
|
+
eventName: "core.subtitletrackloading",
|
|
80793
|
+
...data2
|
|
80794
|
+
});
|
|
80795
|
+
});
|
|
80796
|
+
hls.on(Hls.Events.SUBTITLE_TRACK_LOADED, (_, data2) => {
|
|
80797
|
+
player.emit("core_event", {
|
|
80798
|
+
eventName: "core.subtitletrackloaded",
|
|
80799
|
+
...data2
|
|
80800
|
+
});
|
|
80801
|
+
});
|
|
80802
|
+
}
|
|
80803
|
+
class TrackManager {
|
|
80804
|
+
constructor(hls, player) {
|
|
80805
|
+
this.hls = hls;
|
|
80806
|
+
this.player = player;
|
|
80807
|
+
}
|
|
80808
|
+
// Audio Track Methods
|
|
80809
|
+
getAudioTracks() {
|
|
80810
|
+
if (!this.hls) {
|
|
80811
|
+
console.warn("HLS instance not initialized");
|
|
80812
|
+
return [];
|
|
80813
|
+
}
|
|
80814
|
+
try {
|
|
80815
|
+
return this.hls.audioTracks || [];
|
|
80816
|
+
} catch (error) {
|
|
80817
|
+
console.error("Failed to get audio tracks:", error);
|
|
80818
|
+
return [];
|
|
80819
|
+
}
|
|
80820
|
+
}
|
|
80821
|
+
getCurrentAudioTrack() {
|
|
80822
|
+
if (!this.hls) {
|
|
80823
|
+
console.warn("HLS instance not initialized");
|
|
80824
|
+
return -1;
|
|
80825
|
+
}
|
|
80826
|
+
try {
|
|
80827
|
+
return this.hls.audioTrack;
|
|
80828
|
+
} catch (error) {
|
|
80829
|
+
console.error("Failed to get current audio track:", error);
|
|
80830
|
+
return -1;
|
|
80831
|
+
}
|
|
80832
|
+
}
|
|
80833
|
+
switchAudioTrack(trackId) {
|
|
80834
|
+
if (!this.hls) {
|
|
80835
|
+
console.warn("HLS instance not initialized");
|
|
80836
|
+
return false;
|
|
80837
|
+
}
|
|
80838
|
+
const audioTracks = this.getAudioTracks();
|
|
80839
|
+
if (audioTracks.length === 0) {
|
|
80840
|
+
console.warn("No audio tracks available");
|
|
80841
|
+
return false;
|
|
80842
|
+
}
|
|
80843
|
+
const trackExists = audioTracks.some((_, index2) => index2 === trackId);
|
|
80844
|
+
if (!trackExists) {
|
|
80845
|
+
console.warn(`Audio track with ID ${trackId} not found`);
|
|
80846
|
+
return false;
|
|
80847
|
+
}
|
|
80848
|
+
try {
|
|
80849
|
+
this.hls.audioTrack = trackId;
|
|
80850
|
+
this.player.emit("core_event", {
|
|
80851
|
+
eventName: "core.audiotrackchange",
|
|
80852
|
+
trackId,
|
|
80853
|
+
trackInfo: audioTracks[trackId] || null
|
|
80854
|
+
});
|
|
80855
|
+
return true;
|
|
80856
|
+
} catch (error) {
|
|
80857
|
+
console.error("Failed to switch audio track:", error);
|
|
80858
|
+
return false;
|
|
80859
|
+
}
|
|
80860
|
+
}
|
|
80861
|
+
// Subtitle Track Methods
|
|
80862
|
+
getSubtitleTracks() {
|
|
80863
|
+
if (!this.hls) {
|
|
80864
|
+
console.warn("HLS instance not initialized");
|
|
80865
|
+
return [];
|
|
80866
|
+
}
|
|
80867
|
+
try {
|
|
80868
|
+
return this.hls.subtitleTracks || [];
|
|
80869
|
+
} catch (error) {
|
|
80870
|
+
console.error("Failed to get subtitle tracks:", error);
|
|
80871
|
+
return [];
|
|
80872
|
+
}
|
|
80873
|
+
}
|
|
80874
|
+
getAllSubtitleTracks() {
|
|
80875
|
+
if (!this.hls) {
|
|
80876
|
+
console.warn("HLS instance not initialized");
|
|
80877
|
+
return [];
|
|
80878
|
+
}
|
|
80879
|
+
try {
|
|
80880
|
+
return this.hls.allSubtitleTracks || [];
|
|
80881
|
+
} catch (error) {
|
|
80882
|
+
console.error("Failed to get all subtitle tracks:", error);
|
|
80883
|
+
return [];
|
|
80884
|
+
}
|
|
80885
|
+
}
|
|
80886
|
+
getCurrentSubtitleTrack() {
|
|
80887
|
+
if (!this.hls) {
|
|
80888
|
+
console.warn("HLS instance not initialized");
|
|
80889
|
+
return -1;
|
|
80890
|
+
}
|
|
80891
|
+
try {
|
|
80892
|
+
return this.hls.subtitleTrack;
|
|
80893
|
+
} catch (error) {
|
|
80894
|
+
console.error("Failed to get current subtitle track:", error);
|
|
80895
|
+
return -1;
|
|
80896
|
+
}
|
|
80897
|
+
}
|
|
80898
|
+
switchSubtitleTrack(trackId) {
|
|
80899
|
+
if (!this.hls) {
|
|
80900
|
+
console.warn("HLS instance not initialized");
|
|
80901
|
+
return false;
|
|
80902
|
+
}
|
|
80903
|
+
const subtitleTracks = this.getSubtitleTracks();
|
|
80904
|
+
if (trackId === -1) {
|
|
80905
|
+
try {
|
|
80906
|
+
this.hls.subtitleTrack = -1;
|
|
80907
|
+
this.player.emit("core_event", {
|
|
80908
|
+
eventName: "core.subtitletrackchange",
|
|
80909
|
+
trackId: -1,
|
|
80910
|
+
trackInfo: null
|
|
80911
|
+
});
|
|
80912
|
+
return true;
|
|
80913
|
+
} catch (error) {
|
|
80914
|
+
console.error("Failed to disable subtitle track:", error);
|
|
80915
|
+
return false;
|
|
80916
|
+
}
|
|
80917
|
+
}
|
|
80918
|
+
if (subtitleTracks.length === 0) {
|
|
80919
|
+
console.warn("No subtitle tracks available");
|
|
80920
|
+
return false;
|
|
80921
|
+
}
|
|
80922
|
+
const trackExists = subtitleTracks.some((_, index2) => index2 === trackId);
|
|
80923
|
+
if (!trackExists) {
|
|
80924
|
+
console.warn(`Subtitle track with ID ${trackId} not found`);
|
|
80925
|
+
return false;
|
|
80926
|
+
}
|
|
80927
|
+
try {
|
|
80928
|
+
this.hls.subtitleTrack = trackId;
|
|
80929
|
+
this.player.emit("core_event", {
|
|
80930
|
+
eventName: "core.subtitletrackchange",
|
|
80931
|
+
trackId,
|
|
80932
|
+
trackInfo: subtitleTracks[trackId] || null
|
|
80933
|
+
});
|
|
80934
|
+
return true;
|
|
80935
|
+
} catch (error) {
|
|
80936
|
+
console.error("Failed to switch subtitle track:", error);
|
|
80937
|
+
return false;
|
|
80938
|
+
}
|
|
80939
|
+
}
|
|
80940
|
+
getSubtitleDisplay() {
|
|
80941
|
+
if (!this.hls) {
|
|
80942
|
+
console.warn("HLS instance not initialized");
|
|
80943
|
+
return false;
|
|
80944
|
+
}
|
|
80945
|
+
try {
|
|
80946
|
+
return this.hls.subtitleDisplay;
|
|
80947
|
+
} catch (error) {
|
|
80948
|
+
console.error("Failed to get subtitle display status:", error);
|
|
80949
|
+
return false;
|
|
80950
|
+
}
|
|
80951
|
+
}
|
|
80952
|
+
setSubtitleDisplay(enabled) {
|
|
80953
|
+
if (!this.hls) {
|
|
80954
|
+
console.warn("HLS instance not initialized");
|
|
80955
|
+
return false;
|
|
80956
|
+
}
|
|
80957
|
+
try {
|
|
80958
|
+
this.hls.subtitleDisplay = enabled;
|
|
80959
|
+
this.player.emit("core_event", {
|
|
80960
|
+
eventName: "core.subtitledisplaychange",
|
|
80961
|
+
enabled
|
|
80962
|
+
});
|
|
80963
|
+
return true;
|
|
80964
|
+
} catch (error) {
|
|
80965
|
+
console.error("Failed to set subtitle display:", error);
|
|
80966
|
+
return false;
|
|
80967
|
+
}
|
|
80968
|
+
}
|
|
80969
|
+
}
|
|
80522
80970
|
const MAX_HOLE = 0.1;
|
|
80523
80971
|
class XgHls extends BasePlugin$1 {
|
|
80524
80972
|
constructor(options) {
|
|
80525
|
-
super(
|
|
80973
|
+
super({
|
|
80974
|
+
...options,
|
|
80975
|
+
pluginName: XgHls.pluginName
|
|
80976
|
+
});
|
|
80526
80977
|
this._tickInterval = 500;
|
|
80978
|
+
this._currentIndex = 0;
|
|
80527
80979
|
this._onPlay = () => {
|
|
80528
80980
|
this.hls.startLoad();
|
|
80529
80981
|
};
|
|
@@ -80561,8 +81013,7 @@ class XgHls extends BasePlugin$1 {
|
|
|
80561
81013
|
var _a;
|
|
80562
81014
|
(_a = this.hls) == null ? void 0 : _a.on(eventName, func);
|
|
80563
81015
|
};
|
|
80564
|
-
|
|
80565
|
-
this.config = config2;
|
|
81016
|
+
this.config = options.config || {};
|
|
80566
81017
|
this.player.handleSource = false;
|
|
80567
81018
|
}
|
|
80568
81019
|
static get pluginName() {
|
|
@@ -80572,209 +81023,7 @@ class XgHls extends BasePlugin$1 {
|
|
|
80572
81023
|
this.register(this.player.config.url);
|
|
80573
81024
|
}
|
|
80574
81025
|
initEvt() {
|
|
80575
|
-
this.hls
|
|
80576
|
-
this.player.emit("core_event", {
|
|
80577
|
-
eventName: "core.subtitlesegments",
|
|
80578
|
-
list: frag
|
|
80579
|
-
});
|
|
80580
|
-
});
|
|
80581
|
-
this.hls.on(Hls.Events.MANIFEST_PARSED, (_, { levels }) => {
|
|
80582
|
-
this.player.emit("core_event", {
|
|
80583
|
-
eventName: "core.subtitleplaylist",
|
|
80584
|
-
list: levels
|
|
80585
|
-
});
|
|
80586
|
-
});
|
|
80587
|
-
this.hls.on(Hls.Events.MANIFEST_LOADING, (_, { url: url2 }) => {
|
|
80588
|
-
this.player.emit("core_event", {
|
|
80589
|
-
eventName: "core.loadstart",
|
|
80590
|
-
url: url2
|
|
80591
|
-
});
|
|
80592
|
-
});
|
|
80593
|
-
this.hls.on(Hls.Events.LEVEL_LOADING, (_, { url: url2 }) => {
|
|
80594
|
-
this.player.emit("core_event", {
|
|
80595
|
-
eventName: "core.loadstart",
|
|
80596
|
-
url: url2
|
|
80597
|
-
});
|
|
80598
|
-
});
|
|
80599
|
-
this.hls.on(Hls.Events.FRAG_LOADING, (_, { frag }) => {
|
|
80600
|
-
this.player.emit("core_event", {
|
|
80601
|
-
eventName: "core.loadstart",
|
|
80602
|
-
url: frag.url
|
|
80603
|
-
});
|
|
80604
|
-
});
|
|
80605
|
-
this.hls.on(Hls.Events.MANIFEST_LOADED, (_, data2) => {
|
|
80606
|
-
const { url: url2 } = data2;
|
|
80607
|
-
this.player.emit("core_event", {
|
|
80608
|
-
eventName: "core.loadcomplete",
|
|
80609
|
-
url: url2
|
|
80610
|
-
});
|
|
80611
|
-
});
|
|
80612
|
-
this.hls.on(Hls.Events.LEVEL_LOADED, (_, data2) => {
|
|
80613
|
-
const { details, stats } = data2;
|
|
80614
|
-
this.player.emit("core_event", {
|
|
80615
|
-
eventName: "core.loadcomplete",
|
|
80616
|
-
...stats,
|
|
80617
|
-
url: details == null ? void 0 : details.url
|
|
80618
|
-
});
|
|
80619
|
-
});
|
|
80620
|
-
this.hls.on(Hls.Events.FRAG_LOADED, (_, data2) => {
|
|
80621
|
-
const { frag } = data2;
|
|
80622
|
-
this.player.emit("core_event", {
|
|
80623
|
-
eventName: "core.loadcomplete",
|
|
80624
|
-
url: frag.url
|
|
80625
|
-
});
|
|
80626
|
-
});
|
|
80627
|
-
this.hls.on(Hls.Events.FRAG_PARSING_USERDATA, (_, { samples }) => {
|
|
80628
|
-
this.player.emit("core_event", {
|
|
80629
|
-
eventName: "core.sei",
|
|
80630
|
-
sei: samples
|
|
80631
|
-
});
|
|
80632
|
-
});
|
|
80633
|
-
this.hls.on(Hls.Events.MANIFEST_LOADED, (_, { levels, networkDetails }) => {
|
|
80634
|
-
this.player.emit("core_event", {
|
|
80635
|
-
eventName: "core.hlsmanifestloaded",
|
|
80636
|
-
playlist: levels
|
|
80637
|
-
});
|
|
80638
|
-
this.player.emit("core_event", {
|
|
80639
|
-
eventName: "core.loadresponseheaders",
|
|
80640
|
-
headers: networkDetails.headers
|
|
80641
|
-
});
|
|
80642
|
-
});
|
|
80643
|
-
this.hls.on(Hls.Events.LEVEL_LOADED, (_, { details }) => {
|
|
80644
|
-
const dateRanges = {};
|
|
80645
|
-
Object.keys(details.dateRanges).forEach((key2) => {
|
|
80646
|
-
dateRanges[key2] = details.dateRanges[key2].attr["START-DATE"];
|
|
80647
|
-
});
|
|
80648
|
-
this.player.emit("core_event", {
|
|
80649
|
-
eventName: "core.hlslevelloaded",
|
|
80650
|
-
playlist: {
|
|
80651
|
-
...details,
|
|
80652
|
-
segments: details.fragments,
|
|
80653
|
-
dateRanges
|
|
80654
|
-
}
|
|
80655
|
-
});
|
|
80656
|
-
});
|
|
80657
|
-
this.hls.on(Hls.Events.ERROR, (_, data2) => {
|
|
80658
|
-
const { details, fatal, type, response, reason, error } = data2;
|
|
80659
|
-
if (!fatal) {
|
|
80660
|
-
return;
|
|
80661
|
-
}
|
|
80662
|
-
let errorCode;
|
|
80663
|
-
let errorType;
|
|
80664
|
-
switch (type) {
|
|
80665
|
-
case Hls.ErrorTypes.NETWORK_ERROR:
|
|
80666
|
-
errorCode = 2100;
|
|
80667
|
-
if (details.includes("TimeOut")) {
|
|
80668
|
-
errorCode = 2101;
|
|
80669
|
-
} else if ((response == null ? void 0 : response.code) === 403) {
|
|
80670
|
-
errorCode = 2103;
|
|
80671
|
-
} else if ((response == null ? void 0 : response.code) === 404) {
|
|
80672
|
-
errorCode = 2104;
|
|
80673
|
-
}
|
|
80674
|
-
this.player.emit("error", {
|
|
80675
|
-
errorType: "network",
|
|
80676
|
-
errorCode,
|
|
80677
|
-
message: (error == null ? void 0 : error.message) || details,
|
|
80678
|
-
originError: data2
|
|
80679
|
-
});
|
|
80680
|
-
break;
|
|
80681
|
-
case Hls.ErrorTypes.MEDIA_ERROR:
|
|
80682
|
-
errorType = "media";
|
|
80683
|
-
if (details === Hls.ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR) {
|
|
80684
|
-
errorCode = 5104;
|
|
80685
|
-
} else if (details === Hls.ErrorDetails.FRAG_DECRYPT_ERROR) {
|
|
80686
|
-
errorCode = 5105;
|
|
80687
|
-
} else if (details === Hls.ErrorDetails.FRAG_PARSING_ERROR) {
|
|
80688
|
-
errorCode = 1100;
|
|
80689
|
-
errorType = "manifest";
|
|
80690
|
-
} else if (details === Hls.ErrorDetails.FRAG_GAP) {
|
|
80691
|
-
errorCode = 5104;
|
|
80692
|
-
} else if (details === Hls.ErrorDetails.BUFFER_ADD_CODEC_ERROR) {
|
|
80693
|
-
errorCode = 5200;
|
|
80694
|
-
} else if (details === Hls.ErrorDetails.BUFFER_INCOMPATIBLE_CODECS_ERROR) {
|
|
80695
|
-
errorCode = 5104;
|
|
80696
|
-
} else if (details === Hls.ErrorDetails.BUFFER_APPEND_ERROR) {
|
|
80697
|
-
errorCode = 5201;
|
|
80698
|
-
} else if (details === Hls.ErrorDetails.BUFFER_APPENDING_ERROR) {
|
|
80699
|
-
errorCode = 5201;
|
|
80700
|
-
} else if (details === Hls.ErrorDetails.BUFFER_STALLED_ERROR) {
|
|
80701
|
-
errorCode = 5203;
|
|
80702
|
-
} else if (details === Hls.ErrorDetails.BUFFER_FULL_ERROR) {
|
|
80703
|
-
errorCode = 5203;
|
|
80704
|
-
} else if (details === Hls.ErrorDetails.BUFFER_SEEK_OVER_HOLE) {
|
|
80705
|
-
errorCode = 5202;
|
|
80706
|
-
} else if (details === Hls.ErrorDetails.BUFFER_NUDGE_ON_STALL) {
|
|
80707
|
-
errorCode = 5202;
|
|
80708
|
-
}
|
|
80709
|
-
this.player.emit("error", {
|
|
80710
|
-
errorType: errorType || type,
|
|
80711
|
-
errorCode,
|
|
80712
|
-
message: (error == null ? void 0 : error.message) || details,
|
|
80713
|
-
originError: data2
|
|
80714
|
-
});
|
|
80715
|
-
break;
|
|
80716
|
-
case Hls.ErrorTypes.MUX_ERROR:
|
|
80717
|
-
errorCode = 4100;
|
|
80718
|
-
this.player.emit("error", {
|
|
80719
|
-
errorType: "remux",
|
|
80720
|
-
errorCode,
|
|
80721
|
-
message: (error == null ? void 0 : error.message) || details,
|
|
80722
|
-
originError: data2
|
|
80723
|
-
});
|
|
80724
|
-
break;
|
|
80725
|
-
case Hls.ErrorTypes.KEY_SYSTEM_ERROR:
|
|
80726
|
-
errorCode = 7111;
|
|
80727
|
-
if (details === Hls.ErrorDetails.KEY_SYSTEM_NO_KEYS) {
|
|
80728
|
-
errorCode = 7103;
|
|
80729
|
-
} else if (details === Hls.ErrorDetails.KEY_SYSTEM_NO_ACCESS) {
|
|
80730
|
-
errorCode = 7101;
|
|
80731
|
-
} else if (details === Hls.ErrorDetails.KEY_SYSTEM_NO_SESSION) {
|
|
80732
|
-
errorCode = 7104;
|
|
80733
|
-
} else if (details === Hls.ErrorDetails.KEY_SYSTEM_NO_CONFIGURED_LICENSE) {
|
|
80734
|
-
errorCode = 7107;
|
|
80735
|
-
} else if (details === Hls.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED) {
|
|
80736
|
-
errorCode = 7108;
|
|
80737
|
-
} else if (details === Hls.ErrorDetails.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED) {
|
|
80738
|
-
errorCode = 7110;
|
|
80739
|
-
} else if (details === Hls.ErrorDetails.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED) {
|
|
80740
|
-
errorCode = 7110;
|
|
80741
|
-
} else if (details === Hls.ErrorDetails.KEY_SYSTEM_SESSION_UPDATE_FAILED) {
|
|
80742
|
-
errorCode = 7104;
|
|
80743
|
-
} else if (details === Hls.ErrorDetails.KEY_SYSTEM_STATUS_INTERNAL_ERROR) {
|
|
80744
|
-
errorCode = 7111;
|
|
80745
|
-
}
|
|
80746
|
-
this.player.emit("error", {
|
|
80747
|
-
errorType: "drm",
|
|
80748
|
-
errorCode,
|
|
80749
|
-
message: (error == null ? void 0 : error.message) || reason || details,
|
|
80750
|
-
originError: data2
|
|
80751
|
-
});
|
|
80752
|
-
break;
|
|
80753
|
-
default:
|
|
80754
|
-
if (details === Hls.ErrorDetails.LEVEL_SWITCH_ERROR) {
|
|
80755
|
-
errorCode = 2100;
|
|
80756
|
-
errorType = "network";
|
|
80757
|
-
}
|
|
80758
|
-
this.player.emit("error", {
|
|
80759
|
-
errorType: errorType || "other",
|
|
80760
|
-
errorCode,
|
|
80761
|
-
message: (error == null ? void 0 : error.message) || reason || details,
|
|
80762
|
-
originError: data2
|
|
80763
|
-
});
|
|
80764
|
-
break;
|
|
80765
|
-
}
|
|
80766
|
-
try {
|
|
80767
|
-
this.hls.stopLoad();
|
|
80768
|
-
this.player.pause();
|
|
80769
|
-
} catch (error2) {
|
|
80770
|
-
}
|
|
80771
|
-
});
|
|
80772
|
-
this.hls.on(Hls.Events.MEDIA_ATTACHED, () => {
|
|
80773
|
-
this.player.emit("sourceopen");
|
|
80774
|
-
});
|
|
80775
|
-
this.hls.on(Hls.Events.BUFFER_APPENDED, () => {
|
|
80776
|
-
this.player.emit("bufferappend");
|
|
80777
|
-
});
|
|
81026
|
+
initHlsEvents(this.hls, this.player);
|
|
80778
81027
|
}
|
|
80779
81028
|
afterCreate() {
|
|
80780
81029
|
const media = this.player.media;
|
|
@@ -80800,8 +81049,9 @@ class XgHls extends BasePlugin$1 {
|
|
|
80800
81049
|
if (this.hls) {
|
|
80801
81050
|
this.hls.destroy();
|
|
80802
81051
|
}
|
|
80803
|
-
const hlsConfig = getHlsConfig(this.config
|
|
81052
|
+
const hlsConfig = getHlsConfig(this.config);
|
|
80804
81053
|
this.hls = new Hls(hlsConfig);
|
|
81054
|
+
this._trackManager = new TrackManager(this.hls, this.player);
|
|
80805
81055
|
this.initEvt();
|
|
80806
81056
|
if (player.config.preProcessUrl) {
|
|
80807
81057
|
const { url: newUrl } = player.config.preProcessUrl(url2);
|
|
@@ -80815,10 +81065,47 @@ class XgHls extends BasePlugin$1 {
|
|
|
80815
81065
|
media.removeEventListener("play", this._onPlay);
|
|
80816
81066
|
media.addEventListener("play", this._onPlay);
|
|
80817
81067
|
}
|
|
81068
|
+
switchUrl(url2, { startTime, bitrate, seamless }) {
|
|
81069
|
+
this.hls.loadSource(url2);
|
|
81070
|
+
if (startTime !== void 0) {
|
|
81071
|
+
const media = this.player.media;
|
|
81072
|
+
media.currentTime = startTime;
|
|
81073
|
+
}
|
|
81074
|
+
}
|
|
81075
|
+
// Audio Track Methods
|
|
81076
|
+
getAudioTracks() {
|
|
81077
|
+
return this._trackManager.getAudioTracks();
|
|
81078
|
+
}
|
|
81079
|
+
getCurrentAudioTrack() {
|
|
81080
|
+
return this._trackManager.getCurrentAudioTrack();
|
|
81081
|
+
}
|
|
81082
|
+
switchAudioTrack(trackId) {
|
|
81083
|
+
return this._trackManager.switchAudioTrack(trackId);
|
|
81084
|
+
}
|
|
81085
|
+
// Subtitle Track Methods
|
|
81086
|
+
getSubtitleTracks() {
|
|
81087
|
+
return this._trackManager.getSubtitleTracks();
|
|
81088
|
+
}
|
|
81089
|
+
getAllSubtitleTracks() {
|
|
81090
|
+
return this._trackManager.getAllSubtitleTracks();
|
|
81091
|
+
}
|
|
81092
|
+
getCurrentSubtitleTrack() {
|
|
81093
|
+
return this._trackManager.getCurrentSubtitleTrack();
|
|
81094
|
+
}
|
|
81095
|
+
switchSubtitleTrack(trackId) {
|
|
81096
|
+
return this._trackManager.switchSubtitleTrack(trackId);
|
|
81097
|
+
}
|
|
81098
|
+
getSubtitleDisplay() {
|
|
81099
|
+
return this._trackManager.getSubtitleDisplay();
|
|
81100
|
+
}
|
|
81101
|
+
setSubtitleDisplay(enabled) {
|
|
81102
|
+
return this._trackManager.setSubtitleDisplay(enabled);
|
|
81103
|
+
}
|
|
80818
81104
|
destroy() {
|
|
81105
|
+
var _a;
|
|
80819
81106
|
clearTimeout(this._tickTimer);
|
|
80820
81107
|
this.player.off(URL_CHANGE, this.onUrlChange);
|
|
80821
|
-
this.hls.destroy();
|
|
81108
|
+
(_a = this.hls) == null ? void 0 : _a.destroy();
|
|
80822
81109
|
}
|
|
80823
81110
|
}
|
|
80824
81111
|
class HlsPlugin extends XgHls {
|