@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.
package/dist/index.js CHANGED
@@ -1277,11 +1277,20 @@ function Video({
1277
1277
  const applySubtitleMode = useCallback((mode) => {
1278
1278
  const video = videoRef.current;
1279
1279
  if (!video) return;
1280
+ let activeTrack = null;
1280
1281
  Array.from(video.textTracks).forEach((track) => {
1281
1282
  if (track.kind === "metadata") return;
1282
- track.mode = mode !== "off" && track.language === mode ? "hidden" : "disabled";
1283
+ const enabled = mode !== "off" && track.language === mode;
1284
+ track.mode = enabled ? "hidden" : "disabled";
1285
+ if (enabled) activeTrack = track;
1283
1286
  });
1284
- if (mode === "off") setActiveCue(null);
1287
+ if (!activeTrack) {
1288
+ setActiveCue(null);
1289
+ return;
1290
+ }
1291
+ const cues = activeTrack.activeCues;
1292
+ const cue = cues && cues.length > 0 ? cues[0] : null;
1293
+ setActiveCue(cue ? cue.text.replace(/<[^>]*>/g, "") : null);
1285
1294
  }, []);
1286
1295
  const showControlsTemporarily = useCallback(() => {
1287
1296
  setControlsVisible(true);
@@ -1415,6 +1424,7 @@ function Video({
1415
1424
  t.removeEventListener("cuechange", onCueChange);
1416
1425
  t.addEventListener("cuechange", onCueChange);
1417
1426
  });
1427
+ applySubtitleMode(subtitleModeRef.current);
1418
1428
  };
1419
1429
  bindTracks();
1420
1430
  video.textTracks.addEventListener("addtrack", bindTracks);
@@ -1957,7 +1967,7 @@ function Video({
1957
1967
  label: subtitle.label,
1958
1968
  default: subtitle.default
1959
1969
  },
1960
- `${activeSource.src}-${subtitle.srclang}`
1970
+ `${activeSource.src}-${subtitle.srclang}-${subtitle.src}`
1961
1971
  )),
1962
1972
  parsed.storyboard?.src && /* @__PURE__ */ jsx(
1963
1973
  "track",