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