@livo-tv/blocks 1.30.2 → 1.31.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 +28 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.js +28 -16
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -5778,6 +5778,14 @@ var VIDEO_MEDIA_STYLE = `
|
|
|
5778
5778
|
display: none !important;
|
|
5779
5779
|
}
|
|
5780
5780
|
`;
|
|
5781
|
+
function hasCaptionSource(mode, src, liveCaptionsBaseUrl) {
|
|
5782
|
+
if (mode === "live") {
|
|
5783
|
+
return Boolean(liveCaptionsBaseUrl?.trim());
|
|
5784
|
+
}
|
|
5785
|
+
return CAPTION_LOCALES.some(
|
|
5786
|
+
(locale) => captionsVttUrlFromPlayback(src, locale) != null
|
|
5787
|
+
);
|
|
5788
|
+
}
|
|
5781
5789
|
function captionLocaleLabel(locale, labels) {
|
|
5782
5790
|
switch (locale) {
|
|
5783
5791
|
case "en":
|
|
@@ -5821,6 +5829,7 @@ function VideoPlayer({
|
|
|
5821
5829
|
fit = "aspect-video",
|
|
5822
5830
|
className,
|
|
5823
5831
|
defaultCaptionLocale,
|
|
5832
|
+
captionsEnabled = true,
|
|
5824
5833
|
liveCaptionsBaseUrl
|
|
5825
5834
|
}) {
|
|
5826
5835
|
const t = { ...DEFAULT_LABELS3, ...labels };
|
|
@@ -5868,6 +5877,9 @@ function VideoPlayer({
|
|
|
5868
5877
|
onRebuffer,
|
|
5869
5878
|
onQualityChange
|
|
5870
5879
|
});
|
|
5880
|
+
const liveCaptionPollUrl = liveCaptionsBaseUrl?.trim() || void 0;
|
|
5881
|
+
const showCaptionsMenu = captionsEnabled && hasCaptionSource(mode, src, liveCaptionPollUrl);
|
|
5882
|
+
const activeLiveCaptionsBaseUrl = showCaptionsMenu ? liveCaptionPollUrl : void 0;
|
|
5871
5883
|
const [isPlaying, setIsPlaying] = React11__namespace.useState(false);
|
|
5872
5884
|
const [isMuted, setIsMuted] = React11__namespace.useState(muted);
|
|
5873
5885
|
const isMutedRef = React11__namespace.useRef(isMuted);
|
|
@@ -5953,7 +5965,7 @@ function VideoPlayer({
|
|
|
5953
5965
|
const edge = video.seekable.end(video.seekable.length - 1);
|
|
5954
5966
|
const lagSeconds = edge - video.currentTime;
|
|
5955
5967
|
setBehindLive(lagSeconds > LIVE_EDGE_THRESHOLD_S);
|
|
5956
|
-
if (
|
|
5968
|
+
if (activeLiveCaptionsBaseUrl) {
|
|
5957
5969
|
setLiveLagMs((prev) => stabilizeLiveLagMs(prev, lagSeconds * 1e3));
|
|
5958
5970
|
}
|
|
5959
5971
|
}
|
|
@@ -5984,7 +5996,7 @@ function VideoPlayer({
|
|
|
5984
5996
|
video.removeEventListener("ratechange", onRate);
|
|
5985
5997
|
video.removeEventListener("playing", onPlaying);
|
|
5986
5998
|
};
|
|
5987
|
-
}, [videoRef, active, effectiveMode,
|
|
5999
|
+
}, [videoRef, active, effectiveMode, activeLiveCaptionsBaseUrl]);
|
|
5988
6000
|
React11__namespace.useLayoutEffect(() => {
|
|
5989
6001
|
const video = videoRef.current;
|
|
5990
6002
|
if (video) video.muted = isMuted;
|
|
@@ -6098,7 +6110,7 @@ function VideoPlayer({
|
|
|
6098
6110
|
};
|
|
6099
6111
|
}, []);
|
|
6100
6112
|
React11__namespace.useEffect(() => {
|
|
6101
|
-
if (captionLocale === "off") {
|
|
6113
|
+
if (captionLocale === "off" || !showCaptionsMenu) {
|
|
6102
6114
|
setCaptionCues([]);
|
|
6103
6115
|
setLiveCaptionCues([]);
|
|
6104
6116
|
return;
|
|
@@ -6106,7 +6118,7 @@ function VideoPlayer({
|
|
|
6106
6118
|
setLiveCaptionCues([]);
|
|
6107
6119
|
let cancelled = false;
|
|
6108
6120
|
const load = async () => {
|
|
6109
|
-
const liveBase =
|
|
6121
|
+
const liveBase = activeLiveCaptionsBaseUrl;
|
|
6110
6122
|
if (liveBase) {
|
|
6111
6123
|
const loaded = await loadLiveCaptions(
|
|
6112
6124
|
liveCaptionsUrl(liveBase, captionLocale)
|
|
@@ -6125,15 +6137,15 @@ function VideoPlayer({
|
|
|
6125
6137
|
if (!cancelled) setCaptionCues(cues);
|
|
6126
6138
|
};
|
|
6127
6139
|
void load();
|
|
6128
|
-
if (!
|
|
6140
|
+
if (!activeLiveCaptionsBaseUrl) return;
|
|
6129
6141
|
const timer = window.setInterval(() => void load(), 2e3);
|
|
6130
6142
|
return () => {
|
|
6131
6143
|
cancelled = true;
|
|
6132
6144
|
window.clearInterval(timer);
|
|
6133
6145
|
};
|
|
6134
|
-
}, [captionLocale,
|
|
6146
|
+
}, [captionLocale, activeLiveCaptionsBaseUrl, showCaptionsMenu, src]);
|
|
6135
6147
|
React11__namespace.useEffect(() => {
|
|
6136
|
-
if (!
|
|
6148
|
+
if (!activeLiveCaptionsBaseUrl || captionLocale === "off") {
|
|
6137
6149
|
setLivePlayout(EMPTY_LIVE_CAPTION_PLAYOUT);
|
|
6138
6150
|
return;
|
|
6139
6151
|
}
|
|
@@ -6151,12 +6163,12 @@ function VideoPlayer({
|
|
|
6151
6163
|
tick();
|
|
6152
6164
|
const timer = window.setInterval(tick, LIVE_CAPTION_PLAYOUT_MS);
|
|
6153
6165
|
return () => window.clearInterval(timer);
|
|
6154
|
-
}, [
|
|
6166
|
+
}, [activeLiveCaptionsBaseUrl, captionLocale]);
|
|
6155
6167
|
const captionWrapWidth = compactChrome ? CAPTION_COMPACT_CHARS_PER_LINE : CAPTION_MAX_CHARS_PER_LINE;
|
|
6156
|
-
const captionScreen =
|
|
6168
|
+
const captionScreen = activeLiveCaptionsBaseUrl ? livePlayout.screen : captionScreenAtTime(captionCues, currentTime, captionWrapWidth);
|
|
6157
6169
|
React11__namespace.useEffect(() => {
|
|
6158
6170
|
const video = videoRef.current;
|
|
6159
|
-
if (!video || !
|
|
6171
|
+
if (!video || !activeLiveCaptionsBaseUrl) return;
|
|
6160
6172
|
try {
|
|
6161
6173
|
ensureLiveSubtitleTracks(video, {
|
|
6162
6174
|
en: t.captionsEn,
|
|
@@ -6170,7 +6182,7 @@ function VideoPlayer({
|
|
|
6170
6182
|
}, [
|
|
6171
6183
|
videoRef,
|
|
6172
6184
|
active,
|
|
6173
|
-
|
|
6185
|
+
activeLiveCaptionsBaseUrl,
|
|
6174
6186
|
captionLocale,
|
|
6175
6187
|
t.captionsEn,
|
|
6176
6188
|
t.captionsEs,
|
|
@@ -6194,10 +6206,10 @@ function VideoPlayer({
|
|
|
6194
6206
|
setCaptionLocale(showing);
|
|
6195
6207
|
};
|
|
6196
6208
|
return listenTextTracksChange(video.textTracks, onChange);
|
|
6197
|
-
}, [videoRef, active, src,
|
|
6209
|
+
}, [videoRef, active, src, activeLiveCaptionsBaseUrl]);
|
|
6198
6210
|
React11__namespace.useEffect(() => {
|
|
6199
6211
|
const video = videoRef.current;
|
|
6200
|
-
if (!video || captionLocale === "off" || !
|
|
6212
|
+
if (!video || captionLocale === "off" || !activeLiveCaptionsBaseUrl) return;
|
|
6201
6213
|
const track = findSubtitleTrack(video, captionLocale);
|
|
6202
6214
|
if (!track) return;
|
|
6203
6215
|
const remaining = livePlayout.screen ? Math.max(0.2, (livePlayout.hideAt - Date.now()) / 1e3) : 0;
|
|
@@ -6207,7 +6219,7 @@ function VideoPlayer({
|
|
|
6207
6219
|
livePlayout.screen?.text ?? "",
|
|
6208
6220
|
remaining
|
|
6209
6221
|
);
|
|
6210
|
-
}, [livePlayout, captionLocale,
|
|
6222
|
+
}, [livePlayout, captionLocale, activeLiveCaptionsBaseUrl]);
|
|
6211
6223
|
function togglePlay() {
|
|
6212
6224
|
const video = videoRef.current;
|
|
6213
6225
|
if (!video) return;
|
|
@@ -6410,7 +6422,7 @@ function VideoPlayer({
|
|
|
6410
6422
|
className: "livo-video-player-media h-full w-full bg-black object-contain",
|
|
6411
6423
|
onClick: active ? toggleControls : void 0,
|
|
6412
6424
|
poster,
|
|
6413
|
-
children: !
|
|
6425
|
+
children: showCaptionsMenu && !activeLiveCaptionsBaseUrl ? CAPTION_LOCALES.map((locale) => {
|
|
6414
6426
|
const url = captionsVttUrlFromPlayback(src, locale);
|
|
6415
6427
|
if (!url) return null;
|
|
6416
6428
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -6559,7 +6571,7 @@ function VideoPlayer({
|
|
|
6559
6571
|
),
|
|
6560
6572
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "ml-auto flex shrink-0 items-center gap-1", children: [
|
|
6561
6573
|
!compactChrome && effectiveMode === "vod" && typeof stats?.views === "number" && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "mr-1 text-xs", children: t.formatViews ? t.formatViews(stats.views) : `${stats.views} views` }),
|
|
6562
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
6574
|
+
showCaptionsMenu && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
6563
6575
|
MenuControl,
|
|
6564
6576
|
{
|
|
6565
6577
|
label: t.captions,
|