@livo-tv/blocks 1.9.1 → 1.10.0
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.cjs +10 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +10 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -3908,8 +3908,13 @@ function parseCaptionVtt(text) {
|
|
|
3908
3908
|
}
|
|
3909
3909
|
return cues;
|
|
3910
3910
|
}
|
|
3911
|
-
function captionAtTime(cues, time) {
|
|
3912
|
-
|
|
3911
|
+
function captionAtTime(cues, time, options) {
|
|
3912
|
+
const matched = cues.find((cue) => time >= cue.start && time < cue.end) ?? null;
|
|
3913
|
+
if (matched) return matched;
|
|
3914
|
+
if (options?.live && cues.length > 0) {
|
|
3915
|
+
return cues[cues.length - 1] ?? null;
|
|
3916
|
+
}
|
|
3917
|
+
return null;
|
|
3913
3918
|
}
|
|
3914
3919
|
async function loadCaptionVtt(url) {
|
|
3915
3920
|
try {
|
|
@@ -4173,7 +4178,9 @@ function VideoPlayer({
|
|
|
4173
4178
|
window.clearInterval(timer);
|
|
4174
4179
|
};
|
|
4175
4180
|
}, [captionLocale, liveCaptionsBaseUrl, src]);
|
|
4176
|
-
const activeCaption = captionAtTime(captionCues, currentTime
|
|
4181
|
+
const activeCaption = captionAtTime(captionCues, currentTime, {
|
|
4182
|
+
live: Boolean(liveCaptionsBaseUrl)
|
|
4183
|
+
});
|
|
4177
4184
|
function togglePlay() {
|
|
4178
4185
|
const video = videoRef.current;
|
|
4179
4186
|
if (!video) return;
|