@geekapps/silo-elements-nextjs 0.2.49 → 0.2.51
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 +12 -6
- package/dist/VideoPlayer.js.map +1 -1
- package/dist/index.js +11 -5
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
- package/styles.css +1 -1
package/dist/VideoPlayer.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useMemo, useState,
|
|
1
|
+
import React, { useMemo, useState, useRef, useEffect, useCallback } from 'react';
|
|
2
2
|
import gsap from 'gsap';
|
|
3
3
|
import { Pause, Play, VolumeX, Volume2, Captions as Captions$1, Settings, Minimize, Maximize } from 'lucide-react';
|
|
4
4
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
@@ -42,14 +42,19 @@ function Video({
|
|
|
42
42
|
const parsed = useMemo(() => parseVideoChildren(children), [children]);
|
|
43
43
|
const [captions, setCaptions] = useState([]);
|
|
44
44
|
const [poster, setPoster] = useState(void 0);
|
|
45
|
+
const captionsSourceRef = useRef("");
|
|
45
46
|
useEffect(() => {
|
|
47
|
+
const sourceKey = parsed.captionsSrc ?? parsed.captionsData?.[0]?.srclang ?? "";
|
|
46
48
|
function applyResolved(data) {
|
|
47
49
|
const resolved = data.map((c, i) => ({ ...c, default: c.default ?? i === 0 }));
|
|
48
50
|
setCaptions(resolved);
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
if (captionsSourceRef.current !== sourceKey) {
|
|
52
|
+
captionsSourceRef.current = sourceKey;
|
|
53
|
+
const defaultTrack = resolved.find((c) => c.default);
|
|
54
|
+
if (defaultTrack) {
|
|
55
|
+
setSubtitleMode(defaultTrack.srclang);
|
|
56
|
+
setSubtitleStyle((st) => ({ ...st, track: defaultTrack.srclang }));
|
|
57
|
+
}
|
|
53
58
|
}
|
|
54
59
|
}
|
|
55
60
|
if (parsed.captionsData) {
|
|
@@ -283,6 +288,7 @@ function Video({
|
|
|
283
288
|
t.removeEventListener("cuechange", onCueChange);
|
|
284
289
|
t.addEventListener("cuechange", onCueChange);
|
|
285
290
|
});
|
|
291
|
+
applySubtitleMode(subtitleModeRef.current);
|
|
286
292
|
};
|
|
287
293
|
bindTracks();
|
|
288
294
|
video.textTracks.addEventListener("addtrack", bindTracks);
|
|
@@ -825,7 +831,7 @@ function Video({
|
|
|
825
831
|
label: subtitle.label,
|
|
826
832
|
default: subtitle.default
|
|
827
833
|
},
|
|
828
|
-
`${activeSource.src}-${subtitle.srclang}`
|
|
834
|
+
`${activeSource.src}-${subtitle.srclang}-${subtitle.src}`
|
|
829
835
|
)),
|
|
830
836
|
parsed.storyboard?.src && /* @__PURE__ */ jsx(
|
|
831
837
|
"track",
|