@byteplus/veplayer-plugin 2.10.3-rc.0 → 2.10.3-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 +495 -217
- 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 +1 -1
- 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
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { DynamicModule } from "@byteplus/veplayer";
|
|
1
2
|
function ownKeys$1(object, enumerableOnly) {
|
|
2
3
|
var keys = Object.keys(object);
|
|
3
4
|
if (Object.getOwnPropertySymbols) {
|
|
@@ -32173,7 +32174,7 @@ class Hls {
|
|
|
32173
32174
|
}
|
|
32174
32175
|
}
|
|
32175
32176
|
Hls.defaultConfig = void 0;
|
|
32176
|
-
const
|
|
32177
|
+
const OPTIONS_MAP = {
|
|
32177
32178
|
liveSyncDuration: {
|
|
32178
32179
|
key: "targetLatency",
|
|
32179
32180
|
val: 10
|
|
@@ -32190,20 +32191,40 @@ const optionsMap = {
|
|
|
32190
32191
|
key: "minSegmentsStartPlay",
|
|
32191
32192
|
val: 3
|
|
32192
32193
|
},
|
|
32193
|
-
preferManagedMediaSource:
|
|
32194
|
-
|
|
32195
|
-
|
|
32196
|
-
|
|
32194
|
+
preferManagedMediaSource: [
|
|
32195
|
+
{
|
|
32196
|
+
key: "preferMMS",
|
|
32197
|
+
val: false
|
|
32198
|
+
},
|
|
32199
|
+
{
|
|
32200
|
+
key: "preferMMSStreaming",
|
|
32201
|
+
val: false
|
|
32202
|
+
}
|
|
32203
|
+
],
|
|
32197
32204
|
lowLatencyMode: {
|
|
32198
32205
|
key: "useLowLatency",
|
|
32199
32206
|
val: true
|
|
32207
|
+
},
|
|
32208
|
+
startPosition: {
|
|
32209
|
+
key: "startTime",
|
|
32210
|
+
val: 0
|
|
32211
|
+
},
|
|
32212
|
+
interstitialLiveLookAhead: {
|
|
32213
|
+
key: "preloadTime",
|
|
32214
|
+
val: 30
|
|
32200
32215
|
}
|
|
32201
32216
|
};
|
|
32202
|
-
function getHlsConfig(config
|
|
32217
|
+
function getHlsConfig(config) {
|
|
32203
32218
|
const hlsConfig = {};
|
|
32204
|
-
Object.keys(
|
|
32205
|
-
const tmp =
|
|
32206
|
-
|
|
32219
|
+
Object.keys(OPTIONS_MAP).forEach((keyStr) => {
|
|
32220
|
+
const tmp = OPTIONS_MAP[keyStr];
|
|
32221
|
+
if (tmp instanceof Array) {
|
|
32222
|
+
tmp.forEach((item) => {
|
|
32223
|
+
hlsConfig[keyStr] = item.val;
|
|
32224
|
+
});
|
|
32225
|
+
} else {
|
|
32226
|
+
hlsConfig[keyStr] = config[tmp.key] || tmp.val;
|
|
32227
|
+
}
|
|
32207
32228
|
});
|
|
32208
32229
|
const maxNumRetry = typeof config.retryCount === "number" ? config.retryCount : 3;
|
|
32209
32230
|
const retryDelayMs = typeof config.retryDelay === "number" ? config.retryDelay : 1e3;
|
|
@@ -32254,11 +32275,434 @@ function getHlsConfig(config, playerConfig) {
|
|
|
32254
32275
|
...config
|
|
32255
32276
|
};
|
|
32256
32277
|
}
|
|
32278
|
+
function initHlsEvents(hls, player) {
|
|
32279
|
+
hls.on(Hls.Events.SUBTITLE_FRAG_PROCESSED, (_, { frag }) => {
|
|
32280
|
+
player.emit("core_event", {
|
|
32281
|
+
eventName: "core.subtitlesegments",
|
|
32282
|
+
list: frag
|
|
32283
|
+
});
|
|
32284
|
+
});
|
|
32285
|
+
hls.on(Hls.Events.MANIFEST_PARSED, (_, { levels }) => {
|
|
32286
|
+
player.emit("core_event", {
|
|
32287
|
+
eventName: "core.subtitleplaylist",
|
|
32288
|
+
list: levels
|
|
32289
|
+
});
|
|
32290
|
+
});
|
|
32291
|
+
hls.on(Hls.Events.MANIFEST_LOADING, (_, { url }) => {
|
|
32292
|
+
player.emit("core_event", {
|
|
32293
|
+
eventName: "core.loadstart",
|
|
32294
|
+
url
|
|
32295
|
+
});
|
|
32296
|
+
});
|
|
32297
|
+
hls.on(Hls.Events.LEVEL_LOADING, (_, { url }) => {
|
|
32298
|
+
player.emit("core_event", {
|
|
32299
|
+
eventName: "core.loadstart",
|
|
32300
|
+
url
|
|
32301
|
+
});
|
|
32302
|
+
});
|
|
32303
|
+
hls.on(Hls.Events.FRAG_LOADING, (_, { frag }) => {
|
|
32304
|
+
player.emit("core_event", {
|
|
32305
|
+
eventName: "core.loadstart",
|
|
32306
|
+
url: frag.url
|
|
32307
|
+
});
|
|
32308
|
+
});
|
|
32309
|
+
hls.on(Hls.Events.MANIFEST_LOADED, (_, data) => {
|
|
32310
|
+
const { url } = data;
|
|
32311
|
+
player.emit("core_event", {
|
|
32312
|
+
eventName: "core.loadcomplete",
|
|
32313
|
+
url
|
|
32314
|
+
});
|
|
32315
|
+
});
|
|
32316
|
+
hls.on(Hls.Events.LEVEL_LOADED, (_, data) => {
|
|
32317
|
+
const { details, stats } = data;
|
|
32318
|
+
player.emit("core_event", {
|
|
32319
|
+
eventName: "core.loadcomplete",
|
|
32320
|
+
...stats,
|
|
32321
|
+
url: details == null ? void 0 : details.url
|
|
32322
|
+
});
|
|
32323
|
+
});
|
|
32324
|
+
hls.on(Hls.Events.FRAG_LOADED, (_, data) => {
|
|
32325
|
+
const { frag } = data;
|
|
32326
|
+
player.emit("core_event", {
|
|
32327
|
+
eventName: "core.loadcomplete",
|
|
32328
|
+
url: frag.url
|
|
32329
|
+
});
|
|
32330
|
+
});
|
|
32331
|
+
hls.on(Hls.Events.FRAG_PARSING_USERDATA, (_, { samples }) => {
|
|
32332
|
+
player.emit("core_event", {
|
|
32333
|
+
eventName: "core.sei",
|
|
32334
|
+
sei: samples
|
|
32335
|
+
});
|
|
32336
|
+
});
|
|
32337
|
+
hls.on(Hls.Events.MANIFEST_LOADED, (_, { levels, networkDetails }) => {
|
|
32338
|
+
player.emit("core_event", {
|
|
32339
|
+
eventName: "core.hlsmanifestloaded",
|
|
32340
|
+
playlist: levels
|
|
32341
|
+
});
|
|
32342
|
+
player.emit("core_event", {
|
|
32343
|
+
eventName: "core.loadresponseheaders",
|
|
32344
|
+
headers: networkDetails.headers
|
|
32345
|
+
});
|
|
32346
|
+
});
|
|
32347
|
+
hls.on(Hls.Events.LEVEL_LOADED, (_, { details }) => {
|
|
32348
|
+
const dateRanges = {};
|
|
32349
|
+
Object.keys(details.dateRanges).forEach((key) => {
|
|
32350
|
+
dateRanges[key] = details.dateRanges[key].attr["START-DATE"];
|
|
32351
|
+
});
|
|
32352
|
+
player.emit("core_event", {
|
|
32353
|
+
eventName: "core.hlslevelloaded",
|
|
32354
|
+
playlist: {
|
|
32355
|
+
...details,
|
|
32356
|
+
segments: details.fragments,
|
|
32357
|
+
dateRanges
|
|
32358
|
+
}
|
|
32359
|
+
});
|
|
32360
|
+
});
|
|
32361
|
+
hls.on(Hls.Events.ERROR, (_, data) => {
|
|
32362
|
+
const { details, fatal, type, response, reason, error } = data;
|
|
32363
|
+
if (!fatal) {
|
|
32364
|
+
return;
|
|
32365
|
+
}
|
|
32366
|
+
let errorCode;
|
|
32367
|
+
let errorType;
|
|
32368
|
+
switch (type) {
|
|
32369
|
+
case Hls.ErrorTypes.NETWORK_ERROR:
|
|
32370
|
+
errorCode = 2100;
|
|
32371
|
+
if (details.includes("TimeOut")) {
|
|
32372
|
+
errorCode = 2101;
|
|
32373
|
+
} else if ((response == null ? void 0 : response.code) === 403) {
|
|
32374
|
+
errorCode = 2103;
|
|
32375
|
+
} else if ((response == null ? void 0 : response.code) === 404) {
|
|
32376
|
+
errorCode = 2104;
|
|
32377
|
+
}
|
|
32378
|
+
player.emit("error", {
|
|
32379
|
+
errorType: "network",
|
|
32380
|
+
errorCode,
|
|
32381
|
+
message: (error == null ? void 0 : error.message) || details,
|
|
32382
|
+
originError: data
|
|
32383
|
+
});
|
|
32384
|
+
break;
|
|
32385
|
+
case Hls.ErrorTypes.MEDIA_ERROR:
|
|
32386
|
+
errorType = "media";
|
|
32387
|
+
if (details === Hls.ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR) {
|
|
32388
|
+
errorCode = 5104;
|
|
32389
|
+
} else if (details === Hls.ErrorDetails.FRAG_DECRYPT_ERROR) {
|
|
32390
|
+
errorCode = 5105;
|
|
32391
|
+
} else if (details === Hls.ErrorDetails.FRAG_PARSING_ERROR) {
|
|
32392
|
+
errorCode = 1100;
|
|
32393
|
+
errorType = "manifest";
|
|
32394
|
+
} else if (details === Hls.ErrorDetails.FRAG_GAP) {
|
|
32395
|
+
errorCode = 5104;
|
|
32396
|
+
} else if (details === Hls.ErrorDetails.BUFFER_ADD_CODEC_ERROR) {
|
|
32397
|
+
errorCode = 5200;
|
|
32398
|
+
} else if (details === Hls.ErrorDetails.BUFFER_INCOMPATIBLE_CODECS_ERROR) {
|
|
32399
|
+
errorCode = 5104;
|
|
32400
|
+
} else if (details === Hls.ErrorDetails.BUFFER_APPEND_ERROR) {
|
|
32401
|
+
errorCode = 5201;
|
|
32402
|
+
} else if (details === Hls.ErrorDetails.BUFFER_APPENDING_ERROR) {
|
|
32403
|
+
errorCode = 5201;
|
|
32404
|
+
} else if (details === Hls.ErrorDetails.BUFFER_STALLED_ERROR) {
|
|
32405
|
+
errorCode = 5203;
|
|
32406
|
+
} else if (details === Hls.ErrorDetails.BUFFER_FULL_ERROR) {
|
|
32407
|
+
errorCode = 5203;
|
|
32408
|
+
} else if (details === Hls.ErrorDetails.BUFFER_SEEK_OVER_HOLE) {
|
|
32409
|
+
errorCode = 5202;
|
|
32410
|
+
} else if (details === Hls.ErrorDetails.BUFFER_NUDGE_ON_STALL) {
|
|
32411
|
+
errorCode = 5202;
|
|
32412
|
+
}
|
|
32413
|
+
player.emit("error", {
|
|
32414
|
+
errorType: errorType || type,
|
|
32415
|
+
errorCode,
|
|
32416
|
+
message: (error == null ? void 0 : error.message) || details,
|
|
32417
|
+
originError: data
|
|
32418
|
+
});
|
|
32419
|
+
break;
|
|
32420
|
+
case Hls.ErrorTypes.MUX_ERROR:
|
|
32421
|
+
errorCode = 4100;
|
|
32422
|
+
player.emit("error", {
|
|
32423
|
+
errorType: "remux",
|
|
32424
|
+
errorCode,
|
|
32425
|
+
message: (error == null ? void 0 : error.message) || details,
|
|
32426
|
+
originError: data
|
|
32427
|
+
});
|
|
32428
|
+
break;
|
|
32429
|
+
case Hls.ErrorTypes.KEY_SYSTEM_ERROR:
|
|
32430
|
+
errorCode = 7111;
|
|
32431
|
+
if (details === Hls.ErrorDetails.KEY_SYSTEM_NO_KEYS) {
|
|
32432
|
+
errorCode = 7103;
|
|
32433
|
+
} else if (details === Hls.ErrorDetails.KEY_SYSTEM_NO_ACCESS) {
|
|
32434
|
+
errorCode = 7101;
|
|
32435
|
+
} else if (details === Hls.ErrorDetails.KEY_SYSTEM_NO_SESSION) {
|
|
32436
|
+
errorCode = 7104;
|
|
32437
|
+
} else if (details === Hls.ErrorDetails.KEY_SYSTEM_NO_CONFIGURED_LICENSE) {
|
|
32438
|
+
errorCode = 7107;
|
|
32439
|
+
} else if (details === Hls.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED) {
|
|
32440
|
+
errorCode = 7108;
|
|
32441
|
+
} else if (details === Hls.ErrorDetails.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED) {
|
|
32442
|
+
errorCode = 7110;
|
|
32443
|
+
} else if (details === Hls.ErrorDetails.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED) {
|
|
32444
|
+
errorCode = 7110;
|
|
32445
|
+
} else if (details === Hls.ErrorDetails.KEY_SYSTEM_SESSION_UPDATE_FAILED) {
|
|
32446
|
+
errorCode = 7104;
|
|
32447
|
+
} else if (details === Hls.ErrorDetails.KEY_SYSTEM_STATUS_INTERNAL_ERROR) {
|
|
32448
|
+
errorCode = 7111;
|
|
32449
|
+
}
|
|
32450
|
+
player.emit("error", {
|
|
32451
|
+
errorType: "drm",
|
|
32452
|
+
errorCode,
|
|
32453
|
+
message: (error == null ? void 0 : error.message) || reason || details,
|
|
32454
|
+
originError: data
|
|
32455
|
+
});
|
|
32456
|
+
break;
|
|
32457
|
+
default:
|
|
32458
|
+
if (details === Hls.ErrorDetails.LEVEL_SWITCH_ERROR) {
|
|
32459
|
+
errorCode = 2100;
|
|
32460
|
+
errorType = "network";
|
|
32461
|
+
}
|
|
32462
|
+
player.emit("error", {
|
|
32463
|
+
errorType: errorType || "other",
|
|
32464
|
+
errorCode,
|
|
32465
|
+
message: (error == null ? void 0 : error.message) || reason || details,
|
|
32466
|
+
originError: data
|
|
32467
|
+
});
|
|
32468
|
+
break;
|
|
32469
|
+
}
|
|
32470
|
+
try {
|
|
32471
|
+
hls.stopLoad();
|
|
32472
|
+
player.pause();
|
|
32473
|
+
} catch (error2) {
|
|
32474
|
+
}
|
|
32475
|
+
});
|
|
32476
|
+
hls.on(Hls.Events.MEDIA_ATTACHED, () => {
|
|
32477
|
+
player.emit("sourceopen");
|
|
32478
|
+
});
|
|
32479
|
+
hls.on(Hls.Events.BUFFER_APPENDED, () => {
|
|
32480
|
+
player.emit("bufferappend");
|
|
32481
|
+
});
|
|
32482
|
+
hls.on(Hls.Events.AUDIO_TRACKS_UPDATED, (_, { audioTracks }) => {
|
|
32483
|
+
player.emit("core_event", {
|
|
32484
|
+
eventName: "core.audiotracksupdate",
|
|
32485
|
+
audioTracks
|
|
32486
|
+
});
|
|
32487
|
+
});
|
|
32488
|
+
hls.on(Hls.Events.AUDIO_TRACK_SWITCHING, (_, data) => {
|
|
32489
|
+
player.emit("core_event", {
|
|
32490
|
+
eventName: "core.audiotrackswitching",
|
|
32491
|
+
...data
|
|
32492
|
+
});
|
|
32493
|
+
});
|
|
32494
|
+
hls.on(Hls.Events.AUDIO_TRACK_SWITCHED, (_, data) => {
|
|
32495
|
+
player.emit("core_event", {
|
|
32496
|
+
eventName: "core.audiotrackswitched",
|
|
32497
|
+
...data
|
|
32498
|
+
});
|
|
32499
|
+
});
|
|
32500
|
+
hls.on(Hls.Events.SUBTITLE_TRACKS_UPDATED, (_, { subtitleTracks }) => {
|
|
32501
|
+
player.emit("core_event", {
|
|
32502
|
+
eventName: "core.subtitletracksupdate",
|
|
32503
|
+
subtitleTracks
|
|
32504
|
+
});
|
|
32505
|
+
});
|
|
32506
|
+
hls.on(Hls.Events.SUBTITLE_TRACKS_CLEARED, () => {
|
|
32507
|
+
player.emit("core_event", {
|
|
32508
|
+
eventName: "core.subtitletracksclear"
|
|
32509
|
+
});
|
|
32510
|
+
});
|
|
32511
|
+
hls.on(Hls.Events.SUBTITLE_TRACK_SWITCH, (_, data) => {
|
|
32512
|
+
player.emit("core_event", {
|
|
32513
|
+
eventName: "core.subtitletrackswitch",
|
|
32514
|
+
...data
|
|
32515
|
+
});
|
|
32516
|
+
});
|
|
32517
|
+
hls.on(Hls.Events.SUBTITLE_TRACK_LOADING, (_, data) => {
|
|
32518
|
+
player.emit("core_event", {
|
|
32519
|
+
eventName: "core.subtitletrackloading",
|
|
32520
|
+
...data
|
|
32521
|
+
});
|
|
32522
|
+
});
|
|
32523
|
+
hls.on(Hls.Events.SUBTITLE_TRACK_LOADED, (_, data) => {
|
|
32524
|
+
player.emit("core_event", {
|
|
32525
|
+
eventName: "core.subtitletrackloaded",
|
|
32526
|
+
...data
|
|
32527
|
+
});
|
|
32528
|
+
});
|
|
32529
|
+
}
|
|
32530
|
+
class TrackManager {
|
|
32531
|
+
constructor(hls, player) {
|
|
32532
|
+
this.hls = hls;
|
|
32533
|
+
this.player = player;
|
|
32534
|
+
}
|
|
32535
|
+
// Audio Track Methods
|
|
32536
|
+
getAudioTracks() {
|
|
32537
|
+
if (!this.hls) {
|
|
32538
|
+
console.warn("HLS instance not initialized");
|
|
32539
|
+
return [];
|
|
32540
|
+
}
|
|
32541
|
+
try {
|
|
32542
|
+
return this.hls.audioTracks || [];
|
|
32543
|
+
} catch (error) {
|
|
32544
|
+
console.error("Failed to get audio tracks:", error);
|
|
32545
|
+
return [];
|
|
32546
|
+
}
|
|
32547
|
+
}
|
|
32548
|
+
getCurrentAudioTrack() {
|
|
32549
|
+
if (!this.hls) {
|
|
32550
|
+
console.warn("HLS instance not initialized");
|
|
32551
|
+
return -1;
|
|
32552
|
+
}
|
|
32553
|
+
try {
|
|
32554
|
+
return this.hls.audioTrack;
|
|
32555
|
+
} catch (error) {
|
|
32556
|
+
console.error("Failed to get current audio track:", error);
|
|
32557
|
+
return -1;
|
|
32558
|
+
}
|
|
32559
|
+
}
|
|
32560
|
+
switchAudioTrack(trackId) {
|
|
32561
|
+
if (!this.hls) {
|
|
32562
|
+
console.warn("HLS instance not initialized");
|
|
32563
|
+
return false;
|
|
32564
|
+
}
|
|
32565
|
+
const audioTracks = this.getAudioTracks();
|
|
32566
|
+
if (audioTracks.length === 0) {
|
|
32567
|
+
console.warn("No audio tracks available");
|
|
32568
|
+
return false;
|
|
32569
|
+
}
|
|
32570
|
+
const trackExists = audioTracks.some((_, index) => index === trackId);
|
|
32571
|
+
if (!trackExists) {
|
|
32572
|
+
console.warn(`Audio track with ID ${trackId} not found`);
|
|
32573
|
+
return false;
|
|
32574
|
+
}
|
|
32575
|
+
try {
|
|
32576
|
+
this.hls.audioTrack = trackId;
|
|
32577
|
+
this.player.emit("core_event", {
|
|
32578
|
+
eventName: "core.audiotrackchange",
|
|
32579
|
+
trackId,
|
|
32580
|
+
trackInfo: audioTracks[trackId] || null
|
|
32581
|
+
});
|
|
32582
|
+
return true;
|
|
32583
|
+
} catch (error) {
|
|
32584
|
+
console.error("Failed to switch audio track:", error);
|
|
32585
|
+
return false;
|
|
32586
|
+
}
|
|
32587
|
+
}
|
|
32588
|
+
// Subtitle Track Methods
|
|
32589
|
+
getSubtitleTracks() {
|
|
32590
|
+
if (!this.hls) {
|
|
32591
|
+
console.warn("HLS instance not initialized");
|
|
32592
|
+
return [];
|
|
32593
|
+
}
|
|
32594
|
+
try {
|
|
32595
|
+
return this.hls.subtitleTracks || [];
|
|
32596
|
+
} catch (error) {
|
|
32597
|
+
console.error("Failed to get subtitle tracks:", error);
|
|
32598
|
+
return [];
|
|
32599
|
+
}
|
|
32600
|
+
}
|
|
32601
|
+
getAllSubtitleTracks() {
|
|
32602
|
+
if (!this.hls) {
|
|
32603
|
+
console.warn("HLS instance not initialized");
|
|
32604
|
+
return [];
|
|
32605
|
+
}
|
|
32606
|
+
try {
|
|
32607
|
+
return this.hls.allSubtitleTracks || [];
|
|
32608
|
+
} catch (error) {
|
|
32609
|
+
console.error("Failed to get all subtitle tracks:", error);
|
|
32610
|
+
return [];
|
|
32611
|
+
}
|
|
32612
|
+
}
|
|
32613
|
+
getCurrentSubtitleTrack() {
|
|
32614
|
+
if (!this.hls) {
|
|
32615
|
+
console.warn("HLS instance not initialized");
|
|
32616
|
+
return -1;
|
|
32617
|
+
}
|
|
32618
|
+
try {
|
|
32619
|
+
return this.hls.subtitleTrack;
|
|
32620
|
+
} catch (error) {
|
|
32621
|
+
console.error("Failed to get current subtitle track:", error);
|
|
32622
|
+
return -1;
|
|
32623
|
+
}
|
|
32624
|
+
}
|
|
32625
|
+
switchSubtitleTrack(trackId) {
|
|
32626
|
+
if (!this.hls) {
|
|
32627
|
+
console.warn("HLS instance not initialized");
|
|
32628
|
+
return false;
|
|
32629
|
+
}
|
|
32630
|
+
const subtitleTracks = this.getSubtitleTracks();
|
|
32631
|
+
if (trackId === -1) {
|
|
32632
|
+
try {
|
|
32633
|
+
this.hls.subtitleTrack = -1;
|
|
32634
|
+
this.player.emit("core_event", {
|
|
32635
|
+
eventName: "core.subtitletrackchange",
|
|
32636
|
+
trackId: -1,
|
|
32637
|
+
trackInfo: null
|
|
32638
|
+
});
|
|
32639
|
+
return true;
|
|
32640
|
+
} catch (error) {
|
|
32641
|
+
console.error("Failed to disable subtitle track:", error);
|
|
32642
|
+
return false;
|
|
32643
|
+
}
|
|
32644
|
+
}
|
|
32645
|
+
if (subtitleTracks.length === 0) {
|
|
32646
|
+
console.warn("No subtitle tracks available");
|
|
32647
|
+
return false;
|
|
32648
|
+
}
|
|
32649
|
+
const trackExists = subtitleTracks.some((_, index) => index === trackId);
|
|
32650
|
+
if (!trackExists) {
|
|
32651
|
+
console.warn(`Subtitle track with ID ${trackId} not found`);
|
|
32652
|
+
return false;
|
|
32653
|
+
}
|
|
32654
|
+
try {
|
|
32655
|
+
this.hls.subtitleTrack = trackId;
|
|
32656
|
+
this.player.emit("core_event", {
|
|
32657
|
+
eventName: "core.subtitletrackchange",
|
|
32658
|
+
trackId,
|
|
32659
|
+
trackInfo: subtitleTracks[trackId] || null
|
|
32660
|
+
});
|
|
32661
|
+
return true;
|
|
32662
|
+
} catch (error) {
|
|
32663
|
+
console.error("Failed to switch subtitle track:", error);
|
|
32664
|
+
return false;
|
|
32665
|
+
}
|
|
32666
|
+
}
|
|
32667
|
+
getSubtitleDisplay() {
|
|
32668
|
+
if (!this.hls) {
|
|
32669
|
+
console.warn("HLS instance not initialized");
|
|
32670
|
+
return false;
|
|
32671
|
+
}
|
|
32672
|
+
try {
|
|
32673
|
+
return this.hls.subtitleDisplay;
|
|
32674
|
+
} catch (error) {
|
|
32675
|
+
console.error("Failed to get subtitle display status:", error);
|
|
32676
|
+
return false;
|
|
32677
|
+
}
|
|
32678
|
+
}
|
|
32679
|
+
setSubtitleDisplay(enabled) {
|
|
32680
|
+
if (!this.hls) {
|
|
32681
|
+
console.warn("HLS instance not initialized");
|
|
32682
|
+
return false;
|
|
32683
|
+
}
|
|
32684
|
+
try {
|
|
32685
|
+
this.hls.subtitleDisplay = enabled;
|
|
32686
|
+
this.player.emit("core_event", {
|
|
32687
|
+
eventName: "core.subtitledisplaychange",
|
|
32688
|
+
enabled
|
|
32689
|
+
});
|
|
32690
|
+
return true;
|
|
32691
|
+
} catch (error) {
|
|
32692
|
+
console.error("Failed to set subtitle display:", error);
|
|
32693
|
+
return false;
|
|
32694
|
+
}
|
|
32695
|
+
}
|
|
32696
|
+
}
|
|
32257
32697
|
const MAX_HOLE = 0.1;
|
|
32258
32698
|
class XgHls extends BasePlugin {
|
|
32259
32699
|
constructor(options) {
|
|
32260
|
-
super(
|
|
32700
|
+
super({
|
|
32701
|
+
...options,
|
|
32702
|
+
pluginName: XgHls.pluginName
|
|
32703
|
+
});
|
|
32261
32704
|
this._tickInterval = 500;
|
|
32705
|
+
this._currentIndex = 0;
|
|
32262
32706
|
this._onPlay = () => {
|
|
32263
32707
|
this.hls.startLoad();
|
|
32264
32708
|
};
|
|
@@ -32296,8 +32740,7 @@ class XgHls extends BasePlugin {
|
|
|
32296
32740
|
var _a;
|
|
32297
32741
|
(_a = this.hls) == null ? void 0 : _a.on(eventName, func);
|
|
32298
32742
|
};
|
|
32299
|
-
|
|
32300
|
-
this.config = config;
|
|
32743
|
+
this.config = options.config || {};
|
|
32301
32744
|
this.player.handleSource = false;
|
|
32302
32745
|
}
|
|
32303
32746
|
static get pluginName() {
|
|
@@ -32307,209 +32750,7 @@ class XgHls extends BasePlugin {
|
|
|
32307
32750
|
this.register(this.player.config.url);
|
|
32308
32751
|
}
|
|
32309
32752
|
initEvt() {
|
|
32310
|
-
this.hls
|
|
32311
|
-
this.player.emit("core_event", {
|
|
32312
|
-
eventName: "core.subtitlesegments",
|
|
32313
|
-
list: frag
|
|
32314
|
-
});
|
|
32315
|
-
});
|
|
32316
|
-
this.hls.on(Hls.Events.MANIFEST_PARSED, (_, { levels }) => {
|
|
32317
|
-
this.player.emit("core_event", {
|
|
32318
|
-
eventName: "core.subtitleplaylist",
|
|
32319
|
-
list: levels
|
|
32320
|
-
});
|
|
32321
|
-
});
|
|
32322
|
-
this.hls.on(Hls.Events.MANIFEST_LOADING, (_, { url }) => {
|
|
32323
|
-
this.player.emit("core_event", {
|
|
32324
|
-
eventName: "core.loadstart",
|
|
32325
|
-
url
|
|
32326
|
-
});
|
|
32327
|
-
});
|
|
32328
|
-
this.hls.on(Hls.Events.LEVEL_LOADING, (_, { url }) => {
|
|
32329
|
-
this.player.emit("core_event", {
|
|
32330
|
-
eventName: "core.loadstart",
|
|
32331
|
-
url
|
|
32332
|
-
});
|
|
32333
|
-
});
|
|
32334
|
-
this.hls.on(Hls.Events.FRAG_LOADING, (_, { frag }) => {
|
|
32335
|
-
this.player.emit("core_event", {
|
|
32336
|
-
eventName: "core.loadstart",
|
|
32337
|
-
url: frag.url
|
|
32338
|
-
});
|
|
32339
|
-
});
|
|
32340
|
-
this.hls.on(Hls.Events.MANIFEST_LOADED, (_, data) => {
|
|
32341
|
-
const { url } = data;
|
|
32342
|
-
this.player.emit("core_event", {
|
|
32343
|
-
eventName: "core.loadcomplete",
|
|
32344
|
-
url
|
|
32345
|
-
});
|
|
32346
|
-
});
|
|
32347
|
-
this.hls.on(Hls.Events.LEVEL_LOADED, (_, data) => {
|
|
32348
|
-
const { details, stats } = data;
|
|
32349
|
-
this.player.emit("core_event", {
|
|
32350
|
-
eventName: "core.loadcomplete",
|
|
32351
|
-
...stats,
|
|
32352
|
-
url: details == null ? void 0 : details.url
|
|
32353
|
-
});
|
|
32354
|
-
});
|
|
32355
|
-
this.hls.on(Hls.Events.FRAG_LOADED, (_, data) => {
|
|
32356
|
-
const { frag } = data;
|
|
32357
|
-
this.player.emit("core_event", {
|
|
32358
|
-
eventName: "core.loadcomplete",
|
|
32359
|
-
url: frag.url
|
|
32360
|
-
});
|
|
32361
|
-
});
|
|
32362
|
-
this.hls.on(Hls.Events.FRAG_PARSING_USERDATA, (_, { samples }) => {
|
|
32363
|
-
this.player.emit("core_event", {
|
|
32364
|
-
eventName: "core.sei",
|
|
32365
|
-
sei: samples
|
|
32366
|
-
});
|
|
32367
|
-
});
|
|
32368
|
-
this.hls.on(Hls.Events.MANIFEST_LOADED, (_, { levels, networkDetails }) => {
|
|
32369
|
-
this.player.emit("core_event", {
|
|
32370
|
-
eventName: "core.hlsmanifestloaded",
|
|
32371
|
-
playlist: levels
|
|
32372
|
-
});
|
|
32373
|
-
this.player.emit("core_event", {
|
|
32374
|
-
eventName: "core.loadresponseheaders",
|
|
32375
|
-
headers: networkDetails.headers
|
|
32376
|
-
});
|
|
32377
|
-
});
|
|
32378
|
-
this.hls.on(Hls.Events.LEVEL_LOADED, (_, { details }) => {
|
|
32379
|
-
const dateRanges = {};
|
|
32380
|
-
Object.keys(details.dateRanges).forEach((key) => {
|
|
32381
|
-
dateRanges[key] = details.dateRanges[key].attr["START-DATE"];
|
|
32382
|
-
});
|
|
32383
|
-
this.player.emit("core_event", {
|
|
32384
|
-
eventName: "core.hlslevelloaded",
|
|
32385
|
-
playlist: {
|
|
32386
|
-
...details,
|
|
32387
|
-
segments: details.fragments,
|
|
32388
|
-
dateRanges
|
|
32389
|
-
}
|
|
32390
|
-
});
|
|
32391
|
-
});
|
|
32392
|
-
this.hls.on(Hls.Events.ERROR, (_, data) => {
|
|
32393
|
-
const { details, fatal, type, response, reason, error } = data;
|
|
32394
|
-
if (!fatal) {
|
|
32395
|
-
return;
|
|
32396
|
-
}
|
|
32397
|
-
let errorCode;
|
|
32398
|
-
let errorType;
|
|
32399
|
-
switch (type) {
|
|
32400
|
-
case Hls.ErrorTypes.NETWORK_ERROR:
|
|
32401
|
-
errorCode = 2100;
|
|
32402
|
-
if (details.includes("TimeOut")) {
|
|
32403
|
-
errorCode = 2101;
|
|
32404
|
-
} else if ((response == null ? void 0 : response.code) === 403) {
|
|
32405
|
-
errorCode = 2103;
|
|
32406
|
-
} else if ((response == null ? void 0 : response.code) === 404) {
|
|
32407
|
-
errorCode = 2104;
|
|
32408
|
-
}
|
|
32409
|
-
this.player.emit("error", {
|
|
32410
|
-
errorType: "network",
|
|
32411
|
-
errorCode,
|
|
32412
|
-
message: (error == null ? void 0 : error.message) || details,
|
|
32413
|
-
originError: data
|
|
32414
|
-
});
|
|
32415
|
-
break;
|
|
32416
|
-
case Hls.ErrorTypes.MEDIA_ERROR:
|
|
32417
|
-
errorType = "media";
|
|
32418
|
-
if (details === Hls.ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR) {
|
|
32419
|
-
errorCode = 5104;
|
|
32420
|
-
} else if (details === Hls.ErrorDetails.FRAG_DECRYPT_ERROR) {
|
|
32421
|
-
errorCode = 5105;
|
|
32422
|
-
} else if (details === Hls.ErrorDetails.FRAG_PARSING_ERROR) {
|
|
32423
|
-
errorCode = 1100;
|
|
32424
|
-
errorType = "manifest";
|
|
32425
|
-
} else if (details === Hls.ErrorDetails.FRAG_GAP) {
|
|
32426
|
-
errorCode = 5104;
|
|
32427
|
-
} else if (details === Hls.ErrorDetails.BUFFER_ADD_CODEC_ERROR) {
|
|
32428
|
-
errorCode = 5200;
|
|
32429
|
-
} else if (details === Hls.ErrorDetails.BUFFER_INCOMPATIBLE_CODECS_ERROR) {
|
|
32430
|
-
errorCode = 5104;
|
|
32431
|
-
} else if (details === Hls.ErrorDetails.BUFFER_APPEND_ERROR) {
|
|
32432
|
-
errorCode = 5201;
|
|
32433
|
-
} else if (details === Hls.ErrorDetails.BUFFER_APPENDING_ERROR) {
|
|
32434
|
-
errorCode = 5201;
|
|
32435
|
-
} else if (details === Hls.ErrorDetails.BUFFER_STALLED_ERROR) {
|
|
32436
|
-
errorCode = 5203;
|
|
32437
|
-
} else if (details === Hls.ErrorDetails.BUFFER_FULL_ERROR) {
|
|
32438
|
-
errorCode = 5203;
|
|
32439
|
-
} else if (details === Hls.ErrorDetails.BUFFER_SEEK_OVER_HOLE) {
|
|
32440
|
-
errorCode = 5202;
|
|
32441
|
-
} else if (details === Hls.ErrorDetails.BUFFER_NUDGE_ON_STALL) {
|
|
32442
|
-
errorCode = 5202;
|
|
32443
|
-
}
|
|
32444
|
-
this.player.emit("error", {
|
|
32445
|
-
errorType: errorType || type,
|
|
32446
|
-
errorCode,
|
|
32447
|
-
message: (error == null ? void 0 : error.message) || details,
|
|
32448
|
-
originError: data
|
|
32449
|
-
});
|
|
32450
|
-
break;
|
|
32451
|
-
case Hls.ErrorTypes.MUX_ERROR:
|
|
32452
|
-
errorCode = 4100;
|
|
32453
|
-
this.player.emit("error", {
|
|
32454
|
-
errorType: "remux",
|
|
32455
|
-
errorCode,
|
|
32456
|
-
message: (error == null ? void 0 : error.message) || details,
|
|
32457
|
-
originError: data
|
|
32458
|
-
});
|
|
32459
|
-
break;
|
|
32460
|
-
case Hls.ErrorTypes.KEY_SYSTEM_ERROR:
|
|
32461
|
-
errorCode = 7111;
|
|
32462
|
-
if (details === Hls.ErrorDetails.KEY_SYSTEM_NO_KEYS) {
|
|
32463
|
-
errorCode = 7103;
|
|
32464
|
-
} else if (details === Hls.ErrorDetails.KEY_SYSTEM_NO_ACCESS) {
|
|
32465
|
-
errorCode = 7101;
|
|
32466
|
-
} else if (details === Hls.ErrorDetails.KEY_SYSTEM_NO_SESSION) {
|
|
32467
|
-
errorCode = 7104;
|
|
32468
|
-
} else if (details === Hls.ErrorDetails.KEY_SYSTEM_NO_CONFIGURED_LICENSE) {
|
|
32469
|
-
errorCode = 7107;
|
|
32470
|
-
} else if (details === Hls.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED) {
|
|
32471
|
-
errorCode = 7108;
|
|
32472
|
-
} else if (details === Hls.ErrorDetails.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED) {
|
|
32473
|
-
errorCode = 7110;
|
|
32474
|
-
} else if (details === Hls.ErrorDetails.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED) {
|
|
32475
|
-
errorCode = 7110;
|
|
32476
|
-
} else if (details === Hls.ErrorDetails.KEY_SYSTEM_SESSION_UPDATE_FAILED) {
|
|
32477
|
-
errorCode = 7104;
|
|
32478
|
-
} else if (details === Hls.ErrorDetails.KEY_SYSTEM_STATUS_INTERNAL_ERROR) {
|
|
32479
|
-
errorCode = 7111;
|
|
32480
|
-
}
|
|
32481
|
-
this.player.emit("error", {
|
|
32482
|
-
errorType: "drm",
|
|
32483
|
-
errorCode,
|
|
32484
|
-
message: (error == null ? void 0 : error.message) || reason || details,
|
|
32485
|
-
originError: data
|
|
32486
|
-
});
|
|
32487
|
-
break;
|
|
32488
|
-
default:
|
|
32489
|
-
if (details === Hls.ErrorDetails.LEVEL_SWITCH_ERROR) {
|
|
32490
|
-
errorCode = 2100;
|
|
32491
|
-
errorType = "network";
|
|
32492
|
-
}
|
|
32493
|
-
this.player.emit("error", {
|
|
32494
|
-
errorType: errorType || "other",
|
|
32495
|
-
errorCode,
|
|
32496
|
-
message: (error == null ? void 0 : error.message) || reason || details,
|
|
32497
|
-
originError: data
|
|
32498
|
-
});
|
|
32499
|
-
break;
|
|
32500
|
-
}
|
|
32501
|
-
try {
|
|
32502
|
-
this.hls.stopLoad();
|
|
32503
|
-
this.player.pause();
|
|
32504
|
-
} catch (error2) {
|
|
32505
|
-
}
|
|
32506
|
-
});
|
|
32507
|
-
this.hls.on(Hls.Events.MEDIA_ATTACHED, () => {
|
|
32508
|
-
this.player.emit("sourceopen");
|
|
32509
|
-
});
|
|
32510
|
-
this.hls.on(Hls.Events.BUFFER_APPENDED, () => {
|
|
32511
|
-
this.player.emit("bufferappend");
|
|
32512
|
-
});
|
|
32753
|
+
initHlsEvents(this.hls, this.player);
|
|
32513
32754
|
}
|
|
32514
32755
|
afterCreate() {
|
|
32515
32756
|
const media = this.player.media;
|
|
@@ -32535,8 +32776,9 @@ class XgHls extends BasePlugin {
|
|
|
32535
32776
|
if (this.hls) {
|
|
32536
32777
|
this.hls.destroy();
|
|
32537
32778
|
}
|
|
32538
|
-
const hlsConfig = getHlsConfig(this.config
|
|
32779
|
+
const hlsConfig = getHlsConfig(this.config);
|
|
32539
32780
|
this.hls = new Hls(hlsConfig);
|
|
32781
|
+
this._trackManager = new TrackManager(this.hls, this.player);
|
|
32540
32782
|
this.initEvt();
|
|
32541
32783
|
if (player.config.preProcessUrl) {
|
|
32542
32784
|
const { url: newUrl } = player.config.preProcessUrl(url);
|
|
@@ -32550,10 +32792,47 @@ class XgHls extends BasePlugin {
|
|
|
32550
32792
|
media.removeEventListener("play", this._onPlay);
|
|
32551
32793
|
media.addEventListener("play", this._onPlay);
|
|
32552
32794
|
}
|
|
32795
|
+
switchUrl(url, { startTime, bitrate, seamless }) {
|
|
32796
|
+
this.hls.loadSource(url);
|
|
32797
|
+
if (startTime !== void 0) {
|
|
32798
|
+
const media = this.player.media;
|
|
32799
|
+
media.currentTime = startTime;
|
|
32800
|
+
}
|
|
32801
|
+
}
|
|
32802
|
+
// Audio Track Methods
|
|
32803
|
+
getAudioTracks() {
|
|
32804
|
+
return this._trackManager.getAudioTracks();
|
|
32805
|
+
}
|
|
32806
|
+
getCurrentAudioTrack() {
|
|
32807
|
+
return this._trackManager.getCurrentAudioTrack();
|
|
32808
|
+
}
|
|
32809
|
+
switchAudioTrack(trackId) {
|
|
32810
|
+
return this._trackManager.switchAudioTrack(trackId);
|
|
32811
|
+
}
|
|
32812
|
+
// Subtitle Track Methods
|
|
32813
|
+
getSubtitleTracks() {
|
|
32814
|
+
return this._trackManager.getSubtitleTracks();
|
|
32815
|
+
}
|
|
32816
|
+
getAllSubtitleTracks() {
|
|
32817
|
+
return this._trackManager.getAllSubtitleTracks();
|
|
32818
|
+
}
|
|
32819
|
+
getCurrentSubtitleTrack() {
|
|
32820
|
+
return this._trackManager.getCurrentSubtitleTrack();
|
|
32821
|
+
}
|
|
32822
|
+
switchSubtitleTrack(trackId) {
|
|
32823
|
+
return this._trackManager.switchSubtitleTrack(trackId);
|
|
32824
|
+
}
|
|
32825
|
+
getSubtitleDisplay() {
|
|
32826
|
+
return this._trackManager.getSubtitleDisplay();
|
|
32827
|
+
}
|
|
32828
|
+
setSubtitleDisplay(enabled) {
|
|
32829
|
+
return this._trackManager.setSubtitleDisplay(enabled);
|
|
32830
|
+
}
|
|
32553
32831
|
destroy() {
|
|
32832
|
+
var _a;
|
|
32554
32833
|
clearTimeout(this._tickTimer);
|
|
32555
32834
|
this.player.off(URL_CHANGE, this.onUrlChange);
|
|
32556
|
-
this.hls.destroy();
|
|
32835
|
+
(_a = this.hls) == null ? void 0 : _a.destroy();
|
|
32557
32836
|
}
|
|
32558
32837
|
}
|
|
32559
32838
|
class HlsPlugin extends XgHls {
|
|
@@ -32577,7 +32856,6 @@ class HlsPlugin extends XgHls {
|
|
|
32577
32856
|
});
|
|
32578
32857
|
}
|
|
32579
32858
|
}
|
|
32580
|
-
const DynamicModule = window["VePlayer"].DynamicModule;
|
|
32581
32859
|
const __PLUGIN_NAME__ = DynamicModule.PluginHlsJs;
|
|
32582
32860
|
export {
|
|
32583
32861
|
HlsPlugin,
|