@livo-tv/blocks 1.16.0 → 1.18.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.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import * as React9 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, Captions, 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, EllipsisVertical, 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';
@@ -3616,7 +3616,13 @@ function useHlsPlayback({
3616
3616
  el.muted = true;
3617
3617
  void el.play().then(
3618
3618
  () => setAutoplayState(muted ? "playing" : "muted"),
3619
- () => setAutoplayState("blocked")
3619
+ () => {
3620
+ if (el.paused) {
3621
+ setAutoplayState("blocked");
3622
+ return;
3623
+ }
3624
+ setAutoplayState(el.muted && !muted ? "muted" : "playing");
3625
+ }
3620
3626
  );
3621
3627
  }
3622
3628
  );
@@ -3682,6 +3688,9 @@ function useHlsPlayback({
3682
3688
  mediaErrorRetries = 0;
3683
3689
  clearRetryTimer();
3684
3690
  setState("ready");
3691
+ setAutoplayState(
3692
+ (prev) => prev === "blocked" || prev === "none" ? "playing" : prev
3693
+ );
3685
3694
  onPlayingChangeRef.current?.(true);
3686
3695
  }
3687
3696
  function onPaused() {
@@ -3858,10 +3867,18 @@ function useHlsPlayback({
3858
3867
  };
3859
3868
  }
3860
3869
 
3870
+ // src/components/video/appleMobile.ts
3871
+ function isAppleMobileDevice(nav = navigator) {
3872
+ if (/iP(hone|ad|od)/.test(nav.userAgent)) return true;
3873
+ return nav.platform === "MacIntel" && nav.maxTouchPoints > 1;
3874
+ }
3875
+
3861
3876
  // src/components/video/captions.ts
3862
3877
  var CAPTION_LOCALES = ["en", "es", "pt"];
3863
3878
  var LIVE_CUE_EXTRA_LAG_MS = 2e3;
3864
3879
  var LIVE_STACK_MAX_CUES = 150;
3880
+ var IOS_CAPTION_WINDOW_LINES = 3;
3881
+ var IOS_CAPTION_CHARS_PER_LINE = 40;
3865
3882
  var LIVE_LAG_SPIKE_MS = 2500;
3866
3883
  function stabilizeLiveLagMs(previous, next) {
3867
3884
  if (previous == null || !Number.isFinite(previous)) return next;
@@ -4009,6 +4026,17 @@ function coalesceLiveCaptionCues(cues) {
4009
4026
  }
4010
4027
  return out;
4011
4028
  }
4029
+ function lastLiveCaptionWindow(cues, maxCues = IOS_CAPTION_WINDOW_LINES) {
4030
+ return cues.slice(-Math.max(1, maxCues));
4031
+ }
4032
+ function lastCaptionLines(text, lines = IOS_CAPTION_WINDOW_LINES, charsPerLine = IOS_CAPTION_CHARS_PER_LINE) {
4033
+ const trimmed = text.trim().replace(/\s+/g, " ");
4034
+ const maxChars = Math.max(1, lines) * Math.max(1, charsPerLine);
4035
+ if (trimmed.length <= maxChars) return trimmed;
4036
+ const slice = trimmed.slice(-maxChars);
4037
+ const space = slice.indexOf(" ");
4038
+ return (space > 0 ? slice.slice(space + 1) : slice).trim();
4039
+ }
4012
4040
  function mergeLiveCaptionCues(existing, incoming, cap = LIVE_STACK_MAX_CUES) {
4013
4041
  const map = /* @__PURE__ */ new Map();
4014
4042
  for (const cue of existing) {
@@ -4056,8 +4084,33 @@ async function loadLiveCaptions(url) {
4056
4084
  return { ok: false, cues: [] };
4057
4085
  }
4058
4086
  }
4087
+
4088
+ // src/components/video/fullscreen.ts
4089
+ function asWebkitVideo(video) {
4090
+ return video;
4091
+ }
4092
+ function hasWebkitVideoFullscreen(video) {
4093
+ return typeof asWebkitVideo(video)?.webkitEnterFullscreen === "function";
4094
+ }
4095
+ function hasStandardFullscreen() {
4096
+ if (typeof document === "undefined") return false;
4097
+ if (document.fullscreenEnabled) return true;
4098
+ const doc = document;
4099
+ return !!doc.webkitFullscreenEnabled;
4100
+ }
4101
+ function isEmbeddedWindow(win = window) {
4102
+ try {
4103
+ return win.self !== win.top;
4104
+ } catch {
4105
+ return true;
4106
+ }
4107
+ }
4059
4108
  var NEAR_BOTTOM_PX = 24;
4060
- function LiveCaptionStack({ cues, latestLabel }) {
4109
+ function LiveCaptionStack({
4110
+ cues,
4111
+ latestLabel,
4112
+ variant = "scroll"
4113
+ }) {
4061
4114
  const scrollerRef = React9.useRef(null);
4062
4115
  const followRef = React9.useRef(true);
4063
4116
  const ignoreScrollRef = React9.useRef(false);
@@ -4096,13 +4149,15 @@ function LiveCaptionStack({ cues, latestLabel }) {
4096
4149
  });
4097
4150
  }, [lastReceivedAt, prefersReduced, cues.length]);
4098
4151
  if (cues.length === 0) return null;
4152
+ const windowed = variant === "window";
4099
4153
  return /* @__PURE__ */ jsx(
4100
4154
  "div",
4101
4155
  {
4102
4156
  className: "pointer-events-none absolute inset-x-0 bottom-16 z-[1] flex justify-center px-4",
4103
4157
  "data-slot": "video-captions",
4158
+ "data-caption-mode": variant,
4104
4159
  children: /* @__PURE__ */ jsxs("div", { className: "relative w-full max-w-[90%]", children: [
4105
- !following && /* @__PURE__ */ jsx(
4160
+ !windowed && !following && /* @__PURE__ */ jsx(
4106
4161
  "button",
4107
4162
  {
4108
4163
  type: "button",
@@ -4114,11 +4169,14 @@ function LiveCaptionStack({ cues, latestLabel }) {
4114
4169
  /* @__PURE__ */ jsx(
4115
4170
  "div",
4116
4171
  {
4117
- ref: scrollerRef,
4172
+ ref: windowed ? void 0 : scrollerRef,
4118
4173
  role: "log",
4119
4174
  "aria-relevant": "additions",
4120
- className: "pointer-events-auto max-h-[4.5rem] overflow-x-hidden overflow-y-auto rounded-sm bg-black/70 px-3 py-1.5 text-sm font-medium text-white shadow-sm",
4121
- onScroll: (event) => {
4175
+ className: cn(
4176
+ "rounded-sm bg-black/70 px-3 py-1.5 text-[length:clamp(10px,2.6cqh,0.875rem)] font-medium text-white shadow-sm [-webkit-text-size-adjust:100%] [text-size-adjust:100%]",
4177
+ windowed ? "overflow-hidden" : "pointer-events-auto max-h-[min(4.5rem,18cqh)] overflow-x-hidden overflow-y-auto"
4178
+ ),
4179
+ onScroll: windowed ? void 0 : (event) => {
4122
4180
  if (ignoreScrollRef.current) return;
4123
4181
  const scroller = event.currentTarget;
4124
4182
  const nearBottom = scroller.scrollHeight - scroller.scrollTop - scroller.clientHeight < NEAR_BOTTOM_PX;
@@ -4129,7 +4187,8 @@ function LiveCaptionStack({ cues, latestLabel }) {
4129
4187
  "p",
4130
4188
  {
4131
4189
  className: cn(
4132
- "text-justify [text-align-last:left] leading-5 break-words",
4190
+ "text-justify [text-align-last:left] leading-snug break-words",
4191
+ windowed && "line-clamp-3",
4133
4192
  !prefersReduced && "transition-opacity"
4134
4193
  ),
4135
4194
  children: cues.map((cue, index) => {
@@ -4157,6 +4216,46 @@ function LiveCaptionStack({ cues, latestLabel }) {
4157
4216
  }
4158
4217
  );
4159
4218
  }
4219
+
4220
+ // src/components/video/nativeCaptionTrack.ts
4221
+ var NATIVE_CAPTION_HOLD_S = 4;
4222
+ function joinCaptionTexts(cues) {
4223
+ return cues.map((cue) => cue.text.trim()).filter(Boolean).join(" ");
4224
+ }
4225
+ function clearNativeCaptionCues(track) {
4226
+ const cues = track.cues;
4227
+ if (!cues) return;
4228
+ for (let index = cues.length - 1; index >= 0; index -= 1) {
4229
+ const cue = cues[index];
4230
+ if (cue) track.removeCue(cue);
4231
+ }
4232
+ }
4233
+ function ensureNativeCaptionTrack(video, locale, existing) {
4234
+ if (existing && existing.language === locale) return existing;
4235
+ if (existing) existing.mode = "disabled";
4236
+ const track = video.addTextTrack("captions", "Livo", locale);
4237
+ track.mode = "hidden";
4238
+ return track;
4239
+ }
4240
+ function syncNativeCaptionCue(video, track, text) {
4241
+ clearNativeCaptionCues(track);
4242
+ const trimmed = text.trim();
4243
+ if (!trimmed) return;
4244
+ const start = Number.isFinite(video.currentTime) ? video.currentTime : 0;
4245
+ track.addCue(new VTTCue(start, start + NATIVE_CAPTION_HOLD_S, trimmed));
4246
+ }
4247
+ function syncNativeVodCues(track, cues) {
4248
+ clearNativeCaptionCues(track);
4249
+ for (const cue of cues) {
4250
+ const text = cue.text.trim();
4251
+ if (!text) continue;
4252
+ track.addCue(new VTTCue(cue.start, cue.end, text));
4253
+ }
4254
+ }
4255
+ function setNativeCaptionTrackVisible(track, showing) {
4256
+ if (!track) return;
4257
+ track.mode = showing ? "showing" : "hidden";
4258
+ }
4160
4259
  var DEFAULT_LABELS3 = {
4161
4260
  play: "Play",
4162
4261
  pause: "Pause",
@@ -4167,6 +4266,7 @@ var DEFAULT_LABELS3 = {
4167
4266
  pictureInPicture: "Picture in picture",
4168
4267
  cast: "Cast",
4169
4268
  settings: "Settings",
4269
+ more: "More",
4170
4270
  quality: "Quality",
4171
4271
  auto: "Auto",
4172
4272
  speed: "Speed",
@@ -4192,19 +4292,16 @@ var PLAYBACK_RATES = [0.75, 1, 1.25, 1.5, 2];
4192
4292
  var CONTROLS_HIDE_MS = 3e3;
4193
4293
  var LIVE_EDGE_THRESHOLD_S = 8;
4194
4294
  var SEEK_STEP_S = 5;
4195
- function asWebkitVideo(video) {
4196
- return video;
4197
- }
4198
- function hasWebkitVideoFullscreen(video) {
4199
- const webkit = asWebkitVideo(video);
4200
- return typeof webkit?.webkitEnterFullscreen === "function";
4295
+ var COMPACT_CHROME_PX = 640;
4296
+ var VIDEO_MEDIA_STYLE = `
4297
+ .livo-video-player-media::-webkit-media-controls-start-playback-button {
4298
+ display: none !important;
4299
+ -webkit-appearance: none;
4201
4300
  }
4202
- function hasStandardFullscreen() {
4203
- if (typeof document === "undefined") return false;
4204
- if (document.fullscreenEnabled) return true;
4205
- const doc = document;
4206
- return !!doc.webkitFullscreenEnabled;
4301
+ .livo-video-player-media::-webkit-media-controls {
4302
+ display: none !important;
4207
4303
  }
4304
+ `;
4208
4305
  function captionLocaleLabel(locale, labels) {
4209
4306
  switch (locale) {
4210
4307
  case "en":
@@ -4250,6 +4347,9 @@ function VideoPlayer({
4250
4347
  const t = { ...DEFAULT_LABELS3, ...labels };
4251
4348
  const containerRef = React9.useRef(null);
4252
4349
  const firstPlayFiredRef = React9.useRef(false);
4350
+ const nativeTrackRef = React9.useRef(null);
4351
+ const cssFullscreenRef = React9.useRef(false);
4352
+ const webkitFsRef = React9.useRef(false);
4253
4353
  const [userStarted, setUserStarted] = React9.useState(false);
4254
4354
  const active = autoPlay || !poster || userStarted;
4255
4355
  const autoplayActive = autoPlay || userStarted;
@@ -4295,15 +4395,35 @@ function VideoPlayer({
4295
4395
  const [controlsVisible, setControlsVisible] = React9.useState(true);
4296
4396
  const [playbackRate, setPlaybackRate] = React9.useState(1);
4297
4397
  const [openMenu, setOpenMenu] = React9.useState(null);
4398
+ const [compactChrome, setCompactChrome] = React9.useState(false);
4298
4399
  const [captionLocale, setCaptionLocale] = React9.useState(defaultCaptionLocale ?? "off");
4299
4400
  const [captionCues, setCaptionCues] = React9.useState([]);
4300
4401
  const [liveCaptionCues, setLiveCaptionCues] = React9.useState([]);
4301
4402
  const [liveLagMs, setLiveLagMs] = React9.useState(null);
4302
4403
  const [behindLive, setBehindLive] = React9.useState(false);
4303
4404
  const [webkitFullscreenSupported, setWebkitFullscreenSupported] = React9.useState(false);
4405
+ const [embedded, setEmbedded] = React9.useState(false);
4406
+ const [cssFullscreen, setCssFullscreen] = React9.useState(false);
4407
+ const [appleMobile, setAppleMobile] = React9.useState(false);
4304
4408
  const hideTimerRef = React9.useRef(null);
4409
+ cssFullscreenRef.current = cssFullscreen;
4410
+ React9.useEffect(() => {
4411
+ const el = containerRef.current;
4412
+ if (!el || typeof ResizeObserver === "undefined") return;
4413
+ const apply = (width) => {
4414
+ if (width <= 0) return;
4415
+ setCompactChrome(width < COMPACT_CHROME_PX);
4416
+ };
4417
+ apply(el.clientWidth);
4418
+ const observer = new ResizeObserver((entries) => {
4419
+ const width = entries[0]?.contentRect.width;
4420
+ if (typeof width === "number") apply(width);
4421
+ });
4422
+ observer.observe(el);
4423
+ return () => observer.disconnect();
4424
+ }, [active]);
4305
4425
  const pipSupported = typeof document !== "undefined" && "pictureInPictureEnabled" in document && document.pictureInPictureEnabled;
4306
- const fullscreenSupported = hasStandardFullscreen() || webkitFullscreenSupported;
4426
+ const fullscreenSupported = hasStandardFullscreen() || webkitFullscreenSupported || !embedded;
4307
4427
  React9.useEffect(() => {
4308
4428
  const video = videoRef.current;
4309
4429
  if (!video || !active) return;
@@ -4356,19 +4476,37 @@ function VideoPlayer({
4356
4476
  video.pause();
4357
4477
  }, [paused, videoRef, isPlaying]);
4358
4478
  React9.useEffect(() => {
4479
+ setEmbedded(isEmbeddedWindow());
4480
+ setAppleMobile(isAppleMobileDevice());
4359
4481
  setWebkitFullscreenSupported(hasWebkitVideoFullscreen(videoRef.current));
4360
4482
  videoRef.current?.setAttribute("x-webkit-airplay", "allow");
4483
+ videoRef.current?.setAttribute("webkit-playsinline", "");
4361
4484
  }, [videoRef, active]);
4362
4485
  React9.useEffect(() => {
4363
- const onFsChange = () => setIsFullscreen(document.fullscreenElement === containerRef.current);
4486
+ const onFsChange = () => {
4487
+ if (document.fullscreenElement === containerRef.current) {
4488
+ setIsFullscreen(true);
4489
+ return;
4490
+ }
4491
+ if (cssFullscreenRef.current || webkitFsRef.current) return;
4492
+ setIsFullscreen(false);
4493
+ };
4364
4494
  document.addEventListener("fullscreenchange", onFsChange);
4365
4495
  return () => document.removeEventListener("fullscreenchange", onFsChange);
4366
4496
  }, []);
4367
4497
  React9.useEffect(() => {
4368
4498
  const video = asWebkitVideo(videoRef.current);
4369
4499
  if (!video) return;
4370
- const onBegin = () => setIsFullscreen(true);
4371
- const onEnd = () => setIsFullscreen(false);
4500
+ const onBegin = () => {
4501
+ webkitFsRef.current = true;
4502
+ setIsFullscreen(true);
4503
+ setNativeCaptionTrackVisible(nativeTrackRef.current, true);
4504
+ };
4505
+ const onEnd = () => {
4506
+ webkitFsRef.current = false;
4507
+ setNativeCaptionTrackVisible(nativeTrackRef.current, false);
4508
+ if (!cssFullscreenRef.current) setIsFullscreen(false);
4509
+ };
4372
4510
  video.addEventListener("webkitbeginfullscreen", onBegin);
4373
4511
  video.addEventListener("webkitendfullscreen", onEnd);
4374
4512
  return () => {
@@ -4376,6 +4514,21 @@ function VideoPlayer({
4376
4514
  video.removeEventListener("webkitendfullscreen", onEnd);
4377
4515
  };
4378
4516
  }, [videoRef, active]);
4517
+ React9.useEffect(() => {
4518
+ if (!cssFullscreen) return;
4519
+ const previousOverflow = document.body.style.overflow;
4520
+ document.body.style.overflow = "hidden";
4521
+ const onKey = (event) => {
4522
+ if (event.key !== "Escape") return;
4523
+ setCssFullscreen(false);
4524
+ setIsFullscreen(false);
4525
+ };
4526
+ document.addEventListener("keydown", onKey);
4527
+ return () => {
4528
+ document.body.style.overflow = previousOverflow;
4529
+ document.removeEventListener("keydown", onKey);
4530
+ };
4531
+ }, [cssFullscreen]);
4379
4532
  React9.useEffect(() => {
4380
4533
  const video = videoRef.current;
4381
4534
  if (!video) return;
@@ -4444,7 +4597,45 @@ function VideoPlayer({
4444
4597
  const liveDueCues = liveCaptionsBaseUrl ? coalesceLiveCaptionCues(
4445
4598
  liveCuesDue(liveCaptionCues, Date.now(), liveLagMs)
4446
4599
  ) : endedLiveReplay ? coalesceLiveCaptionCues(vttCuesDueAt(captionCues, currentTime)) : [];
4600
+ const captionStackCues = appleMobile ? lastLiveCaptionWindow(liveDueCues) : liveDueCues;
4447
4601
  const activeCaption = liveCaptionsBaseUrl || endedLiveReplay ? null : captionAtTime(captionCues, currentTime);
4602
+ React9.useEffect(() => {
4603
+ const video = videoRef.current;
4604
+ if (!video || captionLocale === "off") {
4605
+ if (nativeTrackRef.current) {
4606
+ nativeTrackRef.current.mode = "disabled";
4607
+ nativeTrackRef.current = null;
4608
+ }
4609
+ return;
4610
+ }
4611
+ try {
4612
+ nativeTrackRef.current = ensureNativeCaptionTrack(
4613
+ video,
4614
+ captionLocale,
4615
+ nativeTrackRef.current
4616
+ );
4617
+ setNativeCaptionTrackVisible(nativeTrackRef.current, webkitFsRef.current);
4618
+ } catch {
4619
+ nativeTrackRef.current = null;
4620
+ }
4621
+ }, [videoRef, active, captionLocale]);
4622
+ React9.useEffect(() => {
4623
+ const track = nativeTrackRef.current;
4624
+ if (!track || captionLocale === "off") return;
4625
+ if (liveCaptionsBaseUrl || endedLiveReplay) return;
4626
+ syncNativeVodCues(track, captionCues);
4627
+ }, [captionCues, captionLocale, liveCaptionsBaseUrl, endedLiveReplay]);
4628
+ React9.useEffect(() => {
4629
+ const video = videoRef.current;
4630
+ const track = nativeTrackRef.current;
4631
+ if (!video || !track) return;
4632
+ if (!(liveCaptionsBaseUrl || endedLiveReplay)) return;
4633
+ syncNativeCaptionCue(
4634
+ video,
4635
+ track,
4636
+ lastCaptionLines(joinCaptionTexts(captionStackCues))
4637
+ );
4638
+ }, [captionStackCues, liveCaptionsBaseUrl, endedLiveReplay]);
4448
4639
  function togglePlay() {
4449
4640
  const video = videoRef.current;
4450
4641
  if (!video) return;
@@ -4479,6 +4670,10 @@ function VideoPlayer({
4479
4670
  video.currentTime = video.seekable.end(video.seekable.length - 1);
4480
4671
  if (video.paused) void video.play();
4481
4672
  }
4673
+ function exitCssFullscreen() {
4674
+ setCssFullscreen(false);
4675
+ setIsFullscreen(false);
4676
+ }
4482
4677
  function toggleFullscreen() {
4483
4678
  const el = containerRef.current;
4484
4679
  const video = asWebkitVideo(videoRef.current);
@@ -4490,13 +4685,20 @@ function VideoPlayer({
4490
4685
  video.webkitExitFullscreen();
4491
4686
  return;
4492
4687
  }
4688
+ if (cssFullscreen) {
4689
+ exitCssFullscreen();
4690
+ return;
4691
+ }
4493
4692
  if (el && hasStandardFullscreen() && typeof el.requestFullscreen === "function") {
4494
4693
  void el.requestFullscreen();
4495
4694
  return;
4496
4695
  }
4497
- if (video && typeof video.webkitEnterFullscreen === "function") {
4696
+ if (embedded && video && typeof video.webkitEnterFullscreen === "function") {
4498
4697
  video.webkitEnterFullscreen();
4698
+ return;
4499
4699
  }
4700
+ setCssFullscreen(true);
4701
+ setIsFullscreen(true);
4500
4702
  }
4501
4703
  function togglePip() {
4502
4704
  const video = videoRef.current;
@@ -4531,6 +4733,12 @@ function VideoPlayer({
4531
4733
  case "f":
4532
4734
  toggleFullscreen();
4533
4735
  break;
4736
+ case "Escape":
4737
+ if (cssFullscreen) {
4738
+ e.preventDefault();
4739
+ exitCssFullscreen();
4740
+ }
4741
+ break;
4534
4742
  case "ArrowLeft":
4535
4743
  if (mode === "vod") {
4536
4744
  e.preventDefault();
@@ -4579,6 +4787,7 @@ function VideoPlayer({
4579
4787
  const showControls = active && state === "ready" && (controlsVisible || !isPlaying);
4580
4788
  const showPoster = !active && !!poster;
4581
4789
  const currentLevelLabel = activeLevel < 0 ? t.auto : `${qualities.find((q) => q.index === activeLevel)?.height ?? ""}p`;
4790
+ const showQuality = showQualitySelector && qualities.length > 1;
4582
4791
  return /* @__PURE__ */ jsxs(
4583
4792
  "div",
4584
4793
  {
@@ -4586,9 +4795,11 @@ function VideoPlayer({
4586
4795
  "data-slot": "video-player",
4587
4796
  "data-mode": mode,
4588
4797
  "data-fit": fit,
4798
+ "data-css-fullscreen": cssFullscreen ? "" : void 0,
4589
4799
  className: cn(
4590
- "group relative w-full overflow-hidden rounded-lg bg-black text-white select-none",
4800
+ "@container group relative w-full overflow-hidden rounded-lg bg-black text-white select-none",
4591
4801
  fit === "contain" ? "h-full min-h-0 aspect-auto" : "aspect-video",
4802
+ cssFullscreen && "fixed inset-0 z-50 h-dvh w-dvw rounded-none",
4592
4803
  className
4593
4804
  ),
4594
4805
  onMouseMove: revealControls,
@@ -4600,13 +4811,14 @@ function VideoPlayer({
4600
4811
  role: "region",
4601
4812
  "aria-label": "Video player",
4602
4813
  children: [
4814
+ /* @__PURE__ */ jsx("style", { children: VIDEO_MEDIA_STYLE }),
4603
4815
  /* @__PURE__ */ jsx(
4604
4816
  "video",
4605
4817
  {
4606
4818
  ref: videoRef,
4607
4819
  playsInline: true,
4608
4820
  muted: isMuted,
4609
- className: "h-full w-full bg-black object-contain",
4821
+ className: "livo-video-player-media h-full w-full bg-black object-contain",
4610
4822
  onClick: active ? togglePlay : void 0,
4611
4823
  poster
4612
4824
  }
@@ -4645,7 +4857,7 @@ function VideoPlayer({
4645
4857
  }
4646
4858
  )
4647
4859
  ] }),
4648
- state === "ready" && autoplayState === "blocked" && /* @__PURE__ */ jsx("div", { className: "absolute inset-0 flex items-center justify-center bg-black/40", children: /* @__PURE__ */ jsx(
4860
+ state === "ready" && autoplayState === "blocked" && !isPlaying && /* @__PURE__ */ jsx("div", { className: "absolute inset-0 flex items-center justify-center bg-black/40", children: /* @__PURE__ */ jsx(
4649
4861
  "button",
4650
4862
  {
4651
4863
  type: "button",
@@ -4674,13 +4886,20 @@ function VideoPlayer({
4674
4886
  ] }),
4675
4887
  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}` })
4676
4888
  ] }),
4677
- (liveCaptionsBaseUrl || endedLiveReplay) && captionLocale !== "off" && /* @__PURE__ */ jsx(LiveCaptionStack, { cues: liveDueCues, latestLabel: t.captionsLatest }),
4889
+ (liveCaptionsBaseUrl || endedLiveReplay) && captionLocale !== "off" && /* @__PURE__ */ jsx(
4890
+ LiveCaptionStack,
4891
+ {
4892
+ cues: captionStackCues,
4893
+ latestLabel: t.captionsLatest,
4894
+ variant: appleMobile ? "window" : "scroll"
4895
+ }
4896
+ ),
4678
4897
  !liveCaptionsBaseUrl && !endedLiveReplay && activeCaption && captionLocale !== "off" && /* @__PURE__ */ jsx(
4679
4898
  "div",
4680
4899
  {
4681
4900
  className: "pointer-events-none absolute inset-x-0 bottom-16 z-[1] flex justify-center px-4",
4682
4901
  "data-slot": "video-captions",
4683
- children: /* @__PURE__ */ jsx("p", { className: "line-clamp-2 max-w-[90%] break-words rounded-sm bg-black/70 px-3 py-1.5 text-center text-sm font-medium text-white shadow-sm", children: activeCaption.text })
4902
+ children: /* @__PURE__ */ jsx("p", { className: "line-clamp-2 max-w-[90%] break-words rounded-sm bg-black/70 px-3 py-1.5 text-center text-[length:clamp(10px,2.6cqh,0.875rem)] font-medium text-white shadow-sm [-webkit-text-size-adjust:100%] [text-size-adjust:100%]", children: activeCaption.text })
4684
4903
  }
4685
4904
  ),
4686
4905
  active && /* @__PURE__ */ jsxs(
@@ -4703,7 +4922,7 @@ function VideoPlayer({
4703
4922
  formatTime
4704
4923
  }
4705
4924
  ),
4706
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
4925
+ /* @__PURE__ */ jsxs("div", { className: "flex min-w-0 items-center gap-1 sm:gap-2", children: [
4707
4926
  /* @__PURE__ */ jsx(
4708
4927
  ControlButton,
4709
4928
  {
@@ -4721,7 +4940,7 @@ function VideoPlayer({
4721
4940
  children: /* @__PURE__ */ jsx(VolumeIcon, { className: "size-5" })
4722
4941
  }
4723
4942
  ),
4724
- /* @__PURE__ */ jsx("div", { className: "w-20 px-1", children: /* @__PURE__ */ jsx(
4943
+ !compactChrome && /* @__PURE__ */ jsx("div", { className: "w-20 px-1", children: /* @__PURE__ */ jsx(
4725
4944
  Slider,
4726
4945
  {
4727
4946
  "aria-label": "Volume",
@@ -4733,25 +4952,24 @@ function VideoPlayer({
4733
4952
  }
4734
4953
  ) })
4735
4954
  ] }),
4736
- mode === "vod" && /* @__PURE__ */ jsxs("span", { className: "ml-1 text-xs tabular-nums", children: [
4955
+ mode === "vod" && /* @__PURE__ */ jsxs("span", { className: "ml-1 shrink-0 text-xs tabular-nums", children: [
4737
4956
  formatTime(currentTime),
4738
- " / ",
4739
- formatTime(duration)
4957
+ !compactChrome && ` / ${formatTime(duration)}`
4740
4958
  ] }),
4741
4959
  mode === "live" && behindLive && /* @__PURE__ */ jsxs(
4742
4960
  "button",
4743
4961
  {
4744
4962
  type: "button",
4745
4963
  onClick: goToLiveEdge,
4746
- className: "ml-1 flex items-center gap-1 rounded bg-white/15 px-2 py-0.5 text-xs hover:bg-white/25",
4964
+ className: "ml-1 flex shrink-0 items-center gap-1 rounded bg-white/15 px-2 py-0.5 text-xs hover:bg-white/25",
4747
4965
  children: [
4748
4966
  /* @__PURE__ */ jsx("span", { className: "size-1.5 rounded-full bg-red-500" }),
4749
4967
  t.goLive
4750
4968
  ]
4751
4969
  }
4752
4970
  ),
4753
- /* @__PURE__ */ jsxs("div", { className: "ml-auto flex items-center gap-1", children: [
4754
- mode === "vod" && typeof stats?.views === "number" && /* @__PURE__ */ jsx("span", { className: "mr-1 text-xs", children: t.formatViews ? t.formatViews(stats.views) : `${stats.views} views` }),
4971
+ /* @__PURE__ */ jsxs("div", { className: "ml-auto flex shrink-0 items-center gap-1", children: [
4972
+ !compactChrome && mode === "vod" && typeof stats?.views === "number" && /* @__PURE__ */ jsx("span", { className: "mr-1 text-xs", children: t.formatViews ? t.formatViews(stats.views) : `${stats.views} views` }),
4755
4973
  /* @__PURE__ */ jsxs(
4756
4974
  MenuControl,
4757
4975
  {
@@ -4780,7 +4998,7 @@ function VideoPlayer({
4780
4998
  ]
4781
4999
  }
4782
5000
  ),
4783
- mode === "vod" && /* @__PURE__ */ jsx(
5001
+ !compactChrome && mode === "vod" && /* @__PURE__ */ jsx(
4784
5002
  MenuControl,
4785
5003
  {
4786
5004
  label: t.speed,
@@ -4804,7 +5022,7 @@ function VideoPlayer({
4804
5022
  ))
4805
5023
  }
4806
5024
  ),
4807
- showQualitySelector && qualities.length > 1 && /* @__PURE__ */ jsxs(
5025
+ !compactChrome && showQuality && /* @__PURE__ */ jsxs(
4808
5026
  MenuControl,
4809
5027
  {
4810
5028
  label: t.quality,
@@ -4836,7 +5054,7 @@ function VideoPlayer({
4836
5054
  ]
4837
5055
  }
4838
5056
  ),
4839
- /* @__PURE__ */ jsx(
5057
+ !compactChrome && /* @__PURE__ */ jsx(
4840
5058
  ControlButton,
4841
5059
  {
4842
5060
  label: t.cast,
@@ -4846,12 +5064,81 @@ function VideoPlayer({
4846
5064
  children: /* @__PURE__ */ jsx(Cast, { className: "size-5" })
4847
5065
  }
4848
5066
  ),
4849
- pipSupported && /* @__PURE__ */ jsx(ControlButton, { label: t.pictureInPicture, onClick: togglePip, children: /* @__PURE__ */ jsx(
5067
+ !compactChrome && pipSupported && /* @__PURE__ */ jsx(ControlButton, { label: t.pictureInPicture, onClick: togglePip, children: /* @__PURE__ */ jsx(
4850
5068
  PictureInPicture2,
4851
5069
  {
4852
5070
  className: cn("size-5", pipActive && "text-primary")
4853
5071
  }
4854
5072
  ) }),
5073
+ compactChrome && /* @__PURE__ */ jsxs(
5074
+ MenuControl,
5075
+ {
5076
+ label: t.more,
5077
+ open: openMenu === "more",
5078
+ onOpenChange: (o) => setOpenMenu(o ? "more" : null),
5079
+ trigger: /* @__PURE__ */ jsx(EllipsisVertical, { className: "size-5" }),
5080
+ children: [
5081
+ mode === "vod" && /* @__PURE__ */ jsxs(Fragment, { children: [
5082
+ /* @__PURE__ */ jsx(MenuSection, { children: t.speed }),
5083
+ PLAYBACK_RATES.map((rate) => /* @__PURE__ */ jsxs(
5084
+ MenuItem,
5085
+ {
5086
+ selected: rate === playbackRate,
5087
+ onSelect: () => changeRate(rate),
5088
+ children: [
5089
+ rate,
5090
+ "\xD7"
5091
+ ]
5092
+ },
5093
+ rate
5094
+ ))
5095
+ ] }),
5096
+ showQuality && /* @__PURE__ */ jsxs(Fragment, { children: [
5097
+ /* @__PURE__ */ jsx(MenuSection, { children: t.quality }),
5098
+ /* @__PURE__ */ jsx(
5099
+ MenuItem,
5100
+ {
5101
+ selected: activeLevel < 0,
5102
+ onSelect: () => chooseLevel(-1),
5103
+ children: t.auto
5104
+ }
5105
+ ),
5106
+ qualities.map((q) => /* @__PURE__ */ jsxs(
5107
+ MenuItem,
5108
+ {
5109
+ selected: activeLevel === q.index,
5110
+ onSelect: () => chooseLevel(q.index),
5111
+ children: [
5112
+ q.height,
5113
+ "p"
5114
+ ]
5115
+ },
5116
+ q.index
5117
+ ))
5118
+ ] }),
5119
+ /* @__PURE__ */ jsx(
5120
+ MenuAction,
5121
+ {
5122
+ onSelect: () => {
5123
+ setOpenMenu(null);
5124
+ void castHlsUrl(src).catch(() => void 0);
5125
+ },
5126
+ children: t.cast
5127
+ }
5128
+ ),
5129
+ pipSupported && /* @__PURE__ */ jsx(
5130
+ MenuAction,
5131
+ {
5132
+ onSelect: () => {
5133
+ setOpenMenu(null);
5134
+ togglePip();
5135
+ },
5136
+ children: t.pictureInPicture
5137
+ }
5138
+ )
5139
+ ]
5140
+ }
5141
+ ),
4855
5142
  fullscreenSupported && /* @__PURE__ */ jsx(
4856
5143
  ControlButton,
4857
5144
  {
@@ -4921,6 +5208,9 @@ function MenuControl({
4921
5208
  )
4922
5209
  ] });
4923
5210
  }
5211
+ function MenuSection({ children }) {
5212
+ return /* @__PURE__ */ jsx("div", { className: "px-2 pt-1.5 pb-0.5 text-[10px] font-semibold tracking-wide text-white/50 uppercase", children });
5213
+ }
4924
5214
  function MenuItem({
4925
5215
  selected,
4926
5216
  onSelect,
@@ -4941,6 +5231,21 @@ function MenuItem({
4941
5231
  }
4942
5232
  );
4943
5233
  }
5234
+ function MenuAction({
5235
+ onSelect,
5236
+ children
5237
+ }) {
5238
+ return /* @__PURE__ */ jsx(
5239
+ "button",
5240
+ {
5241
+ type: "button",
5242
+ role: "menuitem",
5243
+ onClick: onSelect,
5244
+ className: "flex w-full items-center rounded px-2 py-1.5 text-left text-white/90 hover:bg-white/15",
5245
+ children
5246
+ }
5247
+ );
5248
+ }
4944
5249
 
4945
5250
  // src/components/video/feedPlaybackCoordinator.ts
4946
5251
  var players = /* @__PURE__ */ new Map();