@therealtinhtute/baroiplayer 1.0.2 → 1.0.4
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/core.js +1 -1
- package/dist/core.mjs +2 -2
- package/dist/hooks-BCMilGRf.cjs +4 -0
- package/dist/hooks-BCMilGRf.cjs.map +1 -0
- package/dist/{hooks-BhW_i-9L.js → hooks-BPtHV1ZT.js} +793 -764
- package/dist/hooks-BPtHV1ZT.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/{minimal-components-BsqodtY8.cjs → minimal-components-BHJMuaL7.cjs} +2 -2
- package/dist/{minimal-components-BsqodtY8.cjs.map → minimal-components-BHJMuaL7.cjs.map} +1 -1
- package/dist/{minimal-components-B0bILe18.js → minimal-components-BmqRefl1.js} +2 -2
- package/dist/{minimal-components-B0bILe18.js.map → minimal-components-BmqRefl1.js.map} +1 -1
- package/dist/package.json +18 -4
- package/dist/src/hooks/use-enhanced-media-player.ts +12 -12
- package/dist/src/hooks/use-intelligent-preloading.ts +27 -22
- package/dist/src/hooks/use-media-player.ts +0 -2
- package/dist/src/hooks/use-memory-optimization.ts +19 -19
- package/dist/src/index-legacy.ts +2 -1
- package/dist/styles/globals.css +462 -0
- package/dist/styles/pixel-art.css +46 -0
- package/dist/styles/videojs.css +100 -0
- package/package.json +4 -2
- package/src/hooks/use-enhanced-media-player.ts +12 -12
- package/src/hooks/use-intelligent-preloading.ts +27 -22
- package/src/hooks/use-media-player.ts +0 -2
- package/src/hooks/use-memory-optimization.ts +19 -19
- package/src/index-legacy.ts +2 -1
- package/dist/hooks-BhW_i-9L.js.map +0 -1
- package/dist/hooks-DTXeB5Z-.cjs +0 -4
- package/dist/hooks-DTXeB5Z-.cjs.map +0 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import * as re from "react";
|
|
2
|
-
import
|
|
3
|
-
import { c as
|
|
2
|
+
import B, { useEffect as j, useOptimistic as ce, useRef as z, useTransition as le, useCallback as A, useMemo as ue, useState as Y } from "react";
|
|
3
|
+
import { c as N, d as pe, e as W, M as H } from "./context-Af84FynT.js";
|
|
4
4
|
import { s as ve } from "./utils-nTO4AnHo.js";
|
|
5
5
|
function Ie({ enabled: e = !0, state: t, controls: n, seekStep: s = 10, volumeStep: u = 0.1 }) {
|
|
6
6
|
const o = (a) => {
|
|
7
7
|
if (!e)
|
|
8
8
|
return;
|
|
9
|
-
const
|
|
10
|
-
if (!(
|
|
9
|
+
const m = a.target;
|
|
10
|
+
if (!(m.tagName === "INPUT" || m.tagName === "TEXTAREA" || m.contentEditable === "true"))
|
|
11
11
|
switch (a.code) {
|
|
12
12
|
case "Space":
|
|
13
13
|
case "KeyK":
|
|
@@ -42,8 +42,8 @@ function Ie({ enabled: e = !0, state: t, controls: n, seekStep: s = 10, volumeSt
|
|
|
42
42
|
case "Digit8":
|
|
43
43
|
case "Digit9":
|
|
44
44
|
a.preventDefault();
|
|
45
|
-
const
|
|
46
|
-
n.seek(t.duration *
|
|
45
|
+
const F = parseInt(a.code.replace("Digit", ""), 10) / 10;
|
|
46
|
+
n.seek(t.duration * F);
|
|
47
47
|
break;
|
|
48
48
|
case "Home":
|
|
49
49
|
a.preventDefault(), n.seek(0);
|
|
@@ -53,7 +53,7 @@ function Ie({ enabled: e = !0, state: t, controls: n, seekStep: s = 10, volumeSt
|
|
|
53
53
|
break;
|
|
54
54
|
}
|
|
55
55
|
};
|
|
56
|
-
return
|
|
56
|
+
return j(() => {
|
|
57
57
|
if (e)
|
|
58
58
|
return document.addEventListener("keydown", o), () => {
|
|
59
59
|
document.removeEventListener("keydown", o);
|
|
@@ -102,33 +102,33 @@ function ye(e, t) {
|
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
104
|
function Ee(e) {
|
|
105
|
-
const t =
|
|
106
|
-
|
|
107
|
-
}, [e, s]), o =
|
|
105
|
+
const t = B.useSyncExternalStore(e.subscribe, e.getState, e.getState), [n, s] = ce(t, ye), u = B.useCallback(async (m) => {
|
|
106
|
+
m.optimistic && s(m), await e.dispatchOptimistic(m);
|
|
107
|
+
}, [e, s]), o = B.useMemo(() => ({
|
|
108
108
|
// Play/Pause with immediate feedback
|
|
109
109
|
togglePlayPause: async () => {
|
|
110
|
-
const
|
|
110
|
+
const m = {
|
|
111
111
|
type: n.isPlaying ? "PAUSE" : "PLAY",
|
|
112
112
|
optimistic: !0,
|
|
113
113
|
timestamp: Date.now()
|
|
114
114
|
};
|
|
115
|
-
await u(
|
|
115
|
+
await u(m);
|
|
116
116
|
},
|
|
117
117
|
// Volume control with immediate slider feedback
|
|
118
|
-
setVolumeOptimistic: async (
|
|
118
|
+
setVolumeOptimistic: async (m) => {
|
|
119
119
|
const S = {
|
|
120
120
|
type: "SET_VOLUME",
|
|
121
|
-
detail: Math.max(0, Math.min(1,
|
|
121
|
+
detail: Math.max(0, Math.min(1, m)),
|
|
122
122
|
optimistic: !0,
|
|
123
123
|
timestamp: Date.now()
|
|
124
124
|
};
|
|
125
125
|
await u(S);
|
|
126
126
|
},
|
|
127
127
|
// Seek with immediate scrub feedback
|
|
128
|
-
seekOptimistic: async (
|
|
128
|
+
seekOptimistic: async (m) => {
|
|
129
129
|
const S = {
|
|
130
130
|
type: "SEEK",
|
|
131
|
-
detail:
|
|
131
|
+
detail: m,
|
|
132
132
|
optimistic: !0,
|
|
133
133
|
timestamp: Date.now()
|
|
134
134
|
};
|
|
@@ -136,27 +136,27 @@ function Ee(e) {
|
|
|
136
136
|
},
|
|
137
137
|
// Mute toggle with immediate icon change
|
|
138
138
|
toggleMuteOptimistic: async () => {
|
|
139
|
-
const
|
|
139
|
+
const m = {
|
|
140
140
|
type: "TOGGLE_MUTE",
|
|
141
141
|
optimistic: !0,
|
|
142
142
|
timestamp: Date.now()
|
|
143
143
|
};
|
|
144
|
-
await u(
|
|
144
|
+
await u(m);
|
|
145
145
|
},
|
|
146
146
|
// Fullscreen toggle with immediate layout change
|
|
147
147
|
toggleFullscreenOptimistic: async () => {
|
|
148
|
-
const
|
|
148
|
+
const m = {
|
|
149
149
|
type: n.isFullscreen ? "EXIT_FULLSCREEN" : "ENTER_FULLSCREEN",
|
|
150
150
|
optimistic: !0,
|
|
151
151
|
timestamp: Date.now()
|
|
152
152
|
};
|
|
153
|
-
await u(
|
|
153
|
+
await u(m);
|
|
154
154
|
},
|
|
155
155
|
// Playback rate with immediate feedback
|
|
156
|
-
setPlaybackRateOptimistic: async (
|
|
156
|
+
setPlaybackRateOptimistic: async (m) => {
|
|
157
157
|
const S = {
|
|
158
158
|
type: "SET_PLAYBACK_RATE",
|
|
159
|
-
detail:
|
|
159
|
+
detail: m,
|
|
160
160
|
optimistic: !0,
|
|
161
161
|
timestamp: Date.now()
|
|
162
162
|
};
|
|
@@ -164,14 +164,14 @@ function Ee(e) {
|
|
|
164
164
|
},
|
|
165
165
|
// Subtitle toggle with immediate visibility change
|
|
166
166
|
toggleSubtitlesOptimistic: async () => {
|
|
167
|
-
const
|
|
167
|
+
const m = {
|
|
168
168
|
type: "TOGGLE_SUBTITLES",
|
|
169
169
|
optimistic: !0,
|
|
170
170
|
timestamp: Date.now()
|
|
171
171
|
};
|
|
172
|
-
await u(
|
|
172
|
+
await u(m);
|
|
173
173
|
}
|
|
174
|
-
}), [n, u]), a =
|
|
174
|
+
}), [n, u]), a = B.useMemo(() => ({
|
|
175
175
|
isPlaying: n.isPlaying,
|
|
176
176
|
currentTime: n.currentTime,
|
|
177
177
|
volume: n.volume,
|
|
@@ -203,7 +203,7 @@ function me(e) {
|
|
|
203
203
|
const t = Math.floor(e / 60), n = Math.floor(e % 60), s = Math.floor(t / 60);
|
|
204
204
|
return s > 0 ? `${s}:${String(t % 60).padStart(2, "0")}:${String(n).padStart(2, "0")}` : `${t}:${String(n).padStart(2, "0")}`;
|
|
205
205
|
}
|
|
206
|
-
function
|
|
206
|
+
function K(e, t) {
|
|
207
207
|
return ((n, s = !1) => {
|
|
208
208
|
const u = {
|
|
209
209
|
type: e,
|
|
@@ -215,43 +215,43 @@ function $(e, t) {
|
|
|
215
215
|
});
|
|
216
216
|
}
|
|
217
217
|
function we(e) {
|
|
218
|
-
const [t, n] =
|
|
219
|
-
return
|
|
218
|
+
const [t, n] = B.useState(e.getActionState());
|
|
219
|
+
return B.useEffect(() => e.subscribe(() => {
|
|
220
220
|
const u = e.getActionState();
|
|
221
221
|
n((o) => JSON.stringify(o) !== JSON.stringify(u) ? u : o);
|
|
222
222
|
}), [e]), t;
|
|
223
223
|
}
|
|
224
224
|
function Te(e) {
|
|
225
|
-
const t =
|
|
225
|
+
const t = B.useMemo(() => ({
|
|
226
226
|
// Playback actions
|
|
227
|
-
play:
|
|
228
|
-
pause:
|
|
229
|
-
seek:
|
|
227
|
+
play: K(N.PLAY, e),
|
|
228
|
+
pause: K(N.PAUSE, e),
|
|
229
|
+
seek: K(N.SEEK, e),
|
|
230
230
|
// Volume actions
|
|
231
|
-
setVolume:
|
|
232
|
-
mute:
|
|
233
|
-
unmute:
|
|
234
|
-
toggleMute:
|
|
231
|
+
setVolume: K(N.SET_VOLUME, e),
|
|
232
|
+
mute: K(N.MUTE, e),
|
|
233
|
+
unmute: K(N.UNMUTE, e),
|
|
234
|
+
toggleMute: K(N.TOGGLE_MUTE, e),
|
|
235
235
|
// Media state actions
|
|
236
|
-
setDuration:
|
|
237
|
-
setCurrentTime:
|
|
238
|
-
setBuffered:
|
|
239
|
-
setLoading:
|
|
240
|
-
setError:
|
|
236
|
+
setDuration: K(N.SET_DURATION, e),
|
|
237
|
+
setCurrentTime: K(N.SET_CURRENT_TIME, e),
|
|
238
|
+
setBuffered: K(N.SET_BUFFERED, e),
|
|
239
|
+
setLoading: K(N.SET_LOADING, e),
|
|
240
|
+
setError: K(N.SET_ERROR, e),
|
|
241
241
|
// Display actions
|
|
242
|
-
enterFullscreen:
|
|
243
|
-
exitFullscreen:
|
|
244
|
-
enterPiP:
|
|
245
|
-
exitPiP:
|
|
242
|
+
enterFullscreen: K(N.ENTER_FULLSCREEN, e),
|
|
243
|
+
exitFullscreen: K(N.EXIT_FULLSCREEN, e),
|
|
244
|
+
enterPiP: K(N.ENTER_PIP, e),
|
|
245
|
+
exitPiP: K(N.EXIT_PIP, e),
|
|
246
246
|
// Advanced actions
|
|
247
|
-
setPlaybackRate:
|
|
248
|
-
setSubtitleTrack:
|
|
249
|
-
setRendition:
|
|
250
|
-
toggleSubtitles:
|
|
247
|
+
setPlaybackRate: K(N.SET_PLAYBACK_RATE, e),
|
|
248
|
+
setSubtitleTrack: K(N.SET_SUBTITLE_TRACK, e),
|
|
249
|
+
setRendition: K(N.SET_RENDITION, e),
|
|
250
|
+
toggleSubtitles: K(N.TOGGLE_SUBTITLES, e),
|
|
251
251
|
// Preview actions
|
|
252
|
-
previewTime:
|
|
253
|
-
clearPreview:
|
|
254
|
-
}), [e]), n = we(e), s =
|
|
252
|
+
previewTime: K(N.PREVIEW_TIME, e),
|
|
253
|
+
clearPreview: K(N.CLEAR_PREVIEW, e)
|
|
254
|
+
}), [e]), n = we(e), s = B.useMemo(() => ({
|
|
255
255
|
// These actions benefit from immediate UI feedback
|
|
256
256
|
togglePlayPause: async (o) => {
|
|
257
257
|
o ? await t.pause(!0) : await t.play(!0);
|
|
@@ -260,13 +260,13 @@ function Te(e) {
|
|
|
260
260
|
await t.previewTime(o, !0), await t.seek(o, !0);
|
|
261
261
|
},
|
|
262
262
|
adjustVolume: async (o, a) => {
|
|
263
|
-
const
|
|
264
|
-
await t.setVolume(
|
|
263
|
+
const m = Math.max(0, Math.min(1, a + o));
|
|
264
|
+
await t.setVolume(m, !0);
|
|
265
265
|
},
|
|
266
266
|
toggleFullscreenOptimistic: async (o) => {
|
|
267
267
|
o ? await t.exitFullscreen(!0) : await t.enterFullscreen(!0);
|
|
268
268
|
}
|
|
269
|
-
}), [t]), u =
|
|
269
|
+
}), [t]), u = B.useCallback(async () => {
|
|
270
270
|
const { lastAction: o } = n;
|
|
271
271
|
o && n.error && await e.dispatchOptimistic({
|
|
272
272
|
...o,
|
|
@@ -285,17 +285,17 @@ function Te(e) {
|
|
|
285
285
|
};
|
|
286
286
|
}
|
|
287
287
|
function Oe(e) {
|
|
288
|
-
const t =
|
|
289
|
-
|
|
290
|
-
const
|
|
291
|
-
|
|
292
|
-
const
|
|
288
|
+
const t = z(null), n = z(null), [s, u] = le(), [o, a] = le();
|
|
289
|
+
B.useRef(0);
|
|
290
|
+
const m = B.useRef(0), S = B.useRef(0);
|
|
291
|
+
z();
|
|
292
|
+
const F = z(0), D = pe(), g = "getOptimisticState" in D, r = W((i) => i.isPlaying), y = W((i) => i.currentTime), p = W((i) => i.duration), d = W((i) => i.volume), v = W((i) => i.isMuted), L = W((i) => i.isLoading), h = W((i) => i.isBuffering), l = W((i) => i.error), T = W((i) => i.buffered), E = W((i) => i.isFullscreen), w = D, b = g ? Ee(w) : null, f = g ? Te(w) : null, [G, R] = B.useState({
|
|
293
293
|
frameRate: 0,
|
|
294
294
|
averageRenderTime: 0,
|
|
295
295
|
droppedFrames: 0,
|
|
296
296
|
bufferHealth: 0
|
|
297
|
-
}), [
|
|
298
|
-
ce(y, (i, k) => Math.max(0, Math.min(p || 0, k))),
|
|
297
|
+
}), [I, P] = ce(d, (i, k) => Math.max(0, Math.min(1, k)));
|
|
298
|
+
ce(y, (i, k) => Math.max(0, Math.min(p || 0, k))), j(() => {
|
|
299
299
|
const i = t.current;
|
|
300
300
|
if (!i)
|
|
301
301
|
return;
|
|
@@ -307,8 +307,8 @@ function Oe(e) {
|
|
|
307
307
|
preload: e.preload,
|
|
308
308
|
crossOrigin: e.crossOrigin
|
|
309
309
|
};
|
|
310
|
-
Object.entries(k).forEach(([
|
|
311
|
-
|
|
310
|
+
Object.entries(k).forEach(([V, X]) => {
|
|
311
|
+
X !== void 0 && (i[V] = X);
|
|
312
312
|
}), i.setAttribute("preload", e.preloadStrategy === "eager" ? "auto" : "metadata"), e.bufferingStrategy === "aggressive" && i.setAttribute("buffered", "auto"), i instanceof HTMLVideoElement && (i.style.willChange = "transform", i.style.transform = "translateZ(0)");
|
|
313
313
|
}, [
|
|
314
314
|
e.volume,
|
|
@@ -320,106 +320,106 @@ function Oe(e) {
|
|
|
320
320
|
e.preloadStrategy,
|
|
321
321
|
e.bufferingStrategy
|
|
322
322
|
]);
|
|
323
|
-
const
|
|
323
|
+
const M = A(() => {
|
|
324
324
|
const i = t.current;
|
|
325
325
|
if (!i)
|
|
326
326
|
return;
|
|
327
327
|
const k = performance.now();
|
|
328
328
|
if (e.enableTimeUpdateThrottling !== !1) {
|
|
329
|
-
if (k -
|
|
329
|
+
if (k - F.current < (e.timeUpdateThrottleMs || 100))
|
|
330
330
|
return;
|
|
331
|
-
|
|
331
|
+
F.current = k;
|
|
332
332
|
}
|
|
333
333
|
u(() => {
|
|
334
|
-
g &&
|
|
334
|
+
g && f && f.setCurrentTime(i.currentTime);
|
|
335
335
|
});
|
|
336
|
-
}, [e.enableTimeUpdateThrottling, e.timeUpdateThrottleMs, g,
|
|
336
|
+
}, [e.enableTimeUpdateThrottling, e.timeUpdateThrottleMs, g, f]), C = A(() => {
|
|
337
337
|
u(() => {
|
|
338
|
-
g &&
|
|
338
|
+
g && f && f.play(!0);
|
|
339
339
|
}), e.onPlay?.();
|
|
340
|
-
}, [g,
|
|
340
|
+
}, [g, f, e.onPlay]), O = A(() => {
|
|
341
341
|
u(() => {
|
|
342
|
-
g &&
|
|
342
|
+
g && f && f.pause(!0);
|
|
343
343
|
}), e.onPause?.();
|
|
344
|
-
}, [g,
|
|
344
|
+
}, [g, f, e.onPause]), U = A(() => {
|
|
345
345
|
const i = t.current;
|
|
346
346
|
i && u(() => {
|
|
347
|
-
g &&
|
|
347
|
+
g && f && (f.setVolume(i.volume, !0), i.muted ? f.mute(!0) : f.unmute(!0));
|
|
348
348
|
});
|
|
349
|
-
}, [g,
|
|
349
|
+
}, [g, f]), c = A(() => {
|
|
350
350
|
a(() => {
|
|
351
351
|
});
|
|
352
|
+
}, []), _ = A(() => {
|
|
352
353
|
}, []), ee = A(() => {
|
|
353
|
-
}, []), f = A(() => {
|
|
354
354
|
const i = t.current;
|
|
355
355
|
i && u(() => {
|
|
356
|
-
g &&
|
|
356
|
+
g && f && f.setBuffered(i.buffered);
|
|
357
357
|
});
|
|
358
|
-
}, [g,
|
|
358
|
+
}, [g, f]), Q = A(() => {
|
|
359
359
|
const i = performance.now();
|
|
360
|
-
if (i - S.current > 0 && (
|
|
361
|
-
const
|
|
362
|
-
|
|
363
|
-
...
|
|
364
|
-
frameRate:
|
|
365
|
-
droppedFrames: Math.max(0, 60 -
|
|
366
|
-
})),
|
|
360
|
+
if (i - S.current > 0 && (m.current++, m.current >= 60)) {
|
|
361
|
+
const V = Math.round(m.current * 1e3 / (i - S.current));
|
|
362
|
+
R((X) => ({
|
|
363
|
+
...X,
|
|
364
|
+
frameRate: V,
|
|
365
|
+
droppedFrames: Math.max(0, 60 - V)
|
|
366
|
+
})), m.current = 0, S.current = i;
|
|
367
367
|
}
|
|
368
368
|
}, []);
|
|
369
|
-
|
|
369
|
+
j(() => {
|
|
370
370
|
const i = t.current;
|
|
371
371
|
if (!i)
|
|
372
372
|
return;
|
|
373
373
|
const k = [
|
|
374
|
-
{ event: "timeupdate", handler:
|
|
375
|
-
{ event: "play", handler:
|
|
376
|
-
{ event: "pause", handler:
|
|
377
|
-
{ event: "volumechange", handler:
|
|
378
|
-
{ event: "seeking", handler:
|
|
379
|
-
{ event: "seeked", handler:
|
|
380
|
-
{ event: "progress", handler:
|
|
381
|
-
{ event: "loadedmetadata", handler: () =>
|
|
382
|
-
{ event: "loadeddata", handler: () =>
|
|
374
|
+
{ event: "timeupdate", handler: M, passive: !0 },
|
|
375
|
+
{ event: "play", handler: C },
|
|
376
|
+
{ event: "pause", handler: O },
|
|
377
|
+
{ event: "volumechange", handler: U },
|
|
378
|
+
{ event: "seeking", handler: c },
|
|
379
|
+
{ event: "seeked", handler: _ },
|
|
380
|
+
{ event: "progress", handler: ee, passive: !0 },
|
|
381
|
+
{ event: "loadedmetadata", handler: () => Q() },
|
|
382
|
+
{ event: "loadeddata", handler: () => Q() }
|
|
383
383
|
];
|
|
384
384
|
k.forEach(({ event: te, handler: ne, passive: ie }) => {
|
|
385
385
|
const oe = ie ? { passive: !0 } : {};
|
|
386
386
|
i.addEventListener(te, ne, oe);
|
|
387
387
|
});
|
|
388
|
-
let
|
|
389
|
-
const
|
|
390
|
-
|
|
388
|
+
let V;
|
|
389
|
+
const X = () => {
|
|
390
|
+
Q(), V = requestAnimationFrame(X);
|
|
391
391
|
};
|
|
392
|
-
return e.enablePerformanceMonitoring &&
|
|
392
|
+
return e.enablePerformanceMonitoring && X(), () => {
|
|
393
393
|
k.forEach(({ event: te, handler: ne }) => {
|
|
394
394
|
i.removeEventListener(te, ne);
|
|
395
|
-
}),
|
|
395
|
+
}), V && cancelAnimationFrame(V);
|
|
396
396
|
};
|
|
397
397
|
}, [
|
|
398
|
-
|
|
399
|
-
|
|
398
|
+
M,
|
|
399
|
+
C,
|
|
400
|
+
O,
|
|
400
401
|
U,
|
|
402
|
+
c,
|
|
401
403
|
_,
|
|
402
|
-
C,
|
|
403
404
|
ee,
|
|
404
|
-
|
|
405
|
-
V,
|
|
405
|
+
Q,
|
|
406
406
|
e.enablePerformanceMonitoring
|
|
407
407
|
]);
|
|
408
408
|
const se = ue(() => {
|
|
409
409
|
const i = async () => {
|
|
410
410
|
const x = t.current;
|
|
411
411
|
if (x)
|
|
412
|
-
if (g &&
|
|
413
|
-
await
|
|
412
|
+
if (g && f)
|
|
413
|
+
await f.play(!0);
|
|
414
414
|
else
|
|
415
415
|
try {
|
|
416
416
|
await x.play();
|
|
417
|
-
} catch (
|
|
418
|
-
console.error("Failed to play media:",
|
|
417
|
+
} catch (q) {
|
|
418
|
+
console.error("Failed to play media:", q);
|
|
419
419
|
}
|
|
420
420
|
}, k = () => {
|
|
421
421
|
const x = t.current;
|
|
422
|
-
x && (g &&
|
|
422
|
+
x && (g && f ? f.pause(!0) : x.pause());
|
|
423
423
|
};
|
|
424
424
|
return {
|
|
425
425
|
play: i,
|
|
@@ -428,40 +428,40 @@ function Oe(e) {
|
|
|
428
428
|
r ? k() : i();
|
|
429
429
|
},
|
|
430
430
|
seek: (x) => {
|
|
431
|
-
const
|
|
432
|
-
if (!
|
|
431
|
+
const q = t.current;
|
|
432
|
+
if (!q)
|
|
433
433
|
return;
|
|
434
434
|
const Z = Math.max(0, Math.min(x, p || 0));
|
|
435
|
-
g &&
|
|
436
|
-
|
|
437
|
-
}) :
|
|
435
|
+
g && f ? a(() => {
|
|
436
|
+
f.seek(Z, !0);
|
|
437
|
+
}) : q.currentTime = Z;
|
|
438
438
|
},
|
|
439
439
|
setVolume: (x) => {
|
|
440
|
-
const
|
|
441
|
-
if (!
|
|
440
|
+
const q = t.current;
|
|
441
|
+
if (!q)
|
|
442
442
|
return;
|
|
443
443
|
const Z = Math.max(0, Math.min(1, x));
|
|
444
|
-
g &&
|
|
445
|
-
|
|
446
|
-
})) :
|
|
444
|
+
g && f ? (P(Z), u(() => {
|
|
445
|
+
f.setVolume(Z, !0);
|
|
446
|
+
})) : q.volume = Z;
|
|
447
447
|
},
|
|
448
448
|
toggleMute: () => {
|
|
449
449
|
const x = t.current;
|
|
450
|
-
x && (g &&
|
|
450
|
+
x && (g && f ? f.toggleMute(!0) : x.muted = !x.muted);
|
|
451
451
|
},
|
|
452
452
|
enterFullscreen: async () => {
|
|
453
453
|
const x = n.current;
|
|
454
454
|
if (!(!x || !document.fullscreenEnabled))
|
|
455
455
|
try {
|
|
456
|
-
await x.requestFullscreen(), g &&
|
|
457
|
-
} catch (
|
|
458
|
-
console.error("Failed to enter fullscreen:",
|
|
456
|
+
await x.requestFullscreen(), g && f && f.enterFullscreen(!0);
|
|
457
|
+
} catch (q) {
|
|
458
|
+
console.error("Failed to enter fullscreen:", q);
|
|
459
459
|
}
|
|
460
460
|
},
|
|
461
461
|
exitFullscreen: async () => {
|
|
462
462
|
if (document.fullscreenElement)
|
|
463
463
|
try {
|
|
464
|
-
await document.exitFullscreen(), g &&
|
|
464
|
+
await document.exitFullscreen(), g && f && f.exitFullscreen(!0);
|
|
465
465
|
} catch (x) {
|
|
466
466
|
console.error("Failed to exit fullscreen:", x);
|
|
467
467
|
}
|
|
@@ -471,34 +471,34 @@ function Oe(e) {
|
|
|
471
471
|
r,
|
|
472
472
|
p,
|
|
473
473
|
g,
|
|
474
|
-
|
|
474
|
+
f,
|
|
475
475
|
u,
|
|
476
476
|
a,
|
|
477
477
|
P
|
|
478
478
|
]), ae = ue(() => ({
|
|
479
|
-
isPlaying:
|
|
480
|
-
currentTime:
|
|
481
|
-
duration:
|
|
482
|
-
volume:
|
|
483
|
-
isMuted:
|
|
484
|
-
isLoading:
|
|
485
|
-
isBuffering:
|
|
486
|
-
error:
|
|
487
|
-
buffered:
|
|
488
|
-
isFullscreen:
|
|
479
|
+
isPlaying: b?.isPlaying ?? r,
|
|
480
|
+
currentTime: b?.currentTime ?? y,
|
|
481
|
+
duration: b?.duration ?? p,
|
|
482
|
+
volume: b?.volume ?? I,
|
|
483
|
+
isMuted: b?.isMuted ?? v,
|
|
484
|
+
isLoading: b?.isBuffering ?? L,
|
|
485
|
+
isBuffering: b?.isBuffering ?? h,
|
|
486
|
+
error: b?.error ?? l,
|
|
487
|
+
buffered: b?.buffered ?? T,
|
|
488
|
+
isFullscreen: b?.isFullscreen ?? E,
|
|
489
489
|
progress: p > 0 ? y / p : 0,
|
|
490
490
|
isTransitioning: s || o,
|
|
491
|
-
canPlay: !
|
|
491
|
+
canPlay: !L && !h && !l
|
|
492
492
|
}), [
|
|
493
|
-
|
|
493
|
+
b,
|
|
494
494
|
r,
|
|
495
495
|
y,
|
|
496
496
|
p,
|
|
497
|
-
|
|
497
|
+
I,
|
|
498
498
|
v,
|
|
499
|
-
|
|
499
|
+
L,
|
|
500
500
|
h,
|
|
501
|
-
|
|
501
|
+
l,
|
|
502
502
|
T,
|
|
503
503
|
E,
|
|
504
504
|
s,
|
|
@@ -510,17 +510,17 @@ function Oe(e) {
|
|
|
510
510
|
containerRef: n,
|
|
511
511
|
// State
|
|
512
512
|
state: ae,
|
|
513
|
-
actualState:
|
|
513
|
+
actualState: b?.actualState,
|
|
514
514
|
// Controls
|
|
515
515
|
controls: se,
|
|
516
516
|
// Performance metrics
|
|
517
|
-
performanceMetrics:
|
|
517
|
+
performanceMetrics: G,
|
|
518
518
|
isTransitioning: s || o,
|
|
519
519
|
// Enhanced features
|
|
520
|
-
actions:
|
|
521
|
-
actionState:
|
|
520
|
+
actions: b?.actions,
|
|
521
|
+
actionState: b?.actionState,
|
|
522
522
|
// Optimistic features
|
|
523
|
-
optimisticState:
|
|
523
|
+
optimisticState: b,
|
|
524
524
|
isEnhanced: g
|
|
525
525
|
};
|
|
526
526
|
}
|
|
@@ -533,8 +533,8 @@ function Ue(e = {}) {
|
|
|
533
533
|
enableGC: s = !0,
|
|
534
534
|
monitorMemory: u = !0
|
|
535
535
|
} = e;
|
|
536
|
-
|
|
537
|
-
const o =
|
|
536
|
+
z();
|
|
537
|
+
const o = z(/* @__PURE__ */ new Set()), a = z(/* @__PURE__ */ new Map()), m = z(/* @__PURE__ */ new Set()), S = z(/* @__PURE__ */ new Set()), F = A(() => {
|
|
538
538
|
if (typeof window > "u" || !("memory" in performance))
|
|
539
539
|
return { used: 0, total: 0, limit: 0 };
|
|
540
540
|
const h = performance.memory;
|
|
@@ -543,87 +543,87 @@ function Ue(e = {}) {
|
|
|
543
543
|
total: h.totalJSHeapSize,
|
|
544
544
|
limit: h.jsHeapSizeLimit
|
|
545
545
|
};
|
|
546
|
-
}, []), [
|
|
546
|
+
}, []), [D, g] = B.useState({
|
|
547
547
|
used: 0,
|
|
548
548
|
total: 0,
|
|
549
549
|
limit: 0,
|
|
550
550
|
usage: 0,
|
|
551
551
|
isHighUsage: !1
|
|
552
552
|
});
|
|
553
|
-
|
|
553
|
+
j(() => {
|
|
554
554
|
if (!u)
|
|
555
555
|
return;
|
|
556
556
|
const h = () => {
|
|
557
|
-
const T =
|
|
557
|
+
const T = F(), E = T.used / 1024 / 1024, w = E > t;
|
|
558
558
|
g({
|
|
559
559
|
...T,
|
|
560
560
|
usage: E,
|
|
561
|
-
isHighUsage:
|
|
562
|
-
}),
|
|
561
|
+
isHighUsage: w
|
|
562
|
+
}), w && s && r();
|
|
563
563
|
};
|
|
564
564
|
h();
|
|
565
|
-
const
|
|
566
|
-
return
|
|
567
|
-
clearInterval(
|
|
565
|
+
const l = p(h, n);
|
|
566
|
+
return m.current.add(l), () => {
|
|
567
|
+
clearInterval(l), m.current.delete(l);
|
|
568
568
|
};
|
|
569
|
-
}, [u,
|
|
569
|
+
}, [u, F, t, s, n]);
|
|
570
570
|
const r = A(() => {
|
|
571
|
-
|
|
571
|
+
m.current.forEach((h) => {
|
|
572
572
|
clearTimeout(h);
|
|
573
|
-
}),
|
|
573
|
+
}), m.current.clear(), S.current.forEach((h) => {
|
|
574
574
|
cancelAnimationFrame(h);
|
|
575
575
|
}), S.current.clear(), o.current.forEach((h) => {
|
|
576
576
|
h.disconnect();
|
|
577
|
-
}), o.current.clear(), a.current.forEach((h,
|
|
577
|
+
}), o.current.clear(), a.current.forEach((h, l) => {
|
|
578
578
|
h.forEach(({ event: T, handler: E }) => {
|
|
579
|
-
|
|
579
|
+
l.removeEventListener(T, E);
|
|
580
580
|
});
|
|
581
581
|
}), a.current.clear(), s && "gc" in window && window.gc();
|
|
582
|
-
}, [s]), y = A((h,
|
|
583
|
-
h.removeEventListener(
|
|
584
|
-
const
|
|
585
|
-
if (
|
|
586
|
-
const
|
|
587
|
-
|
|
582
|
+
}, [s]), y = A((h, l, T, E) => (h.addEventListener(l, T, E), a.current.has(h) || a.current.set(h, []), a.current.get(h).push({ event: l, handler: T }), () => {
|
|
583
|
+
h.removeEventListener(l, T);
|
|
584
|
+
const w = a.current.get(h);
|
|
585
|
+
if (w) {
|
|
586
|
+
const b = w.findIndex((f) => f.event === l && f.handler === T);
|
|
587
|
+
b > -1 && w.splice(b, 1), w.length === 0 && a.current.delete(h);
|
|
588
588
|
}
|
|
589
|
-
}), []), p = A((h,
|
|
590
|
-
const T = p(h,
|
|
591
|
-
return
|
|
592
|
-
clearInterval(T),
|
|
589
|
+
}), []), p = A((h, l) => {
|
|
590
|
+
const T = p(h, l);
|
|
591
|
+
return m.current.add(T), () => {
|
|
592
|
+
clearInterval(T), m.current.delete(T);
|
|
593
593
|
};
|
|
594
|
-
}, []),
|
|
595
|
-
const T =
|
|
596
|
-
return
|
|
597
|
-
clearTimeout(T),
|
|
594
|
+
}, []), d = A((h, l) => {
|
|
595
|
+
const T = d(h, l);
|
|
596
|
+
return m.current.add(T), () => {
|
|
597
|
+
clearTimeout(T), m.current.delete(T);
|
|
598
598
|
};
|
|
599
599
|
}, []), v = A((h) => {
|
|
600
|
-
const
|
|
601
|
-
return S.current.add(
|
|
602
|
-
cancelAnimationFrame(
|
|
600
|
+
const l = v(h);
|
|
601
|
+
return S.current.add(l), () => {
|
|
602
|
+
cancelAnimationFrame(l), S.current.delete(l);
|
|
603
603
|
};
|
|
604
|
-
}, []),
|
|
604
|
+
}, []), L = A((h) => (o.current.add(h), () => {
|
|
605
605
|
h.disconnect(), o.current.delete(h);
|
|
606
606
|
}), []);
|
|
607
|
-
return
|
|
607
|
+
return j(() => () => {
|
|
608
608
|
r();
|
|
609
609
|
}, [r]), {
|
|
610
610
|
// Memory stats
|
|
611
|
-
memoryStats:
|
|
612
|
-
getMemoryUsage:
|
|
611
|
+
memoryStats: D,
|
|
612
|
+
getMemoryUsage: F,
|
|
613
613
|
// Cleanup functions
|
|
614
614
|
performCleanup: r,
|
|
615
615
|
// Safe API functions
|
|
616
616
|
addEventListener: y,
|
|
617
617
|
setInterval: p,
|
|
618
|
-
setTimeout:
|
|
618
|
+
setTimeout: d,
|
|
619
619
|
requestAnimationFrame: v,
|
|
620
|
-
addObserver:
|
|
620
|
+
addObserver: L,
|
|
621
621
|
// Utilities
|
|
622
622
|
formatBytes: (h) => {
|
|
623
623
|
if (h === 0)
|
|
624
624
|
return "0 Bytes";
|
|
625
|
-
const
|
|
626
|
-
return parseFloat((h / Math.pow(
|
|
625
|
+
const l = 1024, T = ["Bytes", "KB", "MB", "GB"], E = Math.floor(Math.log(h) / Math.log(l));
|
|
626
|
+
return parseFloat((h / Math.pow(l, E)).toFixed(2)) + " " + T[E];
|
|
627
627
|
}
|
|
628
628
|
};
|
|
629
629
|
}
|
|
@@ -636,8 +636,8 @@ function be({
|
|
|
636
636
|
}) {
|
|
637
637
|
const o = (a) => {
|
|
638
638
|
if (!e) return;
|
|
639
|
-
const
|
|
640
|
-
if (!(
|
|
639
|
+
const m = a.target;
|
|
640
|
+
if (!(m.tagName === "INPUT" || m.tagName === "TEXTAREA" || m.contentEditable === "true"))
|
|
641
641
|
switch (a.code) {
|
|
642
642
|
case "Space":
|
|
643
643
|
case "KeyK":
|
|
@@ -672,8 +672,8 @@ function be({
|
|
|
672
672
|
case "Digit8":
|
|
673
673
|
case "Digit9":
|
|
674
674
|
a.preventDefault();
|
|
675
|
-
const
|
|
676
|
-
n.seek(t.duration *
|
|
675
|
+
const F = parseInt(a.code.replace("Digit", ""), 10) / 10;
|
|
676
|
+
n.seek(t.duration * F);
|
|
677
677
|
break;
|
|
678
678
|
case "Home":
|
|
679
679
|
a.preventDefault(), n.seek(0);
|
|
@@ -683,7 +683,7 @@ function be({
|
|
|
683
683
|
break;
|
|
684
684
|
}
|
|
685
685
|
};
|
|
686
|
-
return
|
|
686
|
+
return j(() => {
|
|
687
687
|
if (e)
|
|
688
688
|
return document.addEventListener("keydown", o), () => {
|
|
689
689
|
document.removeEventListener("keydown", o);
|
|
@@ -696,91 +696,8 @@ const Ve = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
696
696
|
__proto__: null,
|
|
697
697
|
useKeyboardControls: be
|
|
698
698
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
699
|
-
function
|
|
700
|
-
|
|
701
|
-
const u = {
|
|
702
|
-
type: e,
|
|
703
|
-
detail: n,
|
|
704
|
-
optimistic: s,
|
|
705
|
-
timestamp: Date.now()
|
|
706
|
-
};
|
|
707
|
-
return s ? t.dispatchOptimistic(u) : (t.dispatch(u), Promise.resolve());
|
|
708
|
-
});
|
|
709
|
-
}
|
|
710
|
-
function Se(e) {
|
|
711
|
-
const [t, n] = N.useState(e.getActionState());
|
|
712
|
-
return N.useEffect(() => e.subscribe(() => {
|
|
713
|
-
const u = e.getActionState();
|
|
714
|
-
n(
|
|
715
|
-
(o) => JSON.stringify(o) !== JSON.stringify(u) ? u : o
|
|
716
|
-
);
|
|
717
|
-
}), [e]), t;
|
|
718
|
-
}
|
|
719
|
-
function _e(e) {
|
|
720
|
-
const t = N.useMemo(() => ({
|
|
721
|
-
// Playback actions
|
|
722
|
-
play: G(K.PLAY, e),
|
|
723
|
-
pause: G(K.PAUSE, e),
|
|
724
|
-
seek: G(K.SEEK, e),
|
|
725
|
-
// Volume actions
|
|
726
|
-
setVolume: G(K.SET_VOLUME, e),
|
|
727
|
-
mute: G(K.MUTE, e),
|
|
728
|
-
unmute: G(K.UNMUTE, e),
|
|
729
|
-
toggleMute: G(K.TOGGLE_MUTE, e),
|
|
730
|
-
// Media state actions
|
|
731
|
-
setDuration: G(K.SET_DURATION, e),
|
|
732
|
-
setCurrentTime: G(K.SET_CURRENT_TIME, e),
|
|
733
|
-
setBuffered: G(K.SET_BUFFERED, e),
|
|
734
|
-
setLoading: G(K.SET_LOADING, e),
|
|
735
|
-
setError: G(K.SET_ERROR, e),
|
|
736
|
-
// Display actions
|
|
737
|
-
enterFullscreen: G(K.ENTER_FULLSCREEN, e),
|
|
738
|
-
exitFullscreen: G(K.EXIT_FULLSCREEN, e),
|
|
739
|
-
enterPiP: G(K.ENTER_PIP, e),
|
|
740
|
-
exitPiP: G(K.EXIT_PIP, e),
|
|
741
|
-
// Advanced actions
|
|
742
|
-
setPlaybackRate: G(K.SET_PLAYBACK_RATE, e),
|
|
743
|
-
setSubtitleTrack: G(K.SET_SUBTITLE_TRACK, e),
|
|
744
|
-
setRendition: G(K.SET_RENDITION, e),
|
|
745
|
-
toggleSubtitles: G(K.TOGGLE_SUBTITLES, e),
|
|
746
|
-
// Preview actions
|
|
747
|
-
previewTime: G(K.PREVIEW_TIME, e),
|
|
748
|
-
clearPreview: G(K.CLEAR_PREVIEW, e)
|
|
749
|
-
}), [e]), n = Se(e), s = N.useMemo(() => ({
|
|
750
|
-
// These actions benefit from immediate UI feedback
|
|
751
|
-
togglePlayPause: async (o) => {
|
|
752
|
-
o ? await t.pause(!0) : await t.play(!0);
|
|
753
|
-
},
|
|
754
|
-
seekWithPreview: async (o) => {
|
|
755
|
-
await t.previewTime(o, !0), await t.seek(o, !0);
|
|
756
|
-
},
|
|
757
|
-
adjustVolume: async (o, a) => {
|
|
758
|
-
const d = Math.max(0, Math.min(1, a + o));
|
|
759
|
-
await t.setVolume(d, !0);
|
|
760
|
-
},
|
|
761
|
-
toggleFullscreenOptimistic: async (o) => {
|
|
762
|
-
o ? await t.exitFullscreen(!0) : await t.enterFullscreen(!0);
|
|
763
|
-
}
|
|
764
|
-
}), [t]), u = N.useCallback(async () => {
|
|
765
|
-
const { lastAction: o } = n;
|
|
766
|
-
o && n.error && await e.dispatchOptimistic({
|
|
767
|
-
...o,
|
|
768
|
-
retryCount: (o.retryCount || 0) + 1
|
|
769
|
-
});
|
|
770
|
-
}, [e, n]);
|
|
771
|
-
return {
|
|
772
|
-
...t,
|
|
773
|
-
...s,
|
|
774
|
-
actionState: n,
|
|
775
|
-
retryLastAction: u,
|
|
776
|
-
isLoading: n.pending,
|
|
777
|
-
hasError: !!n.error,
|
|
778
|
-
errorMessage: n.error,
|
|
779
|
-
retryCount: n.retryCount
|
|
780
|
-
};
|
|
781
|
-
}
|
|
782
|
-
function Me() {
|
|
783
|
-
const [e, t] = Q({
|
|
699
|
+
function Se() {
|
|
700
|
+
const [e, t] = Y({
|
|
784
701
|
isPlaying: !1,
|
|
785
702
|
currentTime: 0,
|
|
786
703
|
duration: 0,
|
|
@@ -825,138 +742,130 @@ function Me() {
|
|
|
825
742
|
}
|
|
826
743
|
};
|
|
827
744
|
}
|
|
828
|
-
function
|
|
829
|
-
const t =
|
|
745
|
+
function Me(e) {
|
|
746
|
+
const t = z(null), n = z(null), {
|
|
830
747
|
state: s,
|
|
831
748
|
setPlaying: u,
|
|
832
749
|
setCurrentTime: o,
|
|
833
750
|
setDuration: a,
|
|
834
|
-
setVolume:
|
|
751
|
+
setVolume: m,
|
|
835
752
|
setMuted: S,
|
|
836
|
-
setLoading:
|
|
837
|
-
setFullscreen:
|
|
753
|
+
setLoading: F,
|
|
754
|
+
setFullscreen: D,
|
|
838
755
|
setError: g,
|
|
839
756
|
setBuffered: r
|
|
840
|
-
} =
|
|
841
|
-
|
|
842
|
-
const
|
|
843
|
-
|
|
844
|
-
}, [e,
|
|
757
|
+
} = Se();
|
|
758
|
+
j(() => {
|
|
759
|
+
const c = t.current;
|
|
760
|
+
c && (e.volume !== void 0 && (c.volume = e.volume, m(e.volume)), e.muted !== void 0 && (c.muted = e.muted, S(e.muted)), e.autoPlay !== void 0 && (c.autoplay = e.autoPlay), e.loop !== void 0 && (c.loop = e.loop), e.preload !== void 0 && (c.preload = e.preload), e.crossOrigin !== void 0 && (c.crossOrigin = e.crossOrigin));
|
|
761
|
+
}, [e, m, S]);
|
|
845
762
|
const y = () => {
|
|
846
763
|
u(!0), e.onPlay?.();
|
|
847
764
|
}, p = () => {
|
|
848
765
|
u(!1), e.onPause?.();
|
|
849
|
-
},
|
|
850
|
-
const
|
|
851
|
-
|
|
766
|
+
}, d = () => {
|
|
767
|
+
const c = t.current;
|
|
768
|
+
c && (o(c.currentTime), e.onTimeUpdate?.(c.currentTime));
|
|
852
769
|
}, v = () => {
|
|
853
|
-
const
|
|
854
|
-
|
|
855
|
-
},
|
|
856
|
-
const
|
|
857
|
-
|
|
770
|
+
const c = t.current;
|
|
771
|
+
c && (a(c.duration), e.onDurationChange?.(c.duration));
|
|
772
|
+
}, L = () => {
|
|
773
|
+
const c = t.current;
|
|
774
|
+
c && (m(c.volume), S(c.muted), e.onVolumeChange?.(c.volume));
|
|
858
775
|
}, h = () => {
|
|
859
|
-
|
|
860
|
-
},
|
|
861
|
-
|
|
776
|
+
F(!0), g(null), e.onLoadStart?.();
|
|
777
|
+
}, l = () => {
|
|
778
|
+
F(!1), e.onLoadedData?.();
|
|
862
779
|
}, T = () => {
|
|
863
|
-
const
|
|
864
|
-
if (!
|
|
865
|
-
const
|
|
866
|
-
g(
|
|
780
|
+
const c = t.current;
|
|
781
|
+
if (!c) return;
|
|
782
|
+
const _ = c.error?.message || "An error occurred while loading the media";
|
|
783
|
+
g(_), F(!1), e.onError?.(_);
|
|
867
784
|
}, E = () => {
|
|
868
785
|
u(!1), e.onEnded?.();
|
|
869
|
-
},
|
|
870
|
-
const
|
|
871
|
-
|
|
786
|
+
}, w = () => {
|
|
787
|
+
const c = t.current;
|
|
788
|
+
c && r(c.buffered);
|
|
872
789
|
};
|
|
873
|
-
|
|
874
|
-
const
|
|
875
|
-
if (
|
|
876
|
-
return
|
|
877
|
-
|
|
790
|
+
j(() => {
|
|
791
|
+
const c = t.current;
|
|
792
|
+
if (c)
|
|
793
|
+
return c.addEventListener("play", y), c.addEventListener("pause", p), c.addEventListener("timeupdate", d), c.addEventListener("durationchange", v), c.addEventListener("volumechange", L), c.addEventListener("loadstart", h), c.addEventListener("loadeddata", l), c.addEventListener("error", T), c.addEventListener("ended", E), c.addEventListener("progress", w), () => {
|
|
794
|
+
c.removeEventListener("play", y), c.removeEventListener("pause", p), c.removeEventListener("timeupdate", d), c.removeEventListener("durationchange", v), c.removeEventListener("volumechange", L), c.removeEventListener("loadstart", h), c.removeEventListener("loadeddata", l), c.removeEventListener("error", T), c.removeEventListener("ended", E), c.removeEventListener("progress", w);
|
|
878
795
|
};
|
|
879
796
|
}, [
|
|
880
797
|
y,
|
|
881
798
|
p,
|
|
882
|
-
|
|
799
|
+
d,
|
|
883
800
|
v,
|
|
884
|
-
|
|
801
|
+
L,
|
|
885
802
|
h,
|
|
886
|
-
|
|
803
|
+
l,
|
|
887
804
|
T,
|
|
888
805
|
E,
|
|
889
|
-
|
|
806
|
+
w
|
|
890
807
|
]);
|
|
891
|
-
const
|
|
892
|
-
const
|
|
893
|
-
if (
|
|
808
|
+
const b = async () => {
|
|
809
|
+
const c = t.current;
|
|
810
|
+
if (c)
|
|
894
811
|
try {
|
|
895
|
-
await
|
|
896
|
-
} catch (
|
|
897
|
-
console.error("Failed to play media:",
|
|
812
|
+
await c.play();
|
|
813
|
+
} catch (_) {
|
|
814
|
+
console.error("Failed to play media:", _), g("Failed to play media");
|
|
898
815
|
}
|
|
899
|
-
},
|
|
900
|
-
const
|
|
901
|
-
|
|
902
|
-
},
|
|
903
|
-
s.isPlaying ?
|
|
904
|
-
},
|
|
905
|
-
const
|
|
906
|
-
|
|
907
|
-
},
|
|
908
|
-
const
|
|
909
|
-
if (!
|
|
910
|
-
const
|
|
911
|
-
|
|
816
|
+
}, f = () => {
|
|
817
|
+
const c = t.current;
|
|
818
|
+
c && c.pause();
|
|
819
|
+
}, G = () => {
|
|
820
|
+
s.isPlaying ? f() : b();
|
|
821
|
+
}, R = (c) => {
|
|
822
|
+
const _ = t.current;
|
|
823
|
+
_ && (_.currentTime = Math.max(0, Math.min(c, _.duration || 0)));
|
|
824
|
+
}, I = (c) => {
|
|
825
|
+
const _ = t.current;
|
|
826
|
+
if (!_) return;
|
|
827
|
+
const ee = Math.max(0, Math.min(1, c));
|
|
828
|
+
_.volume = ee;
|
|
912
829
|
}, P = () => {
|
|
913
|
-
const
|
|
914
|
-
|
|
915
|
-
},
|
|
916
|
-
const
|
|
917
|
-
|
|
918
|
-
}, I = () => {
|
|
919
|
-
const f = t.current;
|
|
920
|
-
f && (f.muted = !f.muted);
|
|
921
|
-
}, U = async () => {
|
|
922
|
-
const f = n.current;
|
|
923
|
-
if (!(!f || !document.fullscreenEnabled))
|
|
830
|
+
const c = t.current;
|
|
831
|
+
c && (c.muted = !c.muted);
|
|
832
|
+
}, M = async () => {
|
|
833
|
+
const c = n.current;
|
|
834
|
+
if (!(!c || !document.fullscreenEnabled))
|
|
924
835
|
try {
|
|
925
|
-
await
|
|
926
|
-
} catch (
|
|
927
|
-
console.error("Failed to enter fullscreen:",
|
|
836
|
+
await c.requestFullscreen(), D(!0);
|
|
837
|
+
} catch (_) {
|
|
838
|
+
console.error("Failed to enter fullscreen:", _);
|
|
928
839
|
}
|
|
929
|
-
},
|
|
840
|
+
}, C = async () => {
|
|
930
841
|
if (document.fullscreenElement)
|
|
931
842
|
try {
|
|
932
|
-
await document.exitFullscreen(),
|
|
933
|
-
} catch (
|
|
934
|
-
console.error("Failed to exit fullscreen:",
|
|
843
|
+
await document.exitFullscreen(), D(!1);
|
|
844
|
+
} catch (c) {
|
|
845
|
+
console.error("Failed to exit fullscreen:", c);
|
|
935
846
|
}
|
|
936
|
-
},
|
|
937
|
-
document.fullscreenElement ?
|
|
847
|
+
}, O = () => {
|
|
848
|
+
document.fullscreenElement ? C() : M();
|
|
938
849
|
};
|
|
939
|
-
return
|
|
940
|
-
const
|
|
941
|
-
|
|
850
|
+
return j(() => {
|
|
851
|
+
const c = () => {
|
|
852
|
+
D(!!document.fullscreenElement);
|
|
942
853
|
};
|
|
943
|
-
return document.addEventListener("fullscreenchange",
|
|
944
|
-
document.removeEventListener("fullscreenchange",
|
|
854
|
+
return document.addEventListener("fullscreenchange", c), () => {
|
|
855
|
+
document.removeEventListener("fullscreenchange", c);
|
|
945
856
|
};
|
|
946
|
-
}, [
|
|
857
|
+
}, [D]), {
|
|
947
858
|
state: s,
|
|
948
859
|
controls: {
|
|
949
|
-
play:
|
|
950
|
-
pause:
|
|
951
|
-
toggle:
|
|
952
|
-
seek:
|
|
953
|
-
setVolume:
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
exitFullscreen: _,
|
|
959
|
-
toggleFullscreen: C
|
|
860
|
+
play: b,
|
|
861
|
+
pause: f,
|
|
862
|
+
toggle: G,
|
|
863
|
+
seek: R,
|
|
864
|
+
setVolume: I,
|
|
865
|
+
toggleMute: P,
|
|
866
|
+
enterFullscreen: M,
|
|
867
|
+
exitFullscreen: C,
|
|
868
|
+
toggleFullscreen: O
|
|
960
869
|
},
|
|
961
870
|
mediaRef: t,
|
|
962
871
|
containerRef: n
|
|
@@ -1007,7 +916,7 @@ function de() {
|
|
|
1007
916
|
});
|
|
1008
917
|
return re.useEffect(() => {
|
|
1009
918
|
const n = () => {
|
|
1010
|
-
const a = window.innerWidth,
|
|
919
|
+
const a = window.innerWidth, m = window.innerHeight;
|
|
1011
920
|
t({
|
|
1012
921
|
isMobile: a < J.mobile,
|
|
1013
922
|
isTablet: a >= J.mobile && a < J.desktop,
|
|
@@ -1015,8 +924,8 @@ function de() {
|
|
|
1015
924
|
isTouchDevice: ge(),
|
|
1016
925
|
platform: fe(),
|
|
1017
926
|
supportsHaptics: he(),
|
|
1018
|
-
screenSize: { width: a, height:
|
|
1019
|
-
orientation: a >
|
|
927
|
+
screenSize: { width: a, height: m },
|
|
928
|
+
orientation: a > m ? "landscape" : "portrait"
|
|
1020
929
|
});
|
|
1021
930
|
};
|
|
1022
931
|
window.addEventListener("resize", n), window.addEventListener("orientationchange", n);
|
|
@@ -1026,7 +935,7 @@ function de() {
|
|
|
1026
935
|
};
|
|
1027
936
|
}, []), e;
|
|
1028
937
|
}
|
|
1029
|
-
function
|
|
938
|
+
function _e() {
|
|
1030
939
|
const { platform: e, isMobile: t } = de();
|
|
1031
940
|
re.useEffect(() => {
|
|
1032
941
|
if (t) {
|
|
@@ -1042,7 +951,7 @@ function Be() {
|
|
|
1042
951
|
}
|
|
1043
952
|
}, [e, t]);
|
|
1044
953
|
}
|
|
1045
|
-
function
|
|
954
|
+
function Le() {
|
|
1046
955
|
const { supportsHaptics: e } = de();
|
|
1047
956
|
return { triggerHaptic: re.useCallback((n = "light") => {
|
|
1048
957
|
if (!e) return;
|
|
@@ -1057,7 +966,7 @@ function ke() {
|
|
|
1057
966
|
"vibrate" in navigator && navigator.vibrate(u);
|
|
1058
967
|
}, [e]), supportsHaptics: e };
|
|
1059
968
|
}
|
|
1060
|
-
const
|
|
969
|
+
const ke = {
|
|
1061
970
|
enabledGestures: ["tap", "double-tap", "long-press", "swipe-left", "swipe-right", "swipe-up", "swipe-down", "pinch-in", "pinch-out"],
|
|
1062
971
|
tapThreshold: 200,
|
|
1063
972
|
doubleTapThreshold: 300,
|
|
@@ -1068,106 +977,106 @@ const Pe = {
|
|
|
1068
977
|
rotationThreshold: 15,
|
|
1069
978
|
enableHapticFeedback: !0
|
|
1070
979
|
};
|
|
1071
|
-
function
|
|
1072
|
-
const s = { ...
|
|
980
|
+
function Pe(e, t, n = {}) {
|
|
981
|
+
const s = { ...ke, ...n }, { isTouchDevice: u } = de(), { triggerHaptic: o } = Le(), a = re.useRef({
|
|
1073
982
|
isTracking: !1,
|
|
1074
983
|
touches: [],
|
|
1075
984
|
startTouches: []
|
|
1076
|
-
}),
|
|
985
|
+
}), m = (p) => ({
|
|
1077
986
|
id: p.identifier,
|
|
1078
987
|
x: p.clientX,
|
|
1079
988
|
y: p.clientY,
|
|
1080
989
|
timestamp: Date.now()
|
|
1081
|
-
}), S = (p,
|
|
1082
|
-
const v = Math.max(
|
|
990
|
+
}), S = (p, d) => Math.sqrt(Math.pow(d.x - p.x, 2) + Math.pow(d.y - p.y, 2)), F = (p, d) => {
|
|
991
|
+
const v = Math.max(d.timestamp - p.timestamp, 1);
|
|
1083
992
|
return {
|
|
1084
|
-
x: (
|
|
1085
|
-
y: (
|
|
993
|
+
x: (d.x - p.x) / v,
|
|
994
|
+
y: (d.y - p.y) / v
|
|
1086
995
|
};
|
|
1087
|
-
},
|
|
996
|
+
}, D = (p, d, v, L = {}) => ({
|
|
1088
997
|
type: p,
|
|
1089
|
-
startPoint: { x:
|
|
998
|
+
startPoint: { x: d.x, y: d.y },
|
|
1090
999
|
currentPoint: { x: v.x, y: v.y },
|
|
1091
|
-
duration: v.timestamp -
|
|
1000
|
+
duration: v.timestamp - d.timestamp,
|
|
1092
1001
|
target: e.current,
|
|
1093
1002
|
preventDefault: () => {
|
|
1094
1003
|
},
|
|
1095
|
-
...
|
|
1004
|
+
...L
|
|
1096
1005
|
}), g = re.useCallback((p) => {
|
|
1097
1006
|
if (!s.enabledGestures.length) return;
|
|
1098
|
-
const
|
|
1099
|
-
v.isTracking = !0, v.touches =
|
|
1100
|
-
if (v.touches.length === 1 &&
|
|
1101
|
-
const
|
|
1102
|
-
t(
|
|
1007
|
+
const d = Array.from(p.touches).map(m), v = a.current;
|
|
1008
|
+
v.isTracking = !0, v.touches = d, v.startTouches = [...d], v.longPressTimer && clearTimeout(v.longPressTimer), d.length === 1 && s.enabledGestures.includes("long-press") && (v.longPressTimer = setTimeout(() => {
|
|
1009
|
+
if (v.touches.length === 1 && d[0]) {
|
|
1010
|
+
const L = D("long-press", d[0], d[0]);
|
|
1011
|
+
t(L), s.enableHapticFeedback && o("heavy");
|
|
1103
1012
|
}
|
|
1104
|
-
}, s.longPressThreshold)),
|
|
1013
|
+
}, s.longPressThreshold)), d.length === 2 && d[0] && d[1] && (v.initialDistance = S(d[0], d[1]), v.initialScale = 1, v.lastScale = 1);
|
|
1105
1014
|
}, [s, t, o]), r = re.useCallback((p) => {
|
|
1106
|
-
const
|
|
1107
|
-
if (!
|
|
1108
|
-
const v = Array.from(p.touches).map(
|
|
1109
|
-
if (
|
|
1110
|
-
const
|
|
1111
|
-
if (Math.abs(h - (
|
|
1112
|
-
const T = h > (
|
|
1015
|
+
const d = a.current;
|
|
1016
|
+
if (!d.isTracking) return;
|
|
1017
|
+
const v = Array.from(p.touches).map(m);
|
|
1018
|
+
if (d.touches = v, v.length === 2 && d.initialDistance && v[0] && v[1]) {
|
|
1019
|
+
const L = S(v[0], v[1]), h = L / d.initialDistance;
|
|
1020
|
+
if (Math.abs(h - (d.lastScale || 1)) > s.pinchThreshold) {
|
|
1021
|
+
const T = h > (d.lastScale || 1) ? "pinch-out" : "pinch-in";
|
|
1113
1022
|
if (s.enabledGestures.includes(T)) {
|
|
1114
1023
|
const E = {
|
|
1115
1024
|
x: (v[0].x + v[1].x) / 2,
|
|
1116
1025
|
y: (v[0].y + v[1].y) / 2,
|
|
1117
1026
|
timestamp: Date.now()
|
|
1118
|
-
},
|
|
1119
|
-
x: ((
|
|
1120
|
-
y: ((
|
|
1121
|
-
timestamp:
|
|
1122
|
-
},
|
|
1027
|
+
}, w = {
|
|
1028
|
+
x: ((d.startTouches[0]?.x ?? 0) + (d.startTouches[1]?.x ?? 0)) / 2,
|
|
1029
|
+
y: ((d.startTouches[0]?.y ?? 0) + (d.startTouches[1]?.y ?? 0)) / 2,
|
|
1030
|
+
timestamp: d.startTouches[0]?.timestamp ?? Date.now()
|
|
1031
|
+
}, b = D(T, w, E, {
|
|
1123
1032
|
scale: h,
|
|
1124
|
-
distance:
|
|
1033
|
+
distance: L
|
|
1125
1034
|
});
|
|
1126
|
-
t(
|
|
1035
|
+
t(b), d.lastScale = h;
|
|
1127
1036
|
}
|
|
1128
1037
|
}
|
|
1129
1038
|
}
|
|
1130
|
-
if (
|
|
1131
|
-
const
|
|
1132
|
-
S(
|
|
1039
|
+
if (d.longPressTimer && v.length === 1 && d.startTouches[0] && v[0]) {
|
|
1040
|
+
const L = d.startTouches[0], h = v[0];
|
|
1041
|
+
S(L, h) > s.swipeThreshold && (clearTimeout(d.longPressTimer), d.longPressTimer = void 0);
|
|
1133
1042
|
}
|
|
1134
1043
|
}, [s, t]), y = re.useCallback((p) => {
|
|
1135
|
-
const
|
|
1136
|
-
if (!
|
|
1137
|
-
const v = Array.from(p.changedTouches).map(
|
|
1138
|
-
if (
|
|
1139
|
-
const h =
|
|
1044
|
+
const d = a.current;
|
|
1045
|
+
if (!d.isTracking) return;
|
|
1046
|
+
const v = Array.from(p.changedTouches).map(m), L = Date.now();
|
|
1047
|
+
if (d.longPressTimer && (clearTimeout(d.longPressTimer), d.longPressTimer = void 0), d.startTouches.length === 1 && v.length === 1 && d.startTouches[0] && v[0]) {
|
|
1048
|
+
const h = d.startTouches[0], l = v[0], T = S(h, l), E = l.timestamp - h.timestamp;
|
|
1140
1049
|
if (T > s.swipeThreshold) {
|
|
1141
|
-
const
|
|
1142
|
-
if (
|
|
1143
|
-
let
|
|
1144
|
-
if (
|
|
1145
|
-
const
|
|
1146
|
-
velocity:
|
|
1050
|
+
const w = F(h, l), b = Math.abs(w.x), f = Math.abs(w.y);
|
|
1051
|
+
if (b > s.swipeVelocityThreshold || f > s.swipeVelocityThreshold) {
|
|
1052
|
+
let G;
|
|
1053
|
+
if (b > f ? G = w.x > 0 ? "swipe-right" : "swipe-left" : G = w.y > 0 ? "swipe-down" : "swipe-up", s.enabledGestures.includes(G)) {
|
|
1054
|
+
const R = D(G, h, l, {
|
|
1055
|
+
velocity: w,
|
|
1147
1056
|
distance: T
|
|
1148
1057
|
});
|
|
1149
|
-
t(
|
|
1058
|
+
t(R), s.enableHapticFeedback && o("light");
|
|
1150
1059
|
}
|
|
1151
1060
|
}
|
|
1152
1061
|
} else if (E < s.tapThreshold && T < s.swipeThreshold)
|
|
1153
|
-
if (
|
|
1062
|
+
if (d.lastTap && L - d.lastTap.timestamp < s.doubleTapThreshold && S({ ...d.lastTap.point }, l) < s.swipeThreshold) {
|
|
1154
1063
|
if (s.enabledGestures.includes("double-tap")) {
|
|
1155
|
-
const
|
|
1156
|
-
t(
|
|
1064
|
+
const w = D("double-tap", h, l);
|
|
1065
|
+
t(w), s.enableHapticFeedback && o("medium");
|
|
1157
1066
|
}
|
|
1158
|
-
|
|
1067
|
+
d.lastTap = void 0;
|
|
1159
1068
|
} else {
|
|
1160
1069
|
if (s.enabledGestures.includes("tap")) {
|
|
1161
|
-
const
|
|
1162
|
-
t(
|
|
1070
|
+
const w = D("tap", h, l);
|
|
1071
|
+
t(w), s.enableHapticFeedback && o("light");
|
|
1163
1072
|
}
|
|
1164
|
-
|
|
1165
|
-
timestamp:
|
|
1166
|
-
point: { x:
|
|
1073
|
+
d.lastTap = {
|
|
1074
|
+
timestamp: L,
|
|
1075
|
+
point: { x: l.x, y: l.y }
|
|
1167
1076
|
};
|
|
1168
1077
|
}
|
|
1169
1078
|
}
|
|
1170
|
-
p.touches.length === 0 && (
|
|
1079
|
+
p.touches.length === 0 && (d.isTracking = !1, d.touches = [], d.startTouches = [], d.initialDistance = void 0, d.initialScale = void 0, d.lastScale = void 0);
|
|
1171
1080
|
}, [s, t, o]);
|
|
1172
1081
|
return re.useEffect(() => {
|
|
1173
1082
|
const p = e.current;
|
|
@@ -1179,9 +1088,9 @@ function Fe(e, t, n = {}) {
|
|
|
1179
1088
|
isGestureEnabled: u && s.enabledGestures.length > 0
|
|
1180
1089
|
};
|
|
1181
1090
|
}
|
|
1182
|
-
function
|
|
1091
|
+
function Be(e, t) {
|
|
1183
1092
|
const n = re.useCallback((u) => {
|
|
1184
|
-
const { type: o, distance: a, scale:
|
|
1093
|
+
const { type: o, distance: a, scale: m } = u;
|
|
1185
1094
|
switch (o) {
|
|
1186
1095
|
case "double-tap":
|
|
1187
1096
|
t.onPlayPause?.();
|
|
@@ -1191,41 +1100,41 @@ function Ne(e, t) {
|
|
|
1191
1100
|
t.onSeek?.("backward", S);
|
|
1192
1101
|
break;
|
|
1193
1102
|
case "swipe-right":
|
|
1194
|
-
const
|
|
1195
|
-
t.onSeek?.("forward",
|
|
1103
|
+
const F = Math.min((a || 0) / 10, 30);
|
|
1104
|
+
t.onSeek?.("forward", F);
|
|
1196
1105
|
break;
|
|
1197
1106
|
case "swipe-up":
|
|
1198
1107
|
if (u.startPoint.x > (e.current?.clientWidth || 0) / 2) {
|
|
1199
|
-
const
|
|
1200
|
-
t.onVolumeChange?.("up",
|
|
1108
|
+
const D = Math.min((a || 0) / 100, 0.2);
|
|
1109
|
+
t.onVolumeChange?.("up", D);
|
|
1201
1110
|
}
|
|
1202
1111
|
break;
|
|
1203
1112
|
case "swipe-down":
|
|
1204
1113
|
if (u.startPoint.x > (e.current?.clientWidth || 0) / 2) {
|
|
1205
|
-
const
|
|
1206
|
-
t.onVolumeChange?.("down",
|
|
1114
|
+
const D = Math.min((a || 0) / 100, 0.2);
|
|
1115
|
+
t.onVolumeChange?.("down", D);
|
|
1207
1116
|
}
|
|
1208
1117
|
break;
|
|
1209
1118
|
case "pinch-out":
|
|
1210
|
-
t.onZoom?.(
|
|
1119
|
+
t.onZoom?.(m || 1);
|
|
1211
1120
|
break;
|
|
1212
1121
|
case "pinch-in":
|
|
1213
|
-
t.onZoom?.(
|
|
1122
|
+
t.onZoom?.(m || 1);
|
|
1214
1123
|
break;
|
|
1215
1124
|
case "long-press":
|
|
1216
1125
|
t.onToggleFullscreen?.();
|
|
1217
1126
|
break;
|
|
1218
1127
|
}
|
|
1219
1128
|
}, [t, e]);
|
|
1220
|
-
return
|
|
1129
|
+
return Pe(e, n, {
|
|
1221
1130
|
enabledGestures: ["tap", "double-tap", "long-press", "swipe-left", "swipe-right", "swipe-up", "swipe-down", "pinch-in", "pinch-out"],
|
|
1222
1131
|
enableHapticFeedback: !0,
|
|
1223
1132
|
swipeThreshold: 30,
|
|
1224
1133
|
swipeVelocityThreshold: 0.3
|
|
1225
1134
|
});
|
|
1226
1135
|
}
|
|
1227
|
-
function
|
|
1228
|
-
const t =
|
|
1136
|
+
function Ne(e) {
|
|
1137
|
+
const t = z(null), [n, s] = Y({
|
|
1229
1138
|
isPlaying: !1,
|
|
1230
1139
|
currentTime: 0,
|
|
1231
1140
|
duration: 0,
|
|
@@ -1237,55 +1146,55 @@ function He(e) {
|
|
|
1237
1146
|
isBuffering: !1,
|
|
1238
1147
|
bufferedRanges: []
|
|
1239
1148
|
});
|
|
1240
|
-
return
|
|
1149
|
+
return j(() => {
|
|
1241
1150
|
const r = t.current;
|
|
1242
1151
|
if (!r) return;
|
|
1243
1152
|
const y = () => {
|
|
1244
|
-
s((
|
|
1153
|
+
s((R) => ({ ...R, currentTime: r.currentTime }));
|
|
1245
1154
|
}, p = () => {
|
|
1246
|
-
s((
|
|
1247
|
-
},
|
|
1248
|
-
s((
|
|
1155
|
+
s((R) => ({ ...R, duration: r.duration }));
|
|
1156
|
+
}, d = () => {
|
|
1157
|
+
s((R) => ({ ...R, isPlaying: !0, isBuffering: !1 }));
|
|
1249
1158
|
}, v = () => {
|
|
1250
|
-
s((
|
|
1251
|
-
},
|
|
1252
|
-
s((
|
|
1253
|
-
...
|
|
1159
|
+
s((R) => ({ ...R, isPlaying: !1 }));
|
|
1160
|
+
}, L = () => {
|
|
1161
|
+
s((R) => ({
|
|
1162
|
+
...R,
|
|
1254
1163
|
volume: r.volume,
|
|
1255
1164
|
isMuted: r.muted
|
|
1256
1165
|
}));
|
|
1257
1166
|
}, h = () => {
|
|
1258
|
-
s((
|
|
1259
|
-
},
|
|
1260
|
-
s((
|
|
1167
|
+
s((R) => ({ ...R, isLoading: !0 }));
|
|
1168
|
+
}, l = () => {
|
|
1169
|
+
s((R) => ({ ...R, isLoading: !1 }));
|
|
1261
1170
|
}, T = () => {
|
|
1262
|
-
s((
|
|
1171
|
+
s((R) => ({ ...R, isSeeking: !0 }));
|
|
1263
1172
|
}, E = () => {
|
|
1264
|
-
s((
|
|
1265
|
-
}, b = () => {
|
|
1266
|
-
s((F) => ({ ...F, isBuffering: !0 }));
|
|
1173
|
+
s((R) => ({ ...R, isSeeking: !1 }));
|
|
1267
1174
|
}, w = () => {
|
|
1268
|
-
s((
|
|
1269
|
-
},
|
|
1270
|
-
s((
|
|
1271
|
-
},
|
|
1175
|
+
s((R) => ({ ...R, isBuffering: !0 }));
|
|
1176
|
+
}, b = () => {
|
|
1177
|
+
s((R) => ({ ...R, isBuffering: !1, isLoading: !1 }));
|
|
1178
|
+
}, f = () => {
|
|
1179
|
+
s((R) => ({ ...R, isLoading: !1, isBuffering: !1 }));
|
|
1180
|
+
}, G = () => {
|
|
1272
1181
|
if (!r.buffered || r.buffered.length === 0 || r.duration === 0) {
|
|
1273
|
-
s((
|
|
1182
|
+
s((I) => ({ ...I, bufferedRanges: [] }));
|
|
1274
1183
|
return;
|
|
1275
1184
|
}
|
|
1276
|
-
const
|
|
1277
|
-
for (let
|
|
1278
|
-
const P = r.buffered.start(
|
|
1279
|
-
|
|
1185
|
+
const R = [];
|
|
1186
|
+
for (let I = 0; I < r.buffered.length; I++) {
|
|
1187
|
+
const P = r.buffered.start(I), M = r.buffered.end(I);
|
|
1188
|
+
R.push({
|
|
1280
1189
|
start: P,
|
|
1281
|
-
end:
|
|
1282
|
-
percentage: (
|
|
1190
|
+
end: M,
|
|
1191
|
+
percentage: (M - P) / r.duration * 100
|
|
1283
1192
|
});
|
|
1284
1193
|
}
|
|
1285
|
-
s((
|
|
1194
|
+
s((I) => ({ ...I, bufferedRanges: R }));
|
|
1286
1195
|
};
|
|
1287
|
-
return r.addEventListener("timeupdate", y), r.addEventListener("loadedmetadata", p), r.addEventListener("play",
|
|
1288
|
-
r.removeEventListener("timeupdate", y), r.removeEventListener("loadedmetadata", p), r.removeEventListener("play",
|
|
1196
|
+
return r.addEventListener("timeupdate", y), r.addEventListener("loadedmetadata", p), r.addEventListener("play", d), r.addEventListener("pause", v), r.addEventListener("volumechange", L), r.addEventListener("loadstart", h), r.addEventListener("loadeddata", l), r.addEventListener("seeking", T), r.addEventListener("seeked", E), r.addEventListener("waiting", w), r.addEventListener("playing", b), r.addEventListener("canplay", f), r.addEventListener("progress", G), () => {
|
|
1197
|
+
r.removeEventListener("timeupdate", y), r.removeEventListener("loadedmetadata", p), r.removeEventListener("play", d), r.removeEventListener("pause", v), r.removeEventListener("volumechange", L), r.removeEventListener("loadstart", h), r.removeEventListener("loadeddata", l), r.removeEventListener("seeking", T), r.removeEventListener("seeked", E), r.removeEventListener("waiting", w), r.removeEventListener("playing", b), r.removeEventListener("canplay", f), r.removeEventListener("progress", G);
|
|
1289
1198
|
};
|
|
1290
1199
|
}, []), {
|
|
1291
1200
|
videoRef: t,
|
|
@@ -1322,144 +1231,144 @@ function He(e) {
|
|
|
1322
1231
|
}
|
|
1323
1232
|
};
|
|
1324
1233
|
}
|
|
1325
|
-
function
|
|
1234
|
+
function Fe({
|
|
1326
1235
|
subtitleSrc: e,
|
|
1327
1236
|
subtitleTracks: t = [],
|
|
1328
1237
|
defaultFontSize: n = "medium",
|
|
1329
1238
|
onLoadError: s
|
|
1330
1239
|
} = {}) {
|
|
1331
|
-
const [u, o] =
|
|
1240
|
+
const [u, o] = Y(!1), [a, m] = Y([]), [S, F] = Y(""), [D, g] = Y(null), [r, y] = Y(n), [p, d] = Y(null), [v, L] = Y(!1), h = {
|
|
1332
1241
|
small: "text-sm",
|
|
1333
1242
|
medium: "text-base",
|
|
1334
1243
|
large: "text-lg"
|
|
1335
|
-
},
|
|
1336
|
-
const
|
|
1337
|
-
return (
|
|
1244
|
+
}, l = !!(e || t && t.length > 0), T = (P) => {
|
|
1245
|
+
const M = P.split(":"), C = M[2] ? parseFloat(M[2]) : 0, O = M[1] ? parseInt(M[1], 10) * 60 : 0;
|
|
1246
|
+
return (M[0] ? parseInt(M[0], 10) * 3600 : 0) + O + C;
|
|
1338
1247
|
}, E = (P) => {
|
|
1339
|
-
const [
|
|
1340
|
-
return (
|
|
1341
|
-
},
|
|
1342
|
-
|
|
1248
|
+
const [M, C] = P.split(","), O = (M || "").split(":"), U = C ? parseInt(C, 10) / 1e3 : 0, c = O[2] ? parseInt(O[2], 10) : 0, _ = O[1] ? parseInt(O[1], 10) * 60 : 0;
|
|
1249
|
+
return (O[0] ? parseInt(O[0], 10) * 3600 : 0) + _ + c + U;
|
|
1250
|
+
}, w = async (P) => {
|
|
1251
|
+
L(!0), d(null);
|
|
1343
1252
|
try {
|
|
1344
|
-
const
|
|
1345
|
-
if (!
|
|
1346
|
-
throw new Error(`Failed to load subtitles: ${
|
|
1347
|
-
const
|
|
1253
|
+
const M = await fetch(P);
|
|
1254
|
+
if (!M.ok)
|
|
1255
|
+
throw new Error(`Failed to load subtitles: ${M.status} ${M.statusText}`);
|
|
1256
|
+
const C = await M.text(), O = [], U = C.split(`
|
|
1348
1257
|
`);
|
|
1349
|
-
let
|
|
1350
|
-
const
|
|
1351
|
-
if (
|
|
1352
|
-
for (;
|
|
1353
|
-
if (
|
|
1354
|
-
const [
|
|
1355
|
-
|
|
1258
|
+
let c = 0;
|
|
1259
|
+
const _ = C.includes("WEBVTT") || P.endsWith(".vtt"), ee = P.endsWith(".srt") || /^\d+$/.test(U[0]?.trim() || "");
|
|
1260
|
+
if (_)
|
|
1261
|
+
for (; c < U.length; ) {
|
|
1262
|
+
if (U[c]?.includes("-->")) {
|
|
1263
|
+
const [Q, se] = (U[c] || "").split("-->").map((V) => V.trim()), ae = T(Q || ""), i = T(se || "");
|
|
1264
|
+
c++;
|
|
1356
1265
|
let k = "";
|
|
1357
|
-
for (;
|
|
1358
|
-
k += (k ? " " : "") +
|
|
1359
|
-
k &&
|
|
1266
|
+
for (; c < U.length && U[c]?.trim() !== ""; )
|
|
1267
|
+
k += (k ? " " : "") + U[c]?.trim(), c++;
|
|
1268
|
+
k && O.push({ start: ae, end: i, text: k });
|
|
1360
1269
|
}
|
|
1361
|
-
|
|
1270
|
+
c++;
|
|
1362
1271
|
}
|
|
1363
|
-
else if (
|
|
1364
|
-
for (;
|
|
1365
|
-
if (/^\d+$/.test(
|
|
1366
|
-
const [
|
|
1367
|
-
|
|
1272
|
+
else if (ee)
|
|
1273
|
+
for (; c < U.length; ) {
|
|
1274
|
+
if (/^\d+$/.test(U[c]?.trim() || "") && (c++, U[c]?.includes("-->"))) {
|
|
1275
|
+
const [Q, se] = (U[c] || "").split("-->").map((V) => V.trim()), ae = E(Q || ""), i = E(se || "");
|
|
1276
|
+
c++;
|
|
1368
1277
|
let k = "";
|
|
1369
|
-
for (;
|
|
1370
|
-
k += (k ? " " : "") +
|
|
1371
|
-
k &&
|
|
1278
|
+
for (; c < U.length && U[c]?.trim() !== ""; )
|
|
1279
|
+
k += (k ? " " : "") + U[c]?.trim(), c++;
|
|
1280
|
+
k && O.push({ start: ae, end: i, text: k });
|
|
1372
1281
|
}
|
|
1373
|
-
|
|
1282
|
+
c++;
|
|
1374
1283
|
}
|
|
1375
1284
|
else
|
|
1376
1285
|
throw new Error("Unsupported subtitle format. Only VTT and SRT are supported.");
|
|
1377
|
-
if (
|
|
1286
|
+
if (O.length === 0)
|
|
1378
1287
|
throw new Error("No subtitle cues found in file");
|
|
1379
|
-
|
|
1380
|
-
} catch (
|
|
1381
|
-
const
|
|
1382
|
-
console.error("Failed to load subtitles:",
|
|
1288
|
+
m(O), L(!1);
|
|
1289
|
+
} catch (M) {
|
|
1290
|
+
const C = M instanceof Error ? M : new Error("Failed to load subtitles");
|
|
1291
|
+
console.error("Failed to load subtitles:", C), d(C), L(!1), m([]), s?.(C);
|
|
1383
1292
|
}
|
|
1384
|
-
},
|
|
1385
|
-
(
|
|
1386
|
-
)?.text || "",
|
|
1293
|
+
}, b = (P) => !u || a.length === 0 ? "" : a.find(
|
|
1294
|
+
(C) => P >= C.start && P <= C.end
|
|
1295
|
+
)?.text || "", f = () => {
|
|
1387
1296
|
o((P) => {
|
|
1388
|
-
const
|
|
1389
|
-
if (
|
|
1297
|
+
const M = !P;
|
|
1298
|
+
if (M && !p) {
|
|
1390
1299
|
if (a.length === 0 && !v) {
|
|
1391
|
-
const
|
|
1392
|
-
|
|
1300
|
+
const C = e || t[0]?.src;
|
|
1301
|
+
C && (w(C), t[0] && g(t[0].id));
|
|
1393
1302
|
}
|
|
1394
|
-
} else
|
|
1395
|
-
return
|
|
1303
|
+
} else M || F("");
|
|
1304
|
+
return M;
|
|
1396
1305
|
});
|
|
1397
|
-
},
|
|
1306
|
+
}, G = (P) => {
|
|
1398
1307
|
if (!P) {
|
|
1399
|
-
o(!1), g(null),
|
|
1308
|
+
o(!1), g(null), F("");
|
|
1400
1309
|
return;
|
|
1401
1310
|
}
|
|
1402
|
-
const
|
|
1403
|
-
|
|
1404
|
-
},
|
|
1311
|
+
const M = t.find((C) => C.id === P);
|
|
1312
|
+
M?.src && (g(P), w(M.src), o(!0));
|
|
1313
|
+
}, R = (P) => {
|
|
1405
1314
|
y(P);
|
|
1406
|
-
},
|
|
1315
|
+
}, I = {
|
|
1407
1316
|
fontSize: h[r],
|
|
1408
1317
|
className: `${h[r]} font-medium`
|
|
1409
1318
|
};
|
|
1410
|
-
return
|
|
1411
|
-
u ||
|
|
1412
|
-
}, [u]),
|
|
1319
|
+
return j(() => {
|
|
1320
|
+
u || F("");
|
|
1321
|
+
}, [u]), j(() => {
|
|
1413
1322
|
}, []), {
|
|
1414
1323
|
// State
|
|
1415
1324
|
subtitlesEnabled: u,
|
|
1416
1325
|
currentSubtitle: S,
|
|
1417
1326
|
subtitleCues: a,
|
|
1418
|
-
currentTrackId:
|
|
1327
|
+
currentTrackId: D,
|
|
1419
1328
|
fontSize: r,
|
|
1420
1329
|
loadError: p,
|
|
1421
1330
|
isLoading: v,
|
|
1422
|
-
hasSubtitles:
|
|
1331
|
+
hasSubtitles: l,
|
|
1423
1332
|
// Actions
|
|
1424
|
-
toggleSubtitles:
|
|
1425
|
-
selectSubtitleTrack:
|
|
1426
|
-
changeSubtitleFontSize:
|
|
1427
|
-
setCurrentSubtitle:
|
|
1333
|
+
toggleSubtitles: f,
|
|
1334
|
+
selectSubtitleTrack: G,
|
|
1335
|
+
changeSubtitleFontSize: R,
|
|
1336
|
+
setCurrentSubtitle: F,
|
|
1428
1337
|
// Utilities
|
|
1429
|
-
getCurrentSubtitle:
|
|
1430
|
-
getSubtitleStyles:
|
|
1338
|
+
getCurrentSubtitle: b,
|
|
1339
|
+
getSubtitleStyles: I,
|
|
1431
1340
|
// Track info
|
|
1432
1341
|
availableTracks: t
|
|
1433
1342
|
};
|
|
1434
1343
|
}
|
|
1435
|
-
const
|
|
1344
|
+
const He = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
1436
1345
|
__proto__: null,
|
|
1437
|
-
useEnhancedSubtitles:
|
|
1346
|
+
useEnhancedSubtitles: Fe
|
|
1438
1347
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
1439
|
-
function
|
|
1440
|
-
const [n, s] =
|
|
1348
|
+
function Ke(e, t) {
|
|
1349
|
+
const [n, s] = Y(!0), [u, o] = Y(!1), a = z(null), m = () => {
|
|
1441
1350
|
s(!0), a.current && clearTimeout(a.current), e && !t && (a.current = setTimeout(() => {
|
|
1442
1351
|
s(!1);
|
|
1443
1352
|
}, 3e3));
|
|
1444
1353
|
}, S = () => {
|
|
1445
|
-
|
|
1446
|
-
},
|
|
1354
|
+
m();
|
|
1355
|
+
}, F = () => {
|
|
1447
1356
|
s(!0);
|
|
1448
|
-
},
|
|
1357
|
+
}, D = () => {
|
|
1449
1358
|
e && s(!1);
|
|
1450
1359
|
};
|
|
1451
|
-
return
|
|
1360
|
+
return j(() => (m(), () => {
|
|
1452
1361
|
a.current && clearTimeout(a.current);
|
|
1453
|
-
}), [
|
|
1362
|
+
}), [m]), {
|
|
1454
1363
|
controlsVisible: n,
|
|
1455
1364
|
showVolumeSlider: u,
|
|
1456
1365
|
setShowVolumeSlider: o,
|
|
1457
1366
|
handleMouseMove: S,
|
|
1458
|
-
handleMouseEnter:
|
|
1459
|
-
handleMouseLeave:
|
|
1367
|
+
handleMouseEnter: F,
|
|
1368
|
+
handleMouseLeave: D
|
|
1460
1369
|
};
|
|
1461
1370
|
}
|
|
1462
|
-
function
|
|
1371
|
+
function $e({
|
|
1463
1372
|
videoControls: e,
|
|
1464
1373
|
toggleSubtitles: t,
|
|
1465
1374
|
takeScreenshot: n,
|
|
@@ -1505,9 +1414,9 @@ function Ge({
|
|
|
1505
1414
|
break;
|
|
1506
1415
|
}
|
|
1507
1416
|
};
|
|
1508
|
-
|
|
1417
|
+
j(() => (document.addEventListener("keydown", u), () => document.removeEventListener("keydown", u)), [u]);
|
|
1509
1418
|
}
|
|
1510
|
-
function
|
|
1419
|
+
function Ge(e) {
|
|
1511
1420
|
return { takeScreenshot: (n = !1) => {
|
|
1512
1421
|
if (!e.current) return;
|
|
1513
1422
|
const s = e.current, u = document.createElement("canvas");
|
|
@@ -1522,15 +1431,15 @@ function ze(e) {
|
|
|
1522
1431
|
}
|
|
1523
1432
|
if (n)
|
|
1524
1433
|
if (navigator.clipboard && window.ClipboardItem) {
|
|
1525
|
-
const
|
|
1526
|
-
navigator.clipboard.write([
|
|
1434
|
+
const m = new ClipboardItem({ "image/png": a });
|
|
1435
|
+
navigator.clipboard.write([m]).catch((S) => {
|
|
1527
1436
|
console.error("Failed to copy to clipboard:", S);
|
|
1528
1437
|
});
|
|
1529
1438
|
} else
|
|
1530
1439
|
console.warn("Clipboard API not supported");
|
|
1531
1440
|
else {
|
|
1532
|
-
const
|
|
1533
|
-
S.href =
|
|
1441
|
+
const m = URL.createObjectURL(a), S = document.createElement("a");
|
|
1442
|
+
S.href = m, S.download = `screenshot-${Date.now()}.png`, S.click(), URL.revokeObjectURL(m);
|
|
1534
1443
|
}
|
|
1535
1444
|
}, "image/png");
|
|
1536
1445
|
} catch (a) {
|
|
@@ -1538,18 +1447,147 @@ function ze(e) {
|
|
|
1538
1447
|
}
|
|
1539
1448
|
} };
|
|
1540
1449
|
}
|
|
1541
|
-
function
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1450
|
+
function $(e, t) {
|
|
1451
|
+
return ((n, s = !1) => {
|
|
1452
|
+
const u = {
|
|
1453
|
+
type: e,
|
|
1454
|
+
detail: n,
|
|
1455
|
+
optimistic: s,
|
|
1456
|
+
timestamp: Date.now()
|
|
1457
|
+
};
|
|
1458
|
+
return s ? t.dispatchOptimistic(u) : (t.dispatch(u), Promise.resolve());
|
|
1459
|
+
});
|
|
1460
|
+
}
|
|
1461
|
+
function De(e) {
|
|
1462
|
+
const [t, n] = B.useState(e.getActionState());
|
|
1463
|
+
return B.useEffect(() => e.subscribe(() => {
|
|
1464
|
+
const u = e.getActionState();
|
|
1465
|
+
n(
|
|
1466
|
+
(o) => JSON.stringify(o) !== JSON.stringify(u) ? u : o
|
|
1467
|
+
);
|
|
1468
|
+
}), [e]), t;
|
|
1469
|
+
}
|
|
1470
|
+
function ze(e) {
|
|
1471
|
+
const t = B.useMemo(() => ({
|
|
1472
|
+
// Playback actions
|
|
1473
|
+
play: $(H.PLAY, e),
|
|
1474
|
+
pause: $(H.PAUSE, e),
|
|
1475
|
+
seek: $(H.SEEK, e),
|
|
1476
|
+
// Volume actions
|
|
1477
|
+
setVolume: $(H.SET_VOLUME, e),
|
|
1478
|
+
mute: $(H.MUTE, e),
|
|
1479
|
+
unmute: $(H.UNMUTE, e),
|
|
1480
|
+
toggleMute: $(H.TOGGLE_MUTE, e),
|
|
1481
|
+
// Media state actions
|
|
1482
|
+
setDuration: $(H.SET_DURATION, e),
|
|
1483
|
+
setCurrentTime: $(H.SET_CURRENT_TIME, e),
|
|
1484
|
+
setBuffered: $(H.SET_BUFFERED, e),
|
|
1485
|
+
setLoading: $(H.SET_LOADING, e),
|
|
1486
|
+
setError: $(H.SET_ERROR, e),
|
|
1487
|
+
// Display actions
|
|
1488
|
+
enterFullscreen: $(H.ENTER_FULLSCREEN, e),
|
|
1489
|
+
exitFullscreen: $(H.EXIT_FULLSCREEN, e),
|
|
1490
|
+
enterPiP: $(H.ENTER_PIP, e),
|
|
1491
|
+
exitPiP: $(H.EXIT_PIP, e),
|
|
1492
|
+
// Advanced actions
|
|
1493
|
+
setPlaybackRate: $(H.SET_PLAYBACK_RATE, e),
|
|
1494
|
+
setSubtitleTrack: $(H.SET_SUBTITLE_TRACK, e),
|
|
1495
|
+
setRendition: $(H.SET_RENDITION, e),
|
|
1496
|
+
toggleSubtitles: $(H.TOGGLE_SUBTITLES, e),
|
|
1497
|
+
// Preview actions
|
|
1498
|
+
previewTime: $(H.PREVIEW_TIME, e),
|
|
1499
|
+
clearPreview: $(H.CLEAR_PREVIEW, e)
|
|
1500
|
+
}), [e]), n = De(e), s = B.useMemo(() => ({
|
|
1501
|
+
// These actions benefit from immediate UI feedback
|
|
1502
|
+
togglePlayPause: async (o) => {
|
|
1503
|
+
o ? await t.pause(!0) : await t.play(!0);
|
|
1504
|
+
},
|
|
1505
|
+
seekWithPreview: async (o) => {
|
|
1506
|
+
await t.previewTime(o, !0), await t.seek(o, !0);
|
|
1507
|
+
},
|
|
1508
|
+
adjustVolume: async (o, a) => {
|
|
1509
|
+
const m = Math.max(0, Math.min(1, a + o));
|
|
1510
|
+
await t.setVolume(m, !0);
|
|
1511
|
+
},
|
|
1512
|
+
toggleFullscreenOptimistic: async (o) => {
|
|
1513
|
+
o ? await t.exitFullscreen(!0) : await t.enterFullscreen(!0);
|
|
1514
|
+
}
|
|
1515
|
+
}), [t]), u = B.useCallback(async () => {
|
|
1516
|
+
const { lastAction: o } = n;
|
|
1517
|
+
o && n.error && await e.dispatchOptimistic({
|
|
1518
|
+
...o,
|
|
1519
|
+
retryCount: (o.retryCount || 0) + 1
|
|
1520
|
+
});
|
|
1521
|
+
}, [e, n]);
|
|
1522
|
+
return {
|
|
1523
|
+
...t,
|
|
1524
|
+
...s,
|
|
1525
|
+
actionState: n,
|
|
1526
|
+
retryLastAction: u,
|
|
1527
|
+
isLoading: n.pending,
|
|
1528
|
+
hasError: !!n.error,
|
|
1529
|
+
errorMessage: n.error,
|
|
1530
|
+
retryCount: n.retryCount
|
|
1531
|
+
};
|
|
1532
|
+
}
|
|
1533
|
+
function We() {
|
|
1534
|
+
const [e, t] = Y({
|
|
1535
|
+
isPlaying: !1,
|
|
1536
|
+
currentTime: 0,
|
|
1537
|
+
duration: 0,
|
|
1538
|
+
volume: 1,
|
|
1539
|
+
isMuted: !1,
|
|
1540
|
+
isLoading: !1,
|
|
1541
|
+
isFullscreen: !1,
|
|
1542
|
+
error: null,
|
|
1543
|
+
buffered: null
|
|
1544
|
+
}), n = (r) => {
|
|
1545
|
+
t((y) => ({ ...y, ...r }));
|
|
1546
|
+
};
|
|
1547
|
+
return {
|
|
1548
|
+
state: e,
|
|
1549
|
+
updateState: n,
|
|
1550
|
+
setPlaying: (r) => {
|
|
1551
|
+
n({ isPlaying: r });
|
|
1552
|
+
},
|
|
1553
|
+
setCurrentTime: (r) => {
|
|
1554
|
+
n({ currentTime: r });
|
|
1555
|
+
},
|
|
1556
|
+
setDuration: (r) => {
|
|
1557
|
+
n({ duration: r });
|
|
1558
|
+
},
|
|
1559
|
+
setVolume: (r) => {
|
|
1560
|
+
n({ volume: Math.max(0, Math.min(1, r)) });
|
|
1561
|
+
},
|
|
1562
|
+
setMuted: (r) => {
|
|
1563
|
+
n({ isMuted: r });
|
|
1564
|
+
},
|
|
1565
|
+
setLoading: (r) => {
|
|
1566
|
+
n({ isLoading: r });
|
|
1567
|
+
},
|
|
1568
|
+
setFullscreen: (r) => {
|
|
1569
|
+
n({ isFullscreen: r });
|
|
1570
|
+
},
|
|
1571
|
+
setError: (r) => {
|
|
1572
|
+
n({ error: r });
|
|
1573
|
+
},
|
|
1574
|
+
setBuffered: (r) => {
|
|
1575
|
+
n({ buffered: r });
|
|
1576
|
+
}
|
|
1577
|
+
};
|
|
1578
|
+
}
|
|
1579
|
+
function je(e) {
|
|
1580
|
+
const t = z(null), n = z(null), [s, u] = le(), [o, a] = le();
|
|
1581
|
+
B.useRef(0);
|
|
1582
|
+
const m = B.useRef(0), S = B.useRef(0);
|
|
1583
|
+
z(void 0);
|
|
1584
|
+
const F = z(0), D = pe(), g = "getOptimisticState" in D, r = W((i) => i.isPlaying), y = W((i) => i.currentTime), p = W((i) => i.duration), d = W((i) => i.volume), v = W((i) => i.isMuted), L = W((i) => i.isLoading), h = W((i) => i.isBuffering), l = W((i) => i.error), T = W((i) => i.buffered), E = W((i) => i.isFullscreen), w = D, b = g ? Ee(w) : null, f = g ? Te(w) : null, [G, R] = B.useState({
|
|
1547
1585
|
frameRate: 0,
|
|
1548
1586
|
averageRenderTime: 0,
|
|
1549
1587
|
droppedFrames: 0,
|
|
1550
1588
|
bufferHealth: 0
|
|
1551
|
-
}), [
|
|
1552
|
-
ce(y, (i, k) => Math.max(0, Math.min(p || 0, k))),
|
|
1589
|
+
}), [I, P] = ce(d, (i, k) => Math.max(0, Math.min(1, k)));
|
|
1590
|
+
ce(y, (i, k) => Math.max(0, Math.min(p || 0, k))), j(() => {
|
|
1553
1591
|
const i = t.current;
|
|
1554
1592
|
if (!i) return;
|
|
1555
1593
|
const k = {
|
|
@@ -1560,8 +1598,8 @@ function We(e) {
|
|
|
1560
1598
|
preload: e.preload,
|
|
1561
1599
|
crossOrigin: e.crossOrigin
|
|
1562
1600
|
};
|
|
1563
|
-
Object.entries(k).forEach(([
|
|
1564
|
-
|
|
1601
|
+
Object.entries(k).forEach(([V, X]) => {
|
|
1602
|
+
X !== void 0 && (i[V] = X);
|
|
1565
1603
|
}), i.setAttribute("preload", e.preloadStrategy === "eager" ? "auto" : "metadata"), e.bufferingStrategy === "aggressive" && i.setAttribute("buffered", "auto"), i instanceof HTMLVideoElement && (i.style.willChange = "transform", i.style.transform = "translateZ(0)");
|
|
1566
1604
|
}, [
|
|
1567
1605
|
e.volume,
|
|
@@ -1573,135 +1611,135 @@ function We(e) {
|
|
|
1573
1611
|
e.preloadStrategy,
|
|
1574
1612
|
e.bufferingStrategy
|
|
1575
1613
|
]);
|
|
1576
|
-
const
|
|
1614
|
+
const M = A(() => {
|
|
1577
1615
|
const i = t.current;
|
|
1578
1616
|
if (!i) return;
|
|
1579
1617
|
const k = performance.now();
|
|
1580
1618
|
if (e.enableTimeUpdateThrottling !== !1) {
|
|
1581
|
-
if (k -
|
|
1619
|
+
if (k - F.current < (e.timeUpdateThrottleMs || 100))
|
|
1582
1620
|
return;
|
|
1583
|
-
|
|
1621
|
+
F.current = k;
|
|
1584
1622
|
}
|
|
1585
1623
|
u(() => {
|
|
1586
|
-
g &&
|
|
1624
|
+
g && f && f.setCurrentTime(i.currentTime);
|
|
1587
1625
|
});
|
|
1588
|
-
}, [e.enableTimeUpdateThrottling, e.timeUpdateThrottleMs, g,
|
|
1626
|
+
}, [e.enableTimeUpdateThrottling, e.timeUpdateThrottleMs, g, f]), C = A(() => {
|
|
1589
1627
|
u(() => {
|
|
1590
|
-
g &&
|
|
1628
|
+
g && f && f.play(!0);
|
|
1591
1629
|
}), e.onPlay?.();
|
|
1592
|
-
}, [g,
|
|
1630
|
+
}, [g, f, e.onPlay]), O = A(() => {
|
|
1593
1631
|
u(() => {
|
|
1594
|
-
g &&
|
|
1632
|
+
g && f && f.pause(!0);
|
|
1595
1633
|
}), e.onPause?.();
|
|
1596
|
-
}, [g,
|
|
1634
|
+
}, [g, f, e.onPause]), U = A(() => {
|
|
1597
1635
|
const i = t.current;
|
|
1598
1636
|
i && u(() => {
|
|
1599
|
-
g &&
|
|
1637
|
+
g && f && (f.setVolume(i.volume, !0), i.muted ? f.mute(!0) : f.unmute(!0));
|
|
1600
1638
|
});
|
|
1601
|
-
}, [g,
|
|
1639
|
+
}, [g, f]), c = A(() => {
|
|
1602
1640
|
a(() => {
|
|
1603
1641
|
});
|
|
1642
|
+
}, []), _ = A(() => {
|
|
1604
1643
|
}, []), ee = A(() => {
|
|
1605
|
-
}, []), f = A(() => {
|
|
1606
1644
|
const i = t.current;
|
|
1607
1645
|
i && u(() => {
|
|
1608
|
-
g &&
|
|
1646
|
+
g && f && f.setBuffered(i.buffered);
|
|
1609
1647
|
});
|
|
1610
|
-
}, [g,
|
|
1648
|
+
}, [g, f]), Q = A(() => {
|
|
1611
1649
|
const i = performance.now();
|
|
1612
|
-
if (i - S.current > 0 && (
|
|
1613
|
-
const
|
|
1614
|
-
|
|
1615
|
-
...
|
|
1616
|
-
frameRate:
|
|
1617
|
-
droppedFrames: Math.max(0, 60 -
|
|
1618
|
-
})),
|
|
1650
|
+
if (i - S.current > 0 && (m.current++, m.current >= 60)) {
|
|
1651
|
+
const V = Math.round(m.current * 1e3 / (i - S.current));
|
|
1652
|
+
R((X) => ({
|
|
1653
|
+
...X,
|
|
1654
|
+
frameRate: V,
|
|
1655
|
+
droppedFrames: Math.max(0, 60 - V)
|
|
1656
|
+
})), m.current = 0, S.current = i;
|
|
1619
1657
|
}
|
|
1620
1658
|
}, []);
|
|
1621
|
-
|
|
1659
|
+
j(() => {
|
|
1622
1660
|
const i = t.current;
|
|
1623
1661
|
if (!i) return;
|
|
1624
1662
|
const k = [
|
|
1625
|
-
{ event: "timeupdate", handler:
|
|
1626
|
-
{ event: "play", handler:
|
|
1627
|
-
{ event: "pause", handler:
|
|
1628
|
-
{ event: "volumechange", handler:
|
|
1629
|
-
{ event: "seeking", handler:
|
|
1630
|
-
{ event: "seeked", handler:
|
|
1631
|
-
{ event: "progress", handler:
|
|
1632
|
-
{ event: "loadedmetadata", handler: () =>
|
|
1633
|
-
{ event: "loadeddata", handler: () =>
|
|
1663
|
+
{ event: "timeupdate", handler: M, passive: !0 },
|
|
1664
|
+
{ event: "play", handler: C },
|
|
1665
|
+
{ event: "pause", handler: O },
|
|
1666
|
+
{ event: "volumechange", handler: U },
|
|
1667
|
+
{ event: "seeking", handler: c },
|
|
1668
|
+
{ event: "seeked", handler: _ },
|
|
1669
|
+
{ event: "progress", handler: ee, passive: !0 },
|
|
1670
|
+
{ event: "loadedmetadata", handler: () => Q() },
|
|
1671
|
+
{ event: "loadeddata", handler: () => Q() }
|
|
1634
1672
|
];
|
|
1635
1673
|
k.forEach(({ event: te, handler: ne, passive: ie }) => {
|
|
1636
1674
|
const oe = ie ? { passive: !0 } : {};
|
|
1637
1675
|
i.addEventListener(te, ne, oe);
|
|
1638
1676
|
});
|
|
1639
|
-
let
|
|
1640
|
-
const
|
|
1641
|
-
|
|
1677
|
+
let V;
|
|
1678
|
+
const X = () => {
|
|
1679
|
+
Q(), V = requestAnimationFrame(X);
|
|
1642
1680
|
};
|
|
1643
|
-
return e.enablePerformanceMonitoring &&
|
|
1681
|
+
return e.enablePerformanceMonitoring && X(), () => {
|
|
1644
1682
|
k.forEach(({ event: te, handler: ne }) => {
|
|
1645
1683
|
i.removeEventListener(te, ne);
|
|
1646
|
-
}),
|
|
1684
|
+
}), V && cancelAnimationFrame(V);
|
|
1647
1685
|
};
|
|
1648
1686
|
}, [
|
|
1649
|
-
|
|
1650
|
-
|
|
1687
|
+
M,
|
|
1688
|
+
C,
|
|
1689
|
+
O,
|
|
1651
1690
|
U,
|
|
1691
|
+
c,
|
|
1652
1692
|
_,
|
|
1653
|
-
C,
|
|
1654
1693
|
ee,
|
|
1655
|
-
|
|
1656
|
-
V,
|
|
1694
|
+
Q,
|
|
1657
1695
|
e.enablePerformanceMonitoring
|
|
1658
1696
|
]);
|
|
1659
1697
|
const se = ue(() => {
|
|
1660
1698
|
const i = async () => {
|
|
1661
1699
|
const x = t.current;
|
|
1662
1700
|
if (x)
|
|
1663
|
-
if (g &&
|
|
1664
|
-
await
|
|
1701
|
+
if (g && f)
|
|
1702
|
+
await f.play(!0);
|
|
1665
1703
|
else
|
|
1666
1704
|
try {
|
|
1667
1705
|
await x.play();
|
|
1668
|
-
} catch (
|
|
1669
|
-
console.error("Failed to play media:",
|
|
1706
|
+
} catch (q) {
|
|
1707
|
+
console.error("Failed to play media:", q);
|
|
1670
1708
|
}
|
|
1671
1709
|
}, k = () => {
|
|
1672
1710
|
const x = t.current;
|
|
1673
|
-
x && (g &&
|
|
1674
|
-
},
|
|
1711
|
+
x && (g && f ? f.pause(!0) : x.pause());
|
|
1712
|
+
}, V = () => {
|
|
1675
1713
|
r ? k() : i();
|
|
1676
|
-
},
|
|
1677
|
-
const
|
|
1678
|
-
if (!
|
|
1714
|
+
}, X = (x) => {
|
|
1715
|
+
const q = t.current;
|
|
1716
|
+
if (!q) return;
|
|
1679
1717
|
const Z = Math.max(0, Math.min(x, p || 0));
|
|
1680
|
-
g &&
|
|
1681
|
-
|
|
1682
|
-
}) :
|
|
1718
|
+
g && f ? a(() => {
|
|
1719
|
+
f.seek(Z, !0);
|
|
1720
|
+
}) : q.currentTime = Z;
|
|
1683
1721
|
}, te = (x) => {
|
|
1684
|
-
const
|
|
1685
|
-
if (!
|
|
1722
|
+
const q = t.current;
|
|
1723
|
+
if (!q) return;
|
|
1686
1724
|
const Z = Math.max(0, Math.min(1, x));
|
|
1687
|
-
g &&
|
|
1688
|
-
|
|
1689
|
-
})) :
|
|
1725
|
+
g && f ? (P(Z), u(() => {
|
|
1726
|
+
f.setVolume(Z, !0);
|
|
1727
|
+
})) : q.volume = Z;
|
|
1690
1728
|
}, ne = () => {
|
|
1691
1729
|
const x = t.current;
|
|
1692
|
-
x && (g &&
|
|
1730
|
+
x && (g && f ? f.toggleMute(!0) : x.muted = !x.muted);
|
|
1693
1731
|
}, ie = async () => {
|
|
1694
1732
|
const x = n.current;
|
|
1695
1733
|
if (!(!x || !document.fullscreenEnabled))
|
|
1696
1734
|
try {
|
|
1697
|
-
await x.requestFullscreen(), g &&
|
|
1698
|
-
} catch (
|
|
1699
|
-
console.error("Failed to enter fullscreen:",
|
|
1735
|
+
await x.requestFullscreen(), g && f && f.enterFullscreen(!0);
|
|
1736
|
+
} catch (q) {
|
|
1737
|
+
console.error("Failed to enter fullscreen:", q);
|
|
1700
1738
|
}
|
|
1701
1739
|
}, oe = async () => {
|
|
1702
1740
|
if (document.fullscreenElement)
|
|
1703
1741
|
try {
|
|
1704
|
-
await document.exitFullscreen(), g &&
|
|
1742
|
+
await document.exitFullscreen(), g && f && f.exitFullscreen(!0);
|
|
1705
1743
|
} catch (x) {
|
|
1706
1744
|
console.error("Failed to exit fullscreen:", x);
|
|
1707
1745
|
}
|
|
@@ -1709,8 +1747,8 @@ function We(e) {
|
|
|
1709
1747
|
return {
|
|
1710
1748
|
play: i,
|
|
1711
1749
|
pause: k,
|
|
1712
|
-
toggle:
|
|
1713
|
-
seek:
|
|
1750
|
+
toggle: V,
|
|
1751
|
+
seek: X,
|
|
1714
1752
|
setVolume: te,
|
|
1715
1753
|
toggleMute: ne,
|
|
1716
1754
|
enterFullscreen: ie,
|
|
@@ -1723,34 +1761,34 @@ function We(e) {
|
|
|
1723
1761
|
r,
|
|
1724
1762
|
p,
|
|
1725
1763
|
g,
|
|
1726
|
-
|
|
1764
|
+
f,
|
|
1727
1765
|
u,
|
|
1728
1766
|
a,
|
|
1729
1767
|
P
|
|
1730
1768
|
]), ae = ue(() => ({
|
|
1731
|
-
isPlaying:
|
|
1732
|
-
currentTime:
|
|
1733
|
-
duration:
|
|
1734
|
-
volume:
|
|
1735
|
-
isMuted:
|
|
1736
|
-
isLoading:
|
|
1737
|
-
isBuffering:
|
|
1738
|
-
error:
|
|
1739
|
-
buffered:
|
|
1740
|
-
isFullscreen:
|
|
1769
|
+
isPlaying: b?.state?.isPlaying ?? r,
|
|
1770
|
+
currentTime: b?.state?.currentTime ?? y,
|
|
1771
|
+
duration: b?.state?.duration ?? p,
|
|
1772
|
+
volume: b?.state?.volume ?? I,
|
|
1773
|
+
isMuted: b?.state?.isMuted ?? v,
|
|
1774
|
+
isLoading: b?.state?.isBuffering ?? L,
|
|
1775
|
+
isBuffering: b?.state?.isBuffering ?? h,
|
|
1776
|
+
error: b?.state?.error ?? l,
|
|
1777
|
+
buffered: b?.state?.buffered ?? T,
|
|
1778
|
+
isFullscreen: b?.state?.isFullscreen ?? E,
|
|
1741
1779
|
progress: p > 0 ? y / p : 0,
|
|
1742
1780
|
isTransitioning: s || o,
|
|
1743
|
-
canPlay: !
|
|
1781
|
+
canPlay: !L && !h && !l
|
|
1744
1782
|
}), [
|
|
1745
|
-
|
|
1783
|
+
b,
|
|
1746
1784
|
r,
|
|
1747
1785
|
y,
|
|
1748
1786
|
p,
|
|
1749
|
-
|
|
1787
|
+
I,
|
|
1750
1788
|
v,
|
|
1751
|
-
|
|
1789
|
+
L,
|
|
1752
1790
|
h,
|
|
1753
|
-
|
|
1791
|
+
l,
|
|
1754
1792
|
T,
|
|
1755
1793
|
E,
|
|
1756
1794
|
s,
|
|
@@ -1762,28 +1800,29 @@ function We(e) {
|
|
|
1762
1800
|
containerRef: n,
|
|
1763
1801
|
// State
|
|
1764
1802
|
state: ae,
|
|
1765
|
-
actualState:
|
|
1803
|
+
actualState: b?.actualState,
|
|
1766
1804
|
// Controls
|
|
1767
1805
|
controls: se,
|
|
1768
1806
|
// Performance metrics
|
|
1769
|
-
performanceMetrics:
|
|
1807
|
+
performanceMetrics: G,
|
|
1770
1808
|
isTransitioning: s || o,
|
|
1771
1809
|
// Enhanced features
|
|
1772
|
-
actions:
|
|
1773
|
-
|
|
1810
|
+
actions: b,
|
|
1811
|
+
// The optimisticState object contains all the actions
|
|
1812
|
+
actionState: b?.state,
|
|
1774
1813
|
// Optimistic features
|
|
1775
|
-
optimisticState:
|
|
1814
|
+
optimisticState: b,
|
|
1776
1815
|
isEnhanced: g
|
|
1777
1816
|
};
|
|
1778
1817
|
}
|
|
1779
|
-
const
|
|
1818
|
+
const qe = (e, t = {}) => {
|
|
1780
1819
|
const {
|
|
1781
1820
|
trackUserBehavior: n = !0,
|
|
1782
1821
|
adaptToNetwork: s = !0,
|
|
1783
1822
|
strategy: u = "balanced",
|
|
1784
1823
|
maxPreloadItems: o = 3,
|
|
1785
1824
|
preloadRadius: a = 2
|
|
1786
|
-
} = t,
|
|
1825
|
+
} = t, m = z({
|
|
1787
1826
|
mouseMovements: 0,
|
|
1788
1827
|
scrollEvents: 0,
|
|
1789
1828
|
keyPresses: 0,
|
|
@@ -1791,124 +1830,114 @@ const je = (e, t = {}) => {
|
|
|
1791
1830
|
timeOnPage: 0,
|
|
1792
1831
|
engagementScore: 0,
|
|
1793
1832
|
lastInteraction: Date.now()
|
|
1794
|
-
}), S =
|
|
1795
|
-
const
|
|
1796
|
-
(
|
|
1833
|
+
}), S = z(null), F = z(/* @__PURE__ */ new Set()), D = z([]), g = A(() => {
|
|
1834
|
+
const l = m.current, T = Math.min(l.timeOnPage / 6e4, 1), E = Math.min(
|
|
1835
|
+
(l.mouseMovements + l.scrollEvents + l.keyPresses) / 100,
|
|
1797
1836
|
1
|
|
1798
1837
|
);
|
|
1799
1838
|
return (T * 0.4 + E * 0.6) * 100;
|
|
1800
|
-
}, []), r = A((
|
|
1801
|
-
const E =
|
|
1802
|
-
E[
|
|
1839
|
+
}, []), r = A((l, T = 1) => {
|
|
1840
|
+
const E = m.current;
|
|
1841
|
+
E[l] = typeof E[l] == "number" ? E[l] + T : Date.now(), E.engagementScore = g(), E.lastInteraction = Date.now();
|
|
1803
1842
|
}, [g]), y = A(() => {
|
|
1804
1843
|
if (!S.current || !s)
|
|
1805
1844
|
return { type: "unknown", downlink: 10, effectiveType: "4g", saveData: !1 };
|
|
1806
|
-
const
|
|
1845
|
+
const l = S.current;
|
|
1807
1846
|
return {
|
|
1808
|
-
type:
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1847
|
+
type: l.effectiveType || "4g",
|
|
1848
|
+
// Use effectiveType as the primary type indicator
|
|
1849
|
+
downlink: l.downlink || 10,
|
|
1850
|
+
effectiveType: l.effectiveType || "4g",
|
|
1851
|
+
saveData: l.saveData || !1,
|
|
1852
|
+
rtt: l.rtt || 100
|
|
1813
1853
|
};
|
|
1814
|
-
}, [s]), p = A((
|
|
1815
|
-
if (
|
|
1854
|
+
}, [s]), p = A((l, T, E = 0) => {
|
|
1855
|
+
if (F.current.has(l.src))
|
|
1816
1856
|
return { shouldPreload: !1, priority: "low", reason: "Already preloaded" };
|
|
1817
|
-
const
|
|
1818
|
-
if (
|
|
1857
|
+
const w = Math.abs(T - E);
|
|
1858
|
+
if (w > a)
|
|
1819
1859
|
return { shouldPreload: !1, priority: "low", reason: "Outside preload radius" };
|
|
1820
|
-
const
|
|
1821
|
-
if (
|
|
1860
|
+
const b = m.current, f = y(), G = b.engagementScore, R = Date.now() - b.lastInteraction;
|
|
1861
|
+
if (f.saveData)
|
|
1822
1862
|
return { shouldPreload: !1, priority: "low", reason: "Data saver mode" };
|
|
1823
|
-
let
|
|
1863
|
+
let I = !1, P = "medium", M = "";
|
|
1824
1864
|
switch (u) {
|
|
1825
1865
|
case "conservative":
|
|
1826
|
-
|
|
1866
|
+
I = G > 70 && f.effectiveType !== "2g" && w === 1, P = I ? "medium" : "low", M = I ? "High engagement and optimal network" : "Conservative strategy";
|
|
1827
1867
|
break;
|
|
1828
1868
|
case "aggressive":
|
|
1829
|
-
|
|
1869
|
+
I = G > 30 && f.effectiveType !== "slow-2g", P = G > 70 ? "high" : G > 50 ? "medium" : "low", M = I ? "Aggressive preloading" : "Low engagement";
|
|
1830
1870
|
break;
|
|
1831
1871
|
case "balanced":
|
|
1832
1872
|
default:
|
|
1833
|
-
const
|
|
1834
|
-
|
|
1873
|
+
const C = f.effectiveType === "4g" ? 1 : f.effectiveType === "3g" ? 0.7 : 0.3, O = G * C;
|
|
1874
|
+
I = O > 40 && w <= 2, P = O > 70 ? "high" : O > 55 ? "medium" : "low", M = I ? `Balanced: score ${O.toFixed(1)}` : "Low adjusted score";
|
|
1835
1875
|
break;
|
|
1836
1876
|
}
|
|
1837
|
-
|
|
1838
|
-
|
|
1877
|
+
if (I) {
|
|
1878
|
+
const C = l.src.toLowerCase();
|
|
1879
|
+
(C.includes(".m3u8") || C.includes("hls")) && (P = P === "low" ? "medium" : "high"), R < 5e3 && (P = "high", M += " + Recent interaction"), (l.type?.includes("mp4") || l.type?.includes("webm") || C.includes(".mp4") || C.includes(".webm")) && (P = P === "low" ? "medium" : P);
|
|
1880
|
+
}
|
|
1881
|
+
return { shouldPreload: I, priority: P, reason: M };
|
|
1882
|
+
}, [u, a, y, g]), d = A(async (l, T) => {
|
|
1839
1883
|
try {
|
|
1840
1884
|
const E = document.createElement("link");
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
E.as = "fetch";
|
|
1845
|
-
break;
|
|
1846
|
-
case "mp4":
|
|
1847
|
-
case "webm":
|
|
1848
|
-
E.as = "video";
|
|
1849
|
-
break;
|
|
1850
|
-
case "mp3":
|
|
1851
|
-
case "wav":
|
|
1852
|
-
case "ogg":
|
|
1853
|
-
E.as = "audio";
|
|
1854
|
-
break;
|
|
1855
|
-
default:
|
|
1856
|
-
E.as = "fetch";
|
|
1857
|
-
}
|
|
1858
|
-
E.crossOrigin = "anonymous", document.head.appendChild(E), D.current.add(c.src), console.debug(`Preloaded: ${c.src} (${T})`), setTimeout(() => {
|
|
1885
|
+
E.rel = "preload", E.href = l.src;
|
|
1886
|
+
const w = l.src.toLowerCase(), b = l.type?.toLowerCase() || "";
|
|
1887
|
+
w.includes(".m3u8") || w.includes("hls") ? E.as = "fetch" : b.includes("mp4") || b.includes("webm") || w.includes(".mp4") || w.includes(".webm") ? E.as = "video" : b.includes("mp3") || b.includes("wav") || b.includes("ogg") || w.includes(".mp3") || w.includes(".wav") || w.includes(".ogg") ? E.as = "audio" : E.as = "fetch", E.crossOrigin = "anonymous", document.head.appendChild(E), F.current.add(l.src), console.debug(`Preloaded: ${l.src} (${T})`), setTimeout(() => {
|
|
1859
1888
|
document.head.contains(E) && document.head.removeChild(E);
|
|
1860
1889
|
}, 3e4);
|
|
1861
1890
|
} catch (E) {
|
|
1862
|
-
console.warn("Failed to preload source:",
|
|
1891
|
+
console.warn("Failed to preload source:", l.src, E);
|
|
1863
1892
|
}
|
|
1864
1893
|
}, []), v = A(() => {
|
|
1865
|
-
if (
|
|
1866
|
-
const T = [...
|
|
1867
|
-
|
|
1868
|
-
|
|
1894
|
+
if (D.current.length === 0) return;
|
|
1895
|
+
const T = [...D.current].sort((E, w) => w.priority - E.priority).slice(0, o);
|
|
1896
|
+
D.current = [], T.forEach(({ source: E, priority: w }) => {
|
|
1897
|
+
d(E, w);
|
|
1869
1898
|
});
|
|
1870
|
-
}, [o,
|
|
1871
|
-
|
|
1872
|
-
const
|
|
1873
|
-
if (
|
|
1874
|
-
const
|
|
1875
|
-
|
|
1899
|
+
}, [o, d]), L = A((l = 0) => {
|
|
1900
|
+
D.current = [], e.forEach((T, E) => {
|
|
1901
|
+
const w = p(T, E, l);
|
|
1902
|
+
if (w.shouldPreload) {
|
|
1903
|
+
const b = w.priority === "high" ? 3 : w.priority === "medium" ? 2 : 1;
|
|
1904
|
+
D.current.push({ source: T, priority: b });
|
|
1876
1905
|
}
|
|
1877
1906
|
}), v();
|
|
1878
1907
|
}, [e, p, v]);
|
|
1879
|
-
return
|
|
1908
|
+
return j(() => {
|
|
1880
1909
|
if (!n) return;
|
|
1881
|
-
const
|
|
1882
|
-
document.addEventListener("mousemove",
|
|
1883
|
-
const
|
|
1910
|
+
const l = () => r("mouseMovements"), T = () => r("scrollEvents"), E = () => r("keyPresses"), w = () => r("focusEvents");
|
|
1911
|
+
document.addEventListener("mousemove", l, { passive: !0 }), document.addEventListener("scroll", T, { passive: !0 }), document.addEventListener("keydown", E, { passive: !0 }), document.addEventListener("focusin", w, { passive: !0 });
|
|
1912
|
+
const b = setInterval(() => {
|
|
1884
1913
|
r("timeOnPage", 1);
|
|
1885
1914
|
}, 1e3);
|
|
1886
1915
|
return () => {
|
|
1887
|
-
document.removeEventListener("mousemove",
|
|
1916
|
+
document.removeEventListener("mousemove", l), document.removeEventListener("scroll", T), document.removeEventListener("keydown", E), document.removeEventListener("focusin", w), clearInterval(b);
|
|
1888
1917
|
};
|
|
1889
|
-
}, [n, r]),
|
|
1918
|
+
}, [n, r]), j(() => {
|
|
1890
1919
|
if (!s || !("connection" in navigator)) return;
|
|
1891
|
-
const
|
|
1892
|
-
S.current =
|
|
1920
|
+
const l = navigator.connection;
|
|
1921
|
+
S.current = l;
|
|
1893
1922
|
const T = () => {
|
|
1894
|
-
|
|
1923
|
+
L();
|
|
1895
1924
|
};
|
|
1896
|
-
return
|
|
1897
|
-
|
|
1925
|
+
return l.addEventListener("change", T), () => {
|
|
1926
|
+
l.removeEventListener("change", T);
|
|
1898
1927
|
};
|
|
1899
|
-
}, [s,
|
|
1900
|
-
|
|
1901
|
-
}, [
|
|
1928
|
+
}, [s, L]), j(() => {
|
|
1929
|
+
L();
|
|
1930
|
+
}, [L]), ue(() => ({
|
|
1902
1931
|
/**
|
|
1903
1932
|
* Manually trigger preloading for specific index
|
|
1904
1933
|
*/
|
|
1905
|
-
preloadAtIndex: (
|
|
1906
|
-
|
|
1934
|
+
preloadAtIndex: (l) => {
|
|
1935
|
+
L(l);
|
|
1907
1936
|
},
|
|
1908
1937
|
/**
|
|
1909
1938
|
* Get current user behavior data
|
|
1910
1939
|
*/
|
|
1911
|
-
getUserBehavior: () => ({ ...
|
|
1940
|
+
getUserBehavior: () => ({ ...m.current }),
|
|
1912
1941
|
/**
|
|
1913
1942
|
* Get current network conditions
|
|
1914
1943
|
*/
|
|
@@ -1917,36 +1946,36 @@ const je = (e, t = {}) => {
|
|
|
1917
1946
|
* Clear preloaded items cache
|
|
1918
1947
|
*/
|
|
1919
1948
|
clearCache: () => {
|
|
1920
|
-
|
|
1949
|
+
F.current.clear();
|
|
1921
1950
|
},
|
|
1922
1951
|
/**
|
|
1923
1952
|
* Get preloading statistics
|
|
1924
1953
|
*/
|
|
1925
1954
|
getStats: () => ({
|
|
1926
|
-
preloadedItems:
|
|
1927
|
-
engagementScore:
|
|
1928
|
-
queueLength:
|
|
1955
|
+
preloadedItems: F.current.size,
|
|
1956
|
+
engagementScore: m.current.engagementScore,
|
|
1957
|
+
queueLength: D.current.length,
|
|
1929
1958
|
maxPreloadItems: o
|
|
1930
1959
|
})
|
|
1931
|
-
}), [
|
|
1960
|
+
}), [L, y, o]);
|
|
1932
1961
|
};
|
|
1933
1962
|
function Re(e) {
|
|
1934
|
-
const [t, n] =
|
|
1963
|
+
const [t, n] = Y(!1), [s, u] = Y([]), [o, a] = Y(""), m = (g) => {
|
|
1935
1964
|
const r = g.split(":"), y = r[2] ? parseFloat(r[2]) : 0, p = r[1] ? parseInt(r[1], 10) * 60 : 0;
|
|
1936
1965
|
return (r[0] ? parseInt(r[0], 10) * 3600 : 0) + p + y;
|
|
1937
1966
|
}, S = async (g) => {
|
|
1938
1967
|
try {
|
|
1939
|
-
const y = await (await fetch(g)).text(), p = [],
|
|
1968
|
+
const y = await (await fetch(g)).text(), p = [], d = y.split(`
|
|
1940
1969
|
`);
|
|
1941
1970
|
let v = 0;
|
|
1942
|
-
for (; v <
|
|
1943
|
-
if (
|
|
1944
|
-
const [
|
|
1971
|
+
for (; v < d.length; ) {
|
|
1972
|
+
if (d[v]?.includes("-->")) {
|
|
1973
|
+
const [L, h] = (d[v] || "").split("-->").map((w) => w.trim()), l = m(L || ""), T = m(h || "");
|
|
1945
1974
|
v++;
|
|
1946
1975
|
let E = "";
|
|
1947
|
-
for (; v <
|
|
1948
|
-
E += (E ? " " : "") +
|
|
1949
|
-
E && p.push({ start:
|
|
1976
|
+
for (; v < d.length && d[v]?.trim() !== ""; )
|
|
1977
|
+
E += (E ? " " : "") + d[v]?.trim(), v++;
|
|
1978
|
+
E && p.push({ start: l, end: T, text: E });
|
|
1950
1979
|
}
|
|
1951
1980
|
v++;
|
|
1952
1981
|
}
|
|
@@ -1954,60 +1983,60 @@ function Re(e) {
|
|
|
1954
1983
|
} catch (r) {
|
|
1955
1984
|
console.error("Failed to load subtitles:", r);
|
|
1956
1985
|
}
|
|
1957
|
-
},
|
|
1986
|
+
}, F = (g) => !t || s.length === 0 ? "" : s.find(
|
|
1958
1987
|
(y) => g >= y.start && g <= y.end
|
|
1959
|
-
)?.text || "",
|
|
1988
|
+
)?.text || "", D = () => {
|
|
1960
1989
|
n((g) => {
|
|
1961
1990
|
const r = !g;
|
|
1962
1991
|
return r && e && s.length === 0 ? S(e) : r || a(""), r;
|
|
1963
1992
|
});
|
|
1964
1993
|
};
|
|
1965
|
-
return
|
|
1994
|
+
return j(() => {
|
|
1966
1995
|
t || a("");
|
|
1967
1996
|
}, [t]), {
|
|
1968
1997
|
subtitlesEnabled: t,
|
|
1969
1998
|
currentSubtitle: o,
|
|
1970
|
-
toggleSubtitles:
|
|
1971
|
-
getCurrentSubtitle:
|
|
1999
|
+
toggleSubtitles: D,
|
|
2000
|
+
getCurrentSubtitle: F,
|
|
1972
2001
|
setCurrentSubtitle: a
|
|
1973
2002
|
};
|
|
1974
2003
|
}
|
|
1975
|
-
function
|
|
2004
|
+
function Xe(e) {
|
|
1976
2005
|
return ve(
|
|
1977
2006
|
"useVideoPlayer",
|
|
1978
2007
|
"useMediaPlayer (the primary media player hook)"
|
|
1979
|
-
),
|
|
2008
|
+
), Me(e);
|
|
1980
2009
|
}
|
|
1981
|
-
function
|
|
2010
|
+
function Ye(e) {
|
|
1982
2011
|
return ve(
|
|
1983
2012
|
"useEnhancedSubtitles",
|
|
1984
2013
|
"useSubtitles (the current subtitle hook)"
|
|
1985
2014
|
), Re(e);
|
|
1986
2015
|
}
|
|
1987
2016
|
export {
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
2017
|
+
_e as a,
|
|
2018
|
+
Be as b,
|
|
2019
|
+
Ne as c,
|
|
2020
|
+
Fe as d,
|
|
2021
|
+
Ke as e,
|
|
2022
|
+
$e as f,
|
|
2023
|
+
Ge as g,
|
|
1995
2024
|
Oe as h,
|
|
1996
2025
|
Ue as i,
|
|
1997
2026
|
Ie as j,
|
|
1998
|
-
|
|
2027
|
+
Me as k,
|
|
1999
2028
|
be as l,
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2029
|
+
We as m,
|
|
2030
|
+
je as n,
|
|
2031
|
+
ze as o,
|
|
2032
|
+
De as p,
|
|
2033
|
+
qe as q,
|
|
2034
|
+
Pe as r,
|
|
2006
2035
|
Re as s,
|
|
2007
|
-
|
|
2036
|
+
Xe as t,
|
|
2008
2037
|
de as u,
|
|
2009
|
-
|
|
2038
|
+
Ye as v,
|
|
2010
2039
|
Ve as w,
|
|
2011
|
-
|
|
2040
|
+
He as x
|
|
2012
2041
|
};
|
|
2013
|
-
//# sourceMappingURL=hooks-
|
|
2042
|
+
//# sourceMappingURL=hooks-BPtHV1ZT.js.map
|