@geekapps/silo-elements-nextjs 0.2.51 → 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);