@djangocfg/ui-tools 2.1.110 → 2.1.111
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/README.md +242 -49
- package/dist/JsonSchemaForm-65NLLK56.mjs +4 -0
- package/dist/JsonSchemaForm-65NLLK56.mjs.map +1 -0
- package/dist/JsonSchemaForm-PY6DH3HE.cjs +13 -0
- package/dist/JsonSchemaForm-PY6DH3HE.cjs.map +1 -0
- package/dist/JsonTree-6RYAOPSS.mjs +4 -0
- package/dist/JsonTree-6RYAOPSS.mjs.map +1 -0
- package/dist/JsonTree-7OH6CIHT.cjs +10 -0
- package/dist/JsonTree-7OH6CIHT.cjs.map +1 -0
- package/dist/MapContainer-GXQLP5WY.mjs +214 -0
- package/dist/MapContainer-GXQLP5WY.mjs.map +1 -0
- package/dist/MapContainer-RYG4HPH4.cjs +221 -0
- package/dist/MapContainer-RYG4HPH4.cjs.map +1 -0
- package/dist/{Mermaid.client-4OCKJ6QD.mjs → Mermaid.client-OKACITCW.mjs} +16 -7
- package/dist/Mermaid.client-OKACITCW.mjs.map +1 -0
- package/dist/{Mermaid.client-ZP6OE46Z.cjs → Mermaid.client-PNXEC6YL.cjs} +16 -7
- package/dist/Mermaid.client-PNXEC6YL.cjs.map +1 -0
- package/dist/{PlaygroundLayout-XXVBU4WZ.cjs → PlaygroundLayout-SYMEAG3J.cjs} +25 -24
- package/dist/PlaygroundLayout-SYMEAG3J.cjs.map +1 -0
- package/dist/{PlaygroundLayout-LMQTVXSP.mjs → PlaygroundLayout-UQRBU5RH.mjs} +4 -3
- package/dist/PlaygroundLayout-UQRBU5RH.mjs.map +1 -0
- package/dist/{PrettyCode.client-2CLSV2VD.cjs → PrettyCode.client-DANYYQYO.cjs} +11 -4
- package/dist/PrettyCode.client-DANYYQYO.cjs.map +1 -0
- package/dist/{PrettyCode.client-Y2BVON7R.mjs → PrettyCode.client-RS5ZTNBT.mjs} +11 -4
- package/dist/PrettyCode.client-RS5ZTNBT.mjs.map +1 -0
- package/dist/chunk-2DSR7V2L.mjs +561 -0
- package/dist/chunk-2DSR7V2L.mjs.map +1 -0
- package/dist/chunk-47T5ECYV.cjs +1357 -0
- package/dist/chunk-47T5ECYV.cjs.map +1 -0
- package/dist/chunk-5QT3QYFZ.cjs +189 -0
- package/dist/chunk-5QT3QYFZ.cjs.map +1 -0
- package/dist/chunk-7IIRYG4S.mjs +1057 -0
- package/dist/chunk-7IIRYG4S.mjs.map +1 -0
- package/dist/{chunk-FB5QBSI3.cjs → chunk-DI3HUXHK.cjs} +15 -195
- package/dist/chunk-DI3HUXHK.cjs.map +1 -0
- package/dist/chunk-EVGWYASL.cjs +1528 -0
- package/dist/chunk-EVGWYASL.cjs.map +1 -0
- package/dist/chunk-F2N7P5XU.cjs +30 -0
- package/dist/chunk-F2N7P5XU.cjs.map +1 -0
- package/dist/{chunk-L6UHASYQ.mjs → chunk-G6PRZP5I.mjs} +7 -186
- package/dist/chunk-G6PRZP5I.mjs.map +1 -0
- package/dist/chunk-JWB2EWQO.mjs +5 -0
- package/dist/chunk-JWB2EWQO.mjs.map +1 -0
- package/dist/chunk-LTJX2JXE.mjs +338 -0
- package/dist/chunk-LTJX2JXE.mjs.map +1 -0
- package/dist/chunk-OVNC4KW6.mjs +1494 -0
- package/dist/chunk-OVNC4KW6.mjs.map +1 -0
- package/dist/chunk-PNZSJN6T.cjs +1086 -0
- package/dist/chunk-PNZSJN6T.cjs.map +1 -0
- package/dist/chunk-TEFRA7GW.cjs +565 -0
- package/dist/chunk-TEFRA7GW.cjs.map +1 -0
- package/dist/chunk-UOMPPIED.mjs +1343 -0
- package/dist/chunk-UOMPPIED.mjs.map +1 -0
- package/dist/chunk-W6YHQI4F.mjs +187 -0
- package/dist/chunk-W6YHQI4F.mjs.map +1 -0
- package/dist/chunk-XTBRWVIV.cjs +346 -0
- package/dist/chunk-XTBRWVIV.cjs.map +1 -0
- package/dist/components-C7ZL7OMY.mjs +5 -0
- package/dist/components-C7ZL7OMY.mjs.map +1 -0
- package/dist/components-CJ2IB65O.cjs +27 -0
- package/dist/components-CJ2IB65O.cjs.map +1 -0
- package/dist/components-EASJYK45.mjs +6 -0
- package/dist/components-EASJYK45.mjs.map +1 -0
- package/dist/components-LDRFDV4A.cjs +22 -0
- package/dist/components-LDRFDV4A.cjs.map +1 -0
- package/dist/components-VZKUTDJK.mjs +5 -0
- package/dist/components-VZKUTDJK.mjs.map +1 -0
- package/dist/components-Y64GTIMQ.cjs +42 -0
- package/dist/components-Y64GTIMQ.cjs.map +1 -0
- package/dist/index.cjs +701 -4813
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1274 -1026
- package/dist/index.d.ts +1274 -1026
- package/dist/index.mjs +358 -4730
- package/dist/index.mjs.map +1 -1
- package/package.json +27 -4
- package/src/components/index.ts +17 -0
- package/src/components/lazy-wrapper.tsx +281 -0
- package/src/index.ts +92 -7
- package/src/tools/AudioPlayer/components/HybridAudioPlayer.tsx +14 -5
- package/src/tools/AudioPlayer/lazy.tsx +85 -0
- package/src/tools/Gallery/components/Gallery.tsx +182 -0
- package/src/tools/Gallery/components/GalleryCarousel.tsx +251 -0
- package/src/tools/Gallery/components/GalleryCompact.tsx +173 -0
- package/src/tools/Gallery/components/GalleryGrid.tsx +493 -0
- package/src/tools/Gallery/components/GalleryImage.tsx +66 -0
- package/src/tools/Gallery/components/GalleryLightbox.tsx +331 -0
- package/src/tools/Gallery/components/GalleryMedia.tsx +66 -0
- package/src/tools/Gallery/components/GalleryThumbnails.tsx +173 -0
- package/src/tools/Gallery/components/GalleryThumbnailsVirtual.tsx +138 -0
- package/src/tools/Gallery/components/GalleryVideo.tsx +222 -0
- package/src/tools/Gallery/components/index.ts +13 -0
- package/src/tools/Gallery/hooks/index.ts +23 -0
- package/src/tools/Gallery/hooks/useGallery.ts +137 -0
- package/src/tools/Gallery/hooks/useImageDimensions.ts +223 -0
- package/src/tools/Gallery/hooks/usePinchZoom.ts +234 -0
- package/src/tools/Gallery/hooks/usePreloadImages.ts +71 -0
- package/src/tools/Gallery/hooks/useSwipe.ts +86 -0
- package/src/tools/Gallery/hooks/useVirtualList.ts +129 -0
- package/src/tools/Gallery/hooks/useZoom.ts +316 -0
- package/src/tools/Gallery/index.ts +66 -0
- package/src/tools/Gallery/types.ts +183 -0
- package/src/tools/Gallery/utils/imageAnalysis.ts +52 -0
- package/src/tools/Gallery/utils/index.ts +11 -0
- package/src/tools/ImageViewer/components/ImageToolbar.tsx +20 -8
- package/src/tools/ImageViewer/components/ImageViewer.tsx +12 -4
- package/src/tools/ImageViewer/lazy.tsx +37 -0
- package/src/tools/JsonForm/lazy.tsx +43 -0
- package/src/tools/JsonForm/widgets/ColorWidget.tsx +4 -1
- package/src/tools/JsonTree/lazy.tsx +45 -0
- package/src/tools/LottiePlayer/lazy.tsx +57 -0
- package/src/tools/Map/components/CustomOverlay.tsx +54 -0
- package/src/tools/Map/components/DrawControl.tsx +36 -0
- package/src/tools/Map/components/GeocoderControl.tsx +70 -0
- package/src/tools/Map/components/LayerSwitcher.tsx +225 -0
- package/src/tools/Map/components/MapCluster.tsx +273 -0
- package/src/tools/Map/components/MapContainer.tsx +191 -0
- package/src/tools/Map/components/MapControls.tsx +44 -0
- package/src/tools/Map/components/MapLegend.tsx +161 -0
- package/src/tools/Map/components/MapMarker.tsx +102 -0
- package/src/tools/Map/components/MapPopup.tsx +46 -0
- package/src/tools/Map/components/MapSource.tsx +30 -0
- package/src/tools/Map/components/index.ts +20 -0
- package/src/tools/Map/context/MapContext.tsx +89 -0
- package/src/tools/Map/context/index.ts +2 -0
- package/src/tools/Map/hooks/index.ts +9 -0
- package/src/tools/Map/hooks/useMap.ts +11 -0
- package/src/tools/Map/hooks/useMapControl.ts +99 -0
- package/src/tools/Map/hooks/useMapEvents.ts +147 -0
- package/src/tools/Map/hooks/useMapLayers.ts +83 -0
- package/src/tools/Map/hooks/useMapViewport.ts +62 -0
- package/src/tools/Map/hooks/useMarkers.ts +85 -0
- package/src/tools/Map/index.ts +116 -0
- package/src/tools/Map/layers/cluster.ts +94 -0
- package/src/tools/Map/layers/index.ts +15 -0
- package/src/tools/Map/layers/line.ts +93 -0
- package/src/tools/Map/layers/point.ts +61 -0
- package/src/tools/Map/layers/polygon.ts +73 -0
- package/src/tools/Map/lazy.tsx +56 -0
- package/src/tools/Map/styles/index.ts +15 -0
- package/src/tools/Map/types.ts +259 -0
- package/src/tools/Map/utils/geo.ts +88 -0
- package/src/tools/Map/utils/index.ts +16 -0
- package/src/tools/Map/utils/transform.ts +107 -0
- package/src/tools/Mermaid/Mermaid.client.tsx +12 -4
- package/src/tools/Mermaid/components/MermaidFullscreenModal.tsx +6 -2
- package/src/tools/Mermaid/lazy.tsx +46 -0
- package/src/tools/OpenapiViewer/lazy.tsx +72 -0
- package/src/tools/PrettyCode/PrettyCode.client.tsx +10 -3
- package/src/tools/PrettyCode/lazy.tsx +64 -0
- package/src/tools/VideoPlayer/lazy.tsx +63 -0
- package/dist/Mermaid.client-4OCKJ6QD.mjs.map +0 -1
- package/dist/Mermaid.client-ZP6OE46Z.cjs.map +0 -1
- package/dist/PlaygroundLayout-LMQTVXSP.mjs.map +0 -1
- package/dist/PlaygroundLayout-XXVBU4WZ.cjs.map +0 -1
- package/dist/PrettyCode.client-2CLSV2VD.cjs.map +0 -1
- package/dist/PrettyCode.client-Y2BVON7R.mjs.map +0 -1
- package/dist/chunk-FB5QBSI3.cjs.map +0 -1
- package/dist/chunk-L6UHASYQ.mjs.map +0 -1
|
@@ -0,0 +1,1357 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkF2N7P5XU_cjs = require('./chunk-F2N7P5XU.cjs');
|
|
4
|
+
var chunkXTBRWVIV_cjs = require('./chunk-XTBRWVIV.cjs');
|
|
5
|
+
var chunkWGEGR3DF_cjs = require('./chunk-WGEGR3DF.cjs');
|
|
6
|
+
var react = require('react');
|
|
7
|
+
require('@vidstack/react/player/styles/base.css');
|
|
8
|
+
require('@vidstack/react/player/styles/default/theme.css');
|
|
9
|
+
require('@vidstack/react/player/styles/default/layouts/video.css');
|
|
10
|
+
var lib = require('@djangocfg/ui-core/lib');
|
|
11
|
+
var react$1 = require('@vidstack/react');
|
|
12
|
+
var _default = require('@vidstack/react/player/layouts/default');
|
|
13
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
14
|
+
var uiCore = require('@djangocfg/ui-core');
|
|
15
|
+
var lucideReact = require('lucide-react');
|
|
16
|
+
|
|
17
|
+
var videoDebug = lib.createMediaLogger("VideoPlayer");
|
|
18
|
+
function getVidstackSrc(source) {
|
|
19
|
+
switch (source.type) {
|
|
20
|
+
case "youtube":
|
|
21
|
+
return `youtube/${source.id}`;
|
|
22
|
+
case "vimeo":
|
|
23
|
+
return `vimeo/${source.id}`;
|
|
24
|
+
case "hls":
|
|
25
|
+
return { src: source.url, type: "application/x-mpegurl" };
|
|
26
|
+
case "dash":
|
|
27
|
+
return { src: source.url, type: "application/dash+xml" };
|
|
28
|
+
case "url":
|
|
29
|
+
return source.url;
|
|
30
|
+
default:
|
|
31
|
+
return "";
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
chunkWGEGR3DF_cjs.__name(getVidstackSrc, "getVidstackSrc");
|
|
35
|
+
function DefaultErrorFallback({ error }) {
|
|
36
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "absolute inset-0 flex flex-col items-center justify-center gap-4 text-white bg-black", children: [
|
|
37
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
38
|
+
"svg",
|
|
39
|
+
{
|
|
40
|
+
className: "w-16 h-16 text-muted-foreground",
|
|
41
|
+
fill: "none",
|
|
42
|
+
stroke: "currentColor",
|
|
43
|
+
viewBox: "0 0 24 24",
|
|
44
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
45
|
+
"path",
|
|
46
|
+
{
|
|
47
|
+
strokeLinecap: "round",
|
|
48
|
+
strokeLinejoin: "round",
|
|
49
|
+
strokeWidth: 2,
|
|
50
|
+
d: "M15 10l4.553-2.276A1 1 0 0121 8.618v6.764a1 1 0 01-1.447.894L15 14M5 18h8a2 2 0 002-2V8a2 2 0 00-2-2H5a2 2 0 00-2 2v8a2 2 0 002 2z"
|
|
51
|
+
}
|
|
52
|
+
)
|
|
53
|
+
}
|
|
54
|
+
),
|
|
55
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-lg", children: error || "Video cannot be played" })
|
|
56
|
+
] });
|
|
57
|
+
}
|
|
58
|
+
chunkWGEGR3DF_cjs.__name(DefaultErrorFallback, "DefaultErrorFallback");
|
|
59
|
+
var VidstackProvider = react.forwardRef(
|
|
60
|
+
({
|
|
61
|
+
source,
|
|
62
|
+
aspectRatio = 16 / 9,
|
|
63
|
+
autoPlay = false,
|
|
64
|
+
muted = false,
|
|
65
|
+
loop = false,
|
|
66
|
+
playsInline = true,
|
|
67
|
+
controls = true,
|
|
68
|
+
className,
|
|
69
|
+
showInfo = false,
|
|
70
|
+
theme = "default",
|
|
71
|
+
errorFallback,
|
|
72
|
+
onPlay,
|
|
73
|
+
onPause,
|
|
74
|
+
onEnded,
|
|
75
|
+
onError,
|
|
76
|
+
onLoadStart,
|
|
77
|
+
onCanPlay,
|
|
78
|
+
onTimeUpdate
|
|
79
|
+
}, ref) => {
|
|
80
|
+
const playerRef = react.useRef(null);
|
|
81
|
+
const [hasError, setHasError] = react.useState(false);
|
|
82
|
+
const [errorMessage, setErrorMessage] = react.useState("Video cannot be played");
|
|
83
|
+
const lastSavedTimeRef = react.useRef(0);
|
|
84
|
+
const hasRestoredPositionRef = react.useRef(false);
|
|
85
|
+
const {
|
|
86
|
+
getPosterUrl,
|
|
87
|
+
cachePosterUrl,
|
|
88
|
+
saveVideoPosition,
|
|
89
|
+
getVideoPosition
|
|
90
|
+
} = chunkXTBRWVIV_cjs.useVideoCache();
|
|
91
|
+
const sourceKey = react.useMemo(() => {
|
|
92
|
+
switch (source.type) {
|
|
93
|
+
case "youtube":
|
|
94
|
+
return `youtube:${source.id}`;
|
|
95
|
+
case "vimeo":
|
|
96
|
+
return `vimeo:${source.id}`;
|
|
97
|
+
case "hls":
|
|
98
|
+
case "dash":
|
|
99
|
+
case "url":
|
|
100
|
+
return `url:${source.url}`;
|
|
101
|
+
default:
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
}, [source]);
|
|
105
|
+
const posterUrl = react.useMemo(() => {
|
|
106
|
+
if (source.poster) return source.poster;
|
|
107
|
+
if (!source.title) return void 0;
|
|
108
|
+
const cached = getPosterUrl(source.title);
|
|
109
|
+
if (cached) return cached;
|
|
110
|
+
const url = lib.generateOgImageUrl({ title: source.title });
|
|
111
|
+
cachePosterUrl(source.title, url);
|
|
112
|
+
return url;
|
|
113
|
+
}, [source.poster, source.title, getPosterUrl, cachePosterUrl]);
|
|
114
|
+
const vidstackSrc = react.useMemo(() => getVidstackSrc(source), [source]);
|
|
115
|
+
react.useEffect(() => {
|
|
116
|
+
const srcString = typeof vidstackSrc === "string" ? vidstackSrc : vidstackSrc.src;
|
|
117
|
+
videoDebug.load(srcString, source.type);
|
|
118
|
+
}, [vidstackSrc, source.type]);
|
|
119
|
+
const retry = react.useCallback(() => {
|
|
120
|
+
setHasError(false);
|
|
121
|
+
setErrorMessage("Video cannot be played");
|
|
122
|
+
const player = playerRef.current;
|
|
123
|
+
if (player) {
|
|
124
|
+
player.currentTime = 0;
|
|
125
|
+
player.play();
|
|
126
|
+
}
|
|
127
|
+
}, []);
|
|
128
|
+
react.useImperativeHandle(
|
|
129
|
+
ref,
|
|
130
|
+
() => {
|
|
131
|
+
const player = playerRef.current;
|
|
132
|
+
return {
|
|
133
|
+
play: /* @__PURE__ */ chunkWGEGR3DF_cjs.__name(() => player?.play(), "play"),
|
|
134
|
+
pause: /* @__PURE__ */ chunkWGEGR3DF_cjs.__name(() => player?.pause(), "pause"),
|
|
135
|
+
togglePlay: /* @__PURE__ */ chunkWGEGR3DF_cjs.__name(() => {
|
|
136
|
+
if (player) {
|
|
137
|
+
player.paused ? player.play() : player.pause();
|
|
138
|
+
}
|
|
139
|
+
}, "togglePlay"),
|
|
140
|
+
seekTo: /* @__PURE__ */ chunkWGEGR3DF_cjs.__name((time) => {
|
|
141
|
+
if (player) player.currentTime = time;
|
|
142
|
+
}, "seekTo"),
|
|
143
|
+
setVolume: /* @__PURE__ */ chunkWGEGR3DF_cjs.__name((volume) => {
|
|
144
|
+
if (player) player.volume = Math.max(0, Math.min(1, volume));
|
|
145
|
+
}, "setVolume"),
|
|
146
|
+
toggleMute: /* @__PURE__ */ chunkWGEGR3DF_cjs.__name(() => {
|
|
147
|
+
if (player) player.muted = !player.muted;
|
|
148
|
+
}, "toggleMute"),
|
|
149
|
+
enterFullscreen: /* @__PURE__ */ chunkWGEGR3DF_cjs.__name(() => player?.enterFullscreen(), "enterFullscreen"),
|
|
150
|
+
exitFullscreen: /* @__PURE__ */ chunkWGEGR3DF_cjs.__name(() => player?.exitFullscreen(), "exitFullscreen"),
|
|
151
|
+
get currentTime() {
|
|
152
|
+
return player?.currentTime ?? 0;
|
|
153
|
+
},
|
|
154
|
+
get duration() {
|
|
155
|
+
return player?.duration ?? 0;
|
|
156
|
+
},
|
|
157
|
+
get paused() {
|
|
158
|
+
return player?.paused ?? true;
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
},
|
|
162
|
+
[]
|
|
163
|
+
);
|
|
164
|
+
const handlePlay = /* @__PURE__ */ chunkWGEGR3DF_cjs.__name(() => onPlay?.(), "handlePlay");
|
|
165
|
+
const handlePause = react.useCallback(() => {
|
|
166
|
+
const player = playerRef.current;
|
|
167
|
+
if (sourceKey && player && player.currentTime > 0) {
|
|
168
|
+
saveVideoPosition(sourceKey, player.currentTime);
|
|
169
|
+
lastSavedTimeRef.current = player.currentTime;
|
|
170
|
+
}
|
|
171
|
+
onPause?.();
|
|
172
|
+
}, [sourceKey, saveVideoPosition, onPause]);
|
|
173
|
+
const handleEnded = /* @__PURE__ */ chunkWGEGR3DF_cjs.__name(() => onEnded?.(), "handleEnded");
|
|
174
|
+
const handleError = /* @__PURE__ */ chunkWGEGR3DF_cjs.__name((detail) => {
|
|
175
|
+
const error = detail;
|
|
176
|
+
const msg = error?.message || "Video playback error";
|
|
177
|
+
videoDebug.error("Vidstack error", { message: msg });
|
|
178
|
+
setHasError(true);
|
|
179
|
+
setErrorMessage(msg);
|
|
180
|
+
onError?.(msg);
|
|
181
|
+
}, "handleError");
|
|
182
|
+
const handleLoadStart = /* @__PURE__ */ chunkWGEGR3DF_cjs.__name(() => onLoadStart?.(), "handleLoadStart");
|
|
183
|
+
const handleCanPlay = react.useCallback(() => {
|
|
184
|
+
const player = playerRef.current;
|
|
185
|
+
if (player) {
|
|
186
|
+
videoDebug.state("canplay", { duration: player.duration });
|
|
187
|
+
const mediaEl = player.provider?.media;
|
|
188
|
+
if (mediaEl?.buffered) {
|
|
189
|
+
videoDebug.buffer(mediaEl.buffered, player.duration);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
setHasError(false);
|
|
193
|
+
if (sourceKey && player && !hasRestoredPositionRef.current) {
|
|
194
|
+
const cachedPosition = getVideoPosition(sourceKey);
|
|
195
|
+
if (cachedPosition && cachedPosition > 0) {
|
|
196
|
+
const duration = player.duration;
|
|
197
|
+
if (cachedPosition < duration - 1) {
|
|
198
|
+
videoDebug.debug(`Restoring position: ${cachedPosition}s`);
|
|
199
|
+
player.currentTime = cachedPosition;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
hasRestoredPositionRef.current = true;
|
|
203
|
+
}
|
|
204
|
+
onCanPlay?.();
|
|
205
|
+
}, [sourceKey, getVideoPosition, onCanPlay]);
|
|
206
|
+
const handleTimeUpdate = react.useCallback(() => {
|
|
207
|
+
const player = playerRef.current;
|
|
208
|
+
if (!player) return;
|
|
209
|
+
if (sourceKey && player.currentTime > 0) {
|
|
210
|
+
const timeSinceLastSave = player.currentTime - lastSavedTimeRef.current;
|
|
211
|
+
if (timeSinceLastSave >= 5 || timeSinceLastSave < 0) {
|
|
212
|
+
saveVideoPosition(sourceKey, player.currentTime);
|
|
213
|
+
lastSavedTimeRef.current = player.currentTime;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
onTimeUpdate?.(player.currentTime, player.duration);
|
|
217
|
+
}, [sourceKey, saveVideoPosition, onTimeUpdate]);
|
|
218
|
+
react.useEffect(() => {
|
|
219
|
+
hasRestoredPositionRef.current = false;
|
|
220
|
+
lastSavedTimeRef.current = 0;
|
|
221
|
+
}, [sourceKey]);
|
|
222
|
+
react.useEffect(() => {
|
|
223
|
+
const player = playerRef.current;
|
|
224
|
+
if (!player) return;
|
|
225
|
+
const handleSeeking = /* @__PURE__ */ chunkWGEGR3DF_cjs.__name(() => {
|
|
226
|
+
videoDebug.event("seeking", { currentTime: player.currentTime });
|
|
227
|
+
}, "handleSeeking");
|
|
228
|
+
const handleSeeked = /* @__PURE__ */ chunkWGEGR3DF_cjs.__name(() => {
|
|
229
|
+
videoDebug.event("seeked", { currentTime: player.currentTime });
|
|
230
|
+
const mediaEl = player.provider?.media;
|
|
231
|
+
if (mediaEl?.buffered) {
|
|
232
|
+
videoDebug.buffer(mediaEl.buffered, player.duration);
|
|
233
|
+
}
|
|
234
|
+
}, "handleSeeked");
|
|
235
|
+
const handleWaiting = /* @__PURE__ */ chunkWGEGR3DF_cjs.__name(() => {
|
|
236
|
+
videoDebug.warn("WAITING - buffering...");
|
|
237
|
+
const mediaEl = player.provider?.media;
|
|
238
|
+
if (mediaEl?.buffered) {
|
|
239
|
+
videoDebug.buffer(mediaEl.buffered, player.duration);
|
|
240
|
+
}
|
|
241
|
+
}, "handleWaiting");
|
|
242
|
+
const handleStalled = /* @__PURE__ */ chunkWGEGR3DF_cjs.__name(() => {
|
|
243
|
+
videoDebug.warn("STALLED - network issue");
|
|
244
|
+
const mediaEl = player.provider?.media;
|
|
245
|
+
if (mediaEl?.buffered) {
|
|
246
|
+
videoDebug.buffer(mediaEl.buffered, player.duration);
|
|
247
|
+
}
|
|
248
|
+
}, "handleStalled");
|
|
249
|
+
player.addEventListener("seeking", handleSeeking);
|
|
250
|
+
player.addEventListener("seeked", handleSeeked);
|
|
251
|
+
player.addEventListener("waiting", handleWaiting);
|
|
252
|
+
player.addEventListener("stalled", handleStalled);
|
|
253
|
+
return () => {
|
|
254
|
+
player.removeEventListener("seeking", handleSeeking);
|
|
255
|
+
player.removeEventListener("seeked", handleSeeked);
|
|
256
|
+
player.removeEventListener("waiting", handleWaiting);
|
|
257
|
+
player.removeEventListener("stalled", handleStalled);
|
|
258
|
+
};
|
|
259
|
+
}, [vidstackSrc]);
|
|
260
|
+
const isFillMode = aspectRatio === "fill";
|
|
261
|
+
const computedAspectRatio = aspectRatio === "auto" || aspectRatio === "fill" ? void 0 : aspectRatio;
|
|
262
|
+
const renderErrorFallback = /* @__PURE__ */ chunkWGEGR3DF_cjs.__name(() => {
|
|
263
|
+
const fallbackProps = { error: errorMessage, retry };
|
|
264
|
+
if (typeof errorFallback === "function") {
|
|
265
|
+
return errorFallback(fallbackProps);
|
|
266
|
+
}
|
|
267
|
+
if (errorFallback) {
|
|
268
|
+
return errorFallback;
|
|
269
|
+
}
|
|
270
|
+
return /* @__PURE__ */ jsxRuntime.jsx(DefaultErrorFallback, { ...fallbackProps });
|
|
271
|
+
}, "renderErrorFallback");
|
|
272
|
+
const containerStyles = isFillMode ? { width: "100%", height: "100%" } : { aspectRatio: computedAspectRatio };
|
|
273
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: lib.cn(isFillMode ? "w-full h-full" : "w-full", className), children: [
|
|
274
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
275
|
+
"div",
|
|
276
|
+
{
|
|
277
|
+
className: lib.cn(
|
|
278
|
+
"relative w-full rounded-sm bg-black overflow-hidden",
|
|
279
|
+
isFillMode && "h-full",
|
|
280
|
+
theme === "minimal" && "rounded-none",
|
|
281
|
+
theme === "modern" && "rounded-xl shadow-2xl"
|
|
282
|
+
),
|
|
283
|
+
style: containerStyles,
|
|
284
|
+
children: hasError ? renderErrorFallback() : /* @__PURE__ */ jsxRuntime.jsxs(
|
|
285
|
+
react$1.MediaPlayer,
|
|
286
|
+
{
|
|
287
|
+
ref: playerRef,
|
|
288
|
+
title: source.title || "Video",
|
|
289
|
+
src: vidstackSrc,
|
|
290
|
+
autoPlay,
|
|
291
|
+
muted,
|
|
292
|
+
loop,
|
|
293
|
+
playsInline,
|
|
294
|
+
onPlay: handlePlay,
|
|
295
|
+
onPause: handlePause,
|
|
296
|
+
onEnded: handleEnded,
|
|
297
|
+
onError: handleError,
|
|
298
|
+
onLoadStart: handleLoadStart,
|
|
299
|
+
onCanPlay: handleCanPlay,
|
|
300
|
+
onTimeUpdate: handleTimeUpdate,
|
|
301
|
+
className: "w-full h-full",
|
|
302
|
+
children: [
|
|
303
|
+
/* @__PURE__ */ jsxRuntime.jsx(react$1.MediaProvider, {}),
|
|
304
|
+
posterUrl && /* @__PURE__ */ jsxRuntime.jsx(
|
|
305
|
+
react$1.Poster,
|
|
306
|
+
{
|
|
307
|
+
className: "vds-poster",
|
|
308
|
+
src: posterUrl,
|
|
309
|
+
alt: source.title || "Video poster",
|
|
310
|
+
style: { objectFit: "cover" }
|
|
311
|
+
}
|
|
312
|
+
),
|
|
313
|
+
controls && /* @__PURE__ */ jsxRuntime.jsx(_default.DefaultVideoLayout, { icons: _default.defaultLayoutIcons, thumbnails: posterUrl })
|
|
314
|
+
]
|
|
315
|
+
}
|
|
316
|
+
)
|
|
317
|
+
}
|
|
318
|
+
),
|
|
319
|
+
showInfo && source.title && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-4 space-y-2", children: /* @__PURE__ */ jsxRuntime.jsx("h3", { className: "text-xl font-semibold text-foreground", children: source.title }) })
|
|
320
|
+
] });
|
|
321
|
+
}
|
|
322
|
+
);
|
|
323
|
+
VidstackProvider.displayName = "VidstackProvider";
|
|
324
|
+
function useVideoPlayerSettings2() {
|
|
325
|
+
const { settings, saveSettings } = chunkXTBRWVIV_cjs.useVideoPlayerSettings();
|
|
326
|
+
const updateVolume = react.useCallback(
|
|
327
|
+
(volume) => {
|
|
328
|
+
saveSettings({ volume: Math.max(0, Math.min(1, volume)) });
|
|
329
|
+
},
|
|
330
|
+
[saveSettings]
|
|
331
|
+
);
|
|
332
|
+
const updateLoop = react.useCallback(
|
|
333
|
+
(isLooping) => {
|
|
334
|
+
saveSettings({ isLooping });
|
|
335
|
+
},
|
|
336
|
+
[saveSettings]
|
|
337
|
+
);
|
|
338
|
+
const updateSettings = react.useCallback(
|
|
339
|
+
(newSettings) => {
|
|
340
|
+
saveSettings(newSettings);
|
|
341
|
+
},
|
|
342
|
+
[saveSettings]
|
|
343
|
+
);
|
|
344
|
+
return {
|
|
345
|
+
settings,
|
|
346
|
+
updateVolume,
|
|
347
|
+
updateLoop,
|
|
348
|
+
updateSettings
|
|
349
|
+
};
|
|
350
|
+
}
|
|
351
|
+
chunkWGEGR3DF_cjs.__name(useVideoPlayerSettings2, "useVideoPlayerSettings");
|
|
352
|
+
function getVideoUrl(source) {
|
|
353
|
+
switch (source.type) {
|
|
354
|
+
case "url":
|
|
355
|
+
return source.url;
|
|
356
|
+
case "data-url":
|
|
357
|
+
return source.data;
|
|
358
|
+
default:
|
|
359
|
+
return "";
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
chunkWGEGR3DF_cjs.__name(getVideoUrl, "getVideoUrl");
|
|
363
|
+
var NativeProvider = react.forwardRef(
|
|
364
|
+
({
|
|
365
|
+
source,
|
|
366
|
+
aspectRatio = 16 / 9,
|
|
367
|
+
autoPlay = true,
|
|
368
|
+
muted = true,
|
|
369
|
+
loop = true,
|
|
370
|
+
playsInline = true,
|
|
371
|
+
preload = "auto",
|
|
372
|
+
controls = false,
|
|
373
|
+
disableContextMenu = true,
|
|
374
|
+
showPreloader = true,
|
|
375
|
+
preloaderTimeout = 5e3,
|
|
376
|
+
className,
|
|
377
|
+
videoClassName,
|
|
378
|
+
onPlay,
|
|
379
|
+
onPause,
|
|
380
|
+
onEnded,
|
|
381
|
+
onError,
|
|
382
|
+
onLoadStart,
|
|
383
|
+
onCanPlay,
|
|
384
|
+
onTimeUpdate
|
|
385
|
+
}, ref) => {
|
|
386
|
+
const [isLoading, setIsLoading] = react.useState(showPreloader);
|
|
387
|
+
const videoRef = react.useRef(null);
|
|
388
|
+
const { settings: savedSettings, updateVolume } = useVideoPlayerSettings2();
|
|
389
|
+
const videoUrl = getVideoUrl(source);
|
|
390
|
+
react.useEffect(() => {
|
|
391
|
+
videoDebug.load(videoUrl, source.type);
|
|
392
|
+
}, [videoUrl, source.type]);
|
|
393
|
+
react.useImperativeHandle(
|
|
394
|
+
ref,
|
|
395
|
+
() => ({
|
|
396
|
+
play: /* @__PURE__ */ chunkWGEGR3DF_cjs.__name(() => videoRef.current?.play(), "play"),
|
|
397
|
+
pause: /* @__PURE__ */ chunkWGEGR3DF_cjs.__name(() => videoRef.current?.pause(), "pause"),
|
|
398
|
+
togglePlay: /* @__PURE__ */ chunkWGEGR3DF_cjs.__name(() => {
|
|
399
|
+
const video = videoRef.current;
|
|
400
|
+
if (video) {
|
|
401
|
+
video.paused ? video.play() : video.pause();
|
|
402
|
+
}
|
|
403
|
+
}, "togglePlay"),
|
|
404
|
+
seekTo: /* @__PURE__ */ chunkWGEGR3DF_cjs.__name((time) => {
|
|
405
|
+
if (videoRef.current) videoRef.current.currentTime = time;
|
|
406
|
+
}, "seekTo"),
|
|
407
|
+
setVolume: /* @__PURE__ */ chunkWGEGR3DF_cjs.__name((volume) => {
|
|
408
|
+
if (videoRef.current) videoRef.current.volume = Math.max(0, Math.min(1, volume));
|
|
409
|
+
}, "setVolume"),
|
|
410
|
+
toggleMute: /* @__PURE__ */ chunkWGEGR3DF_cjs.__name(() => {
|
|
411
|
+
if (videoRef.current) videoRef.current.muted = !videoRef.current.muted;
|
|
412
|
+
}, "toggleMute"),
|
|
413
|
+
enterFullscreen: /* @__PURE__ */ chunkWGEGR3DF_cjs.__name(() => videoRef.current?.requestFullscreen(), "enterFullscreen"),
|
|
414
|
+
exitFullscreen: /* @__PURE__ */ chunkWGEGR3DF_cjs.__name(() => document.exitFullscreen(), "exitFullscreen"),
|
|
415
|
+
get currentTime() {
|
|
416
|
+
return videoRef.current?.currentTime ?? 0;
|
|
417
|
+
},
|
|
418
|
+
get duration() {
|
|
419
|
+
return videoRef.current?.duration ?? 0;
|
|
420
|
+
},
|
|
421
|
+
get paused() {
|
|
422
|
+
return videoRef.current?.paused ?? true;
|
|
423
|
+
}
|
|
424
|
+
}),
|
|
425
|
+
[]
|
|
426
|
+
);
|
|
427
|
+
react.useEffect(() => {
|
|
428
|
+
if (!showPreloader) return;
|
|
429
|
+
const video = videoRef.current;
|
|
430
|
+
if (!video) return;
|
|
431
|
+
if (video.readyState >= 3) {
|
|
432
|
+
setIsLoading(false);
|
|
433
|
+
return;
|
|
434
|
+
}
|
|
435
|
+
const hideLoader = /* @__PURE__ */ chunkWGEGR3DF_cjs.__name(() => setIsLoading(false), "hideLoader");
|
|
436
|
+
video.addEventListener("canplay", hideLoader);
|
|
437
|
+
video.addEventListener("loadeddata", hideLoader);
|
|
438
|
+
video.addEventListener("playing", hideLoader);
|
|
439
|
+
const timeout = setTimeout(hideLoader, preloaderTimeout);
|
|
440
|
+
return () => {
|
|
441
|
+
video.removeEventListener("canplay", hideLoader);
|
|
442
|
+
video.removeEventListener("loadeddata", hideLoader);
|
|
443
|
+
video.removeEventListener("playing", hideLoader);
|
|
444
|
+
clearTimeout(timeout);
|
|
445
|
+
};
|
|
446
|
+
}, [showPreloader, preloaderTimeout]);
|
|
447
|
+
react.useEffect(() => {
|
|
448
|
+
const video = videoRef.current;
|
|
449
|
+
if (!video) return;
|
|
450
|
+
const handleLoadedMetadata = /* @__PURE__ */ chunkWGEGR3DF_cjs.__name(() => {
|
|
451
|
+
videoDebug.state("loadedmetadata", { duration: video.duration });
|
|
452
|
+
}, "handleLoadedMetadata");
|
|
453
|
+
const handleCanPlayDebug = /* @__PURE__ */ chunkWGEGR3DF_cjs.__name(() => {
|
|
454
|
+
videoDebug.state("canplay", { duration: video.duration, buffered: video.buffered.length });
|
|
455
|
+
videoDebug.buffer(video.buffered, video.duration);
|
|
456
|
+
video.volume = savedSettings.volume;
|
|
457
|
+
}, "handleCanPlayDebug");
|
|
458
|
+
const handleSeeking = /* @__PURE__ */ chunkWGEGR3DF_cjs.__name(() => {
|
|
459
|
+
videoDebug.event("seeking", { currentTime: video.currentTime });
|
|
460
|
+
}, "handleSeeking");
|
|
461
|
+
const handleSeeked = /* @__PURE__ */ chunkWGEGR3DF_cjs.__name(() => {
|
|
462
|
+
videoDebug.event("seeked", { currentTime: video.currentTime });
|
|
463
|
+
videoDebug.buffer(video.buffered, video.duration);
|
|
464
|
+
}, "handleSeeked");
|
|
465
|
+
const handleWaiting = /* @__PURE__ */ chunkWGEGR3DF_cjs.__name(() => {
|
|
466
|
+
videoDebug.warn("WAITING - buffering...");
|
|
467
|
+
videoDebug.buffer(video.buffered, video.duration);
|
|
468
|
+
}, "handleWaiting");
|
|
469
|
+
const handleStalled = /* @__PURE__ */ chunkWGEGR3DF_cjs.__name(() => {
|
|
470
|
+
videoDebug.warn("STALLED - network issue");
|
|
471
|
+
videoDebug.buffer(video.buffered, video.duration);
|
|
472
|
+
}, "handleStalled");
|
|
473
|
+
video.addEventListener("loadedmetadata", handleLoadedMetadata);
|
|
474
|
+
video.addEventListener("canplay", handleCanPlayDebug);
|
|
475
|
+
video.addEventListener("seeking", handleSeeking);
|
|
476
|
+
video.addEventListener("seeked", handleSeeked);
|
|
477
|
+
video.addEventListener("waiting", handleWaiting);
|
|
478
|
+
video.addEventListener("stalled", handleStalled);
|
|
479
|
+
return () => {
|
|
480
|
+
video.removeEventListener("loadedmetadata", handleLoadedMetadata);
|
|
481
|
+
video.removeEventListener("canplay", handleCanPlayDebug);
|
|
482
|
+
video.removeEventListener("seeking", handleSeeking);
|
|
483
|
+
video.removeEventListener("seeked", handleSeeked);
|
|
484
|
+
video.removeEventListener("waiting", handleWaiting);
|
|
485
|
+
video.removeEventListener("stalled", handleStalled);
|
|
486
|
+
};
|
|
487
|
+
}, [savedSettings.volume]);
|
|
488
|
+
react.useEffect(() => {
|
|
489
|
+
const video = videoRef.current;
|
|
490
|
+
if (!video) return;
|
|
491
|
+
const handleVolumeChange = /* @__PURE__ */ chunkWGEGR3DF_cjs.__name(() => {
|
|
492
|
+
updateVolume(video.volume);
|
|
493
|
+
}, "handleVolumeChange");
|
|
494
|
+
video.addEventListener("volumechange", handleVolumeChange);
|
|
495
|
+
return () => video.removeEventListener("volumechange", handleVolumeChange);
|
|
496
|
+
}, [updateVolume]);
|
|
497
|
+
const handleContextMenu = /* @__PURE__ */ chunkWGEGR3DF_cjs.__name((e) => {
|
|
498
|
+
if (disableContextMenu) {
|
|
499
|
+
e.preventDefault();
|
|
500
|
+
}
|
|
501
|
+
}, "handleContextMenu");
|
|
502
|
+
const handleError = /* @__PURE__ */ chunkWGEGR3DF_cjs.__name((e) => {
|
|
503
|
+
const video = e.currentTarget;
|
|
504
|
+
const errorMsg = video.error?.message || "Video playback error";
|
|
505
|
+
videoDebug.error("Video error", { code: video.error?.code, message: errorMsg });
|
|
506
|
+
setIsLoading(false);
|
|
507
|
+
onError?.(errorMsg);
|
|
508
|
+
}, "handleError");
|
|
509
|
+
const handleTimeUpdate = /* @__PURE__ */ chunkWGEGR3DF_cjs.__name(() => {
|
|
510
|
+
const video = videoRef.current;
|
|
511
|
+
if (video && onTimeUpdate) {
|
|
512
|
+
onTimeUpdate(video.currentTime, video.duration);
|
|
513
|
+
}
|
|
514
|
+
}, "handleTimeUpdate");
|
|
515
|
+
const isFillMode = aspectRatio === "fill";
|
|
516
|
+
const computedAspectRatio = aspectRatio === "auto" || aspectRatio === "fill" ? void 0 : aspectRatio;
|
|
517
|
+
const videoContent = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
518
|
+
showPreloader && isLoading && /* @__PURE__ */ jsxRuntime.jsx(
|
|
519
|
+
"div",
|
|
520
|
+
{
|
|
521
|
+
className: lib.cn(
|
|
522
|
+
"absolute inset-0 flex items-center justify-center bg-muted/30 backdrop-blur-sm z-10"
|
|
523
|
+
),
|
|
524
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(uiCore.Preloader, { size: "lg", spinnerClassName: "text-white" })
|
|
525
|
+
}
|
|
526
|
+
),
|
|
527
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
528
|
+
"video",
|
|
529
|
+
{
|
|
530
|
+
ref: videoRef,
|
|
531
|
+
className: lib.cn("w-full h-full object-cover", videoClassName),
|
|
532
|
+
src: videoUrl,
|
|
533
|
+
autoPlay,
|
|
534
|
+
muted,
|
|
535
|
+
loop,
|
|
536
|
+
playsInline,
|
|
537
|
+
preload,
|
|
538
|
+
controls,
|
|
539
|
+
poster: source.poster,
|
|
540
|
+
onContextMenu: handleContextMenu,
|
|
541
|
+
onLoadStart,
|
|
542
|
+
onCanPlay,
|
|
543
|
+
onPlay,
|
|
544
|
+
onPause,
|
|
545
|
+
onPlaying: () => setIsLoading(false),
|
|
546
|
+
onEnded,
|
|
547
|
+
onError: handleError,
|
|
548
|
+
onTimeUpdate: handleTimeUpdate
|
|
549
|
+
}
|
|
550
|
+
)
|
|
551
|
+
] });
|
|
552
|
+
if (isFillMode) {
|
|
553
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: lib.cn("relative w-full h-full overflow-hidden", className), children: videoContent });
|
|
554
|
+
}
|
|
555
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: lib.cn("relative overflow-hidden", className), children: /* @__PURE__ */ jsxRuntime.jsx(uiCore.AspectRatio, { ratio: computedAspectRatio, children: videoContent }) });
|
|
556
|
+
}
|
|
557
|
+
);
|
|
558
|
+
NativeProvider.displayName = "NativeProvider";
|
|
559
|
+
function DefaultErrorFallback2({ error }) {
|
|
560
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "absolute inset-0 flex flex-col items-center justify-center gap-4 text-white", children: [
|
|
561
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
562
|
+
"svg",
|
|
563
|
+
{
|
|
564
|
+
className: "w-16 h-16 text-muted-foreground",
|
|
565
|
+
fill: "none",
|
|
566
|
+
stroke: "currentColor",
|
|
567
|
+
viewBox: "0 0 24 24",
|
|
568
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
569
|
+
"path",
|
|
570
|
+
{
|
|
571
|
+
strokeLinecap: "round",
|
|
572
|
+
strokeLinejoin: "round",
|
|
573
|
+
strokeWidth: 2,
|
|
574
|
+
d: "M15 10l4.553-2.276A1 1 0 0121 8.618v6.764a1 1 0 01-1.447.894L15 14M5 18h8a2 2 0 002-2V8a2 2 0 00-2-2H5a2 2 0 00-2 2v8a2 2 0 002 2z"
|
|
575
|
+
}
|
|
576
|
+
)
|
|
577
|
+
}
|
|
578
|
+
),
|
|
579
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-lg", children: error || "Video cannot be previewed" })
|
|
580
|
+
] });
|
|
581
|
+
}
|
|
582
|
+
chunkWGEGR3DF_cjs.__name(DefaultErrorFallback2, "DefaultErrorFallback");
|
|
583
|
+
var StreamProvider = react.forwardRef(
|
|
584
|
+
({
|
|
585
|
+
source,
|
|
586
|
+
aspectRatio = 16 / 9,
|
|
587
|
+
autoPlay = false,
|
|
588
|
+
muted = false,
|
|
589
|
+
loop = false,
|
|
590
|
+
playsInline = true,
|
|
591
|
+
preload = "metadata",
|
|
592
|
+
controls = true,
|
|
593
|
+
disableContextMenu = false,
|
|
594
|
+
showPreloader = true,
|
|
595
|
+
preloaderTimeout = 1e4,
|
|
596
|
+
className,
|
|
597
|
+
videoClassName,
|
|
598
|
+
errorFallback,
|
|
599
|
+
onPlay,
|
|
600
|
+
onPause,
|
|
601
|
+
onEnded,
|
|
602
|
+
onError,
|
|
603
|
+
onLoadStart,
|
|
604
|
+
onCanPlay,
|
|
605
|
+
onTimeUpdate,
|
|
606
|
+
onBufferProgress
|
|
607
|
+
}, ref) => {
|
|
608
|
+
const [videoUrl, setVideoUrl] = react.useState(null);
|
|
609
|
+
const [isLoading, setIsLoading] = react.useState(true);
|
|
610
|
+
const [hasError, setHasError] = react.useState(false);
|
|
611
|
+
const [errorMessage, setErrorMessage] = react.useState("Video cannot be previewed");
|
|
612
|
+
const videoRef = react.useRef(null);
|
|
613
|
+
const contentKeyRef = react.useRef(null);
|
|
614
|
+
const lastSavedTimeRef = react.useRef(0);
|
|
615
|
+
const getOrCreateBlobUrl = chunkXTBRWVIV_cjs.useMediaCacheStore.getState().getOrCreateBlobUrl;
|
|
616
|
+
const releaseBlobUrl = chunkXTBRWVIV_cjs.useMediaCacheStore.getState().releaseBlobUrl;
|
|
617
|
+
const getOrCreateStreamUrl = chunkXTBRWVIV_cjs.useMediaCacheStore.getState().getOrCreateStreamUrl;
|
|
618
|
+
const saveVideoPosition = chunkXTBRWVIV_cjs.useMediaCacheStore.getState().saveVideoPosition;
|
|
619
|
+
const getVideoPosition = chunkXTBRWVIV_cjs.useMediaCacheStore.getState().getVideoPosition;
|
|
620
|
+
const { settings: savedSettings, updateVolume } = useVideoPlayerSettings2();
|
|
621
|
+
const retry = react.useCallback(() => {
|
|
622
|
+
setHasError(false);
|
|
623
|
+
setIsLoading(true);
|
|
624
|
+
if (source.type === "stream") {
|
|
625
|
+
const streamSource = source;
|
|
626
|
+
const freshUrl = streamSource.getStreamUrl(streamSource.sessionId, streamSource.path);
|
|
627
|
+
setVideoUrl(freshUrl);
|
|
628
|
+
return;
|
|
629
|
+
}
|
|
630
|
+
const video = videoRef.current;
|
|
631
|
+
if (video && videoUrl) {
|
|
632
|
+
video.load();
|
|
633
|
+
}
|
|
634
|
+
}, [source, videoUrl]);
|
|
635
|
+
react.useImperativeHandle(
|
|
636
|
+
ref,
|
|
637
|
+
() => ({
|
|
638
|
+
play: /* @__PURE__ */ chunkWGEGR3DF_cjs.__name(() => videoRef.current?.play(), "play"),
|
|
639
|
+
pause: /* @__PURE__ */ chunkWGEGR3DF_cjs.__name(() => videoRef.current?.pause(), "pause"),
|
|
640
|
+
togglePlay: /* @__PURE__ */ chunkWGEGR3DF_cjs.__name(() => {
|
|
641
|
+
const video = videoRef.current;
|
|
642
|
+
if (video) {
|
|
643
|
+
video.paused ? video.play() : video.pause();
|
|
644
|
+
}
|
|
645
|
+
}, "togglePlay"),
|
|
646
|
+
seekTo: /* @__PURE__ */ chunkWGEGR3DF_cjs.__name((time) => {
|
|
647
|
+
if (videoRef.current) videoRef.current.currentTime = time;
|
|
648
|
+
}, "seekTo"),
|
|
649
|
+
setVolume: /* @__PURE__ */ chunkWGEGR3DF_cjs.__name((volume) => {
|
|
650
|
+
if (videoRef.current) videoRef.current.volume = Math.max(0, Math.min(1, volume));
|
|
651
|
+
}, "setVolume"),
|
|
652
|
+
toggleMute: /* @__PURE__ */ chunkWGEGR3DF_cjs.__name(() => {
|
|
653
|
+
if (videoRef.current) videoRef.current.muted = !videoRef.current.muted;
|
|
654
|
+
}, "toggleMute"),
|
|
655
|
+
enterFullscreen: /* @__PURE__ */ chunkWGEGR3DF_cjs.__name(() => videoRef.current?.requestFullscreen(), "enterFullscreen"),
|
|
656
|
+
exitFullscreen: /* @__PURE__ */ chunkWGEGR3DF_cjs.__name(() => document.exitFullscreen(), "exitFullscreen"),
|
|
657
|
+
get currentTime() {
|
|
658
|
+
return videoRef.current?.currentTime ?? 0;
|
|
659
|
+
},
|
|
660
|
+
get duration() {
|
|
661
|
+
return videoRef.current?.duration ?? 0;
|
|
662
|
+
},
|
|
663
|
+
get paused() {
|
|
664
|
+
return videoRef.current?.paused ?? true;
|
|
665
|
+
}
|
|
666
|
+
}),
|
|
667
|
+
[]
|
|
668
|
+
);
|
|
669
|
+
const isMountedRef = react.useRef(true);
|
|
670
|
+
react.useEffect(() => {
|
|
671
|
+
isMountedRef.current = true;
|
|
672
|
+
return () => {
|
|
673
|
+
isMountedRef.current = false;
|
|
674
|
+
if (contentKeyRef.current) {
|
|
675
|
+
chunkXTBRWVIV_cjs.useMediaCacheStore.getState().releaseBlobUrl(contentKeyRef.current);
|
|
676
|
+
contentKeyRef.current = null;
|
|
677
|
+
}
|
|
678
|
+
};
|
|
679
|
+
}, []);
|
|
680
|
+
react.useEffect(() => {
|
|
681
|
+
if (contentKeyRef.current) {
|
|
682
|
+
const newKey = source.type === "blob" ? chunkXTBRWVIV_cjs.generateContentKey(source.data) : null;
|
|
683
|
+
if (newKey !== contentKeyRef.current) {
|
|
684
|
+
releaseBlobUrl(contentKeyRef.current);
|
|
685
|
+
contentKeyRef.current = null;
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
setHasError(false);
|
|
689
|
+
setIsLoading(true);
|
|
690
|
+
switch (source.type) {
|
|
691
|
+
case "stream": {
|
|
692
|
+
const streamSource = source;
|
|
693
|
+
const url = getOrCreateStreamUrl(
|
|
694
|
+
streamSource.sessionId,
|
|
695
|
+
streamSource.path,
|
|
696
|
+
streamSource.getStreamUrl
|
|
697
|
+
);
|
|
698
|
+
videoDebug.load(url, "stream");
|
|
699
|
+
setVideoUrl(url);
|
|
700
|
+
break;
|
|
701
|
+
}
|
|
702
|
+
case "blob": {
|
|
703
|
+
const blobSource = source;
|
|
704
|
+
const contentKey = chunkXTBRWVIV_cjs.generateContentKey(blobSource.data);
|
|
705
|
+
contentKeyRef.current = contentKey;
|
|
706
|
+
const url = getOrCreateBlobUrl(
|
|
707
|
+
contentKey,
|
|
708
|
+
blobSource.data,
|
|
709
|
+
blobSource.mimeType || "video/mp4"
|
|
710
|
+
);
|
|
711
|
+
videoDebug.load(url, "blob");
|
|
712
|
+
setVideoUrl(url);
|
|
713
|
+
break;
|
|
714
|
+
}
|
|
715
|
+
case "data-url": {
|
|
716
|
+
const dataUrlSource = source;
|
|
717
|
+
videoDebug.load(dataUrlSource.data.slice(0, 50) + "...", "data-url");
|
|
718
|
+
setVideoUrl(dataUrlSource.data);
|
|
719
|
+
break;
|
|
720
|
+
}
|
|
721
|
+
default:
|
|
722
|
+
videoDebug.error("Invalid video source type", { type: source.type });
|
|
723
|
+
setVideoUrl(null);
|
|
724
|
+
setHasError(true);
|
|
725
|
+
setErrorMessage("Invalid video source");
|
|
726
|
+
}
|
|
727
|
+
}, [source]);
|
|
728
|
+
const getSourceKey = react.useCallback(() => {
|
|
729
|
+
switch (source.type) {
|
|
730
|
+
case "stream":
|
|
731
|
+
return `stream:${source.sessionId}:${source.path}`;
|
|
732
|
+
case "blob":
|
|
733
|
+
return contentKeyRef.current ? `blob:${contentKeyRef.current}` : null;
|
|
734
|
+
case "data-url":
|
|
735
|
+
return `data:${source.data.slice(0, 50)}`;
|
|
736
|
+
default:
|
|
737
|
+
return null;
|
|
738
|
+
}
|
|
739
|
+
}, [source]);
|
|
740
|
+
const handleCanPlay = react.useCallback(() => {
|
|
741
|
+
const video = videoRef.current;
|
|
742
|
+
if (video) {
|
|
743
|
+
videoDebug.state("canplay", { duration: video.duration, buffered: video.buffered.length });
|
|
744
|
+
videoDebug.buffer(video.buffered, video.duration);
|
|
745
|
+
video.volume = savedSettings.volume;
|
|
746
|
+
}
|
|
747
|
+
setIsLoading(false);
|
|
748
|
+
const sourceKey = getSourceKey();
|
|
749
|
+
if (sourceKey && video) {
|
|
750
|
+
const cachedPosition = getVideoPosition(sourceKey);
|
|
751
|
+
if (cachedPosition && cachedPosition > 0) {
|
|
752
|
+
const duration = video.duration;
|
|
753
|
+
if (cachedPosition < duration - 1) {
|
|
754
|
+
videoDebug.debug(`Restoring position: ${cachedPosition}s`);
|
|
755
|
+
video.currentTime = cachedPosition;
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
onCanPlay?.();
|
|
760
|
+
}, [getSourceKey, onCanPlay, savedSettings.volume]);
|
|
761
|
+
const handleTimeUpdate = react.useCallback(() => {
|
|
762
|
+
const video = videoRef.current;
|
|
763
|
+
if (!video) return;
|
|
764
|
+
const sourceKey = getSourceKey();
|
|
765
|
+
if (sourceKey && video.currentTime > 0) {
|
|
766
|
+
const timeSinceLastSave = video.currentTime - lastSavedTimeRef.current;
|
|
767
|
+
if (timeSinceLastSave >= 5 || timeSinceLastSave < 0) {
|
|
768
|
+
saveVideoPosition(sourceKey, video.currentTime);
|
|
769
|
+
lastSavedTimeRef.current = video.currentTime;
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
onTimeUpdate?.(video.currentTime, video.duration);
|
|
773
|
+
}, [getSourceKey, onTimeUpdate]);
|
|
774
|
+
const handlePause = react.useCallback(() => {
|
|
775
|
+
const video = videoRef.current;
|
|
776
|
+
const sourceKey = getSourceKey();
|
|
777
|
+
if (sourceKey && video && video.currentTime > 0) {
|
|
778
|
+
saveVideoPosition(sourceKey, video.currentTime);
|
|
779
|
+
lastSavedTimeRef.current = video.currentTime;
|
|
780
|
+
}
|
|
781
|
+
onPause?.();
|
|
782
|
+
}, [getSourceKey, onPause]);
|
|
783
|
+
const handleProgress = react.useCallback(() => {
|
|
784
|
+
const video = videoRef.current;
|
|
785
|
+
if (!video || !onBufferProgress) return;
|
|
786
|
+
if (video.buffered.length > 0) {
|
|
787
|
+
const bufferedEnd = video.buffered.end(video.buffered.length - 1);
|
|
788
|
+
const duration = video.duration;
|
|
789
|
+
if (duration > 0 && !isNaN(bufferedEnd)) {
|
|
790
|
+
onBufferProgress(bufferedEnd, duration);
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
}, [onBufferProgress]);
|
|
794
|
+
react.useEffect(() => {
|
|
795
|
+
if (!showPreloader || !isLoading) return;
|
|
796
|
+
const timeout = setTimeout(() => {
|
|
797
|
+
setIsLoading(false);
|
|
798
|
+
}, preloaderTimeout);
|
|
799
|
+
return () => clearTimeout(timeout);
|
|
800
|
+
}, [showPreloader, isLoading, preloaderTimeout]);
|
|
801
|
+
const handleContextMenu = /* @__PURE__ */ chunkWGEGR3DF_cjs.__name((e) => {
|
|
802
|
+
if (disableContextMenu) {
|
|
803
|
+
e.preventDefault();
|
|
804
|
+
}
|
|
805
|
+
}, "handleContextMenu");
|
|
806
|
+
const handleLoadedData = /* @__PURE__ */ chunkWGEGR3DF_cjs.__name(() => {
|
|
807
|
+
setIsLoading(false);
|
|
808
|
+
}, "handleLoadedData");
|
|
809
|
+
const handleError = /* @__PURE__ */ chunkWGEGR3DF_cjs.__name(() => {
|
|
810
|
+
const video = videoRef.current;
|
|
811
|
+
if (video) {
|
|
812
|
+
videoDebug.error("Video error", { code: video.error?.code, message: video.error?.message });
|
|
813
|
+
}
|
|
814
|
+
setIsLoading(false);
|
|
815
|
+
setHasError(true);
|
|
816
|
+
setErrorMessage("Failed to load video");
|
|
817
|
+
onError?.("Video playback error");
|
|
818
|
+
}, "handleError");
|
|
819
|
+
react.useEffect(() => {
|
|
820
|
+
const video = videoRef.current;
|
|
821
|
+
if (!video) return;
|
|
822
|
+
const handleLoadedMetadata = /* @__PURE__ */ chunkWGEGR3DF_cjs.__name(() => {
|
|
823
|
+
videoDebug.state("loadedmetadata", { duration: video.duration });
|
|
824
|
+
}, "handleLoadedMetadata");
|
|
825
|
+
const handleSeeking = /* @__PURE__ */ chunkWGEGR3DF_cjs.__name(() => {
|
|
826
|
+
videoDebug.event("seeking", { currentTime: video.currentTime });
|
|
827
|
+
}, "handleSeeking");
|
|
828
|
+
const handleSeeked = /* @__PURE__ */ chunkWGEGR3DF_cjs.__name(() => {
|
|
829
|
+
videoDebug.event("seeked", { currentTime: video.currentTime });
|
|
830
|
+
videoDebug.buffer(video.buffered, video.duration);
|
|
831
|
+
}, "handleSeeked");
|
|
832
|
+
const handleWaiting = /* @__PURE__ */ chunkWGEGR3DF_cjs.__name(() => {
|
|
833
|
+
videoDebug.warn("WAITING - buffering...");
|
|
834
|
+
videoDebug.buffer(video.buffered, video.duration);
|
|
835
|
+
}, "handleWaiting");
|
|
836
|
+
const handleStalled = /* @__PURE__ */ chunkWGEGR3DF_cjs.__name(() => {
|
|
837
|
+
videoDebug.warn("STALLED - network issue");
|
|
838
|
+
videoDebug.buffer(video.buffered, video.duration);
|
|
839
|
+
}, "handleStalled");
|
|
840
|
+
video.addEventListener("loadedmetadata", handleLoadedMetadata);
|
|
841
|
+
video.addEventListener("seeking", handleSeeking);
|
|
842
|
+
video.addEventListener("seeked", handleSeeked);
|
|
843
|
+
video.addEventListener("waiting", handleWaiting);
|
|
844
|
+
video.addEventListener("stalled", handleStalled);
|
|
845
|
+
return () => {
|
|
846
|
+
video.removeEventListener("loadedmetadata", handleLoadedMetadata);
|
|
847
|
+
video.removeEventListener("seeking", handleSeeking);
|
|
848
|
+
video.removeEventListener("seeked", handleSeeked);
|
|
849
|
+
video.removeEventListener("waiting", handleWaiting);
|
|
850
|
+
video.removeEventListener("stalled", handleStalled);
|
|
851
|
+
};
|
|
852
|
+
}, [videoUrl]);
|
|
853
|
+
react.useEffect(() => {
|
|
854
|
+
const video = videoRef.current;
|
|
855
|
+
if (!video) return;
|
|
856
|
+
const handleVolumeChange = /* @__PURE__ */ chunkWGEGR3DF_cjs.__name(() => {
|
|
857
|
+
updateVolume(video.volume);
|
|
858
|
+
}, "handleVolumeChange");
|
|
859
|
+
video.addEventListener("volumechange", handleVolumeChange);
|
|
860
|
+
return () => video.removeEventListener("volumechange", handleVolumeChange);
|
|
861
|
+
}, [videoUrl, updateVolume]);
|
|
862
|
+
const isFillMode = aspectRatio === "fill";
|
|
863
|
+
const computedAspectRatio = aspectRatio === "auto" || aspectRatio === "fill" ? void 0 : aspectRatio;
|
|
864
|
+
const renderErrorFallback = /* @__PURE__ */ chunkWGEGR3DF_cjs.__name(() => {
|
|
865
|
+
const fallbackProps = { error: errorMessage, retry };
|
|
866
|
+
if (typeof errorFallback === "function") {
|
|
867
|
+
return errorFallback(fallbackProps);
|
|
868
|
+
}
|
|
869
|
+
if (errorFallback) {
|
|
870
|
+
return errorFallback;
|
|
871
|
+
}
|
|
872
|
+
return /* @__PURE__ */ jsxRuntime.jsx(DefaultErrorFallback2, { ...fallbackProps });
|
|
873
|
+
}, "renderErrorFallback");
|
|
874
|
+
if (!videoUrl || hasError) {
|
|
875
|
+
if (isFillMode) {
|
|
876
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: lib.cn("relative w-full h-full overflow-hidden bg-black", className), children: renderErrorFallback() });
|
|
877
|
+
}
|
|
878
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: lib.cn("relative overflow-hidden bg-black", className), children: /* @__PURE__ */ jsxRuntime.jsx(uiCore.AspectRatio, { ratio: computedAspectRatio, children: renderErrorFallback() }) });
|
|
879
|
+
}
|
|
880
|
+
const videoContent = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
881
|
+
showPreloader && isLoading && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute inset-0 flex items-center justify-center bg-black/50 z-10", children: /* @__PURE__ */ jsxRuntime.jsx(uiCore.Preloader, { size: "lg", spinnerClassName: "text-white" }) }),
|
|
882
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
883
|
+
"video",
|
|
884
|
+
{
|
|
885
|
+
ref: videoRef,
|
|
886
|
+
src: videoUrl,
|
|
887
|
+
className: lib.cn(
|
|
888
|
+
"w-full h-full object-contain",
|
|
889
|
+
isLoading && "opacity-0",
|
|
890
|
+
videoClassName
|
|
891
|
+
),
|
|
892
|
+
autoPlay,
|
|
893
|
+
muted,
|
|
894
|
+
loop,
|
|
895
|
+
playsInline,
|
|
896
|
+
preload,
|
|
897
|
+
controls,
|
|
898
|
+
crossOrigin: "anonymous",
|
|
899
|
+
poster: source.poster,
|
|
900
|
+
onContextMenu: handleContextMenu,
|
|
901
|
+
onLoadStart,
|
|
902
|
+
onCanPlay: handleCanPlay,
|
|
903
|
+
onLoadedData: handleLoadedData,
|
|
904
|
+
onPlay,
|
|
905
|
+
onPause: handlePause,
|
|
906
|
+
onEnded,
|
|
907
|
+
onError: handleError,
|
|
908
|
+
onTimeUpdate: handleTimeUpdate,
|
|
909
|
+
onProgress: handleProgress
|
|
910
|
+
}
|
|
911
|
+
)
|
|
912
|
+
] });
|
|
913
|
+
if (isFillMode) {
|
|
914
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: lib.cn("relative w-full h-full overflow-hidden bg-black", className), children: videoContent });
|
|
915
|
+
}
|
|
916
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: lib.cn("relative overflow-hidden bg-black", className), children: /* @__PURE__ */ jsxRuntime.jsx(uiCore.AspectRatio, { ratio: computedAspectRatio, children: videoContent }) });
|
|
917
|
+
}
|
|
918
|
+
);
|
|
919
|
+
StreamProvider.displayName = "StreamProvider";
|
|
920
|
+
var VideoPlayerContext = react.createContext(null);
|
|
921
|
+
function VideoPlayerProvider({
|
|
922
|
+
children,
|
|
923
|
+
getStreamUrl,
|
|
924
|
+
sessionId
|
|
925
|
+
}) {
|
|
926
|
+
const value = react.useMemo(
|
|
927
|
+
() => ({ getStreamUrl, sessionId }),
|
|
928
|
+
[getStreamUrl, sessionId]
|
|
929
|
+
);
|
|
930
|
+
return /* @__PURE__ */ jsxRuntime.jsx(VideoPlayerContext.Provider, { value, children });
|
|
931
|
+
}
|
|
932
|
+
chunkWGEGR3DF_cjs.__name(VideoPlayerProvider, "VideoPlayerProvider");
|
|
933
|
+
function useVideoPlayerContext() {
|
|
934
|
+
return react.useContext(VideoPlayerContext);
|
|
935
|
+
}
|
|
936
|
+
chunkWGEGR3DF_cjs.__name(useVideoPlayerContext, "useVideoPlayerContext");
|
|
937
|
+
|
|
938
|
+
// src/tools/VideoPlayer/utils/resolvers.ts
|
|
939
|
+
function resolvePlayerMode(source, mode = "auto") {
|
|
940
|
+
if (mode !== "auto") {
|
|
941
|
+
return mode;
|
|
942
|
+
}
|
|
943
|
+
switch (source.type) {
|
|
944
|
+
case "youtube":
|
|
945
|
+
case "vimeo":
|
|
946
|
+
case "hls":
|
|
947
|
+
case "dash":
|
|
948
|
+
return "vidstack";
|
|
949
|
+
case "stream":
|
|
950
|
+
case "blob":
|
|
951
|
+
return "streaming";
|
|
952
|
+
case "data-url":
|
|
953
|
+
case "url":
|
|
954
|
+
default:
|
|
955
|
+
return "native";
|
|
956
|
+
}
|
|
957
|
+
}
|
|
958
|
+
chunkWGEGR3DF_cjs.__name(resolvePlayerMode, "resolvePlayerMode");
|
|
959
|
+
function isSimpleStreamSource(source) {
|
|
960
|
+
return source.type === "stream" && !("getStreamUrl" in source);
|
|
961
|
+
}
|
|
962
|
+
chunkWGEGR3DF_cjs.__name(isSimpleStreamSource, "isSimpleStreamSource");
|
|
963
|
+
function resolveStreamSource(source, context) {
|
|
964
|
+
if (!context?.getStreamUrl) {
|
|
965
|
+
console.warn(
|
|
966
|
+
"VideoPlayer: Stream source requires getStreamUrl. Either provide it in source or wrap with VideoPlayerProvider."
|
|
967
|
+
);
|
|
968
|
+
return null;
|
|
969
|
+
}
|
|
970
|
+
const sessionId = source.sessionId || context.sessionId;
|
|
971
|
+
if (!sessionId) {
|
|
972
|
+
console.warn("VideoPlayer: Stream source requires sessionId.");
|
|
973
|
+
return null;
|
|
974
|
+
}
|
|
975
|
+
return {
|
|
976
|
+
type: "stream",
|
|
977
|
+
sessionId,
|
|
978
|
+
path: source.path,
|
|
979
|
+
getStreamUrl: context.getStreamUrl,
|
|
980
|
+
mimeType: source.mimeType,
|
|
981
|
+
title: source.title,
|
|
982
|
+
poster: source.poster
|
|
983
|
+
};
|
|
984
|
+
}
|
|
985
|
+
chunkWGEGR3DF_cjs.__name(resolveStreamSource, "resolveStreamSource");
|
|
986
|
+
|
|
987
|
+
// src/tools/VideoPlayer/utils/fileSource.ts
|
|
988
|
+
function resolveFileSource(options) {
|
|
989
|
+
const {
|
|
990
|
+
content,
|
|
991
|
+
path,
|
|
992
|
+
mimeType,
|
|
993
|
+
sessionId,
|
|
994
|
+
loadMethod,
|
|
995
|
+
getStreamUrl,
|
|
996
|
+
title,
|
|
997
|
+
poster
|
|
998
|
+
} = options;
|
|
999
|
+
const contentSize = content ? typeof content === "string" ? content.length : content.byteLength : 0;
|
|
1000
|
+
const hasContent = contentSize > 0;
|
|
1001
|
+
if (loadMethod === "http_stream" && !hasContent && sessionId && getStreamUrl) {
|
|
1002
|
+
return {
|
|
1003
|
+
type: "stream",
|
|
1004
|
+
sessionId,
|
|
1005
|
+
path,
|
|
1006
|
+
getStreamUrl,
|
|
1007
|
+
mimeType,
|
|
1008
|
+
title,
|
|
1009
|
+
poster
|
|
1010
|
+
};
|
|
1011
|
+
}
|
|
1012
|
+
if (typeof content === "string" && hasContent) {
|
|
1013
|
+
return {
|
|
1014
|
+
type: "data-url",
|
|
1015
|
+
data: content,
|
|
1016
|
+
title,
|
|
1017
|
+
poster
|
|
1018
|
+
};
|
|
1019
|
+
}
|
|
1020
|
+
if (content instanceof ArrayBuffer && hasContent) {
|
|
1021
|
+
return {
|
|
1022
|
+
type: "blob",
|
|
1023
|
+
data: content,
|
|
1024
|
+
mimeType: mimeType || "video/mp4",
|
|
1025
|
+
title,
|
|
1026
|
+
poster
|
|
1027
|
+
};
|
|
1028
|
+
}
|
|
1029
|
+
return null;
|
|
1030
|
+
}
|
|
1031
|
+
chunkWGEGR3DF_cjs.__name(resolveFileSource, "resolveFileSource");
|
|
1032
|
+
var VideoPlayer = react.forwardRef(
|
|
1033
|
+
({
|
|
1034
|
+
source: rawSource,
|
|
1035
|
+
mode = "auto",
|
|
1036
|
+
aspectRatio = 16 / 9,
|
|
1037
|
+
autoPlay = false,
|
|
1038
|
+
muted = false,
|
|
1039
|
+
loop = false,
|
|
1040
|
+
playsInline = true,
|
|
1041
|
+
controls = true,
|
|
1042
|
+
preload = "metadata",
|
|
1043
|
+
theme = "default",
|
|
1044
|
+
showInfo = false,
|
|
1045
|
+
className,
|
|
1046
|
+
videoClassName,
|
|
1047
|
+
disableContextMenu = false,
|
|
1048
|
+
showPreloader = true,
|
|
1049
|
+
preloaderTimeout = 5e3,
|
|
1050
|
+
errorFallback,
|
|
1051
|
+
onPlay,
|
|
1052
|
+
onPause,
|
|
1053
|
+
onEnded,
|
|
1054
|
+
onError,
|
|
1055
|
+
onLoadStart,
|
|
1056
|
+
onCanPlay,
|
|
1057
|
+
onTimeUpdate
|
|
1058
|
+
}, ref) => {
|
|
1059
|
+
const context = useVideoPlayerContext();
|
|
1060
|
+
const source = react.useMemo(() => {
|
|
1061
|
+
if (isSimpleStreamSource(rawSource)) {
|
|
1062
|
+
const resolved = resolveStreamSource(rawSource, context);
|
|
1063
|
+
if (!resolved) {
|
|
1064
|
+
return null;
|
|
1065
|
+
}
|
|
1066
|
+
return resolved;
|
|
1067
|
+
}
|
|
1068
|
+
return rawSource;
|
|
1069
|
+
}, [rawSource, context]);
|
|
1070
|
+
if (!source) {
|
|
1071
|
+
const errorMessage = "Stream source requires VideoPlayerProvider with getStreamUrl and sessionId";
|
|
1072
|
+
if (typeof errorFallback === "function") {
|
|
1073
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className, style: { aspectRatio: aspectRatio === "fill" ? void 0 : aspectRatio }, children: errorFallback({ error: errorMessage }) });
|
|
1074
|
+
}
|
|
1075
|
+
if (errorFallback) {
|
|
1076
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className, style: { aspectRatio: aspectRatio === "fill" ? void 0 : aspectRatio }, children: errorFallback });
|
|
1077
|
+
}
|
|
1078
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1079
|
+
"div",
|
|
1080
|
+
{
|
|
1081
|
+
className,
|
|
1082
|
+
style: {
|
|
1083
|
+
aspectRatio: aspectRatio === "fill" ? void 0 : aspectRatio,
|
|
1084
|
+
display: "flex",
|
|
1085
|
+
alignItems: "center",
|
|
1086
|
+
justifyContent: "center",
|
|
1087
|
+
backgroundColor: "black",
|
|
1088
|
+
color: "white"
|
|
1089
|
+
},
|
|
1090
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("p", { children: errorMessage })
|
|
1091
|
+
}
|
|
1092
|
+
);
|
|
1093
|
+
}
|
|
1094
|
+
const resolvedMode = resolvePlayerMode(source, mode);
|
|
1095
|
+
const commonProps = {
|
|
1096
|
+
aspectRatio,
|
|
1097
|
+
autoPlay,
|
|
1098
|
+
muted,
|
|
1099
|
+
loop,
|
|
1100
|
+
playsInline,
|
|
1101
|
+
controls,
|
|
1102
|
+
preload,
|
|
1103
|
+
className,
|
|
1104
|
+
onPlay,
|
|
1105
|
+
onPause,
|
|
1106
|
+
onEnded,
|
|
1107
|
+
onError,
|
|
1108
|
+
onLoadStart,
|
|
1109
|
+
onCanPlay,
|
|
1110
|
+
onTimeUpdate
|
|
1111
|
+
};
|
|
1112
|
+
switch (resolvedMode) {
|
|
1113
|
+
case "vidstack":
|
|
1114
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1115
|
+
VidstackProvider,
|
|
1116
|
+
{
|
|
1117
|
+
ref,
|
|
1118
|
+
source,
|
|
1119
|
+
theme,
|
|
1120
|
+
showInfo,
|
|
1121
|
+
errorFallback,
|
|
1122
|
+
...commonProps
|
|
1123
|
+
}
|
|
1124
|
+
);
|
|
1125
|
+
case "streaming":
|
|
1126
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1127
|
+
StreamProvider,
|
|
1128
|
+
{
|
|
1129
|
+
ref,
|
|
1130
|
+
source,
|
|
1131
|
+
videoClassName,
|
|
1132
|
+
disableContextMenu,
|
|
1133
|
+
showPreloader,
|
|
1134
|
+
preloaderTimeout,
|
|
1135
|
+
errorFallback,
|
|
1136
|
+
...commonProps
|
|
1137
|
+
}
|
|
1138
|
+
);
|
|
1139
|
+
case "native":
|
|
1140
|
+
default:
|
|
1141
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1142
|
+
NativeProvider,
|
|
1143
|
+
{
|
|
1144
|
+
ref,
|
|
1145
|
+
source,
|
|
1146
|
+
videoClassName,
|
|
1147
|
+
disableContextMenu,
|
|
1148
|
+
showPreloader,
|
|
1149
|
+
preloaderTimeout,
|
|
1150
|
+
...commonProps
|
|
1151
|
+
}
|
|
1152
|
+
);
|
|
1153
|
+
}
|
|
1154
|
+
}
|
|
1155
|
+
);
|
|
1156
|
+
VideoPlayer.displayName = "VideoPlayer";
|
|
1157
|
+
function VideoControls({ player, className }) {
|
|
1158
|
+
const store = react$1.useMediaStore(player);
|
|
1159
|
+
const remote = react$1.useMediaRemote();
|
|
1160
|
+
const isPaused = store.paused;
|
|
1161
|
+
const isMuted = store.muted;
|
|
1162
|
+
const isFullscreen = store.fullscreen;
|
|
1163
|
+
const currentTime = store.currentTime;
|
|
1164
|
+
const duration = store.duration;
|
|
1165
|
+
const volume = store.volume;
|
|
1166
|
+
const formatTime = /* @__PURE__ */ chunkWGEGR3DF_cjs.__name((seconds) => {
|
|
1167
|
+
if (!seconds || seconds < 0) return "0:00";
|
|
1168
|
+
const minutes = Math.floor(seconds / 60);
|
|
1169
|
+
const secs = Math.floor(seconds % 60);
|
|
1170
|
+
return `${minutes}:${secs.toString().padStart(2, "0")}`;
|
|
1171
|
+
}, "formatTime");
|
|
1172
|
+
const handleProgressClick = /* @__PURE__ */ chunkWGEGR3DF_cjs.__name((e) => {
|
|
1173
|
+
if (!duration) return;
|
|
1174
|
+
const rect = e.currentTarget.getBoundingClientRect();
|
|
1175
|
+
const clickX = e.clientX - rect.left;
|
|
1176
|
+
const percentage = clickX / rect.width;
|
|
1177
|
+
const newTime = percentage * duration;
|
|
1178
|
+
remote.seek(newTime);
|
|
1179
|
+
}, "handleProgressClick");
|
|
1180
|
+
const handleVolumeChange = /* @__PURE__ */ chunkWGEGR3DF_cjs.__name((e) => {
|
|
1181
|
+
const rect = e.currentTarget.getBoundingClientRect();
|
|
1182
|
+
const clickX = e.clientX - rect.left;
|
|
1183
|
+
const percentage = Math.max(0, Math.min(1, clickX / rect.width));
|
|
1184
|
+
remote.changeVolume(percentage);
|
|
1185
|
+
if (percentage > 0 && isMuted) {
|
|
1186
|
+
remote.toggleMuted();
|
|
1187
|
+
}
|
|
1188
|
+
}, "handleVolumeChange");
|
|
1189
|
+
const progress = duration > 0 ? currentTime / duration * 100 : 0;
|
|
1190
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1191
|
+
"div",
|
|
1192
|
+
{
|
|
1193
|
+
className: lib.cn(
|
|
1194
|
+
"absolute inset-0 flex flex-col justify-end transition-opacity duration-300",
|
|
1195
|
+
"bg-gradient-to-t from-black/80 via-black/20 to-transparent",
|
|
1196
|
+
"opacity-0 group-hover:opacity-100 focus-within:opacity-100",
|
|
1197
|
+
"pointer-events-none group-hover:pointer-events-auto",
|
|
1198
|
+
className
|
|
1199
|
+
),
|
|
1200
|
+
children: [
|
|
1201
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-4 pb-2 pointer-events-auto", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1202
|
+
"div",
|
|
1203
|
+
{
|
|
1204
|
+
className: "h-1.5 bg-white/20 rounded-full cursor-pointer hover:h-2 transition-all group",
|
|
1205
|
+
onClick: handleProgressClick,
|
|
1206
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1207
|
+
"div",
|
|
1208
|
+
{
|
|
1209
|
+
className: "h-full bg-primary rounded-full transition-all relative group-hover:bg-primary/90",
|
|
1210
|
+
style: { width: `${progress}%` },
|
|
1211
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute right-0 top-1/2 -translate-y-1/2 w-3 h-3 bg-white rounded-full opacity-0 group-hover:opacity-100 transition-opacity" })
|
|
1212
|
+
}
|
|
1213
|
+
)
|
|
1214
|
+
}
|
|
1215
|
+
) }),
|
|
1216
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-4 px-4 pb-4 pointer-events-auto", children: [
|
|
1217
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1218
|
+
"button",
|
|
1219
|
+
{
|
|
1220
|
+
onClick: () => remote.togglePaused(),
|
|
1221
|
+
className: "text-white hover:text-primary transition-colors p-1.5 hover:bg-white/10 rounded-full",
|
|
1222
|
+
children: isPaused ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Play, { className: "h-6 w-6" }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Pause, { className: "h-6 w-6" })
|
|
1223
|
+
}
|
|
1224
|
+
),
|
|
1225
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-white text-sm font-medium", children: [
|
|
1226
|
+
formatTime(currentTime),
|
|
1227
|
+
" / ",
|
|
1228
|
+
formatTime(duration)
|
|
1229
|
+
] }),
|
|
1230
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1" }),
|
|
1231
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 group/volume", children: [
|
|
1232
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1233
|
+
"button",
|
|
1234
|
+
{
|
|
1235
|
+
onClick: () => remote.toggleMuted(),
|
|
1236
|
+
className: "text-white hover:text-primary transition-colors p-1.5 hover:bg-white/10 rounded-full",
|
|
1237
|
+
children: isMuted || volume === 0 ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.VolumeX, { className: "h-5 w-5" }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Volume2, { className: "h-5 w-5" })
|
|
1238
|
+
}
|
|
1239
|
+
),
|
|
1240
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1241
|
+
"div",
|
|
1242
|
+
{
|
|
1243
|
+
className: "w-0 group-hover/volume:w-20 transition-all overflow-hidden",
|
|
1244
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1245
|
+
"div",
|
|
1246
|
+
{
|
|
1247
|
+
className: "h-1.5 bg-white/20 rounded-full cursor-pointer hover:h-2 transition-all",
|
|
1248
|
+
onClick: handleVolumeChange,
|
|
1249
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1250
|
+
"div",
|
|
1251
|
+
{
|
|
1252
|
+
className: "h-full bg-white rounded-full transition-all",
|
|
1253
|
+
style: { width: `${volume * 100}%` }
|
|
1254
|
+
}
|
|
1255
|
+
)
|
|
1256
|
+
}
|
|
1257
|
+
)
|
|
1258
|
+
}
|
|
1259
|
+
)
|
|
1260
|
+
] }),
|
|
1261
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1262
|
+
"button",
|
|
1263
|
+
{
|
|
1264
|
+
onClick: () => isFullscreen ? remote.exitFullscreen() : remote.enterFullscreen(),
|
|
1265
|
+
className: "text-white hover:text-primary transition-colors p-1.5 hover:bg-white/10 rounded-full",
|
|
1266
|
+
children: isFullscreen ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Minimize, { className: "h-5 w-5" }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Maximize, { className: "h-5 w-5" })
|
|
1267
|
+
}
|
|
1268
|
+
)
|
|
1269
|
+
] })
|
|
1270
|
+
]
|
|
1271
|
+
}
|
|
1272
|
+
);
|
|
1273
|
+
}
|
|
1274
|
+
chunkWGEGR3DF_cjs.__name(VideoControls, "VideoControls");
|
|
1275
|
+
function VideoErrorFallback({
|
|
1276
|
+
error,
|
|
1277
|
+
retry,
|
|
1278
|
+
downloadUrl,
|
|
1279
|
+
downloadFilename,
|
|
1280
|
+
fileSize,
|
|
1281
|
+
showRetry = true,
|
|
1282
|
+
className,
|
|
1283
|
+
icon,
|
|
1284
|
+
title,
|
|
1285
|
+
description
|
|
1286
|
+
}) {
|
|
1287
|
+
const displayTitle = title || error || "Video cannot be previewed";
|
|
1288
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1289
|
+
"div",
|
|
1290
|
+
{
|
|
1291
|
+
className: chunkF2N7P5XU_cjs.cn(
|
|
1292
|
+
"absolute inset-0 flex flex-col items-center justify-center gap-4 bg-black/90 text-white p-6",
|
|
1293
|
+
className
|
|
1294
|
+
),
|
|
1295
|
+
children: [
|
|
1296
|
+
icon || /* @__PURE__ */ jsxRuntime.jsx(lucideReact.FileVideo, { className: "w-16 h-16 text-muted-foreground" }),
|
|
1297
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-lg font-medium text-center", children: displayTitle }),
|
|
1298
|
+
(description || fileSize) && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground text-center", children: description || fileSize }),
|
|
1299
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3 mt-2", children: [
|
|
1300
|
+
showRetry && retry && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1301
|
+
chunkF2N7P5XU_cjs.Button,
|
|
1302
|
+
{
|
|
1303
|
+
variant: "outline",
|
|
1304
|
+
size: "sm",
|
|
1305
|
+
onClick: retry,
|
|
1306
|
+
className: "gap-2",
|
|
1307
|
+
children: [
|
|
1308
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.RefreshCw, { className: "w-4 h-4" }),
|
|
1309
|
+
"Retry"
|
|
1310
|
+
]
|
|
1311
|
+
}
|
|
1312
|
+
),
|
|
1313
|
+
downloadUrl && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1314
|
+
chunkF2N7P5XU_cjs.DownloadButton,
|
|
1315
|
+
{
|
|
1316
|
+
url: downloadUrl,
|
|
1317
|
+
filename: downloadFilename,
|
|
1318
|
+
variant: "default",
|
|
1319
|
+
size: "sm",
|
|
1320
|
+
children: "Download to view"
|
|
1321
|
+
}
|
|
1322
|
+
)
|
|
1323
|
+
] })
|
|
1324
|
+
]
|
|
1325
|
+
}
|
|
1326
|
+
);
|
|
1327
|
+
}
|
|
1328
|
+
chunkWGEGR3DF_cjs.__name(VideoErrorFallback, "VideoErrorFallback");
|
|
1329
|
+
function createVideoErrorFallback(options) {
|
|
1330
|
+
return (props, source) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1331
|
+
VideoErrorFallback,
|
|
1332
|
+
{
|
|
1333
|
+
...props,
|
|
1334
|
+
downloadUrl: options.getDownloadUrl?.(source),
|
|
1335
|
+
downloadFilename: options.getFilename?.(source),
|
|
1336
|
+
fileSize: options.getFileSize?.(source),
|
|
1337
|
+
showRetry: options.showRetry
|
|
1338
|
+
}
|
|
1339
|
+
);
|
|
1340
|
+
}
|
|
1341
|
+
chunkWGEGR3DF_cjs.__name(createVideoErrorFallback, "createVideoErrorFallback");
|
|
1342
|
+
|
|
1343
|
+
exports.NativeProvider = NativeProvider;
|
|
1344
|
+
exports.StreamProvider = StreamProvider;
|
|
1345
|
+
exports.VideoControls = VideoControls;
|
|
1346
|
+
exports.VideoErrorFallback = VideoErrorFallback;
|
|
1347
|
+
exports.VideoPlayer = VideoPlayer;
|
|
1348
|
+
exports.VideoPlayerProvider = VideoPlayerProvider;
|
|
1349
|
+
exports.VidstackProvider = VidstackProvider;
|
|
1350
|
+
exports.createVideoErrorFallback = createVideoErrorFallback;
|
|
1351
|
+
exports.isSimpleStreamSource = isSimpleStreamSource;
|
|
1352
|
+
exports.resolveFileSource = resolveFileSource;
|
|
1353
|
+
exports.resolvePlayerMode = resolvePlayerMode;
|
|
1354
|
+
exports.resolveStreamSource = resolveStreamSource;
|
|
1355
|
+
exports.useVideoPlayerContext = useVideoPlayerContext;
|
|
1356
|
+
//# sourceMappingURL=chunk-47T5ECYV.cjs.map
|
|
1357
|
+
//# sourceMappingURL=chunk-47T5ECYV.cjs.map
|