@geekapps/silo-elements-nextjs 0.3.18 → 0.3.19
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 +29 -14
- package/dist/VideoPlayer.js.map +1 -1
- package/dist/index.js +29 -14
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1559,24 +1559,36 @@ function deviceSupportsOpus() {
|
|
|
1559
1559
|
return false;
|
|
1560
1560
|
}
|
|
1561
1561
|
}
|
|
1562
|
-
function
|
|
1563
|
-
if (typeof window === "undefined") return true;
|
|
1562
|
+
function deviceSupportsVideoCodec(codec) {
|
|
1563
|
+
if (!codec || typeof window === "undefined") return true;
|
|
1564
|
+
if (/^avc1/i.test(codec)) return true;
|
|
1564
1565
|
try {
|
|
1565
1566
|
if (typeof MediaSource !== "undefined" && MediaSource.isTypeSupported) {
|
|
1566
|
-
return MediaSource.isTypeSupported(`video/mp4; codecs="${
|
|
1567
|
+
return MediaSource.isTypeSupported(`video/mp4; codecs="${codec}"`);
|
|
1567
1568
|
}
|
|
1568
1569
|
return true;
|
|
1569
1570
|
} catch {
|
|
1570
1571
|
return true;
|
|
1571
1572
|
}
|
|
1572
1573
|
}
|
|
1574
|
+
function deviceSupportsAudioCodec(codec) {
|
|
1575
|
+
if (!codec || typeof window === "undefined") return true;
|
|
1576
|
+
if (/^mp4a/i.test(codec)) return true;
|
|
1577
|
+
if (/^opus/i.test(codec)) return deviceSupportsOpus();
|
|
1578
|
+
try {
|
|
1579
|
+
if (typeof MediaSource !== "undefined" && MediaSource.isTypeSupported) {
|
|
1580
|
+
return MediaSource.isTypeSupported(`audio/mp4; codecs="${codec}"`);
|
|
1581
|
+
}
|
|
1582
|
+
const a = document.createElement("audio");
|
|
1583
|
+
return a.canPlayType(`audio/mp4; codecs="${codec}"`) !== "";
|
|
1584
|
+
} catch {
|
|
1585
|
+
return true;
|
|
1586
|
+
}
|
|
1587
|
+
}
|
|
1573
1588
|
function isHdrLevel(level) {
|
|
1574
1589
|
const range = level?.videoRange ?? level?.video_range ?? "";
|
|
1575
1590
|
return range === "PQ" || range === "HLG" || range === "HDR10" || typeof level?.name === "string" && /hdr/i.test(level.name);
|
|
1576
1591
|
}
|
|
1577
|
-
function isHdrAudioCodec(codecStr) {
|
|
1578
|
-
return /opus/i.test(codecStr);
|
|
1579
|
-
}
|
|
1580
1592
|
var PLAYBACK_SPEEDS = [0.25, 0.5, 0.75, 1, 1.25, 1.5, 2];
|
|
1581
1593
|
function Source(_props) {
|
|
1582
1594
|
return null;
|
|
@@ -2362,10 +2374,14 @@ function Video({
|
|
|
2362
2374
|
AUTO_QUALITY,
|
|
2363
2375
|
...levels.map((level, index) => {
|
|
2364
2376
|
const hdr = isHdrLevel(level);
|
|
2365
|
-
const
|
|
2366
|
-
const
|
|
2377
|
+
const rawCodecs = (level.attrs?.CODECS ?? "").split(",").map((c) => c.trim());
|
|
2378
|
+
const videoCodec = level.videoCodec ?? rawCodecs.find((c) => /^avc1|^hvc1|^hev1|^av01|^vp09/i.test(c)) ?? rawCodecs[0] ?? "";
|
|
2379
|
+
const audioCodec = level.audioCodec ?? rawCodecs.find((c) => /^mp4a|^opus|^ec-3|^ac-3/i.test(c)) ?? "";
|
|
2380
|
+
const videoOk = deviceSupportsVideoCodec(videoCodec);
|
|
2381
|
+
const audioOk = deviceSupportsAudioCodec(audioCodec);
|
|
2382
|
+
const supported = (hdr ? hdrSupported : true) && videoOk && audioOk;
|
|
2367
2383
|
const baseName = level.name ?? (level.height ? `${level.height}p` : `${index + 1}`);
|
|
2368
|
-
const label = hdr ? `${baseName} HDR` : baseName;
|
|
2384
|
+
const label = hdr && hdrSupported ? `${baseName} HDR` : baseName;
|
|
2369
2385
|
return { id: `hls-${index}`, label, type: "hls", index, supported, hdr };
|
|
2370
2386
|
})
|
|
2371
2387
|
]);
|
|
@@ -2374,8 +2390,8 @@ function Video({
|
|
|
2374
2390
|
if (tracks.length > 1) {
|
|
2375
2391
|
setAudioTracks(
|
|
2376
2392
|
tracks.map((t, i) => {
|
|
2377
|
-
const codec = t.attrs?.CODECS ?? t.codecSet ?? "";
|
|
2378
|
-
const supported =
|
|
2393
|
+
const codec = (t.attrs?.CODECS ?? t.codecSet ?? "").split(",")[0]?.trim() ?? "";
|
|
2394
|
+
const supported = deviceSupportsAudioCodec(codec);
|
|
2379
2395
|
return { id: i, label: t.name ?? t.lang ?? `Track ${i + 1}`, supported };
|
|
2380
2396
|
})
|
|
2381
2397
|
);
|
|
@@ -2388,12 +2404,11 @@ function Video({
|
|
|
2388
2404
|
hls.on(Hls.Events.AUDIO_TRACKS_UPDATED, (_, data) => {
|
|
2389
2405
|
const tracks = data.audioTracks ?? [];
|
|
2390
2406
|
console.debug("[Silo/hls] AUDIO_TRACKS_UPDATED", tracks.length);
|
|
2391
|
-
const opusSupported = deviceSupportsOpus();
|
|
2392
2407
|
if (tracks.length > 1) {
|
|
2393
2408
|
setAudioTracks(
|
|
2394
2409
|
tracks.map((t, i) => {
|
|
2395
|
-
const codec = t.attrs?.CODECS ?? t.codecSet ?? "";
|
|
2396
|
-
const supported =
|
|
2410
|
+
const codec = (t.attrs?.CODECS ?? t.codecSet ?? "").split(",")[0]?.trim() ?? "";
|
|
2411
|
+
const supported = deviceSupportsAudioCodec(codec);
|
|
2397
2412
|
return { id: i, label: t.name ?? t.lang ?? `Track ${i + 1}`, supported };
|
|
2398
2413
|
})
|
|
2399
2414
|
);
|