@livo-tv/blocks 1.15.0 → 1.16.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 +14 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +14 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3928,6 +3928,15 @@ function captionAtTime(cues, time, options) {
|
|
|
3928
3928
|
if (matched) return matched;
|
|
3929
3929
|
return null;
|
|
3930
3930
|
}
|
|
3931
|
+
function vttCuesDueAt(cues, currentTime, cap = LIVE_STACK_MAX_CUES) {
|
|
3932
|
+
if (!Number.isFinite(currentTime)) return [];
|
|
3933
|
+
return cues.filter(
|
|
3934
|
+
(cue) => Boolean(cue.text.trim()) && Number.isFinite(cue.start) && cue.start <= currentTime
|
|
3935
|
+
).sort((left, right) => left.start - right.start).slice(-Math.max(1, cap)).map((cue) => ({
|
|
3936
|
+
text: cue.text.trim(),
|
|
3937
|
+
receivedAt: cue.start * 1e3
|
|
3938
|
+
}));
|
|
3939
|
+
}
|
|
3931
3940
|
function liveCuesDue(cues, now, lagMs, extraLagMs = LIVE_CUE_EXTRA_LAG_MS) {
|
|
3932
3941
|
if (lagMs == null || !Number.isFinite(lagMs) || lagMs < 0) return [];
|
|
3933
3942
|
const threshold = lagMs + extraLagMs;
|
|
@@ -4431,10 +4440,11 @@ function VideoPlayer({
|
|
|
4431
4440
|
window.clearInterval(timer);
|
|
4432
4441
|
};
|
|
4433
4442
|
}, [captionLocale, liveCaptionsBaseUrl, src]);
|
|
4443
|
+
const endedLiveReplay = !liveCaptionsBaseUrl && isLivePlaylistSrc(src);
|
|
4434
4444
|
const liveDueCues = liveCaptionsBaseUrl ? coalesceLiveCaptionCues(
|
|
4435
4445
|
liveCuesDue(liveCaptionCues, Date.now(), liveLagMs)
|
|
4436
|
-
) : [];
|
|
4437
|
-
const activeCaption = liveCaptionsBaseUrl ? null : captionAtTime(captionCues, currentTime);
|
|
4446
|
+
) : endedLiveReplay ? coalesceLiveCaptionCues(vttCuesDueAt(captionCues, currentTime)) : [];
|
|
4447
|
+
const activeCaption = liveCaptionsBaseUrl || endedLiveReplay ? null : captionAtTime(captionCues, currentTime);
|
|
4438
4448
|
function togglePlay() {
|
|
4439
4449
|
const video = videoRef.current;
|
|
4440
4450
|
if (!video) return;
|
|
@@ -4664,8 +4674,8 @@ function VideoPlayer({
|
|
|
4664
4674
|
] }),
|
|
4665
4675
|
typeof stats?.viewers === "number" && /* @__PURE__ */ jsx("span", { className: "rounded bg-black/60 px-2 py-0.5 text-xs", children: t.formatViewers ? t.formatViewers(stats.viewers) : `\u{1F441} ${stats.viewers}` })
|
|
4666
4676
|
] }),
|
|
4667
|
-
liveCaptionsBaseUrl && captionLocale !== "off" && /* @__PURE__ */ jsx(LiveCaptionStack, { cues: liveDueCues, latestLabel: t.captionsLatest }),
|
|
4668
|
-
!liveCaptionsBaseUrl && activeCaption && captionLocale !== "off" && /* @__PURE__ */ jsx(
|
|
4677
|
+
(liveCaptionsBaseUrl || endedLiveReplay) && captionLocale !== "off" && /* @__PURE__ */ jsx(LiveCaptionStack, { cues: liveDueCues, latestLabel: t.captionsLatest }),
|
|
4678
|
+
!liveCaptionsBaseUrl && !endedLiveReplay && activeCaption && captionLocale !== "off" && /* @__PURE__ */ jsx(
|
|
4669
4679
|
"div",
|
|
4670
4680
|
{
|
|
4671
4681
|
className: "pointer-events-none absolute inset-x-0 bottom-16 z-[1] flex justify-center px-4",
|