@livo-tv/blocks 1.18.0 → 1.20.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 +304 -94
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +305 -95
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -750,6 +750,8 @@ interface VideoPlayerLabels {
|
|
|
750
750
|
settings?: string;
|
|
751
751
|
/** Overflow menu for speed / quality / cast / PiP on a narrow player. */
|
|
752
752
|
more?: string;
|
|
753
|
+
/** Back control on compact More speed / quality panes. */
|
|
754
|
+
back?: string;
|
|
753
755
|
quality?: string;
|
|
754
756
|
auto?: string;
|
|
755
757
|
speed?: string;
|
|
@@ -806,7 +808,7 @@ interface VideoPlayerProps {
|
|
|
806
808
|
*/
|
|
807
809
|
fit?: "aspect-video" | "contain";
|
|
808
810
|
className?: string;
|
|
809
|
-
/**
|
|
811
|
+
/** Optional initial CC language. Defaults to Off. UI locale / `?lang=` do not enable captions. */
|
|
810
812
|
defaultCaptionLocale?: CaptionLocale;
|
|
811
813
|
/** Live poll base, e.g. `https://api.livo.tv/public/streams/{id}/captions`. */
|
|
812
814
|
liveCaptionsBaseUrl?: string | null;
|
package/dist/index.d.ts
CHANGED
|
@@ -750,6 +750,8 @@ interface VideoPlayerLabels {
|
|
|
750
750
|
settings?: string;
|
|
751
751
|
/** Overflow menu for speed / quality / cast / PiP on a narrow player. */
|
|
752
752
|
more?: string;
|
|
753
|
+
/** Back control on compact More speed / quality panes. */
|
|
754
|
+
back?: string;
|
|
753
755
|
quality?: string;
|
|
754
756
|
auto?: string;
|
|
755
757
|
speed?: string;
|
|
@@ -806,7 +808,7 @@ interface VideoPlayerProps {
|
|
|
806
808
|
*/
|
|
807
809
|
fit?: "aspect-video" | "contain";
|
|
808
810
|
className?: string;
|
|
809
|
-
/**
|
|
811
|
+
/** Optional initial CC language. Defaults to Off. UI locale / `?lang=` do not enable captions. */
|
|
810
812
|
defaultCaptionLocale?: CaptionLocale;
|
|
811
813
|
/** Live poll base, e.g. `https://api.livo.tv/public/streams/{id}/captions`. */
|
|
812
814
|
liveCaptionsBaseUrl?: string | null;
|
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, EllipsisVertical, 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, Gauge, EllipsisVertical, Minimize, Maximize, ChevronRight, ChevronLeft, 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';
|
|
@@ -4219,6 +4219,7 @@ function LiveCaptionStack({
|
|
|
4219
4219
|
|
|
4220
4220
|
// src/components/video/nativeCaptionTrack.ts
|
|
4221
4221
|
var NATIVE_CAPTION_HOLD_S = 4;
|
|
4222
|
+
var NATIVE_SUBTITLE_KIND = "subtitles";
|
|
4222
4223
|
function joinCaptionTexts(cues) {
|
|
4223
4224
|
return cues.map((cue) => cue.text.trim()).filter(Boolean).join(" ");
|
|
4224
4225
|
}
|
|
@@ -4230,12 +4231,46 @@ function clearNativeCaptionCues(track) {
|
|
|
4230
4231
|
if (cue) track.removeCue(cue);
|
|
4231
4232
|
}
|
|
4232
4233
|
}
|
|
4233
|
-
function
|
|
4234
|
-
|
|
4235
|
-
|
|
4236
|
-
|
|
4237
|
-
|
|
4238
|
-
|
|
4234
|
+
function subtitleTracksForLocales(video) {
|
|
4235
|
+
return Array.from(video.textTracks).filter(
|
|
4236
|
+
(track) => track.kind === NATIVE_SUBTITLE_KIND && isCaptionLocale(track.language)
|
|
4237
|
+
);
|
|
4238
|
+
}
|
|
4239
|
+
function findSubtitleTrack(video, locale) {
|
|
4240
|
+
return subtitleTracksForLocales(video).find(
|
|
4241
|
+
(track) => track.language === locale
|
|
4242
|
+
) ?? null;
|
|
4243
|
+
}
|
|
4244
|
+
function showingCaptionLocale(video) {
|
|
4245
|
+
for (const track of subtitleTracksForLocales(video)) {
|
|
4246
|
+
if (track.mode === "showing" && isCaptionLocale(track.language)) {
|
|
4247
|
+
return track.language;
|
|
4248
|
+
}
|
|
4249
|
+
}
|
|
4250
|
+
return "off";
|
|
4251
|
+
}
|
|
4252
|
+
function applyCaptionTrackModes(video, locale, nativeVisible) {
|
|
4253
|
+
for (const track of subtitleTracksForLocales(video)) {
|
|
4254
|
+
if (locale !== "off" && track.language === locale) {
|
|
4255
|
+
track.mode = nativeVisible ? "showing" : "hidden";
|
|
4256
|
+
} else {
|
|
4257
|
+
track.mode = "disabled";
|
|
4258
|
+
}
|
|
4259
|
+
}
|
|
4260
|
+
}
|
|
4261
|
+
function ensureLiveSubtitleTracks(video, labels) {
|
|
4262
|
+
const existing = subtitleTracksForLocales(video);
|
|
4263
|
+
return CAPTION_LOCALES.map((locale) => {
|
|
4264
|
+
const found = existing.find((track2) => track2.language === locale);
|
|
4265
|
+
if (found) return found;
|
|
4266
|
+
const track = video.addTextTrack(
|
|
4267
|
+
NATIVE_SUBTITLE_KIND,
|
|
4268
|
+
labels[locale],
|
|
4269
|
+
locale
|
|
4270
|
+
);
|
|
4271
|
+
track.mode = "disabled";
|
|
4272
|
+
return track;
|
|
4273
|
+
});
|
|
4239
4274
|
}
|
|
4240
4275
|
function syncNativeCaptionCue(video, track, text) {
|
|
4241
4276
|
clearNativeCaptionCues(track);
|
|
@@ -4244,17 +4279,45 @@ function syncNativeCaptionCue(video, track, text) {
|
|
|
4244
4279
|
const start = Number.isFinite(video.currentTime) ? video.currentTime : 0;
|
|
4245
4280
|
track.addCue(new VTTCue(start, start + NATIVE_CAPTION_HOLD_S, trimmed));
|
|
4246
4281
|
}
|
|
4247
|
-
function
|
|
4248
|
-
|
|
4249
|
-
|
|
4250
|
-
|
|
4251
|
-
|
|
4252
|
-
|
|
4282
|
+
function zeroAnchorNativeTrackCues(track) {
|
|
4283
|
+
const list = track.cues;
|
|
4284
|
+
if (!list || list.length === 0) return;
|
|
4285
|
+
let origin = Number.POSITIVE_INFINITY;
|
|
4286
|
+
for (let index = 0; index < list.length; index += 1) {
|
|
4287
|
+
const cue = list[index];
|
|
4288
|
+
if (cue && Number.isFinite(cue.startTime) && cue.startTime < origin) {
|
|
4289
|
+
origin = cue.startTime;
|
|
4290
|
+
}
|
|
4253
4291
|
}
|
|
4292
|
+
if (!Number.isFinite(origin) || origin <= 0) return;
|
|
4293
|
+
const next = [];
|
|
4294
|
+
for (let index = 0; index < list.length; index += 1) {
|
|
4295
|
+
const cue = list[index];
|
|
4296
|
+
if (!(cue instanceof VTTCue)) continue;
|
|
4297
|
+
next.push(
|
|
4298
|
+
new VTTCue(
|
|
4299
|
+
Math.max(0, cue.startTime - origin),
|
|
4300
|
+
Math.max(0, cue.endTime - origin),
|
|
4301
|
+
cue.text
|
|
4302
|
+
)
|
|
4303
|
+
);
|
|
4304
|
+
}
|
|
4305
|
+
clearNativeCaptionCues(track);
|
|
4306
|
+
for (const cue of next) track.addCue(cue);
|
|
4254
4307
|
}
|
|
4255
|
-
function
|
|
4256
|
-
if (
|
|
4257
|
-
|
|
4308
|
+
function listenTextTracksChange(tracks, onChange) {
|
|
4309
|
+
if (typeof tracks.addEventListener === "function") {
|
|
4310
|
+
tracks.addEventListener("change", onChange);
|
|
4311
|
+
return () => {
|
|
4312
|
+
if (typeof tracks.removeEventListener === "function") {
|
|
4313
|
+
tracks.removeEventListener("change", onChange);
|
|
4314
|
+
}
|
|
4315
|
+
};
|
|
4316
|
+
}
|
|
4317
|
+
tracks.onchange = onChange;
|
|
4318
|
+
return () => {
|
|
4319
|
+
if (tracks.onchange === onChange) tracks.onchange = null;
|
|
4320
|
+
};
|
|
4258
4321
|
}
|
|
4259
4322
|
var DEFAULT_LABELS3 = {
|
|
4260
4323
|
play: "Play",
|
|
@@ -4267,6 +4330,7 @@ var DEFAULT_LABELS3 = {
|
|
|
4267
4330
|
cast: "Cast",
|
|
4268
4331
|
settings: "Settings",
|
|
4269
4332
|
more: "More",
|
|
4333
|
+
back: "Back",
|
|
4270
4334
|
quality: "Quality",
|
|
4271
4335
|
auto: "Auto",
|
|
4272
4336
|
speed: "Speed",
|
|
@@ -4347,7 +4411,8 @@ function VideoPlayer({
|
|
|
4347
4411
|
const t = { ...DEFAULT_LABELS3, ...labels };
|
|
4348
4412
|
const containerRef = React9.useRef(null);
|
|
4349
4413
|
const firstPlayFiredRef = React9.useRef(false);
|
|
4350
|
-
const
|
|
4414
|
+
const applyingTrackModesRef = React9.useRef(false);
|
|
4415
|
+
const captionLocaleRef = React9.useRef("off");
|
|
4351
4416
|
const cssFullscreenRef = React9.useRef(false);
|
|
4352
4417
|
const webkitFsRef = React9.useRef(false);
|
|
4353
4418
|
const [userStarted, setUserStarted] = React9.useState(false);
|
|
@@ -4395,6 +4460,9 @@ function VideoPlayer({
|
|
|
4395
4460
|
const [controlsVisible, setControlsVisible] = React9.useState(true);
|
|
4396
4461
|
const [playbackRate, setPlaybackRate] = React9.useState(1);
|
|
4397
4462
|
const [openMenu, setOpenMenu] = React9.useState(null);
|
|
4463
|
+
const [morePane, setMorePane] = React9.useState(
|
|
4464
|
+
"root"
|
|
4465
|
+
);
|
|
4398
4466
|
const [compactChrome, setCompactChrome] = React9.useState(false);
|
|
4399
4467
|
const [captionLocale, setCaptionLocale] = React9.useState(defaultCaptionLocale ?? "off");
|
|
4400
4468
|
const [captionCues, setCaptionCues] = React9.useState([]);
|
|
@@ -4405,8 +4473,10 @@ function VideoPlayer({
|
|
|
4405
4473
|
const [embedded, setEmbedded] = React9.useState(false);
|
|
4406
4474
|
const [cssFullscreen, setCssFullscreen] = React9.useState(false);
|
|
4407
4475
|
const [appleMobile, setAppleMobile] = React9.useState(false);
|
|
4476
|
+
const [webkitNativeFs, setWebkitNativeFs] = React9.useState(false);
|
|
4408
4477
|
const hideTimerRef = React9.useRef(null);
|
|
4409
4478
|
cssFullscreenRef.current = cssFullscreen;
|
|
4479
|
+
captionLocaleRef.current = captionLocale;
|
|
4410
4480
|
React9.useEffect(() => {
|
|
4411
4481
|
const el = containerRef.current;
|
|
4412
4482
|
if (!el || typeof ResizeObserver === "undefined") return;
|
|
@@ -4422,6 +4492,9 @@ function VideoPlayer({
|
|
|
4422
4492
|
observer.observe(el);
|
|
4423
4493
|
return () => observer.disconnect();
|
|
4424
4494
|
}, [active]);
|
|
4495
|
+
React9.useEffect(() => {
|
|
4496
|
+
if (openMenu !== "more") setMorePane("root");
|
|
4497
|
+
}, [openMenu]);
|
|
4425
4498
|
const pipSupported = typeof document !== "undefined" && "pictureInPictureEnabled" in document && document.pictureInPictureEnabled;
|
|
4426
4499
|
const fullscreenSupported = hasStandardFullscreen() || webkitFullscreenSupported || !embedded;
|
|
4427
4500
|
React9.useEffect(() => {
|
|
@@ -4494,17 +4567,42 @@ function VideoPlayer({
|
|
|
4494
4567
|
document.addEventListener("fullscreenchange", onFsChange);
|
|
4495
4568
|
return () => document.removeEventListener("fullscreenchange", onFsChange);
|
|
4496
4569
|
}, []);
|
|
4570
|
+
function applyNativeTrackModes(video, locale, nativeVisible) {
|
|
4571
|
+
applyingTrackModesRef.current = true;
|
|
4572
|
+
try {
|
|
4573
|
+
applyCaptionTrackModes(video, locale, nativeVisible);
|
|
4574
|
+
} finally {
|
|
4575
|
+
applyingTrackModesRef.current = false;
|
|
4576
|
+
}
|
|
4577
|
+
}
|
|
4578
|
+
function onSidecarTrackLoad(event) {
|
|
4579
|
+
const track = event.currentTarget.track;
|
|
4580
|
+
if (!track) return;
|
|
4581
|
+
if (isLivePlaylistSrc(src)) {
|
|
4582
|
+
zeroAnchorNativeTrackCues(track);
|
|
4583
|
+
}
|
|
4584
|
+
const video = videoRef.current;
|
|
4585
|
+
if (video) {
|
|
4586
|
+
applyNativeTrackModes(
|
|
4587
|
+
video,
|
|
4588
|
+
captionLocaleRef.current,
|
|
4589
|
+
webkitFsRef.current
|
|
4590
|
+
);
|
|
4591
|
+
}
|
|
4592
|
+
}
|
|
4497
4593
|
React9.useEffect(() => {
|
|
4498
4594
|
const video = asWebkitVideo(videoRef.current);
|
|
4499
4595
|
if (!video) return;
|
|
4500
4596
|
const onBegin = () => {
|
|
4501
4597
|
webkitFsRef.current = true;
|
|
4598
|
+
setWebkitNativeFs(true);
|
|
4502
4599
|
setIsFullscreen(true);
|
|
4503
|
-
|
|
4600
|
+
applyNativeTrackModes(video, captionLocaleRef.current, true);
|
|
4504
4601
|
};
|
|
4505
4602
|
const onEnd = () => {
|
|
4506
4603
|
webkitFsRef.current = false;
|
|
4507
|
-
|
|
4604
|
+
setWebkitNativeFs(false);
|
|
4605
|
+
applyNativeTrackModes(video, captionLocaleRef.current, false);
|
|
4508
4606
|
if (!cssFullscreenRef.current) setIsFullscreen(false);
|
|
4509
4607
|
};
|
|
4510
4608
|
video.addEventListener("webkitbeginfullscreen", onBegin);
|
|
@@ -4601,41 +4699,56 @@ function VideoPlayer({
|
|
|
4601
4699
|
const activeCaption = liveCaptionsBaseUrl || endedLiveReplay ? null : captionAtTime(captionCues, currentTime);
|
|
4602
4700
|
React9.useEffect(() => {
|
|
4603
4701
|
const video = videoRef.current;
|
|
4604
|
-
if (!video ||
|
|
4605
|
-
if (nativeTrackRef.current) {
|
|
4606
|
-
nativeTrackRef.current.mode = "disabled";
|
|
4607
|
-
nativeTrackRef.current = null;
|
|
4608
|
-
}
|
|
4609
|
-
return;
|
|
4610
|
-
}
|
|
4702
|
+
if (!video || !liveCaptionsBaseUrl) return;
|
|
4611
4703
|
try {
|
|
4612
|
-
|
|
4613
|
-
|
|
4614
|
-
|
|
4615
|
-
|
|
4616
|
-
);
|
|
4617
|
-
setNativeCaptionTrackVisible(nativeTrackRef.current, webkitFsRef.current);
|
|
4704
|
+
ensureLiveSubtitleTracks(video, {
|
|
4705
|
+
en: t.captionsEn,
|
|
4706
|
+
es: t.captionsEs,
|
|
4707
|
+
pt: t.captionsPt
|
|
4708
|
+
});
|
|
4618
4709
|
} catch {
|
|
4619
|
-
|
|
4710
|
+
return;
|
|
4620
4711
|
}
|
|
4621
|
-
|
|
4712
|
+
applyNativeTrackModes(video, captionLocale, webkitFsRef.current);
|
|
4713
|
+
}, [
|
|
4714
|
+
videoRef,
|
|
4715
|
+
active,
|
|
4716
|
+
liveCaptionsBaseUrl,
|
|
4717
|
+
captionLocale,
|
|
4718
|
+
t.captionsEn,
|
|
4719
|
+
t.captionsEs,
|
|
4720
|
+
t.captionsPt
|
|
4721
|
+
]);
|
|
4622
4722
|
React9.useEffect(() => {
|
|
4623
|
-
const
|
|
4624
|
-
if (!
|
|
4625
|
-
|
|
4626
|
-
|
|
4627
|
-
|
|
4723
|
+
const video = videoRef.current;
|
|
4724
|
+
if (!video) return;
|
|
4725
|
+
applyNativeTrackModes(video, captionLocale, webkitFsRef.current);
|
|
4726
|
+
}, [videoRef, active, captionLocale, src]);
|
|
4727
|
+
React9.useEffect(() => {
|
|
4728
|
+
const video = videoRef.current;
|
|
4729
|
+
if (!video) return;
|
|
4730
|
+
const onChange = () => {
|
|
4731
|
+
if (applyingTrackModesRef.current) return;
|
|
4732
|
+
const showing = showingCaptionLocale(video);
|
|
4733
|
+
if (!webkitFsRef.current) {
|
|
4734
|
+
if (showing !== "off") setCaptionLocale(showing);
|
|
4735
|
+
return;
|
|
4736
|
+
}
|
|
4737
|
+
setCaptionLocale(showing);
|
|
4738
|
+
};
|
|
4739
|
+
return listenTextTracksChange(video.textTracks, onChange);
|
|
4740
|
+
}, [videoRef, active, src, liveCaptionsBaseUrl]);
|
|
4628
4741
|
React9.useEffect(() => {
|
|
4629
4742
|
const video = videoRef.current;
|
|
4630
|
-
|
|
4631
|
-
|
|
4632
|
-
if (!
|
|
4743
|
+
if (!video || captionLocale === "off" || !liveCaptionsBaseUrl) return;
|
|
4744
|
+
const track = findSubtitleTrack(video, captionLocale);
|
|
4745
|
+
if (!track) return;
|
|
4633
4746
|
syncNativeCaptionCue(
|
|
4634
4747
|
video,
|
|
4635
4748
|
track,
|
|
4636
4749
|
lastCaptionLines(joinCaptionTexts(captionStackCues))
|
|
4637
4750
|
);
|
|
4638
|
-
}, [captionStackCues,
|
|
4751
|
+
}, [captionStackCues, captionLocale, liveCaptionsBaseUrl]);
|
|
4639
4752
|
function togglePlay() {
|
|
4640
4753
|
const video = videoRef.current;
|
|
4641
4754
|
if (!video) return;
|
|
@@ -4820,7 +4933,22 @@ function VideoPlayer({
|
|
|
4820
4933
|
muted: isMuted,
|
|
4821
4934
|
className: "livo-video-player-media h-full w-full bg-black object-contain",
|
|
4822
4935
|
onClick: active ? togglePlay : void 0,
|
|
4823
|
-
poster
|
|
4936
|
+
poster,
|
|
4937
|
+
children: !liveCaptionsBaseUrl ? CAPTION_LOCALES.map((locale) => {
|
|
4938
|
+
const url = captionsVttUrlFromPlayback(src, locale);
|
|
4939
|
+
if (!url) return null;
|
|
4940
|
+
return /* @__PURE__ */ jsx(
|
|
4941
|
+
"track",
|
|
4942
|
+
{
|
|
4943
|
+
kind: "subtitles",
|
|
4944
|
+
srcLang: locale,
|
|
4945
|
+
label: captionLocaleLabel(locale, t),
|
|
4946
|
+
src: url,
|
|
4947
|
+
onLoad: onSidecarTrackLoad
|
|
4948
|
+
},
|
|
4949
|
+
`${locale}:${url}`
|
|
4950
|
+
);
|
|
4951
|
+
}) : null
|
|
4824
4952
|
}
|
|
4825
4953
|
),
|
|
4826
4954
|
showPoster && /* @__PURE__ */ jsx(
|
|
@@ -4886,7 +5014,7 @@ function VideoPlayer({
|
|
|
4886
5014
|
] }),
|
|
4887
5015
|
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}` })
|
|
4888
5016
|
] }),
|
|
4889
|
-
(liveCaptionsBaseUrl || endedLiveReplay) && captionLocale !== "off" && /* @__PURE__ */ jsx(
|
|
5017
|
+
(liveCaptionsBaseUrl || endedLiveReplay) && captionLocale !== "off" && !webkitNativeFs && /* @__PURE__ */ jsx(
|
|
4890
5018
|
LiveCaptionStack,
|
|
4891
5019
|
{
|
|
4892
5020
|
cues: captionStackCues,
|
|
@@ -4894,7 +5022,7 @@ function VideoPlayer({
|
|
|
4894
5022
|
variant: appleMobile ? "window" : "scroll"
|
|
4895
5023
|
}
|
|
4896
5024
|
),
|
|
4897
|
-
!liveCaptionsBaseUrl && !endedLiveReplay && activeCaption && captionLocale !== "off" && /* @__PURE__ */ jsx(
|
|
5025
|
+
!liveCaptionsBaseUrl && !endedLiveReplay && activeCaption && captionLocale !== "off" && !webkitNativeFs && /* @__PURE__ */ jsx(
|
|
4898
5026
|
"div",
|
|
4899
5027
|
{
|
|
4900
5028
|
className: "pointer-events-none absolute inset-x-0 bottom-16 z-[1] flex justify-center px-4",
|
|
@@ -5070,55 +5198,87 @@ function VideoPlayer({
|
|
|
5070
5198
|
className: cn("size-5", pipActive && "text-primary")
|
|
5071
5199
|
}
|
|
5072
5200
|
) }),
|
|
5073
|
-
compactChrome && /* @__PURE__ */
|
|
5201
|
+
compactChrome && /* @__PURE__ */ jsx(
|
|
5074
5202
|
MenuControl,
|
|
5075
5203
|
{
|
|
5076
5204
|
label: t.more,
|
|
5077
5205
|
open: openMenu === "more",
|
|
5078
5206
|
onOpenChange: (o) => setOpenMenu(o ? "more" : null),
|
|
5079
5207
|
trigger: /* @__PURE__ */ jsx(EllipsisVertical, { className: "size-5" }),
|
|
5080
|
-
children: [
|
|
5081
|
-
|
|
5082
|
-
|
|
5083
|
-
|
|
5084
|
-
|
|
5085
|
-
|
|
5086
|
-
|
|
5087
|
-
|
|
5088
|
-
|
|
5089
|
-
|
|
5090
|
-
|
|
5091
|
-
|
|
5092
|
-
|
|
5093
|
-
rate
|
|
5094
|
-
|
|
5095
|
-
|
|
5096
|
-
|
|
5097
|
-
|
|
5098
|
-
|
|
5099
|
-
|
|
5100
|
-
|
|
5101
|
-
|
|
5102
|
-
|
|
5103
|
-
|
|
5104
|
-
|
|
5105
|
-
|
|
5106
|
-
|
|
5107
|
-
|
|
5108
|
-
|
|
5109
|
-
|
|
5110
|
-
|
|
5111
|
-
|
|
5112
|
-
|
|
5113
|
-
|
|
5114
|
-
|
|
5115
|
-
|
|
5116
|
-
|
|
5117
|
-
|
|
5118
|
-
|
|
5208
|
+
children: morePane === "speed" ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5209
|
+
/* @__PURE__ */ jsx(
|
|
5210
|
+
MenuBack,
|
|
5211
|
+
{
|
|
5212
|
+
label: t.back,
|
|
5213
|
+
title: t.speed,
|
|
5214
|
+
onSelect: () => setMorePane("root")
|
|
5215
|
+
}
|
|
5216
|
+
),
|
|
5217
|
+
PLAYBACK_RATES.map((rate) => /* @__PURE__ */ jsxs(
|
|
5218
|
+
MenuItem,
|
|
5219
|
+
{
|
|
5220
|
+
selected: rate === playbackRate,
|
|
5221
|
+
onSelect: () => changeRate(rate),
|
|
5222
|
+
children: [
|
|
5223
|
+
rate,
|
|
5224
|
+
"\xD7"
|
|
5225
|
+
]
|
|
5226
|
+
},
|
|
5227
|
+
rate
|
|
5228
|
+
))
|
|
5229
|
+
] }) : morePane === "quality" ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5230
|
+
/* @__PURE__ */ jsx(
|
|
5231
|
+
MenuBack,
|
|
5232
|
+
{
|
|
5233
|
+
label: t.back,
|
|
5234
|
+
title: t.quality,
|
|
5235
|
+
onSelect: () => setMorePane("root")
|
|
5236
|
+
}
|
|
5237
|
+
),
|
|
5238
|
+
/* @__PURE__ */ jsx(
|
|
5239
|
+
MenuItem,
|
|
5240
|
+
{
|
|
5241
|
+
selected: activeLevel < 0,
|
|
5242
|
+
onSelect: () => chooseLevel(-1),
|
|
5243
|
+
children: t.auto
|
|
5244
|
+
}
|
|
5245
|
+
),
|
|
5246
|
+
qualities.map((q) => /* @__PURE__ */ jsxs(
|
|
5247
|
+
MenuItem,
|
|
5248
|
+
{
|
|
5249
|
+
selected: activeLevel === q.index,
|
|
5250
|
+
onSelect: () => chooseLevel(q.index),
|
|
5251
|
+
children: [
|
|
5252
|
+
q.height,
|
|
5253
|
+
"p"
|
|
5254
|
+
]
|
|
5255
|
+
},
|
|
5256
|
+
q.index
|
|
5257
|
+
))
|
|
5258
|
+
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5259
|
+
mode === "vod" && /* @__PURE__ */ jsx(
|
|
5260
|
+
MenuNavRow,
|
|
5261
|
+
{
|
|
5262
|
+
icon: /* @__PURE__ */ jsx(Gauge, { className: "size-4" }),
|
|
5263
|
+
label: t.speed,
|
|
5264
|
+
value: `${playbackRate}\xD7`,
|
|
5265
|
+
onSelect: () => setMorePane("speed")
|
|
5266
|
+
}
|
|
5267
|
+
),
|
|
5268
|
+
showQuality && /* @__PURE__ */ jsx(
|
|
5269
|
+
MenuNavRow,
|
|
5270
|
+
{
|
|
5271
|
+
icon: /* @__PURE__ */ jsx(Settings, { className: "size-4" }),
|
|
5272
|
+
label: t.quality,
|
|
5273
|
+
value: currentLevelLabel,
|
|
5274
|
+
onSelect: () => setMorePane("quality")
|
|
5275
|
+
}
|
|
5276
|
+
),
|
|
5277
|
+
(mode === "vod" || showQuality) && /* @__PURE__ */ jsx("div", { className: "my-1 h-px bg-white/15" }),
|
|
5119
5278
|
/* @__PURE__ */ jsx(
|
|
5120
5279
|
MenuAction,
|
|
5121
5280
|
{
|
|
5281
|
+
icon: /* @__PURE__ */ jsx(Cast, { className: "size-4" }),
|
|
5122
5282
|
onSelect: () => {
|
|
5123
5283
|
setOpenMenu(null);
|
|
5124
5284
|
void castHlsUrl(src).catch(() => void 0);
|
|
@@ -5129,6 +5289,8 @@ function VideoPlayer({
|
|
|
5129
5289
|
pipSupported && /* @__PURE__ */ jsx(
|
|
5130
5290
|
MenuAction,
|
|
5131
5291
|
{
|
|
5292
|
+
icon: /* @__PURE__ */ jsx(PictureInPicture2, { className: "size-4" }),
|
|
5293
|
+
active: pipActive,
|
|
5132
5294
|
onSelect: () => {
|
|
5133
5295
|
setOpenMenu(null);
|
|
5134
5296
|
togglePip();
|
|
@@ -5136,7 +5298,7 @@ function VideoPlayer({
|
|
|
5136
5298
|
children: t.pictureInPicture
|
|
5137
5299
|
}
|
|
5138
5300
|
)
|
|
5139
|
-
]
|
|
5301
|
+
] })
|
|
5140
5302
|
}
|
|
5141
5303
|
),
|
|
5142
5304
|
fullscreenSupported && /* @__PURE__ */ jsx(
|
|
@@ -5202,15 +5364,12 @@ function MenuControl({
|
|
|
5202
5364
|
"div",
|
|
5203
5365
|
{
|
|
5204
5366
|
role: "menu",
|
|
5205
|
-
className: "absolute right-0 bottom-full z-10 mb-2 min-w-
|
|
5367
|
+
className: "absolute right-0 bottom-full z-10 mb-2 min-w-52 rounded-md bg-black/90 p-1 text-sm shadow-lg backdrop-blur-sm",
|
|
5206
5368
|
children
|
|
5207
5369
|
}
|
|
5208
5370
|
)
|
|
5209
5371
|
] });
|
|
5210
5372
|
}
|
|
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
|
-
}
|
|
5214
5373
|
function MenuItem({
|
|
5215
5374
|
selected,
|
|
5216
5375
|
onSelect,
|
|
@@ -5223,7 +5382,7 @@ function MenuItem({
|
|
|
5223
5382
|
role: "menuitemradio",
|
|
5224
5383
|
"aria-checked": selected,
|
|
5225
5384
|
onClick: onSelect,
|
|
5226
|
-
className: "flex w-full items-center justify-between gap-3 rounded px-2 py-
|
|
5385
|
+
className: "flex w-full items-center justify-between gap-3 rounded px-2 py-2.5 text-left text-white/90 hover:bg-white/15",
|
|
5227
5386
|
children: [
|
|
5228
5387
|
children,
|
|
5229
5388
|
selected && /* @__PURE__ */ jsx(Check, { className: "size-4" })
|
|
@@ -5231,18 +5390,69 @@ function MenuItem({
|
|
|
5231
5390
|
}
|
|
5232
5391
|
);
|
|
5233
5392
|
}
|
|
5393
|
+
function MenuNavRow({
|
|
5394
|
+
icon,
|
|
5395
|
+
label,
|
|
5396
|
+
value,
|
|
5397
|
+
onSelect
|
|
5398
|
+
}) {
|
|
5399
|
+
return /* @__PURE__ */ jsxs(
|
|
5400
|
+
"button",
|
|
5401
|
+
{
|
|
5402
|
+
type: "button",
|
|
5403
|
+
role: "menuitem",
|
|
5404
|
+
"aria-label": `${label}, ${value}`,
|
|
5405
|
+
onClick: onSelect,
|
|
5406
|
+
className: "flex w-full items-center gap-2.5 rounded px-2 py-2.5 text-left text-white/90 hover:bg-white/15",
|
|
5407
|
+
children: [
|
|
5408
|
+
/* @__PURE__ */ jsx("span", { className: "text-white/70", children: icon }),
|
|
5409
|
+
/* @__PURE__ */ jsx("span", { className: "flex-1", children: label }),
|
|
5410
|
+
/* @__PURE__ */ jsx("span", { className: "text-white/50", children: value }),
|
|
5411
|
+
/* @__PURE__ */ jsx(ChevronRight, { className: "size-4 text-white/50" })
|
|
5412
|
+
]
|
|
5413
|
+
}
|
|
5414
|
+
);
|
|
5415
|
+
}
|
|
5416
|
+
function MenuBack({
|
|
5417
|
+
label,
|
|
5418
|
+
title,
|
|
5419
|
+
onSelect
|
|
5420
|
+
}) {
|
|
5421
|
+
return /* @__PURE__ */ jsxs(
|
|
5422
|
+
"button",
|
|
5423
|
+
{
|
|
5424
|
+
type: "button",
|
|
5425
|
+
role: "menuitem",
|
|
5426
|
+
"aria-label": label,
|
|
5427
|
+
onClick: onSelect,
|
|
5428
|
+
className: "flex w-full items-center gap-2 rounded px-2 py-2.5 text-left text-white/90 hover:bg-white/15",
|
|
5429
|
+
children: [
|
|
5430
|
+
/* @__PURE__ */ jsx(ChevronLeft, { className: "size-4" }),
|
|
5431
|
+
/* @__PURE__ */ jsx("span", { className: "font-medium", children: title })
|
|
5432
|
+
]
|
|
5433
|
+
}
|
|
5434
|
+
);
|
|
5435
|
+
}
|
|
5234
5436
|
function MenuAction({
|
|
5235
5437
|
onSelect,
|
|
5438
|
+
icon,
|
|
5439
|
+
active,
|
|
5236
5440
|
children
|
|
5237
5441
|
}) {
|
|
5238
|
-
return /* @__PURE__ */
|
|
5442
|
+
return /* @__PURE__ */ jsxs(
|
|
5239
5443
|
"button",
|
|
5240
5444
|
{
|
|
5241
5445
|
type: "button",
|
|
5242
5446
|
role: "menuitem",
|
|
5243
5447
|
onClick: onSelect,
|
|
5244
|
-
className:
|
|
5245
|
-
|
|
5448
|
+
className: cn(
|
|
5449
|
+
"flex w-full items-center gap-2.5 rounded px-2 py-2.5 text-left text-white/90 hover:bg-white/15",
|
|
5450
|
+
active && "text-primary"
|
|
5451
|
+
),
|
|
5452
|
+
children: [
|
|
5453
|
+
icon ? /* @__PURE__ */ jsx("span", { className: cn("text-white/70", active && "text-primary"), children: icon }) : null,
|
|
5454
|
+
children
|
|
5455
|
+
]
|
|
5246
5456
|
}
|
|
5247
5457
|
);
|
|
5248
5458
|
}
|