@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.cjs CHANGED
@@ -3642,7 +3642,13 @@ function useHlsPlayback({
3642
3642
  el.muted = true;
3643
3643
  void el.play().then(
3644
3644
  () => setAutoplayState(muted ? "playing" : "muted"),
3645
- () => setAutoplayState("blocked")
3645
+ () => {
3646
+ if (el.paused) {
3647
+ setAutoplayState("blocked");
3648
+ return;
3649
+ }
3650
+ setAutoplayState(el.muted && !muted ? "muted" : "playing");
3651
+ }
3646
3652
  );
3647
3653
  }
3648
3654
  );
@@ -3708,6 +3714,9 @@ function useHlsPlayback({
3708
3714
  mediaErrorRetries = 0;
3709
3715
  clearRetryTimer();
3710
3716
  setState("ready");
3717
+ setAutoplayState(
3718
+ (prev) => prev === "blocked" || prev === "none" ? "playing" : prev
3719
+ );
3711
3720
  onPlayingChangeRef.current?.(true);
3712
3721
  }
3713
3722
  function onPaused() {
@@ -3884,10 +3893,18 @@ function useHlsPlayback({
3884
3893
  };
3885
3894
  }
3886
3895
 
3896
+ // src/components/video/appleMobile.ts
3897
+ function isAppleMobileDevice(nav = navigator) {
3898
+ if (/iP(hone|ad|od)/.test(nav.userAgent)) return true;
3899
+ return nav.platform === "MacIntel" && nav.maxTouchPoints > 1;
3900
+ }
3901
+
3887
3902
  // src/components/video/captions.ts
3888
3903
  var CAPTION_LOCALES = ["en", "es", "pt"];
3889
3904
  var LIVE_CUE_EXTRA_LAG_MS = 2e3;
3890
3905
  var LIVE_STACK_MAX_CUES = 150;
3906
+ var IOS_CAPTION_WINDOW_LINES = 3;
3907
+ var IOS_CAPTION_CHARS_PER_LINE = 40;
3891
3908
  var LIVE_LAG_SPIKE_MS = 2500;
3892
3909
  function stabilizeLiveLagMs(previous, next) {
3893
3910
  if (previous == null || !Number.isFinite(previous)) return next;
@@ -4035,6 +4052,17 @@ function coalesceLiveCaptionCues(cues) {
4035
4052
  }
4036
4053
  return out;
4037
4054
  }
4055
+ function lastLiveCaptionWindow(cues, maxCues = IOS_CAPTION_WINDOW_LINES) {
4056
+ return cues.slice(-Math.max(1, maxCues));
4057
+ }
4058
+ function lastCaptionLines(text, lines = IOS_CAPTION_WINDOW_LINES, charsPerLine = IOS_CAPTION_CHARS_PER_LINE) {
4059
+ const trimmed = text.trim().replace(/\s+/g, " ");
4060
+ const maxChars = Math.max(1, lines) * Math.max(1, charsPerLine);
4061
+ if (trimmed.length <= maxChars) return trimmed;
4062
+ const slice = trimmed.slice(-maxChars);
4063
+ const space = slice.indexOf(" ");
4064
+ return (space > 0 ? slice.slice(space + 1) : slice).trim();
4065
+ }
4038
4066
  function mergeLiveCaptionCues(existing, incoming, cap = LIVE_STACK_MAX_CUES) {
4039
4067
  const map = /* @__PURE__ */ new Map();
4040
4068
  for (const cue of existing) {
@@ -4082,8 +4110,33 @@ async function loadLiveCaptions(url) {
4082
4110
  return { ok: false, cues: [] };
4083
4111
  }
4084
4112
  }
4113
+
4114
+ // src/components/video/fullscreen.ts
4115
+ function asWebkitVideo(video) {
4116
+ return video;
4117
+ }
4118
+ function hasWebkitVideoFullscreen(video) {
4119
+ return typeof asWebkitVideo(video)?.webkitEnterFullscreen === "function";
4120
+ }
4121
+ function hasStandardFullscreen() {
4122
+ if (typeof document === "undefined") return false;
4123
+ if (document.fullscreenEnabled) return true;
4124
+ const doc = document;
4125
+ return !!doc.webkitFullscreenEnabled;
4126
+ }
4127
+ function isEmbeddedWindow(win = window) {
4128
+ try {
4129
+ return win.self !== win.top;
4130
+ } catch {
4131
+ return true;
4132
+ }
4133
+ }
4085
4134
  var NEAR_BOTTOM_PX = 24;
4086
- function LiveCaptionStack({ cues, latestLabel }) {
4135
+ function LiveCaptionStack({
4136
+ cues,
4137
+ latestLabel,
4138
+ variant = "scroll"
4139
+ }) {
4087
4140
  const scrollerRef = React9__namespace.useRef(null);
4088
4141
  const followRef = React9__namespace.useRef(true);
4089
4142
  const ignoreScrollRef = React9__namespace.useRef(false);
@@ -4122,13 +4175,15 @@ function LiveCaptionStack({ cues, latestLabel }) {
4122
4175
  });
4123
4176
  }, [lastReceivedAt, prefersReduced, cues.length]);
4124
4177
  if (cues.length === 0) return null;
4178
+ const windowed = variant === "window";
4125
4179
  return /* @__PURE__ */ jsxRuntime.jsx(
4126
4180
  "div",
4127
4181
  {
4128
4182
  className: "pointer-events-none absolute inset-x-0 bottom-16 z-[1] flex justify-center px-4",
4129
4183
  "data-slot": "video-captions",
4184
+ "data-caption-mode": variant,
4130
4185
  children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative w-full max-w-[90%]", children: [
4131
- !following && /* @__PURE__ */ jsxRuntime.jsx(
4186
+ !windowed && !following && /* @__PURE__ */ jsxRuntime.jsx(
4132
4187
  "button",
4133
4188
  {
4134
4189
  type: "button",
@@ -4140,11 +4195,14 @@ function LiveCaptionStack({ cues, latestLabel }) {
4140
4195
  /* @__PURE__ */ jsxRuntime.jsx(
4141
4196
  "div",
4142
4197
  {
4143
- ref: scrollerRef,
4198
+ ref: windowed ? void 0 : scrollerRef,
4144
4199
  role: "log",
4145
4200
  "aria-relevant": "additions",
4146
- 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",
4147
- onScroll: (event) => {
4201
+ className: cn(
4202
+ "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%]",
4203
+ windowed ? "overflow-hidden" : "pointer-events-auto max-h-[min(4.5rem,18cqh)] overflow-x-hidden overflow-y-auto"
4204
+ ),
4205
+ onScroll: windowed ? void 0 : (event) => {
4148
4206
  if (ignoreScrollRef.current) return;
4149
4207
  const scroller = event.currentTarget;
4150
4208
  const nearBottom = scroller.scrollHeight - scroller.scrollTop - scroller.clientHeight < NEAR_BOTTOM_PX;
@@ -4155,7 +4213,8 @@ function LiveCaptionStack({ cues, latestLabel }) {
4155
4213
  "p",
4156
4214
  {
4157
4215
  className: cn(
4158
- "text-justify [text-align-last:left] leading-5 break-words",
4216
+ "text-justify [text-align-last:left] leading-snug break-words",
4217
+ windowed && "line-clamp-3",
4159
4218
  !prefersReduced && "transition-opacity"
4160
4219
  ),
4161
4220
  children: cues.map((cue, index) => {
@@ -4183,6 +4242,46 @@ function LiveCaptionStack({ cues, latestLabel }) {
4183
4242
  }
4184
4243
  );
4185
4244
  }
4245
+
4246
+ // src/components/video/nativeCaptionTrack.ts
4247
+ var NATIVE_CAPTION_HOLD_S = 4;
4248
+ function joinCaptionTexts(cues) {
4249
+ return cues.map((cue) => cue.text.trim()).filter(Boolean).join(" ");
4250
+ }
4251
+ function clearNativeCaptionCues(track) {
4252
+ const cues = track.cues;
4253
+ if (!cues) return;
4254
+ for (let index = cues.length - 1; index >= 0; index -= 1) {
4255
+ const cue = cues[index];
4256
+ if (cue) track.removeCue(cue);
4257
+ }
4258
+ }
4259
+ function ensureNativeCaptionTrack(video, locale, existing) {
4260
+ if (existing && existing.language === locale) return existing;
4261
+ if (existing) existing.mode = "disabled";
4262
+ const track = video.addTextTrack("captions", "Livo", locale);
4263
+ track.mode = "hidden";
4264
+ return track;
4265
+ }
4266
+ function syncNativeCaptionCue(video, track, text) {
4267
+ clearNativeCaptionCues(track);
4268
+ const trimmed = text.trim();
4269
+ if (!trimmed) return;
4270
+ const start = Number.isFinite(video.currentTime) ? video.currentTime : 0;
4271
+ track.addCue(new VTTCue(start, start + NATIVE_CAPTION_HOLD_S, trimmed));
4272
+ }
4273
+ function syncNativeVodCues(track, cues) {
4274
+ clearNativeCaptionCues(track);
4275
+ for (const cue of cues) {
4276
+ const text = cue.text.trim();
4277
+ if (!text) continue;
4278
+ track.addCue(new VTTCue(cue.start, cue.end, text));
4279
+ }
4280
+ }
4281
+ function setNativeCaptionTrackVisible(track, showing) {
4282
+ if (!track) return;
4283
+ track.mode = showing ? "showing" : "hidden";
4284
+ }
4186
4285
  var DEFAULT_LABELS3 = {
4187
4286
  play: "Play",
4188
4287
  pause: "Pause",
@@ -4193,6 +4292,7 @@ var DEFAULT_LABELS3 = {
4193
4292
  pictureInPicture: "Picture in picture",
4194
4293
  cast: "Cast",
4195
4294
  settings: "Settings",
4295
+ more: "More",
4196
4296
  quality: "Quality",
4197
4297
  auto: "Auto",
4198
4298
  speed: "Speed",
@@ -4218,19 +4318,16 @@ var PLAYBACK_RATES = [0.75, 1, 1.25, 1.5, 2];
4218
4318
  var CONTROLS_HIDE_MS = 3e3;
4219
4319
  var LIVE_EDGE_THRESHOLD_S = 8;
4220
4320
  var SEEK_STEP_S = 5;
4221
- function asWebkitVideo(video) {
4222
- return video;
4223
- }
4224
- function hasWebkitVideoFullscreen(video) {
4225
- const webkit = asWebkitVideo(video);
4226
- return typeof webkit?.webkitEnterFullscreen === "function";
4321
+ var COMPACT_CHROME_PX = 640;
4322
+ var VIDEO_MEDIA_STYLE = `
4323
+ .livo-video-player-media::-webkit-media-controls-start-playback-button {
4324
+ display: none !important;
4325
+ -webkit-appearance: none;
4227
4326
  }
4228
- function hasStandardFullscreen() {
4229
- if (typeof document === "undefined") return false;
4230
- if (document.fullscreenEnabled) return true;
4231
- const doc = document;
4232
- return !!doc.webkitFullscreenEnabled;
4327
+ .livo-video-player-media::-webkit-media-controls {
4328
+ display: none !important;
4233
4329
  }
4330
+ `;
4234
4331
  function captionLocaleLabel(locale, labels) {
4235
4332
  switch (locale) {
4236
4333
  case "en":
@@ -4276,6 +4373,9 @@ function VideoPlayer({
4276
4373
  const t = { ...DEFAULT_LABELS3, ...labels };
4277
4374
  const containerRef = React9__namespace.useRef(null);
4278
4375
  const firstPlayFiredRef = React9__namespace.useRef(false);
4376
+ const nativeTrackRef = React9__namespace.useRef(null);
4377
+ const cssFullscreenRef = React9__namespace.useRef(false);
4378
+ const webkitFsRef = React9__namespace.useRef(false);
4279
4379
  const [userStarted, setUserStarted] = React9__namespace.useState(false);
4280
4380
  const active = autoPlay || !poster || userStarted;
4281
4381
  const autoplayActive = autoPlay || userStarted;
@@ -4321,15 +4421,35 @@ function VideoPlayer({
4321
4421
  const [controlsVisible, setControlsVisible] = React9__namespace.useState(true);
4322
4422
  const [playbackRate, setPlaybackRate] = React9__namespace.useState(1);
4323
4423
  const [openMenu, setOpenMenu] = React9__namespace.useState(null);
4424
+ const [compactChrome, setCompactChrome] = React9__namespace.useState(false);
4324
4425
  const [captionLocale, setCaptionLocale] = React9__namespace.useState(defaultCaptionLocale ?? "off");
4325
4426
  const [captionCues, setCaptionCues] = React9__namespace.useState([]);
4326
4427
  const [liveCaptionCues, setLiveCaptionCues] = React9__namespace.useState([]);
4327
4428
  const [liveLagMs, setLiveLagMs] = React9__namespace.useState(null);
4328
4429
  const [behindLive, setBehindLive] = React9__namespace.useState(false);
4329
4430
  const [webkitFullscreenSupported, setWebkitFullscreenSupported] = React9__namespace.useState(false);
4431
+ const [embedded, setEmbedded] = React9__namespace.useState(false);
4432
+ const [cssFullscreen, setCssFullscreen] = React9__namespace.useState(false);
4433
+ const [appleMobile, setAppleMobile] = React9__namespace.useState(false);
4330
4434
  const hideTimerRef = React9__namespace.useRef(null);
4435
+ cssFullscreenRef.current = cssFullscreen;
4436
+ React9__namespace.useEffect(() => {
4437
+ const el = containerRef.current;
4438
+ if (!el || typeof ResizeObserver === "undefined") return;
4439
+ const apply = (width) => {
4440
+ if (width <= 0) return;
4441
+ setCompactChrome(width < COMPACT_CHROME_PX);
4442
+ };
4443
+ apply(el.clientWidth);
4444
+ const observer = new ResizeObserver((entries) => {
4445
+ const width = entries[0]?.contentRect.width;
4446
+ if (typeof width === "number") apply(width);
4447
+ });
4448
+ observer.observe(el);
4449
+ return () => observer.disconnect();
4450
+ }, [active]);
4331
4451
  const pipSupported = typeof document !== "undefined" && "pictureInPictureEnabled" in document && document.pictureInPictureEnabled;
4332
- const fullscreenSupported = hasStandardFullscreen() || webkitFullscreenSupported;
4452
+ const fullscreenSupported = hasStandardFullscreen() || webkitFullscreenSupported || !embedded;
4333
4453
  React9__namespace.useEffect(() => {
4334
4454
  const video = videoRef.current;
4335
4455
  if (!video || !active) return;
@@ -4382,19 +4502,37 @@ function VideoPlayer({
4382
4502
  video.pause();
4383
4503
  }, [paused, videoRef, isPlaying]);
4384
4504
  React9__namespace.useEffect(() => {
4505
+ setEmbedded(isEmbeddedWindow());
4506
+ setAppleMobile(isAppleMobileDevice());
4385
4507
  setWebkitFullscreenSupported(hasWebkitVideoFullscreen(videoRef.current));
4386
4508
  videoRef.current?.setAttribute("x-webkit-airplay", "allow");
4509
+ videoRef.current?.setAttribute("webkit-playsinline", "");
4387
4510
  }, [videoRef, active]);
4388
4511
  React9__namespace.useEffect(() => {
4389
- const onFsChange = () => setIsFullscreen(document.fullscreenElement === containerRef.current);
4512
+ const onFsChange = () => {
4513
+ if (document.fullscreenElement === containerRef.current) {
4514
+ setIsFullscreen(true);
4515
+ return;
4516
+ }
4517
+ if (cssFullscreenRef.current || webkitFsRef.current) return;
4518
+ setIsFullscreen(false);
4519
+ };
4390
4520
  document.addEventListener("fullscreenchange", onFsChange);
4391
4521
  return () => document.removeEventListener("fullscreenchange", onFsChange);
4392
4522
  }, []);
4393
4523
  React9__namespace.useEffect(() => {
4394
4524
  const video = asWebkitVideo(videoRef.current);
4395
4525
  if (!video) return;
4396
- const onBegin = () => setIsFullscreen(true);
4397
- const onEnd = () => setIsFullscreen(false);
4526
+ const onBegin = () => {
4527
+ webkitFsRef.current = true;
4528
+ setIsFullscreen(true);
4529
+ setNativeCaptionTrackVisible(nativeTrackRef.current, true);
4530
+ };
4531
+ const onEnd = () => {
4532
+ webkitFsRef.current = false;
4533
+ setNativeCaptionTrackVisible(nativeTrackRef.current, false);
4534
+ if (!cssFullscreenRef.current) setIsFullscreen(false);
4535
+ };
4398
4536
  video.addEventListener("webkitbeginfullscreen", onBegin);
4399
4537
  video.addEventListener("webkitendfullscreen", onEnd);
4400
4538
  return () => {
@@ -4402,6 +4540,21 @@ function VideoPlayer({
4402
4540
  video.removeEventListener("webkitendfullscreen", onEnd);
4403
4541
  };
4404
4542
  }, [videoRef, active]);
4543
+ React9__namespace.useEffect(() => {
4544
+ if (!cssFullscreen) return;
4545
+ const previousOverflow = document.body.style.overflow;
4546
+ document.body.style.overflow = "hidden";
4547
+ const onKey = (event) => {
4548
+ if (event.key !== "Escape") return;
4549
+ setCssFullscreen(false);
4550
+ setIsFullscreen(false);
4551
+ };
4552
+ document.addEventListener("keydown", onKey);
4553
+ return () => {
4554
+ document.body.style.overflow = previousOverflow;
4555
+ document.removeEventListener("keydown", onKey);
4556
+ };
4557
+ }, [cssFullscreen]);
4405
4558
  React9__namespace.useEffect(() => {
4406
4559
  const video = videoRef.current;
4407
4560
  if (!video) return;
@@ -4470,7 +4623,45 @@ function VideoPlayer({
4470
4623
  const liveDueCues = liveCaptionsBaseUrl ? coalesceLiveCaptionCues(
4471
4624
  liveCuesDue(liveCaptionCues, Date.now(), liveLagMs)
4472
4625
  ) : endedLiveReplay ? coalesceLiveCaptionCues(vttCuesDueAt(captionCues, currentTime)) : [];
4626
+ const captionStackCues = appleMobile ? lastLiveCaptionWindow(liveDueCues) : liveDueCues;
4473
4627
  const activeCaption = liveCaptionsBaseUrl || endedLiveReplay ? null : captionAtTime(captionCues, currentTime);
4628
+ React9__namespace.useEffect(() => {
4629
+ const video = videoRef.current;
4630
+ if (!video || captionLocale === "off") {
4631
+ if (nativeTrackRef.current) {
4632
+ nativeTrackRef.current.mode = "disabled";
4633
+ nativeTrackRef.current = null;
4634
+ }
4635
+ return;
4636
+ }
4637
+ try {
4638
+ nativeTrackRef.current = ensureNativeCaptionTrack(
4639
+ video,
4640
+ captionLocale,
4641
+ nativeTrackRef.current
4642
+ );
4643
+ setNativeCaptionTrackVisible(nativeTrackRef.current, webkitFsRef.current);
4644
+ } catch {
4645
+ nativeTrackRef.current = null;
4646
+ }
4647
+ }, [videoRef, active, captionLocale]);
4648
+ React9__namespace.useEffect(() => {
4649
+ const track = nativeTrackRef.current;
4650
+ if (!track || captionLocale === "off") return;
4651
+ if (liveCaptionsBaseUrl || endedLiveReplay) return;
4652
+ syncNativeVodCues(track, captionCues);
4653
+ }, [captionCues, captionLocale, liveCaptionsBaseUrl, endedLiveReplay]);
4654
+ React9__namespace.useEffect(() => {
4655
+ const video = videoRef.current;
4656
+ const track = nativeTrackRef.current;
4657
+ if (!video || !track) return;
4658
+ if (!(liveCaptionsBaseUrl || endedLiveReplay)) return;
4659
+ syncNativeCaptionCue(
4660
+ video,
4661
+ track,
4662
+ lastCaptionLines(joinCaptionTexts(captionStackCues))
4663
+ );
4664
+ }, [captionStackCues, liveCaptionsBaseUrl, endedLiveReplay]);
4474
4665
  function togglePlay() {
4475
4666
  const video = videoRef.current;
4476
4667
  if (!video) return;
@@ -4505,6 +4696,10 @@ function VideoPlayer({
4505
4696
  video.currentTime = video.seekable.end(video.seekable.length - 1);
4506
4697
  if (video.paused) void video.play();
4507
4698
  }
4699
+ function exitCssFullscreen() {
4700
+ setCssFullscreen(false);
4701
+ setIsFullscreen(false);
4702
+ }
4508
4703
  function toggleFullscreen() {
4509
4704
  const el = containerRef.current;
4510
4705
  const video = asWebkitVideo(videoRef.current);
@@ -4516,13 +4711,20 @@ function VideoPlayer({
4516
4711
  video.webkitExitFullscreen();
4517
4712
  return;
4518
4713
  }
4714
+ if (cssFullscreen) {
4715
+ exitCssFullscreen();
4716
+ return;
4717
+ }
4519
4718
  if (el && hasStandardFullscreen() && typeof el.requestFullscreen === "function") {
4520
4719
  void el.requestFullscreen();
4521
4720
  return;
4522
4721
  }
4523
- if (video && typeof video.webkitEnterFullscreen === "function") {
4722
+ if (embedded && video && typeof video.webkitEnterFullscreen === "function") {
4524
4723
  video.webkitEnterFullscreen();
4724
+ return;
4525
4725
  }
4726
+ setCssFullscreen(true);
4727
+ setIsFullscreen(true);
4526
4728
  }
4527
4729
  function togglePip() {
4528
4730
  const video = videoRef.current;
@@ -4557,6 +4759,12 @@ function VideoPlayer({
4557
4759
  case "f":
4558
4760
  toggleFullscreen();
4559
4761
  break;
4762
+ case "Escape":
4763
+ if (cssFullscreen) {
4764
+ e.preventDefault();
4765
+ exitCssFullscreen();
4766
+ }
4767
+ break;
4560
4768
  case "ArrowLeft":
4561
4769
  if (mode === "vod") {
4562
4770
  e.preventDefault();
@@ -4605,6 +4813,7 @@ function VideoPlayer({
4605
4813
  const showControls = active && state === "ready" && (controlsVisible || !isPlaying);
4606
4814
  const showPoster = !active && !!poster;
4607
4815
  const currentLevelLabel = activeLevel < 0 ? t.auto : `${qualities.find((q) => q.index === activeLevel)?.height ?? ""}p`;
4816
+ const showQuality = showQualitySelector && qualities.length > 1;
4608
4817
  return /* @__PURE__ */ jsxRuntime.jsxs(
4609
4818
  "div",
4610
4819
  {
@@ -4612,9 +4821,11 @@ function VideoPlayer({
4612
4821
  "data-slot": "video-player",
4613
4822
  "data-mode": mode,
4614
4823
  "data-fit": fit,
4824
+ "data-css-fullscreen": cssFullscreen ? "" : void 0,
4615
4825
  className: cn(
4616
- "group relative w-full overflow-hidden rounded-lg bg-black text-white select-none",
4826
+ "@container group relative w-full overflow-hidden rounded-lg bg-black text-white select-none",
4617
4827
  fit === "contain" ? "h-full min-h-0 aspect-auto" : "aspect-video",
4828
+ cssFullscreen && "fixed inset-0 z-50 h-dvh w-dvw rounded-none",
4618
4829
  className
4619
4830
  ),
4620
4831
  onMouseMove: revealControls,
@@ -4626,13 +4837,14 @@ function VideoPlayer({
4626
4837
  role: "region",
4627
4838
  "aria-label": "Video player",
4628
4839
  children: [
4840
+ /* @__PURE__ */ jsxRuntime.jsx("style", { children: VIDEO_MEDIA_STYLE }),
4629
4841
  /* @__PURE__ */ jsxRuntime.jsx(
4630
4842
  "video",
4631
4843
  {
4632
4844
  ref: videoRef,
4633
4845
  playsInline: true,
4634
4846
  muted: isMuted,
4635
- className: "h-full w-full bg-black object-contain",
4847
+ className: "livo-video-player-media h-full w-full bg-black object-contain",
4636
4848
  onClick: active ? togglePlay : void 0,
4637
4849
  poster
4638
4850
  }
@@ -4671,7 +4883,7 @@ function VideoPlayer({
4671
4883
  }
4672
4884
  )
4673
4885
  ] }),
4674
- state === "ready" && autoplayState === "blocked" && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute inset-0 flex items-center justify-center bg-black/40", children: /* @__PURE__ */ jsxRuntime.jsx(
4886
+ state === "ready" && autoplayState === "blocked" && !isPlaying && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute inset-0 flex items-center justify-center bg-black/40", children: /* @__PURE__ */ jsxRuntime.jsx(
4675
4887
  "button",
4676
4888
  {
4677
4889
  type: "button",
@@ -4700,13 +4912,20 @@ function VideoPlayer({
4700
4912
  ] }),
4701
4913
  typeof stats?.viewers === "number" && /* @__PURE__ */ jsxRuntime.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}` })
4702
4914
  ] }),
4703
- (liveCaptionsBaseUrl || endedLiveReplay) && captionLocale !== "off" && /* @__PURE__ */ jsxRuntime.jsx(LiveCaptionStack, { cues: liveDueCues, latestLabel: t.captionsLatest }),
4915
+ (liveCaptionsBaseUrl || endedLiveReplay) && captionLocale !== "off" && /* @__PURE__ */ jsxRuntime.jsx(
4916
+ LiveCaptionStack,
4917
+ {
4918
+ cues: captionStackCues,
4919
+ latestLabel: t.captionsLatest,
4920
+ variant: appleMobile ? "window" : "scroll"
4921
+ }
4922
+ ),
4704
4923
  !liveCaptionsBaseUrl && !endedLiveReplay && activeCaption && captionLocale !== "off" && /* @__PURE__ */ jsxRuntime.jsx(
4705
4924
  "div",
4706
4925
  {
4707
4926
  className: "pointer-events-none absolute inset-x-0 bottom-16 z-[1] flex justify-center px-4",
4708
4927
  "data-slot": "video-captions",
4709
- children: /* @__PURE__ */ jsxRuntime.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 })
4928
+ children: /* @__PURE__ */ jsxRuntime.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 })
4710
4929
  }
4711
4930
  ),
4712
4931
  active && /* @__PURE__ */ jsxRuntime.jsxs(
@@ -4729,7 +4948,7 @@ function VideoPlayer({
4729
4948
  formatTime
4730
4949
  }
4731
4950
  ),
4732
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
4951
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex min-w-0 items-center gap-1 sm:gap-2", children: [
4733
4952
  /* @__PURE__ */ jsxRuntime.jsx(
4734
4953
  ControlButton,
4735
4954
  {
@@ -4747,7 +4966,7 @@ function VideoPlayer({
4747
4966
  children: /* @__PURE__ */ jsxRuntime.jsx(VolumeIcon, { className: "size-5" })
4748
4967
  }
4749
4968
  ),
4750
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-20 px-1", children: /* @__PURE__ */ jsxRuntime.jsx(
4969
+ !compactChrome && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-20 px-1", children: /* @__PURE__ */ jsxRuntime.jsx(
4751
4970
  Slider,
4752
4971
  {
4753
4972
  "aria-label": "Volume",
@@ -4759,25 +4978,24 @@ function VideoPlayer({
4759
4978
  }
4760
4979
  ) })
4761
4980
  ] }),
4762
- mode === "vod" && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "ml-1 text-xs tabular-nums", children: [
4981
+ mode === "vod" && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "ml-1 shrink-0 text-xs tabular-nums", children: [
4763
4982
  formatTime(currentTime),
4764
- " / ",
4765
- formatTime(duration)
4983
+ !compactChrome && ` / ${formatTime(duration)}`
4766
4984
  ] }),
4767
4985
  mode === "live" && behindLive && /* @__PURE__ */ jsxRuntime.jsxs(
4768
4986
  "button",
4769
4987
  {
4770
4988
  type: "button",
4771
4989
  onClick: goToLiveEdge,
4772
- className: "ml-1 flex items-center gap-1 rounded bg-white/15 px-2 py-0.5 text-xs hover:bg-white/25",
4990
+ 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",
4773
4991
  children: [
4774
4992
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "size-1.5 rounded-full bg-red-500" }),
4775
4993
  t.goLive
4776
4994
  ]
4777
4995
  }
4778
4996
  ),
4779
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "ml-auto flex items-center gap-1", children: [
4780
- mode === "vod" && typeof stats?.views === "number" && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "mr-1 text-xs", children: t.formatViews ? t.formatViews(stats.views) : `${stats.views} views` }),
4997
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "ml-auto flex shrink-0 items-center gap-1", children: [
4998
+ !compactChrome && mode === "vod" && typeof stats?.views === "number" && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "mr-1 text-xs", children: t.formatViews ? t.formatViews(stats.views) : `${stats.views} views` }),
4781
4999
  /* @__PURE__ */ jsxRuntime.jsxs(
4782
5000
  MenuControl,
4783
5001
  {
@@ -4806,7 +5024,7 @@ function VideoPlayer({
4806
5024
  ]
4807
5025
  }
4808
5026
  ),
4809
- mode === "vod" && /* @__PURE__ */ jsxRuntime.jsx(
5027
+ !compactChrome && mode === "vod" && /* @__PURE__ */ jsxRuntime.jsx(
4810
5028
  MenuControl,
4811
5029
  {
4812
5030
  label: t.speed,
@@ -4830,7 +5048,7 @@ function VideoPlayer({
4830
5048
  ))
4831
5049
  }
4832
5050
  ),
4833
- showQualitySelector && qualities.length > 1 && /* @__PURE__ */ jsxRuntime.jsxs(
5051
+ !compactChrome && showQuality && /* @__PURE__ */ jsxRuntime.jsxs(
4834
5052
  MenuControl,
4835
5053
  {
4836
5054
  label: t.quality,
@@ -4862,7 +5080,7 @@ function VideoPlayer({
4862
5080
  ]
4863
5081
  }
4864
5082
  ),
4865
- /* @__PURE__ */ jsxRuntime.jsx(
5083
+ !compactChrome && /* @__PURE__ */ jsxRuntime.jsx(
4866
5084
  ControlButton,
4867
5085
  {
4868
5086
  label: t.cast,
@@ -4872,12 +5090,81 @@ function VideoPlayer({
4872
5090
  children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Cast, { className: "size-5" })
4873
5091
  }
4874
5092
  ),
4875
- pipSupported && /* @__PURE__ */ jsxRuntime.jsx(ControlButton, { label: t.pictureInPicture, onClick: togglePip, children: /* @__PURE__ */ jsxRuntime.jsx(
5093
+ !compactChrome && pipSupported && /* @__PURE__ */ jsxRuntime.jsx(ControlButton, { label: t.pictureInPicture, onClick: togglePip, children: /* @__PURE__ */ jsxRuntime.jsx(
4876
5094
  lucideReact.PictureInPicture2,
4877
5095
  {
4878
5096
  className: cn("size-5", pipActive && "text-primary")
4879
5097
  }
4880
5098
  ) }),
5099
+ compactChrome && /* @__PURE__ */ jsxRuntime.jsxs(
5100
+ MenuControl,
5101
+ {
5102
+ label: t.more,
5103
+ open: openMenu === "more",
5104
+ onOpenChange: (o) => setOpenMenu(o ? "more" : null),
5105
+ trigger: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.EllipsisVertical, { className: "size-5" }),
5106
+ children: [
5107
+ mode === "vod" && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
5108
+ /* @__PURE__ */ jsxRuntime.jsx(MenuSection, { children: t.speed }),
5109
+ PLAYBACK_RATES.map((rate) => /* @__PURE__ */ jsxRuntime.jsxs(
5110
+ MenuItem,
5111
+ {
5112
+ selected: rate === playbackRate,
5113
+ onSelect: () => changeRate(rate),
5114
+ children: [
5115
+ rate,
5116
+ "\xD7"
5117
+ ]
5118
+ },
5119
+ rate
5120
+ ))
5121
+ ] }),
5122
+ showQuality && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
5123
+ /* @__PURE__ */ jsxRuntime.jsx(MenuSection, { children: t.quality }),
5124
+ /* @__PURE__ */ jsxRuntime.jsx(
5125
+ MenuItem,
5126
+ {
5127
+ selected: activeLevel < 0,
5128
+ onSelect: () => chooseLevel(-1),
5129
+ children: t.auto
5130
+ }
5131
+ ),
5132
+ qualities.map((q) => /* @__PURE__ */ jsxRuntime.jsxs(
5133
+ MenuItem,
5134
+ {
5135
+ selected: activeLevel === q.index,
5136
+ onSelect: () => chooseLevel(q.index),
5137
+ children: [
5138
+ q.height,
5139
+ "p"
5140
+ ]
5141
+ },
5142
+ q.index
5143
+ ))
5144
+ ] }),
5145
+ /* @__PURE__ */ jsxRuntime.jsx(
5146
+ MenuAction,
5147
+ {
5148
+ onSelect: () => {
5149
+ setOpenMenu(null);
5150
+ void castHlsUrl(src).catch(() => void 0);
5151
+ },
5152
+ children: t.cast
5153
+ }
5154
+ ),
5155
+ pipSupported && /* @__PURE__ */ jsxRuntime.jsx(
5156
+ MenuAction,
5157
+ {
5158
+ onSelect: () => {
5159
+ setOpenMenu(null);
5160
+ togglePip();
5161
+ },
5162
+ children: t.pictureInPicture
5163
+ }
5164
+ )
5165
+ ]
5166
+ }
5167
+ ),
4881
5168
  fullscreenSupported && /* @__PURE__ */ jsxRuntime.jsx(
4882
5169
  ControlButton,
4883
5170
  {
@@ -4947,6 +5234,9 @@ function MenuControl({
4947
5234
  )
4948
5235
  ] });
4949
5236
  }
5237
+ function MenuSection({ children }) {
5238
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-2 pt-1.5 pb-0.5 text-[10px] font-semibold tracking-wide text-white/50 uppercase", children });
5239
+ }
4950
5240
  function MenuItem({
4951
5241
  selected,
4952
5242
  onSelect,
@@ -4967,6 +5257,21 @@ function MenuItem({
4967
5257
  }
4968
5258
  );
4969
5259
  }
5260
+ function MenuAction({
5261
+ onSelect,
5262
+ children
5263
+ }) {
5264
+ return /* @__PURE__ */ jsxRuntime.jsx(
5265
+ "button",
5266
+ {
5267
+ type: "button",
5268
+ role: "menuitem",
5269
+ onClick: onSelect,
5270
+ className: "flex w-full items-center rounded px-2 py-1.5 text-left text-white/90 hover:bg-white/15",
5271
+ children
5272
+ }
5273
+ );
5274
+ }
4970
5275
 
4971
5276
  // src/components/video/feedPlaybackCoordinator.ts
4972
5277
  var players = /* @__PURE__ */ new Map();