@geekapps/silo-elements-nextjs 0.2.49 → 0.2.50

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.
@@ -1,4 +1,4 @@
1
- import React, { useMemo, useState, useEffect, useRef, useCallback } from 'react';
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
- const defaultTrack = resolved.find((c) => c.default);
50
- if (defaultTrack) {
51
- setSubtitleMode(defaultTrack.srclang);
52
- setSubtitleStyle((st) => ({ ...st, track: defaultTrack.srclang }));
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) {