@geekapps/silo-elements-nextjs 0.1.17 → 0.1.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 +39 -26
- package/dist/VideoPlayer.js.map +1 -1
- package/dist/index.js +39 -26
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1269,6 +1269,7 @@ function Video({
|
|
|
1269
1269
|
const [currentTime, setCurrentTime] = useState(0);
|
|
1270
1270
|
const [bufferedTime, setBufferedTime] = useState(0);
|
|
1271
1271
|
const [isPlaying, setIsPlaying] = useState(false);
|
|
1272
|
+
const [hasPlayed, setHasPlayed] = useState(false);
|
|
1272
1273
|
const [isLoading, setIsLoading] = useState(true);
|
|
1273
1274
|
const [controlsVisible, setControlsVisible] = useState(true);
|
|
1274
1275
|
const [volume, setVolume] = useState(defaultVolume);
|
|
@@ -1353,6 +1354,7 @@ function Video({
|
|
|
1353
1354
|
};
|
|
1354
1355
|
const onPlay = () => {
|
|
1355
1356
|
setIsPlaying(true);
|
|
1357
|
+
setHasPlayed(true);
|
|
1356
1358
|
showControlsTemporarily();
|
|
1357
1359
|
};
|
|
1358
1360
|
const onPause = () => {
|
|
@@ -1391,16 +1393,22 @@ function Video({
|
|
|
1391
1393
|
}, [volume, isMuted]);
|
|
1392
1394
|
useEffect(() => {
|
|
1393
1395
|
applySubtitleMode(subtitleMode);
|
|
1396
|
+
if (subtitleMode === "off") setActiveCue(null);
|
|
1394
1397
|
}, [subtitleMode, applySubtitleMode]);
|
|
1398
|
+
const subtitleModeRef = useRef(subtitleMode);
|
|
1399
|
+
useEffect(() => {
|
|
1400
|
+
subtitleModeRef.current = subtitleMode;
|
|
1401
|
+
}, [subtitleMode]);
|
|
1395
1402
|
useEffect(() => {
|
|
1396
1403
|
const video = videoRef.current;
|
|
1397
1404
|
if (!video) return;
|
|
1398
1405
|
const onCueChange = () => {
|
|
1399
|
-
|
|
1406
|
+
const mode = subtitleModeRef.current;
|
|
1407
|
+
if (mode === "off") {
|
|
1400
1408
|
setActiveCue(null);
|
|
1401
1409
|
return;
|
|
1402
1410
|
}
|
|
1403
|
-
const track = Array.from(video.textTracks).find((t) => t.language ===
|
|
1411
|
+
const track = Array.from(video.textTracks).find((t) => t.language === mode);
|
|
1404
1412
|
if (!track || !track.activeCues || track.activeCues.length === 0) {
|
|
1405
1413
|
setActiveCue(null);
|
|
1406
1414
|
return;
|
|
@@ -1408,10 +1416,19 @@ function Video({
|
|
|
1408
1416
|
const cue = track.activeCues[0];
|
|
1409
1417
|
setActiveCue(cue.text.replace(/<[^>]*>/g, ""));
|
|
1410
1418
|
};
|
|
1411
|
-
const
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1419
|
+
const bindTracks = () => {
|
|
1420
|
+
Array.from(video.textTracks).forEach((t) => {
|
|
1421
|
+
t.removeEventListener("cuechange", onCueChange);
|
|
1422
|
+
t.addEventListener("cuechange", onCueChange);
|
|
1423
|
+
});
|
|
1424
|
+
};
|
|
1425
|
+
bindTracks();
|
|
1426
|
+
video.textTracks.addEventListener("addtrack", bindTracks);
|
|
1427
|
+
return () => {
|
|
1428
|
+
video.textTracks.removeEventListener("addtrack", bindTracks);
|
|
1429
|
+
Array.from(video.textTracks).forEach((t) => t.removeEventListener("cuechange", onCueChange));
|
|
1430
|
+
};
|
|
1431
|
+
}, []);
|
|
1415
1432
|
useEffect(() => {
|
|
1416
1433
|
const onFullscreenChange = () => {
|
|
1417
1434
|
setIsFullscreen(Boolean(document.fullscreenElement));
|
|
@@ -1819,7 +1836,7 @@ function Video({
|
|
|
1819
1836
|
))
|
|
1820
1837
|
}
|
|
1821
1838
|
),
|
|
1822
|
-
poster && !
|
|
1839
|
+
poster && !hasPlayed && /* @__PURE__ */ jsx(
|
|
1823
1840
|
"img",
|
|
1824
1841
|
{
|
|
1825
1842
|
src: poster,
|
|
@@ -1836,31 +1853,19 @@ function Video({
|
|
|
1836
1853
|
),
|
|
1837
1854
|
isLoading && /* @__PURE__ */ jsx("div", { className: "pointer-events-none absolute inset-0 z-20 grid place-items-center bg-black/10", children: /* @__PURE__ */ jsx("div", { className: "size-9 animate-spin rounded-full border-2 border-white/25 border-t-white" }) }),
|
|
1838
1855
|
error && /* @__PURE__ */ jsx("div", { className: "absolute inset-x-8 top-1/2 z-40 -translate-y-1/2 rounded-2xl border border-white/10 bg-black/75 p-5 text-center text-sm text-white shadow-2xl backdrop-blur-xl", children: error }),
|
|
1839
|
-
activeCue && /* @__PURE__ */ jsx(
|
|
1840
|
-
"div",
|
|
1841
|
-
{
|
|
1842
|
-
className: `pointer-events-none absolute inset-x-0 z-25 flex justify-center transition-all duration-200 ${controlsVisible ? "bottom-24 @sm:bottom-28 @lg:bottom-32" : "bottom-6"}`,
|
|
1843
|
-
children: /* @__PURE__ */ jsx(
|
|
1844
|
-
"div",
|
|
1845
|
-
{
|
|
1846
|
-
className: "mx-4 max-w-3xl rounded-lg bg-black/70 px-4 py-2 text-center text-base font-medium leading-snug text-white backdrop-blur-sm @sm:text-lg @lg:text-xl",
|
|
1847
|
-
style: { textShadow: "0 1px 4px rgba(0,0,0,0.8)" },
|
|
1848
|
-
children: activeCue
|
|
1849
|
-
}
|
|
1850
|
-
)
|
|
1851
|
-
}
|
|
1852
|
-
),
|
|
1853
1856
|
/* @__PURE__ */ jsxs(
|
|
1854
1857
|
"div",
|
|
1855
1858
|
{
|
|
1856
1859
|
ref: chromeRef,
|
|
1857
1860
|
onClick: togglePlay,
|
|
1858
|
-
className: `absolute inset-0 z-30 flex flex-col justify-between
|
|
1861
|
+
className: `absolute inset-0 z-30 flex flex-col justify-between transition-opacity duration-200 ${controlsVisible ? "opacity-100" : "opacity-0 pointer-events-none"}`,
|
|
1859
1862
|
children: [
|
|
1860
|
-
/* @__PURE__ */
|
|
1863
|
+
/* @__PURE__ */ jsx("div", { className: "pointer-events-none absolute inset-x-0 top-0 h-32 bg-linear-to-b from-black/70 to-transparent" }),
|
|
1864
|
+
/* @__PURE__ */ jsx("div", { className: "pointer-events-none absolute inset-x-0 bottom-0 h-40 bg-linear-to-t from-black/80 to-transparent" }),
|
|
1865
|
+
/* @__PURE__ */ jsxs("header", { onClick: (e) => e.stopPropagation(), className: "relative z-10 flex items-start justify-between gap-4 px-4 pt-4 text-white @sm:px-7 @sm:pt-7 @lg:px-9 @lg:pt-8", children: [
|
|
1861
1866
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
1862
|
-
title && /* @__PURE__ */ jsx("h1", { className: "text-
|
|
1863
|
-
description && /* @__PURE__ */ jsx("p", { className: "mt-1 text-
|
|
1867
|
+
title && /* @__PURE__ */ jsx("h1", { className: "text-sm font-bold tracking-wide @sm:text-base @md:text-lg @lg:text-xl", style: { textShadow: "0 1px 6px rgba(0,0,0,0.6)" }, children: title }),
|
|
1868
|
+
description && /* @__PURE__ */ jsx("p", { className: "mt-1 text-xs font-medium text-white/85 @sm:text-sm", children: description })
|
|
1864
1869
|
] }),
|
|
1865
1870
|
parsed.sources.length > 1 && /* @__PURE__ */ jsx(
|
|
1866
1871
|
"select",
|
|
@@ -1873,7 +1878,15 @@ function Video({
|
|
|
1873
1878
|
}
|
|
1874
1879
|
)
|
|
1875
1880
|
] }),
|
|
1876
|
-
/* @__PURE__ */
|
|
1881
|
+
activeCue && /* @__PURE__ */ jsx("div", { className: "pointer-events-none relative z-10 flex justify-center px-4 pb-3 @sm:pb-4", children: /* @__PURE__ */ jsx(
|
|
1882
|
+
"div",
|
|
1883
|
+
{
|
|
1884
|
+
className: "max-w-3xl rounded-lg bg-black/70 px-4 py-2 text-center text-sm font-medium leading-snug text-white backdrop-blur-sm @sm:text-base @lg:text-lg",
|
|
1885
|
+
style: { textShadow: "0 1px 4px rgba(0,0,0,0.8)" },
|
|
1886
|
+
children: activeCue
|
|
1887
|
+
}
|
|
1888
|
+
) }),
|
|
1889
|
+
/* @__PURE__ */ jsxs("footer", { onClick: (e) => e.stopPropagation(), className: "relative z-10 px-3 pb-3 text-white @sm:px-5 @sm:pb-5 @lg:px-9 @lg:pb-8", children: [
|
|
1877
1890
|
/* @__PURE__ */ jsxs(
|
|
1878
1891
|
"div",
|
|
1879
1892
|
{
|