@geekapps/silo-elements-nextjs 0.3.21 → 0.3.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/VideoPlayer.js +34 -31
- package/dist/VideoPlayer.js.map +1 -1
- package/dist/index.js +34 -31
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1550,9 +1550,8 @@ function deviceSupportsHdr() {
|
|
|
1550
1550
|
function deviceSupportsOpus() {
|
|
1551
1551
|
if (typeof window === "undefined") return false;
|
|
1552
1552
|
try {
|
|
1553
|
-
if (typeof MediaSource !== "undefined" && MediaSource.isTypeSupported)
|
|
1554
|
-
|
|
1555
|
-
}
|
|
1553
|
+
if (typeof MediaSource !== "undefined" && MediaSource.isTypeSupported)
|
|
1554
|
+
return MediaSource.isTypeSupported('audio/mp4; codecs="opus"');
|
|
1556
1555
|
const a = document.createElement("audio");
|
|
1557
1556
|
return a.canPlayType('audio/ogg; codecs="opus"') !== "" || a.canPlayType('video/mp4; codecs="opus"') !== "";
|
|
1558
1557
|
} catch {
|
|
@@ -2403,6 +2402,22 @@ function Video({
|
|
|
2403
2402
|
const Hls = HlsModule.default;
|
|
2404
2403
|
console.debug("[Silo/hls] Hls.isSupported()=", Hls.isSupported());
|
|
2405
2404
|
if (Hls.isSupported()) {
|
|
2405
|
+
let tryNextAudioTrack2 = function() {
|
|
2406
|
+
const next = mappedAudioTracks.find((t) => t.supported && !failedAudioTracks.has(t.id));
|
|
2407
|
+
if (next) {
|
|
2408
|
+
console.debug("[Silo/hls] trying audio track", next.id, next.codec || "(unknown codec)");
|
|
2409
|
+
hls.audioTrack = next.id;
|
|
2410
|
+
if (pinnedAudio === -1) setSelectedAudio(next.id);
|
|
2411
|
+
} else {
|
|
2412
|
+
console.warn("[Silo/hls] all audio tracks failed \u2014 disabling demuxed audio");
|
|
2413
|
+
setAudioTracks([]);
|
|
2414
|
+
try {
|
|
2415
|
+
hls.audioTrack = -1;
|
|
2416
|
+
} catch {
|
|
2417
|
+
}
|
|
2418
|
+
}
|
|
2419
|
+
};
|
|
2420
|
+
var tryNextAudioTrack = tryNextAudioTrack2;
|
|
2406
2421
|
const hls = new Hls({
|
|
2407
2422
|
enableWorker: true,
|
|
2408
2423
|
// Buffer ~20s ahead (≈1/6 of a 2min video). maxMaxBufferLength caps the
|
|
@@ -2464,32 +2479,27 @@ function Video({
|
|
|
2464
2479
|
if (pinnedAudio >= 0) hls.audioTrack = pinnedAudio;
|
|
2465
2480
|
setIsLoading(false);
|
|
2466
2481
|
});
|
|
2482
|
+
let mappedAudioTracks = [];
|
|
2483
|
+
const failedAudioTracks = /* @__PURE__ */ new Set();
|
|
2467
2484
|
hls.on(Hls.Events.AUDIO_TRACKS_UPDATED, (_, data) => {
|
|
2468
2485
|
const tracks = data.audioTracks ?? [];
|
|
2469
2486
|
console.debug("[Silo/hls] AUDIO_TRACKS_UPDATED", tracks.length);
|
|
2470
2487
|
if (tracks.length > 0) {
|
|
2471
|
-
|
|
2488
|
+
mappedAudioTracks = tracks.map((t, i) => {
|
|
2472
2489
|
const codec = (t.attrs?.CODECS ?? t.codecSet ?? "").split(",")[0]?.trim() ?? "";
|
|
2473
2490
|
const supported = deviceSupportsAudioCodec(codec);
|
|
2474
2491
|
const label = friendlyAudioLabel(t.name, t.lang, codec, t.channels ?? t.attrs?.CHANNELS);
|
|
2475
|
-
return { id: i, label, supported };
|
|
2492
|
+
return { id: i, label, supported, codec };
|
|
2476
2493
|
});
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
hls.
|
|
2483
|
-
if (pinnedAudio === -1) setSelectedAudio(firstSupported);
|
|
2484
|
-
} else {
|
|
2485
|
-
console.warn("[Silo/hls] no supported audio track found \u2014 disabling separate audio");
|
|
2486
|
-
try {
|
|
2487
|
-
hls.audioTrack = -1;
|
|
2488
|
-
} catch {
|
|
2489
|
-
}
|
|
2494
|
+
if (pinnedAudio === -1) {
|
|
2495
|
+
const first = mappedAudioTracks.find((t) => t.supported) ?? mappedAudioTracks[0];
|
|
2496
|
+
if (first) {
|
|
2497
|
+
hls.audioTrack = first.id;
|
|
2498
|
+
setSelectedAudio(first.id);
|
|
2499
|
+
console.debug("[Silo/hls] starting with audio track", first.id, first.codec || "(unknown codec)");
|
|
2490
2500
|
}
|
|
2491
2501
|
}
|
|
2492
|
-
if (
|
|
2502
|
+
if (mappedAudioTracks.length > 1) setAudioTracks(mappedAudioTracks.map(({ id, label, supported }) => ({ id, label, supported })));
|
|
2493
2503
|
}
|
|
2494
2504
|
if (pinnedAudio >= 0 && hls.audioTrack !== pinnedAudio) {
|
|
2495
2505
|
hls.audioTrack = pinnedAudio;
|
|
@@ -2523,7 +2533,6 @@ function Video({
|
|
|
2523
2533
|
console.debug("[Silo/hls] FRAG_LOADED", data.frag?.type, data.frag?.sn);
|
|
2524
2534
|
});
|
|
2525
2535
|
let mediaErrorAttempts = 0;
|
|
2526
|
-
let audioAppendErrors = 0;
|
|
2527
2536
|
let stalledOnPinnedLevel = 0;
|
|
2528
2537
|
hls.on(Hls.Events.ERROR, (_, data) => {
|
|
2529
2538
|
const fragUrl = (data.frag?.url ?? data.url ?? "").slice(-80);
|
|
@@ -2532,18 +2541,12 @@ function Video({
|
|
|
2532
2541
|
if (!data.fatal) {
|
|
2533
2542
|
const isAudioBufError = fragType === "audio" && (data.details === Hls.ErrorDetails.BUFFER_APPEND_ERROR || data.details === Hls.ErrorDetails.BUFFER_APPENDING_ERROR);
|
|
2534
2543
|
if (isAudioBufError) {
|
|
2535
|
-
|
|
2536
|
-
if (
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
hls.audioTrack = -1;
|
|
2541
|
-
} catch {
|
|
2542
|
-
}
|
|
2543
|
-
audioAppendErrors = 0;
|
|
2544
|
+
const failedTrack = hls.audioTrack;
|
|
2545
|
+
if (failedTrack >= 0 && pinnedAudio === -1) {
|
|
2546
|
+
failedAudioTracks.add(failedTrack);
|
|
2547
|
+
console.warn("[Silo/hls] audio track", failedTrack, "failed \u2014 trying next");
|
|
2548
|
+
tryNextAudioTrack2();
|
|
2544
2549
|
}
|
|
2545
|
-
} else {
|
|
2546
|
-
audioAppendErrors = 0;
|
|
2547
2550
|
}
|
|
2548
2551
|
if (data.details === Hls.ErrorDetails.BUFFER_STALLED_ERROR && pinnedLevel >= 0) {
|
|
2549
2552
|
stalledOnPinnedLevel += 1;
|