@geekapps/silo-elements-nextjs 0.3.19 → 0.3.21
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 +87 -9
- package/dist/VideoPlayer.js.map +1 -1
- package/dist/index.js +87 -9
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1585,6 +1585,68 @@ function deviceSupportsAudioCodec(codec) {
|
|
|
1585
1585
|
return true;
|
|
1586
1586
|
}
|
|
1587
1587
|
}
|
|
1588
|
+
var LANG_NAMES = {
|
|
1589
|
+
pt: "Portugu\xEAs",
|
|
1590
|
+
"pt-br": "Portugu\xEAs (Brasil)",
|
|
1591
|
+
"pt-pt": "Portugu\xEAs (Portugal)",
|
|
1592
|
+
en: "English",
|
|
1593
|
+
"en-us": "English (US)",
|
|
1594
|
+
"en-gb": "English (UK)",
|
|
1595
|
+
es: "Espa\xF1ol",
|
|
1596
|
+
"es-419": "Espa\xF1ol (Latino)",
|
|
1597
|
+
fr: "Fran\xE7ais",
|
|
1598
|
+
de: "Deutsch",
|
|
1599
|
+
it: "Italiano",
|
|
1600
|
+
ja: "\u65E5\u672C\u8A9E",
|
|
1601
|
+
ko: "\uD55C\uAD6D\uC5B4",
|
|
1602
|
+
zh: "\u4E2D\u6587",
|
|
1603
|
+
"zh-cn": "\u666E\u901A\u8BDD",
|
|
1604
|
+
"zh-tw": "\u7E41\u9AD4\u4E2D\u6587",
|
|
1605
|
+
ru: "\u0420\u0443\u0441\u0441\u043A\u0438\u0439",
|
|
1606
|
+
ar: "\u0627\u0644\u0639\u0631\u0628\u064A\u0629",
|
|
1607
|
+
hi: "\u0939\u093F\u0928\u094D\u0926\u0940",
|
|
1608
|
+
nl: "Nederlands",
|
|
1609
|
+
pl: "Polski",
|
|
1610
|
+
sv: "Svenska",
|
|
1611
|
+
tr: "T\xFCrk\xE7e",
|
|
1612
|
+
und: "Original"
|
|
1613
|
+
};
|
|
1614
|
+
var CODEC_LABELS = {
|
|
1615
|
+
"truehd": "Dolby TrueHD",
|
|
1616
|
+
"atmos": "Dolby Atmos",
|
|
1617
|
+
"eac3": "Dolby Digital Plus",
|
|
1618
|
+
"ec-3": "Dolby Digital Plus",
|
|
1619
|
+
"e-ac-3": "Dolby Digital Plus",
|
|
1620
|
+
"ac3": "Dolby Digital",
|
|
1621
|
+
"ac-3": "Dolby Digital",
|
|
1622
|
+
"dts-hd": "DTS-HD",
|
|
1623
|
+
"dts-hd ma": "DTS-HD MA",
|
|
1624
|
+
"dtshd": "DTS-HD MA",
|
|
1625
|
+
"dts": "DTS",
|
|
1626
|
+
"aac": "AAC",
|
|
1627
|
+
"opus": "Opus",
|
|
1628
|
+
"mp3": "MP3",
|
|
1629
|
+
"flac": "FLAC",
|
|
1630
|
+
"alac": "ALAC"
|
|
1631
|
+
};
|
|
1632
|
+
var CHANNEL_LABELS = {
|
|
1633
|
+
1: "Mono",
|
|
1634
|
+
2: "Est\xE9reo",
|
|
1635
|
+
6: "5.1",
|
|
1636
|
+
7: "6.1",
|
|
1637
|
+
8: "7.1"
|
|
1638
|
+
};
|
|
1639
|
+
function friendlyAudioLabel(rawName, lang, codec, channels) {
|
|
1640
|
+
const langKey = (lang ?? "").toLowerCase();
|
|
1641
|
+
const langLabel = LANG_NAMES[langKey] ?? (lang ? lang.toUpperCase() : null);
|
|
1642
|
+
const codecKey = Object.keys(CODEC_LABELS).find((k) => codec.toLowerCase().includes(k));
|
|
1643
|
+
const codecLabel = codecKey ? CODEC_LABELS[codecKey] : null;
|
|
1644
|
+
const chLabel = channels ? CHANNEL_LABELS[channels] ?? `${channels}ch` : null;
|
|
1645
|
+
const looksHuman = rawName && !/^(und|dts|ac3|eac3|aac|opus|truehd|atmos|\w{2,3}-\d+ch|\w{2})/i.test(rawName) && rawName.length > 1;
|
|
1646
|
+
const baseName = looksHuman ? rawName : langLabel ?? "\xC1udio";
|
|
1647
|
+
const suffix = [codecLabel, chLabel].filter(Boolean).join(" ");
|
|
1648
|
+
return suffix ? `${baseName} \u2014 ${suffix}` : baseName;
|
|
1649
|
+
}
|
|
1588
1650
|
function isHdrLevel(level) {
|
|
1589
1651
|
const range = level?.videoRange ?? level?.video_range ?? "";
|
|
1590
1652
|
return range === "PQ" || range === "HLG" || range === "HDR10" || typeof level?.name === "string" && /hdr/i.test(level.name);
|
|
@@ -2392,7 +2454,8 @@ function Video({
|
|
|
2392
2454
|
tracks.map((t, i) => {
|
|
2393
2455
|
const codec = (t.attrs?.CODECS ?? t.codecSet ?? "").split(",")[0]?.trim() ?? "";
|
|
2394
2456
|
const supported = deviceSupportsAudioCodec(codec);
|
|
2395
|
-
|
|
2457
|
+
const label = friendlyAudioLabel(t.name, t.lang, codec, t.channels ?? t.attrs?.CHANNELS);
|
|
2458
|
+
return { id: i, label, supported };
|
|
2396
2459
|
})
|
|
2397
2460
|
);
|
|
2398
2461
|
if (pinnedAudio === -1) setSelectedAudio(hls.audioTrack ?? 0);
|
|
@@ -2404,14 +2467,29 @@ function Video({
|
|
|
2404
2467
|
hls.on(Hls.Events.AUDIO_TRACKS_UPDATED, (_, data) => {
|
|
2405
2468
|
const tracks = data.audioTracks ?? [];
|
|
2406
2469
|
console.debug("[Silo/hls] AUDIO_TRACKS_UPDATED", tracks.length);
|
|
2407
|
-
if (tracks.length >
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2470
|
+
if (tracks.length > 0) {
|
|
2471
|
+
const mapped = tracks.map((t, i) => {
|
|
2472
|
+
const codec = (t.attrs?.CODECS ?? t.codecSet ?? "").split(",")[0]?.trim() ?? "";
|
|
2473
|
+
const supported = deviceSupportsAudioCodec(codec);
|
|
2474
|
+
const label = friendlyAudioLabel(t.name, t.lang, codec, t.channels ?? t.attrs?.CHANNELS);
|
|
2475
|
+
return { id: i, label, supported };
|
|
2476
|
+
});
|
|
2477
|
+
const currentTrackIdx = hls.audioTrack ?? 0;
|
|
2478
|
+
if (mapped[currentTrackIdx] && !mapped[currentTrackIdx].supported) {
|
|
2479
|
+
const firstSupported = mapped.findIndex((t) => t.supported);
|
|
2480
|
+
if (firstSupported >= 0) {
|
|
2481
|
+
console.debug("[Silo/hls] current audio track unsupported \u2014 switching to track", firstSupported);
|
|
2482
|
+
hls.audioTrack = firstSupported;
|
|
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
|
+
}
|
|
2490
|
+
}
|
|
2491
|
+
}
|
|
2492
|
+
if (mapped.length > 1) setAudioTracks(mapped);
|
|
2415
2493
|
}
|
|
2416
2494
|
if (pinnedAudio >= 0 && hls.audioTrack !== pinnedAudio) {
|
|
2417
2495
|
hls.audioTrack = pinnedAudio;
|