@geekapps/silo-elements-nextjs 0.2.47 → 0.2.49
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.d.ts +7 -1
- package/dist/VideoPlayer.js +20 -11
- package/dist/VideoPlayer.js.map +1 -1
- package/dist/index.js +20 -11
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1170,22 +1170,33 @@ function Video({
|
|
|
1170
1170
|
const [captions, setCaptions] = useState([]);
|
|
1171
1171
|
const [poster, setPoster] = useState(void 0);
|
|
1172
1172
|
useEffect(() => {
|
|
1173
|
+
function applyResolved(data) {
|
|
1174
|
+
const resolved = data.map((c, i) => ({ ...c, default: c.default ?? i === 0 }));
|
|
1175
|
+
setCaptions(resolved);
|
|
1176
|
+
const defaultTrack = resolved.find((c) => c.default);
|
|
1177
|
+
if (defaultTrack) {
|
|
1178
|
+
setSubtitleMode(defaultTrack.srclang);
|
|
1179
|
+
setSubtitleStyle((st) => ({ ...st, track: defaultTrack.srclang }));
|
|
1180
|
+
}
|
|
1181
|
+
}
|
|
1182
|
+
if (parsed.captionsData) {
|
|
1183
|
+
applyResolved(parsed.captionsData);
|
|
1184
|
+
return;
|
|
1185
|
+
}
|
|
1173
1186
|
if (!parsed.captionsSrc) {
|
|
1174
1187
|
setCaptions([]);
|
|
1175
1188
|
return;
|
|
1176
1189
|
}
|
|
1177
1190
|
let cancelled = false;
|
|
1178
1191
|
fetch(parsed.captionsSrc, { cache: "no-store" }).then((r) => r.json()).then((data) => {
|
|
1179
|
-
if (!cancelled && Array.isArray(data))
|
|
1180
|
-
setCaptions(data.map((c, i) => ({ ...c, default: i === 0 })));
|
|
1181
|
-
}
|
|
1192
|
+
if (!cancelled && Array.isArray(data)) applyResolved(data);
|
|
1182
1193
|
}).catch(() => {
|
|
1183
1194
|
if (!cancelled) setCaptions([]);
|
|
1184
1195
|
});
|
|
1185
1196
|
return () => {
|
|
1186
1197
|
cancelled = true;
|
|
1187
1198
|
};
|
|
1188
|
-
}, [parsed.captionsSrc]);
|
|
1199
|
+
}, [parsed.captionsSrc, parsed.captionsData]);
|
|
1189
1200
|
useEffect(() => {
|
|
1190
1201
|
if (!parsed.thumbnailSrc) {
|
|
1191
1202
|
setPoster(void 0);
|
|
@@ -1309,12 +1320,6 @@ function Video({
|
|
|
1309
1320
|
setSubtitleMode(initialSubtitleMode);
|
|
1310
1321
|
}
|
|
1311
1322
|
}, [subtitleMode, captions, initialSubtitleMode]);
|
|
1312
|
-
useEffect(() => {
|
|
1313
|
-
if (subtitleMode === "off" && initialSubtitleMode !== "off") {
|
|
1314
|
-
setSubtitleMode(initialSubtitleMode);
|
|
1315
|
-
setSubtitleStyle((st) => ({ ...st, track: initialSubtitleMode }));
|
|
1316
|
-
}
|
|
1317
|
-
}, [initialSubtitleMode]);
|
|
1318
1323
|
useEffect(() => {
|
|
1319
1324
|
const video = videoRef.current;
|
|
1320
1325
|
if (!video) return;
|
|
@@ -2757,7 +2762,11 @@ function parseVideoChildren(children) {
|
|
|
2757
2762
|
}
|
|
2758
2763
|
if (child.type === Captions || name === "SiloCaptions") {
|
|
2759
2764
|
const element = child;
|
|
2760
|
-
|
|
2765
|
+
if (element.props.data) {
|
|
2766
|
+
parsed.captionsData = element.props.data;
|
|
2767
|
+
} else if (element.props.src) {
|
|
2768
|
+
parsed.captionsSrc = element.props.src;
|
|
2769
|
+
}
|
|
2761
2770
|
}
|
|
2762
2771
|
if (child.type === VideoThumbnail || name === "SiloVideoThumbnail") {
|
|
2763
2772
|
const element = child;
|