@geekapps/silo-elements-nextjs 0.2.50 → 0.2.52

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.
@@ -150,11 +150,20 @@ function Video({
150
150
  const applySubtitleMode = useCallback((mode) => {
151
151
  const video = videoRef.current;
152
152
  if (!video) return;
153
+ let activeTrack = null;
153
154
  Array.from(video.textTracks).forEach((track) => {
154
155
  if (track.kind === "metadata") return;
155
- track.mode = mode !== "off" && track.language === mode ? "hidden" : "disabled";
156
+ const enabled = mode !== "off" && track.language === mode;
157
+ track.mode = enabled ? "hidden" : "disabled";
158
+ if (enabled) activeTrack = track;
156
159
  });
157
- if (mode === "off") setActiveCue(null);
160
+ if (!activeTrack) {
161
+ setActiveCue(null);
162
+ return;
163
+ }
164
+ const cues = activeTrack.activeCues;
165
+ const cue = cues && cues.length > 0 ? cues[0] : null;
166
+ setActiveCue(cue ? cue.text.replace(/<[^>]*>/g, "") : null);
158
167
  }, []);
159
168
  const showControlsTemporarily = useCallback(() => {
160
169
  setControlsVisible(true);
@@ -288,6 +297,7 @@ function Video({
288
297
  t.removeEventListener("cuechange", onCueChange);
289
298
  t.addEventListener("cuechange", onCueChange);
290
299
  });
300
+ applySubtitleMode(subtitleModeRef.current);
291
301
  };
292
302
  bindTracks();
293
303
  video.textTracks.addEventListener("addtrack", bindTracks);
@@ -830,7 +840,7 @@ function Video({
830
840
  label: subtitle.label,
831
841
  default: subtitle.default
832
842
  },
833
- `${activeSource.src}-${subtitle.srclang}`
843
+ `${activeSource.src}-${subtitle.srclang}-${subtitle.src}`
834
844
  )),
835
845
  parsed.storyboard?.src && /* @__PURE__ */ jsx(
836
846
  "track",