@geekapps/silo-elements-nextjs 0.3.23 → 0.3.25
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 +66 -7
- package/dist/VideoPlayer.js.map +1 -1
- package/dist/index.js +66 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1637,14 +1637,23 @@ var CHANNEL_LABELS = {
|
|
|
1637
1637
|
};
|
|
1638
1638
|
function friendlyAudioLabel(rawName, lang, codec, channels) {
|
|
1639
1639
|
const langKey = (lang ?? "").toLowerCase();
|
|
1640
|
-
const langLabel = LANG_NAMES[langKey] ?? (lang ? lang.toUpperCase() :
|
|
1641
|
-
const
|
|
1640
|
+
const langLabel = LANG_NAMES[langKey] ?? (lang && lang.toLowerCase() !== "und" ? lang.toUpperCase() : "Original");
|
|
1641
|
+
const chNum = typeof channels === "string" ? parseInt(channels, 10) : channels ?? 0;
|
|
1642
|
+
const searchIn = [codec, rawName ?? ""].join(" ").toLowerCase();
|
|
1643
|
+
const codecKey = Object.keys(CODEC_LABELS).find((k) => searchIn.includes(k));
|
|
1642
1644
|
const codecLabel = codecKey ? CODEC_LABELS[codecKey] : null;
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1645
|
+
let resolvedCh = chNum > 0 ? chNum : 0;
|
|
1646
|
+
if (!resolvedCh && rawName) {
|
|
1647
|
+
const m = rawName.match(/(\d+)\.(\d+)/) ?? rawName.match(/(\d+)\s*ch/i);
|
|
1648
|
+
if (m) {
|
|
1649
|
+
if (m[2] !== void 0) resolvedCh = parseInt(m[1], 10) + (parseInt(m[2], 10) > 0 ? 1 : 0);
|
|
1650
|
+
else resolvedCh = parseInt(m[1], 10);
|
|
1651
|
+
} else if (/stereo/i.test(rawName)) resolvedCh = 2;
|
|
1652
|
+
else if (/mono/i.test(rawName)) resolvedCh = 1;
|
|
1653
|
+
}
|
|
1654
|
+
const chLabel = resolvedCh ? CHANNEL_LABELS[resolvedCh] ?? `${resolvedCh}ch` : null;
|
|
1646
1655
|
const suffix = [codecLabel, chLabel].filter(Boolean).join(" ");
|
|
1647
|
-
return suffix ? `${
|
|
1656
|
+
return suffix ? `${langLabel} \u2014 ${suffix}` : langLabel;
|
|
1648
1657
|
}
|
|
1649
1658
|
function isHdrLevel(level) {
|
|
1650
1659
|
const range = level?.videoRange ?? level?.video_range ?? "";
|
|
@@ -2306,6 +2315,54 @@ function Video({
|
|
|
2306
2315
|
try {
|
|
2307
2316
|
const response = await fetch(parsed.storyboard.src);
|
|
2308
2317
|
if (!response.ok) throw new Error("Storyboard not found");
|
|
2318
|
+
const contentType = response.headers.get("content-type") ?? "";
|
|
2319
|
+
if (contentType.includes("application/json")) {
|
|
2320
|
+
const json = await response.json();
|
|
2321
|
+
if (json.resolutions && Object.keys(json.resolutions).length > 0) {
|
|
2322
|
+
storyboardCacheRef.current.clear();
|
|
2323
|
+
preloadedSpritesRef.current.clear();
|
|
2324
|
+
const RES_ORDER = ["180p", "240p", "360p", "480p", "default"];
|
|
2325
|
+
const keys = Object.keys(json.resolutions).sort((a, b) => {
|
|
2326
|
+
const ai = RES_ORDER.indexOf(a);
|
|
2327
|
+
const bi = RES_ORDER.indexOf(b);
|
|
2328
|
+
return (ai === -1 ? 99 : ai) - (bi === -1 ? 99 : bi);
|
|
2329
|
+
});
|
|
2330
|
+
const loadResFromApi = async (key) => {
|
|
2331
|
+
if (cancelled) return;
|
|
2332
|
+
const res = json.resolutions[key];
|
|
2333
|
+
if (!res) return;
|
|
2334
|
+
const vttResp = await fetch(res.vttUrl);
|
|
2335
|
+
if (!vttResp.ok) return;
|
|
2336
|
+
const vttText = await vttResp.text();
|
|
2337
|
+
const cues2 = parseStoryboardVtt(vttText, res.vttUrl);
|
|
2338
|
+
storyboardCacheRef.current.set(key, cues2);
|
|
2339
|
+
const firstSprite = cues2[0]?.image;
|
|
2340
|
+
if (firstSprite && !preloadedSpritesRef.current.has(firstSprite)) {
|
|
2341
|
+
preloadedSpritesRef.current.add(firstSprite);
|
|
2342
|
+
const img = new window.Image();
|
|
2343
|
+
img.src = firstSprite;
|
|
2344
|
+
}
|
|
2345
|
+
return cues2;
|
|
2346
|
+
};
|
|
2347
|
+
const firstCues = await loadResFromApi(keys[0]);
|
|
2348
|
+
if (!cancelled && firstCues) {
|
|
2349
|
+
setStoryboardCues(firstCues);
|
|
2350
|
+
setActiveStoryboardRes(keys[0]);
|
|
2351
|
+
}
|
|
2352
|
+
for (const key of keys.slice(1)) await loadResFromApi(key);
|
|
2353
|
+
return;
|
|
2354
|
+
}
|
|
2355
|
+
if (json.url) {
|
|
2356
|
+
const vttResp = await fetch(json.url);
|
|
2357
|
+
if (vttResp.ok) {
|
|
2358
|
+
const text2 = await vttResp.text();
|
|
2359
|
+
const spriteUrl = json.url.replace(/\/vtt(\?|$)/, "/sprite$1");
|
|
2360
|
+
const cues2 = parseStoryboardVtt(text2, spriteUrl);
|
|
2361
|
+
if (!cancelled) setStoryboardCues(cues2);
|
|
2362
|
+
}
|
|
2363
|
+
}
|
|
2364
|
+
return;
|
|
2365
|
+
}
|
|
2309
2366
|
const text = await response.text();
|
|
2310
2367
|
const cues = parseStoryboardVtt(text, new URL(parsed.storyboard.src, window.location.href).href);
|
|
2311
2368
|
if (!cancelled) setStoryboardCues(cues);
|
|
@@ -2544,9 +2601,11 @@ function Video({
|
|
|
2544
2601
|
const failedTrack = hls.audioTrack;
|
|
2545
2602
|
if (failedTrack >= 0 && pinnedAudio === -1) {
|
|
2546
2603
|
failedAudioTracks.add(failedTrack);
|
|
2547
|
-
console.warn("[Silo/hls] audio track", failedTrack, "failed \u2014 trying next");
|
|
2604
|
+
console.warn("[Silo/hls] audio track", failedTrack, "failed \u2014 recovering MSE and trying next");
|
|
2605
|
+
hls.recoverMediaError();
|
|
2548
2606
|
tryNextAudioTrack2();
|
|
2549
2607
|
}
|
|
2608
|
+
return;
|
|
2550
2609
|
}
|
|
2551
2610
|
if (data.details === Hls.ErrorDetails.BUFFER_STALLED_ERROR && pinnedLevel >= 0) {
|
|
2552
2611
|
stalledOnPinnedLevel += 1;
|