@livo-tv/blocks 1.8.0 → 1.9.1

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.d.cts CHANGED
@@ -733,6 +733,11 @@ interface UsePlaybackStatsOptions {
733
733
  */
734
734
  declare function usePlaybackStats(statsUrl: string | null | undefined, { intervalMs, enabled }?: UsePlaybackStatsOptions): PlaybackStats;
735
735
 
736
+ declare const CAPTION_LOCALES: readonly ["en", "es", "pt"];
737
+ type CaptionLocale = (typeof CAPTION_LOCALES)[number];
738
+ declare function isCaptionLocale(value: string): value is CaptionLocale;
739
+ declare function captionsVttUrlFromPlayback(src: string, locale: CaptionLocale): string | null;
740
+
736
741
  interface VideoPlayerLabels {
737
742
  play?: string;
738
743
  pause?: string;
@@ -762,6 +767,11 @@ interface VideoPlayerLabels {
762
767
  formatViewers?: (n: number) => string;
763
768
  /** `(n) => "N views"`. */
764
769
  formatViews?: (n: number) => string;
770
+ captions?: string;
771
+ captionsOff?: string;
772
+ captionsEn?: string;
773
+ captionsEs?: string;
774
+ captionsPt?: string;
765
775
  }
766
776
  interface VideoPlayerProps {
767
777
  src: string;
@@ -792,6 +802,10 @@ interface VideoPlayerProps {
792
802
  */
793
803
  fit?: "aspect-video" | "contain";
794
804
  className?: string;
805
+ /** Default CC language from `livo-locale` / `?lang=`. Off when omitted. */
806
+ defaultCaptionLocale?: CaptionLocale;
807
+ /** Live poll base, e.g. `https://api.livo.tv/public/streams/{id}/captions`. */
808
+ liveCaptionsBaseUrl?: string | null;
795
809
  }
796
810
  /**
797
811
  * Standardized HLS video player with a fully custom control bar (no native
@@ -802,7 +816,7 @@ interface VideoPlayerProps {
802
816
  *
803
817
  * hls.js is a peer dependency loaded on demand; see {@link useHlsPlayback}.
804
818
  */
805
- declare function VideoPlayer({ src, mode, poster, autoPlay, muted, stats, labels, showQualitySelector, paused, onPlayingChange, onFirstPlay, onError, fit, className, }: VideoPlayerProps): React.JSX.Element;
819
+ declare function VideoPlayer({ src, mode, poster, autoPlay, muted, stats, labels, showQualitySelector, paused, onPlayingChange, onFirstPlay, onError, fit, className, defaultCaptionLocale, liveCaptionsBaseUrl, }: VideoPlayerProps): React.JSX.Element;
806
820
 
807
821
  interface FeedVideoPlayerProps extends VideoPlayerProps {
808
822
  /** Stable id for exclusive playback (typically the feed post id). */
@@ -1005,4 +1019,4 @@ declare function useMediaQuery(query: string): boolean;
1005
1019
 
1006
1020
  declare function cn(...inputs: ClassValue[]): string;
1007
1021
 
1008
- export { type AutoplayState, AvatarEditor, AvatarEditorDialog, type AvatarEditorDialogProps, type AvatarEditorLabels, type AvatarEditorProps, type BlocksLanguage, ConfirmDestructiveDialog, type ConfirmDestructiveDialogProps, type CreateMultipartUploadControllerOptions, type CurtainKind, CurtainPicker, type CurtainPickerItem, type CurtainPickerLabels, type CurtainPickerOwnerType, type CurtainPickerProps, CurtainPickerSkeleton, CurtainPreview, type CurtainPreviewProps, CurtainStage, type CurtainStageLabels, type CurtainStageProps, DEFAULT_CURTAIN_PICKER_LABELS, DEFAULT_EDITABLE_SECTION_LABELS, DEFAULT_FILE_DROPZONE_LABELS, DEFAULT_FILE_UPLOAD_LABELS, DEFAULT_FILE_UPLOAD_TRAY_LABELS, DEFAULT_NOTIFICATION_BELL_LABELS, DataList, DataListItem, type DataListItemProps, type DataListProps, type DescribedPlaybackError, EditableSection, type EditableSectionLabels, type EditableSectionMode, type EditableSectionProps, type EditableSectionSlots, Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyState, type EmptyStateProps, EmptyTitle, ErrorState, FeedVideoPlayer, type FeedVideoPlayerProps, FieldMessage, type FieldMessageProps, FileDropzone, type FileDropzoneLabels, type FileDropzoneProps, FileUploadMenu, type FileUploadMenuProps, FileUploadTray, type FileUploadTrayLabels, type FileUploadTrayProps, type HlsPlayerMode, type Language, LanguageContext, type LanguageContextValue, LanguageSwitcher, type LanguageSwitcherLabels, type LanguageSwitcherProps, LoadingState, type MultipartUploadAdapter, type MultipartUploadController, type MultipartUploadPart, NotificationBell, type NotificationBellItem, type NotificationBellLabels, type NotificationBellProps, type PartRange, type PlaybackErrorContext, type PlaybackErrorDetail, type PlaybackErrorKind, type PlaybackState, type PlaybackStats, type QualityLevel, SafeImage, type SafeImageProps, ThemeSwitcher, type ThemeSwitcherLabels, type ThemeSwitcherProps, type UploadControllerStatus, type UploadJob, type UploadJobStatus, type UploadProgress, type UseEditableSectionOptions, type UseEditableSectionResult, type UseFeedExclusivePlaybackResult, type UseHlsPlaybackOptions, type UseHlsPlaybackResult, type UsePlaybackStatsOptions, VideoPlayer, type VideoPlayerLabels, type VideoPlayerProps, WaitingRoom, type WaitingRoomCurtain, type WaitingRoomProps, castHlsUrl, cn, createLiveHlsConfig, createMultipartUploadController, createVodHlsConfig, defaultLanguages, describeAvResync, describePlaybackError, fileMatchesAccept, loadCastSender, partRanges, progressFromBytes, shouldRetryLiveEdge404, useEditableSection, useFeedExclusivePlayback, useHlsPlayback, useLanguageContext, useMediaQuery, usePlaybackStats };
1022
+ export { type AutoplayState, AvatarEditor, AvatarEditorDialog, type AvatarEditorDialogProps, type AvatarEditorLabels, type AvatarEditorProps, type BlocksLanguage, CAPTION_LOCALES, type CaptionLocale, ConfirmDestructiveDialog, type ConfirmDestructiveDialogProps, type CreateMultipartUploadControllerOptions, type CurtainKind, CurtainPicker, type CurtainPickerItem, type CurtainPickerLabels, type CurtainPickerOwnerType, type CurtainPickerProps, CurtainPickerSkeleton, CurtainPreview, type CurtainPreviewProps, CurtainStage, type CurtainStageLabels, type CurtainStageProps, DEFAULT_CURTAIN_PICKER_LABELS, DEFAULT_EDITABLE_SECTION_LABELS, DEFAULT_FILE_DROPZONE_LABELS, DEFAULT_FILE_UPLOAD_LABELS, DEFAULT_FILE_UPLOAD_TRAY_LABELS, DEFAULT_NOTIFICATION_BELL_LABELS, DataList, DataListItem, type DataListItemProps, type DataListProps, type DescribedPlaybackError, EditableSection, type EditableSectionLabels, type EditableSectionMode, type EditableSectionProps, type EditableSectionSlots, Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyState, type EmptyStateProps, EmptyTitle, ErrorState, FeedVideoPlayer, type FeedVideoPlayerProps, FieldMessage, type FieldMessageProps, FileDropzone, type FileDropzoneLabels, type FileDropzoneProps, FileUploadMenu, type FileUploadMenuProps, FileUploadTray, type FileUploadTrayLabels, type FileUploadTrayProps, type HlsPlayerMode, type Language, LanguageContext, type LanguageContextValue, LanguageSwitcher, type LanguageSwitcherLabels, type LanguageSwitcherProps, LoadingState, type MultipartUploadAdapter, type MultipartUploadController, type MultipartUploadPart, NotificationBell, type NotificationBellItem, type NotificationBellLabels, type NotificationBellProps, type PartRange, type PlaybackErrorContext, type PlaybackErrorDetail, type PlaybackErrorKind, type PlaybackState, type PlaybackStats, type QualityLevel, SafeImage, type SafeImageProps, ThemeSwitcher, type ThemeSwitcherLabels, type ThemeSwitcherProps, type UploadControllerStatus, type UploadJob, type UploadJobStatus, type UploadProgress, type UseEditableSectionOptions, type UseEditableSectionResult, type UseFeedExclusivePlaybackResult, type UseHlsPlaybackOptions, type UseHlsPlaybackResult, type UsePlaybackStatsOptions, VideoPlayer, type VideoPlayerLabels, type VideoPlayerProps, WaitingRoom, type WaitingRoomCurtain, type WaitingRoomProps, captionsVttUrlFromPlayback, castHlsUrl, cn, createLiveHlsConfig, createMultipartUploadController, createVodHlsConfig, defaultLanguages, describeAvResync, describePlaybackError, fileMatchesAccept, isCaptionLocale, loadCastSender, partRanges, progressFromBytes, shouldRetryLiveEdge404, useEditableSection, useFeedExclusivePlayback, useHlsPlayback, useLanguageContext, useMediaQuery, usePlaybackStats };
package/dist/index.d.ts CHANGED
@@ -733,6 +733,11 @@ interface UsePlaybackStatsOptions {
733
733
  */
734
734
  declare function usePlaybackStats(statsUrl: string | null | undefined, { intervalMs, enabled }?: UsePlaybackStatsOptions): PlaybackStats;
735
735
 
736
+ declare const CAPTION_LOCALES: readonly ["en", "es", "pt"];
737
+ type CaptionLocale = (typeof CAPTION_LOCALES)[number];
738
+ declare function isCaptionLocale(value: string): value is CaptionLocale;
739
+ declare function captionsVttUrlFromPlayback(src: string, locale: CaptionLocale): string | null;
740
+
736
741
  interface VideoPlayerLabels {
737
742
  play?: string;
738
743
  pause?: string;
@@ -762,6 +767,11 @@ interface VideoPlayerLabels {
762
767
  formatViewers?: (n: number) => string;
763
768
  /** `(n) => "N views"`. */
764
769
  formatViews?: (n: number) => string;
770
+ captions?: string;
771
+ captionsOff?: string;
772
+ captionsEn?: string;
773
+ captionsEs?: string;
774
+ captionsPt?: string;
765
775
  }
766
776
  interface VideoPlayerProps {
767
777
  src: string;
@@ -792,6 +802,10 @@ interface VideoPlayerProps {
792
802
  */
793
803
  fit?: "aspect-video" | "contain";
794
804
  className?: string;
805
+ /** Default CC language from `livo-locale` / `?lang=`. Off when omitted. */
806
+ defaultCaptionLocale?: CaptionLocale;
807
+ /** Live poll base, e.g. `https://api.livo.tv/public/streams/{id}/captions`. */
808
+ liveCaptionsBaseUrl?: string | null;
795
809
  }
796
810
  /**
797
811
  * Standardized HLS video player with a fully custom control bar (no native
@@ -802,7 +816,7 @@ interface VideoPlayerProps {
802
816
  *
803
817
  * hls.js is a peer dependency loaded on demand; see {@link useHlsPlayback}.
804
818
  */
805
- declare function VideoPlayer({ src, mode, poster, autoPlay, muted, stats, labels, showQualitySelector, paused, onPlayingChange, onFirstPlay, onError, fit, className, }: VideoPlayerProps): React.JSX.Element;
819
+ declare function VideoPlayer({ src, mode, poster, autoPlay, muted, stats, labels, showQualitySelector, paused, onPlayingChange, onFirstPlay, onError, fit, className, defaultCaptionLocale, liveCaptionsBaseUrl, }: VideoPlayerProps): React.JSX.Element;
806
820
 
807
821
  interface FeedVideoPlayerProps extends VideoPlayerProps {
808
822
  /** Stable id for exclusive playback (typically the feed post id). */
@@ -1005,4 +1019,4 @@ declare function useMediaQuery(query: string): boolean;
1005
1019
 
1006
1020
  declare function cn(...inputs: ClassValue[]): string;
1007
1021
 
1008
- export { type AutoplayState, AvatarEditor, AvatarEditorDialog, type AvatarEditorDialogProps, type AvatarEditorLabels, type AvatarEditorProps, type BlocksLanguage, ConfirmDestructiveDialog, type ConfirmDestructiveDialogProps, type CreateMultipartUploadControllerOptions, type CurtainKind, CurtainPicker, type CurtainPickerItem, type CurtainPickerLabels, type CurtainPickerOwnerType, type CurtainPickerProps, CurtainPickerSkeleton, CurtainPreview, type CurtainPreviewProps, CurtainStage, type CurtainStageLabels, type CurtainStageProps, DEFAULT_CURTAIN_PICKER_LABELS, DEFAULT_EDITABLE_SECTION_LABELS, DEFAULT_FILE_DROPZONE_LABELS, DEFAULT_FILE_UPLOAD_LABELS, DEFAULT_FILE_UPLOAD_TRAY_LABELS, DEFAULT_NOTIFICATION_BELL_LABELS, DataList, DataListItem, type DataListItemProps, type DataListProps, type DescribedPlaybackError, EditableSection, type EditableSectionLabels, type EditableSectionMode, type EditableSectionProps, type EditableSectionSlots, Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyState, type EmptyStateProps, EmptyTitle, ErrorState, FeedVideoPlayer, type FeedVideoPlayerProps, FieldMessage, type FieldMessageProps, FileDropzone, type FileDropzoneLabels, type FileDropzoneProps, FileUploadMenu, type FileUploadMenuProps, FileUploadTray, type FileUploadTrayLabels, type FileUploadTrayProps, type HlsPlayerMode, type Language, LanguageContext, type LanguageContextValue, LanguageSwitcher, type LanguageSwitcherLabels, type LanguageSwitcherProps, LoadingState, type MultipartUploadAdapter, type MultipartUploadController, type MultipartUploadPart, NotificationBell, type NotificationBellItem, type NotificationBellLabels, type NotificationBellProps, type PartRange, type PlaybackErrorContext, type PlaybackErrorDetail, type PlaybackErrorKind, type PlaybackState, type PlaybackStats, type QualityLevel, SafeImage, type SafeImageProps, ThemeSwitcher, type ThemeSwitcherLabels, type ThemeSwitcherProps, type UploadControllerStatus, type UploadJob, type UploadJobStatus, type UploadProgress, type UseEditableSectionOptions, type UseEditableSectionResult, type UseFeedExclusivePlaybackResult, type UseHlsPlaybackOptions, type UseHlsPlaybackResult, type UsePlaybackStatsOptions, VideoPlayer, type VideoPlayerLabels, type VideoPlayerProps, WaitingRoom, type WaitingRoomCurtain, type WaitingRoomProps, castHlsUrl, cn, createLiveHlsConfig, createMultipartUploadController, createVodHlsConfig, defaultLanguages, describeAvResync, describePlaybackError, fileMatchesAccept, loadCastSender, partRanges, progressFromBytes, shouldRetryLiveEdge404, useEditableSection, useFeedExclusivePlayback, useHlsPlayback, useLanguageContext, useMediaQuery, usePlaybackStats };
1022
+ export { type AutoplayState, AvatarEditor, AvatarEditorDialog, type AvatarEditorDialogProps, type AvatarEditorLabels, type AvatarEditorProps, type BlocksLanguage, CAPTION_LOCALES, type CaptionLocale, ConfirmDestructiveDialog, type ConfirmDestructiveDialogProps, type CreateMultipartUploadControllerOptions, type CurtainKind, CurtainPicker, type CurtainPickerItem, type CurtainPickerLabels, type CurtainPickerOwnerType, type CurtainPickerProps, CurtainPickerSkeleton, CurtainPreview, type CurtainPreviewProps, CurtainStage, type CurtainStageLabels, type CurtainStageProps, DEFAULT_CURTAIN_PICKER_LABELS, DEFAULT_EDITABLE_SECTION_LABELS, DEFAULT_FILE_DROPZONE_LABELS, DEFAULT_FILE_UPLOAD_LABELS, DEFAULT_FILE_UPLOAD_TRAY_LABELS, DEFAULT_NOTIFICATION_BELL_LABELS, DataList, DataListItem, type DataListItemProps, type DataListProps, type DescribedPlaybackError, EditableSection, type EditableSectionLabels, type EditableSectionMode, type EditableSectionProps, type EditableSectionSlots, Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyState, type EmptyStateProps, EmptyTitle, ErrorState, FeedVideoPlayer, type FeedVideoPlayerProps, FieldMessage, type FieldMessageProps, FileDropzone, type FileDropzoneLabels, type FileDropzoneProps, FileUploadMenu, type FileUploadMenuProps, FileUploadTray, type FileUploadTrayLabels, type FileUploadTrayProps, type HlsPlayerMode, type Language, LanguageContext, type LanguageContextValue, LanguageSwitcher, type LanguageSwitcherLabels, type LanguageSwitcherProps, LoadingState, type MultipartUploadAdapter, type MultipartUploadController, type MultipartUploadPart, NotificationBell, type NotificationBellItem, type NotificationBellLabels, type NotificationBellProps, type PartRange, type PlaybackErrorContext, type PlaybackErrorDetail, type PlaybackErrorKind, type PlaybackState, type PlaybackStats, type QualityLevel, SafeImage, type SafeImageProps, ThemeSwitcher, type ThemeSwitcherLabels, type ThemeSwitcherProps, type UploadControllerStatus, type UploadJob, type UploadJobStatus, type UploadProgress, type UseEditableSectionOptions, type UseEditableSectionResult, type UseFeedExclusivePlaybackResult, type UseHlsPlaybackOptions, type UseHlsPlaybackResult, type UsePlaybackStatsOptions, VideoPlayer, type VideoPlayerLabels, type VideoPlayerProps, WaitingRoom, type WaitingRoomCurtain, type WaitingRoomProps, captionsVttUrlFromPlayback, castHlsUrl, cn, createLiveHlsConfig, createMultipartUploadController, createVodHlsConfig, defaultLanguages, describeAvResync, describePlaybackError, fileMatchesAccept, isCaptionLocale, loadCastSender, partRanges, progressFromBytes, shouldRetryLiveEdge404, useEditableSection, useFeedExclusivePlayback, useHlsPlayback, useLanguageContext, useMediaQuery, usePlaybackStats };
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import * as React8 from 'react';
3
3
  import { createContext, useContext, useState, useRef, useId, useEffect, useCallback, useLayoutEffect } from 'react';
4
- import { Loader2, AlertTriangle, Inbox, Bell, Monitor, Sun, Moon, Languages, Upload, Move, ZoomOut, ZoomIn, RotateCcw, RotateCw, Grid3X3, RefreshCw, X, User, Pencil, Check, Play, AlertCircle, VolumeX, Pause, Volume1, Volume2, Settings, Cast, PictureInPicture2, Minimize, Maximize, XIcon } from 'lucide-react';
4
+ import { Loader2, AlertTriangle, Inbox, Bell, Monitor, Sun, Moon, Languages, Upload, Move, ZoomOut, ZoomIn, RotateCcw, RotateCw, Grid3X3, RefreshCw, X, User, Pencil, Check, Play, AlertCircle, VolumeX, Pause, Volume1, Volume2, Captions, Settings, Cast, PictureInPicture2, Minimize, Maximize, XIcon } from 'lucide-react';
5
5
  import { clsx } from 'clsx';
6
6
  import { twMerge } from 'tailwind-merge';
7
7
  import { cva } from 'class-variance-authority';
@@ -3841,6 +3841,59 @@ function useHlsPlayback({
3841
3841
  retry
3842
3842
  };
3843
3843
  }
3844
+
3845
+ // src/components/video/captions.ts
3846
+ var CAPTION_LOCALES = ["en", "es", "pt"];
3847
+ function isCaptionLocale(value) {
3848
+ return CAPTION_LOCALES.includes(value);
3849
+ }
3850
+ function captionsVttUrlFromPlayback(src, locale) {
3851
+ const trimmed = src.trim();
3852
+ if (!trimmed) return null;
3853
+ const replaced = trimmed.replace(
3854
+ /index\.m3u8(?:\?.*)?$/i,
3855
+ `subs/${locale}.vtt`
3856
+ );
3857
+ if (replaced === trimmed) return null;
3858
+ return replaced;
3859
+ }
3860
+ function liveCaptionsUrl(base, locale) {
3861
+ return `${base.replace(/\/$/, "")}/${locale}`;
3862
+ }
3863
+ function parseCaptionVtt(text) {
3864
+ const cues = [];
3865
+ const blocks = text.replace(/^\uFEFF?WEBVTT[^\n]*\n/i, "").split(/\n\s*\n/);
3866
+ for (const block of blocks) {
3867
+ const lines = block.split("\n").map((line) => line.trim()).filter(Boolean);
3868
+ const timing = lines.find((line) => line.includes("-->"));
3869
+ if (!timing) continue;
3870
+ const [startRaw, endRaw] = timing.split("-->").map((part) => part.trim());
3871
+ if (!startRaw || !endRaw) continue;
3872
+ const textLines = lines.filter(
3873
+ (line) => line !== timing && !/^\d+$/.test(line)
3874
+ );
3875
+ const payload = textLines.join("\n").trim();
3876
+ if (!payload) continue;
3877
+ cues.push({
3878
+ start: parseVttTimestamp(startRaw.split(" ")[0] ?? startRaw),
3879
+ end: parseVttTimestamp(endRaw.split(" ")[0] ?? endRaw),
3880
+ text: payload
3881
+ });
3882
+ }
3883
+ return cues;
3884
+ }
3885
+ function captionAtTime(cues, time) {
3886
+ return cues.find((cue) => time >= cue.start && time < cue.end) ?? null;
3887
+ }
3888
+ async function loadCaptionVtt(url) {
3889
+ try {
3890
+ const response = await fetch(url, { cache: "no-store" });
3891
+ if (!response.ok) return [];
3892
+ return parseCaptionVtt(await response.text());
3893
+ } catch {
3894
+ return [];
3895
+ }
3896
+ }
3844
3897
  var DEFAULT_LABELS3 = {
3845
3898
  play: "Play",
3846
3899
  pause: "Pause",
@@ -3864,7 +3917,12 @@ var DEFAULT_LABELS3 = {
3864
3917
  errorNetwork: "We couldn't load the video. Check your connection.",
3865
3918
  errorMedia: "There was a playback problem.",
3866
3919
  errorUnsupported: "Your browser can't play this video.",
3867
- errorGeneric: "We couldn't play this video."
3920
+ errorGeneric: "We couldn't play this video.",
3921
+ captions: "Captions",
3922
+ captionsOff: "Off",
3923
+ captionsEn: "English",
3924
+ captionsEs: "Espa\xF1ol",
3925
+ captionsPt: "Portugu\xEAs"
3868
3926
  };
3869
3927
  var PLAYBACK_RATES = [0.75, 1, 1.25, 1.5, 2];
3870
3928
  var CONTROLS_HIDE_MS = 3e3;
@@ -3883,6 +3941,20 @@ function hasStandardFullscreen() {
3883
3941
  const doc = document;
3884
3942
  return !!doc.webkitFullscreenEnabled;
3885
3943
  }
3944
+ function captionLocaleLabel(locale, labels) {
3945
+ switch (locale) {
3946
+ case "en":
3947
+ return labels.captionsEn;
3948
+ case "es":
3949
+ return labels.captionsEs;
3950
+ case "pt":
3951
+ return labels.captionsPt;
3952
+ default: {
3953
+ const _exhaustive = locale;
3954
+ return _exhaustive;
3955
+ }
3956
+ }
3957
+ }
3886
3958
  function formatTime(seconds) {
3887
3959
  if (!Number.isFinite(seconds) || seconds < 0) return "0:00";
3888
3960
  const total = Math.floor(seconds);
@@ -3907,7 +3979,9 @@ function VideoPlayer({
3907
3979
  onFirstPlay,
3908
3980
  onError,
3909
3981
  fit = "aspect-video",
3910
- className
3982
+ className,
3983
+ defaultCaptionLocale,
3984
+ liveCaptionsBaseUrl
3911
3985
  }) {
3912
3986
  const t = { ...DEFAULT_LABELS3, ...labels };
3913
3987
  const containerRef = React8.useRef(null);
@@ -3954,9 +4028,9 @@ function VideoPlayer({
3954
4028
  const [pipActive, setPipActive] = React8.useState(false);
3955
4029
  const [controlsVisible, setControlsVisible] = React8.useState(true);
3956
4030
  const [playbackRate, setPlaybackRate] = React8.useState(1);
3957
- const [openMenu, setOpenMenu] = React8.useState(
3958
- null
3959
- );
4031
+ const [openMenu, setOpenMenu] = React8.useState(null);
4032
+ const [captionLocale, setCaptionLocale] = React8.useState(defaultCaptionLocale ?? "off");
4033
+ const [captionCues, setCaptionCues] = React8.useState([]);
3960
4034
  const [behindLive, setBehindLive] = React8.useState(false);
3961
4035
  const [webkitFullscreenSupported, setWebkitFullscreenSupported] = React8.useState(false);
3962
4036
  const hideTimerRef = React8.useRef(null);
@@ -4049,6 +4123,31 @@ function VideoPlayer({
4049
4123
  if (hideTimerRef.current) clearTimeout(hideTimerRef.current);
4050
4124
  };
4051
4125
  }, []);
4126
+ React8.useEffect(() => {
4127
+ if (captionLocale === "off") {
4128
+ setCaptionCues([]);
4129
+ return;
4130
+ }
4131
+ let cancelled = false;
4132
+ const load = async () => {
4133
+ const liveBase = liveCaptionsBaseUrl?.trim();
4134
+ const url = liveBase ? liveCaptionsUrl(liveBase, captionLocale) : captionsVttUrlFromPlayback(src, captionLocale);
4135
+ if (!url) {
4136
+ if (!cancelled) setCaptionCues([]);
4137
+ return;
4138
+ }
4139
+ const cues = await loadCaptionVtt(url);
4140
+ if (!cancelled) setCaptionCues(cues);
4141
+ };
4142
+ void load();
4143
+ if (!liveCaptionsBaseUrl) return;
4144
+ const timer = window.setInterval(() => void load(), 2e3);
4145
+ return () => {
4146
+ cancelled = true;
4147
+ window.clearInterval(timer);
4148
+ };
4149
+ }, [captionLocale, liveCaptionsBaseUrl, src]);
4150
+ const activeCaption = captionAtTime(captionCues, currentTime);
4052
4151
  function togglePlay() {
4053
4152
  const video = videoRef.current;
4054
4153
  if (!video) return;
@@ -4277,6 +4376,14 @@ function VideoPlayer({
4277
4376
  ] }),
4278
4377
  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}` })
4279
4378
  ] }),
4379
+ activeCaption && captionLocale !== "off" && /* @__PURE__ */ jsx(
4380
+ "div",
4381
+ {
4382
+ className: "pointer-events-none absolute inset-x-0 bottom-16 z-[1] flex justify-center px-4",
4383
+ "data-slot": "video-captions",
4384
+ children: /* @__PURE__ */ jsx("p", { className: "max-w-[90%] rounded-sm bg-black/70 px-3 py-1.5 text-center text-sm font-medium text-white shadow-sm", children: activeCaption.text })
4385
+ }
4386
+ ),
4280
4387
  active && /* @__PURE__ */ jsxs(
4281
4388
  "div",
4282
4389
  {
@@ -4346,6 +4453,34 @@ function VideoPlayer({
4346
4453
  ),
4347
4454
  /* @__PURE__ */ jsxs("div", { className: "ml-auto flex items-center gap-1", children: [
4348
4455
  mode === "vod" && typeof stats?.views === "number" && /* @__PURE__ */ jsx("span", { className: "mr-1 text-xs", children: t.formatViews ? t.formatViews(stats.views) : `${stats.views} views` }),
4456
+ /* @__PURE__ */ jsxs(
4457
+ MenuControl,
4458
+ {
4459
+ label: t.captions,
4460
+ open: openMenu === "captions",
4461
+ onOpenChange: (o) => setOpenMenu(o ? "captions" : null),
4462
+ trigger: /* @__PURE__ */ jsx(Captions, { className: "size-5" }),
4463
+ children: [
4464
+ /* @__PURE__ */ jsx(
4465
+ MenuItem,
4466
+ {
4467
+ selected: captionLocale === "off",
4468
+ onSelect: () => setCaptionLocale("off"),
4469
+ children: t.captionsOff
4470
+ }
4471
+ ),
4472
+ CAPTION_LOCALES.map((locale) => /* @__PURE__ */ jsx(
4473
+ MenuItem,
4474
+ {
4475
+ selected: captionLocale === locale,
4476
+ onSelect: () => setCaptionLocale(locale),
4477
+ children: captionLocaleLabel(locale, t)
4478
+ },
4479
+ locale
4480
+ ))
4481
+ ]
4482
+ }
4483
+ ),
4349
4484
  mode === "vod" && /* @__PURE__ */ jsx(
4350
4485
  MenuControl,
4351
4486
  {
@@ -4903,7 +5038,7 @@ function FileUploadTray({
4903
5038
  /* @__PURE__ */ jsx(
4904
5039
  "p",
4905
5040
  {
4906
- className: "h-[3lh] min-w-0 line-clamp-3 text-sm leading-5 font-medium break-all",
5041
+ className: "min-w-0 line-clamp-3 text-sm leading-5 font-medium break-all",
4907
5042
  title: job.name,
4908
5043
  children: job.name
4909
5044
  }
@@ -5336,6 +5471,6 @@ function avatarFallbackStyle(name) {
5336
5471
  return getAvatarColors(name);
5337
5472
  }
5338
5473
 
5339
- export { AvatarEditor, AvatarEditorDialog, ConfirmDestructiveDialog, CurtainPicker, CurtainPickerSkeleton, CurtainPreview, CurtainStage, DEFAULT_CURTAIN_PICKER_LABELS, DEFAULT_EDITABLE_SECTION_LABELS, DEFAULT_FILE_DROPZONE_LABELS, DEFAULT_FILE_UPLOAD_LABELS, DEFAULT_FILE_UPLOAD_TRAY_LABELS, DEFAULT_NOTIFICATION_BELL_LABELS, DataList, DataListItem, EditableSection, Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyState, EmptyTitle, ErrorState, FeedVideoPlayer, FieldMessage, FileDropzone, FileUploadMenu, FileUploadTray, LanguageContext, LanguageSwitcher, LoadingState, NotificationBell, SafeImage, ThemeSwitcher, VideoPlayer, WaitingRoom, avatarFallbackStyle, castHlsUrl, cn, createLiveHlsConfig, createMultipartUploadController, createVodHlsConfig, defaultLanguages, describeAvResync, describePlaybackError, fileMatchesAccept, getAvatarColors, getInitials, loadCastSender, partRanges, progressFromBytes, shouldRetryLiveEdge404, useEditableSection, useFeedExclusivePlayback, useHlsPlayback, useLanguageContext, useMediaQuery2 as useMediaQuery, usePlaybackStats };
5474
+ export { AvatarEditor, AvatarEditorDialog, CAPTION_LOCALES, ConfirmDestructiveDialog, CurtainPicker, CurtainPickerSkeleton, CurtainPreview, CurtainStage, DEFAULT_CURTAIN_PICKER_LABELS, DEFAULT_EDITABLE_SECTION_LABELS, DEFAULT_FILE_DROPZONE_LABELS, DEFAULT_FILE_UPLOAD_LABELS, DEFAULT_FILE_UPLOAD_TRAY_LABELS, DEFAULT_NOTIFICATION_BELL_LABELS, DataList, DataListItem, EditableSection, Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyState, EmptyTitle, ErrorState, FeedVideoPlayer, FieldMessage, FileDropzone, FileUploadMenu, FileUploadTray, LanguageContext, LanguageSwitcher, LoadingState, NotificationBell, SafeImage, ThemeSwitcher, VideoPlayer, WaitingRoom, avatarFallbackStyle, captionsVttUrlFromPlayback, castHlsUrl, cn, createLiveHlsConfig, createMultipartUploadController, createVodHlsConfig, defaultLanguages, describeAvResync, describePlaybackError, fileMatchesAccept, getAvatarColors, getInitials, isCaptionLocale, loadCastSender, partRanges, progressFromBytes, shouldRetryLiveEdge404, useEditableSection, useFeedExclusivePlayback, useHlsPlayback, useLanguageContext, useMediaQuery2 as useMediaQuery, usePlaybackStats };
5340
5475
  //# sourceMappingURL=index.js.map
5341
5476
  //# sourceMappingURL=index.js.map