@banou/media-player 0.8.13 → 0.8.15
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/engine/index.js +1 -1
- package/dist/engine/playback.d.ts +2 -0
- package/dist/{engine-BUcS6UrE.js → engine-CDdjRm_U.js} +99 -92
- package/dist/index.js +152 -130
- package/package.json +1 -1
- package/src/lib/engine/playback.ts +75 -5
- package/src/lib/react/components/progress-bar.tsx +64 -7
- package/src/lib/react/hooks/use-drag-value.ts +5 -2
- package/src/lib/react/hooks/use-playback.ts +35 -21
package/dist/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { l as e, n as t, o as n, r, s as i, t as a, u as o } from "./engine-
|
|
1
|
+
import { l as e, n as t, o as n, r, s as i, t as a, u as o } from "./engine-CDdjRm_U.js";
|
|
2
2
|
import { Children as s, Fragment as c, isValidElement as l, useCallback as u, useEffect as d, useMemo as f, useRef as p, useState as m } from "react";
|
|
3
3
|
import { css as h, keyframes as g } from "@emotion/react";
|
|
4
4
|
import { createPlayer as _, useContainerAttach as v, useMediaAttach as y } from "@videojs/react";
|
|
5
5
|
import { definePlayerFeature as b, videoFeatures as x } from "@videojs/core/dom";
|
|
6
6
|
import { Fragment as S, jsx as C, jsxs as w } from "@emotion/react/jsx-runtime";
|
|
7
|
-
import { AlertTriangle as T, Check as E, ChevronLeft as D, ChevronRight as O, Copy as k, Maximize as A, Minimize as j, Pause as M, Play as N, RotateCcw as P, Settings as F, Volume1 as I, Volume2 as
|
|
8
|
-
import { Tooltip as
|
|
7
|
+
import { AlertTriangle as T, Check as E, ChevronLeft as D, ChevronRight as O, Copy as k, Maximize as A, Minimize as j, Pause as M, Play as N, RotateCcw as P, Settings as F, Volume1 as I, Volume2 as ee, VolumeX as te } from "react-feather";
|
|
8
|
+
import { Tooltip as ne } from "react-tooltip";
|
|
9
9
|
//#region src/lib/react/source-feature.ts
|
|
10
|
-
var
|
|
10
|
+
var re = {
|
|
11
11
|
indexes: [],
|
|
12
12
|
thumbnails: [],
|
|
13
13
|
subtitleTracks: [],
|
|
@@ -25,19 +25,19 @@ var ne = {
|
|
|
25
25
|
playbackErrors: [],
|
|
26
26
|
ready: !1,
|
|
27
27
|
setSourceState: () => {}
|
|
28
|
-
},
|
|
28
|
+
}, ie = b({
|
|
29
29
|
name: "source",
|
|
30
|
-
state: () => ({ ...
|
|
30
|
+
state: () => ({ ...re }),
|
|
31
31
|
attach({ set: e }) {
|
|
32
32
|
e({
|
|
33
33
|
setSourceState: (t) => e(t),
|
|
34
34
|
setHideUI: (t) => e({ hideUI: t })
|
|
35
35
|
});
|
|
36
36
|
}
|
|
37
|
-
}),
|
|
38
|
-
features: [...x,
|
|
37
|
+
}), L = _({
|
|
38
|
+
features: [...x, ie],
|
|
39
39
|
displayName: "MediaPlayer"
|
|
40
|
-
}),
|
|
40
|
+
}), R = L.usePlayer, ae = (e) => {
|
|
41
41
|
if (!(!e || e === "und")) try {
|
|
42
42
|
return new Intl.DisplayNames([navigator.language || "en"], {
|
|
43
43
|
type: "language",
|
|
@@ -46,39 +46,39 @@ var ne = {
|
|
|
46
46
|
} catch {
|
|
47
47
|
return;
|
|
48
48
|
}
|
|
49
|
-
},
|
|
50
|
-
let t = e.map((e) =>
|
|
49
|
+
}, oe = (e) => e?.replace(/_/g, " ").trim() || void 0, se = (e) => {
|
|
50
|
+
let t = e.map((e) => ae(e.language) ?? oe(e.title) ?? `Track ${e.streamIndex}`), n = t.reduce((e, t) => ({
|
|
51
51
|
...e,
|
|
52
52
|
[t]: (e[t] ?? 0) + 1
|
|
53
53
|
}), {});
|
|
54
54
|
return e.map((e, r) => {
|
|
55
|
-
let i = t[r], a =
|
|
55
|
+
let i = t[r], a = oe(e.title);
|
|
56
56
|
return {
|
|
57
57
|
track: e,
|
|
58
58
|
label: (n[i] ?? 0) > 1 && a && a !== i ? `${i} (${a})` : i
|
|
59
59
|
};
|
|
60
60
|
});
|
|
61
|
-
},
|
|
61
|
+
}, ce = (e) => se(e).map(({ track: e, label: t }) => ({
|
|
62
62
|
id: e.streamIndex,
|
|
63
63
|
label: t
|
|
64
|
-
})),
|
|
64
|
+
})), le = [
|
|
65
65
|
0,
|
|
66
66
|
250,
|
|
67
67
|
1e3,
|
|
68
68
|
3e3,
|
|
69
69
|
1e4
|
|
70
|
-
],
|
|
70
|
+
], ue = 6e4, de = 500, z = (e) => e instanceof Error ? e.message : String(e), fe = (e) => {
|
|
71
71
|
let t = [], n = e?.cause;
|
|
72
72
|
for (let e = 0; n != null && e < 8; e++) {
|
|
73
73
|
if (typeof MediaError < "u" && n instanceof MediaError) {
|
|
74
74
|
t.push(`MediaError code ${n.code}${n.message ? `: ${n.message}` : ""}`);
|
|
75
75
|
break;
|
|
76
76
|
}
|
|
77
|
-
t.push(
|
|
77
|
+
t.push(z(n)), n = n?.cause;
|
|
78
78
|
}
|
|
79
79
|
return t.length ? t.join("\n") : void 0;
|
|
80
|
-
},
|
|
81
|
-
let a =
|
|
80
|
+
}, pe = (e, t, r) => {
|
|
81
|
+
let a = R(), { read: o, size: s, publicPath: c = "", libavWorkerUrl: l = "", jassubWorkerUrl: f = "", jassubWasmUrl: h = "", jassubLegacyWasmUrl: g, defaultFontUrl: _, bufferSize: v, autoplay: y = !1, seekPrepareBudgetMs: b = de } = r ?? {}, [x, S] = m(void 0), [C, w] = m(0), T = p({
|
|
82
82
|
count: 0,
|
|
83
83
|
at: 0
|
|
84
84
|
}), E = p(void 0);
|
|
@@ -88,46 +88,47 @@ var ne = {
|
|
|
88
88
|
}, a.setSourceState({ playbackErrors: [] }), () => {
|
|
89
89
|
E.current && clearTimeout(E.current);
|
|
90
90
|
}), [s]);
|
|
91
|
-
let D = p(null), O = p(null), k = p(
|
|
92
|
-
|
|
93
|
-
let
|
|
94
|
-
|
|
95
|
-
let
|
|
96
|
-
|
|
97
|
-
let
|
|
91
|
+
let D = p(null), O = p(null), k = p(!1), A = p(o);
|
|
92
|
+
A.current = o;
|
|
93
|
+
let j = p(r?.onSeek);
|
|
94
|
+
j.current = r?.onSeek;
|
|
95
|
+
let M = p(r?.onPlaybackError);
|
|
96
|
+
M.current = r?.onPlaybackError;
|
|
97
|
+
let N = u((e) => {
|
|
98
98
|
let t = typeof e == "number" ? e : void 0;
|
|
99
|
-
|
|
100
|
-
}, [a]),
|
|
99
|
+
k.current = !0, a.setSourceState({ selectedSubtitleTrack: t }), D.current?.selectSubtitleStream(t);
|
|
100
|
+
}, [a]), P = u((e) => {
|
|
101
101
|
let t = D.current;
|
|
102
102
|
if (!t || b <= 0) {
|
|
103
103
|
a.seek(e);
|
|
104
104
|
return;
|
|
105
105
|
}
|
|
106
|
-
let n = performance.now(),
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
106
|
+
let n = typeof window < "u" && window.__mediaPlayerSeekDebug, r = performance.now(), i = !1, o = "prepared", s = () => {
|
|
107
|
+
if (!i && (i = !0, a.seek(e), n)) {
|
|
108
|
+
let n = t.videoElement, i = 0;
|
|
109
|
+
if (n) for (let t = 0; t < n.buffered.length; t++) n.buffered.start(t) <= e + 1 && e < n.buffered.end(t) && (i = n.buffered.end(t) - e);
|
|
110
|
+
console.warn(`[media-player] seek to ${e.toFixed(2)} moved after ${Math.round(performance.now() - r)}ms via ${o}, runway ${i.toFixed(1)}s${o === "deadline" ? " (EXPOSED: moved before its data was ready)" : ""}`);
|
|
111
|
+
}
|
|
112
|
+
}, c = setTimeout(() => {
|
|
113
|
+
o = "deadline", s();
|
|
114
|
+
}, b);
|
|
114
115
|
t.prepareSeek(e).catch(() => {}).finally(() => {
|
|
115
|
-
clearTimeout(
|
|
116
|
+
clearTimeout(c), s();
|
|
116
117
|
});
|
|
117
|
-
}, [a, b]),
|
|
118
|
+
}, [a, b]), F = u((e) => {
|
|
118
119
|
typeof e == "number" && (a.setSourceState({ selectedAudioTrack: e }), S(e));
|
|
119
|
-
}, [a]),
|
|
120
|
+
}, [a]), I = R((e) => e.setSourceState);
|
|
120
121
|
d(() => {
|
|
121
|
-
|
|
122
|
-
selectSubtitleTrack:
|
|
123
|
-
selectAudioTrack:
|
|
124
|
-
requestSeek:
|
|
122
|
+
I({
|
|
123
|
+
selectSubtitleTrack: N,
|
|
124
|
+
selectAudioTrack: F,
|
|
125
|
+
requestSeek: P
|
|
125
126
|
});
|
|
126
127
|
}, [
|
|
127
|
-
L,
|
|
128
|
-
P,
|
|
129
128
|
I,
|
|
130
|
-
|
|
129
|
+
N,
|
|
130
|
+
F,
|
|
131
|
+
P
|
|
131
132
|
]), d(() => {
|
|
132
133
|
if (!e || !t || !s || !o) return;
|
|
133
134
|
let r = !1;
|
|
@@ -136,7 +137,7 @@ var ne = {
|
|
|
136
137
|
ready: !1
|
|
137
138
|
});
|
|
138
139
|
let u = (t, n) => {
|
|
139
|
-
let r = Date.now(), i =
|
|
140
|
+
let r = Date.now(), i = z(t), o = fe(t), s = a.playbackErrors, c = s[s.length - 1];
|
|
140
141
|
if (c && c.message === i && c.detail === o && c.recovered === n) {
|
|
141
142
|
let e = {
|
|
142
143
|
...c,
|
|
@@ -161,25 +162,25 @@ var ne = {
|
|
|
161
162
|
let t = n(e);
|
|
162
163
|
if (u(e, t), t) {
|
|
163
164
|
let t = performance.now();
|
|
164
|
-
t - T.current.at >
|
|
165
|
+
t - T.current.at > ue && (T.current = {
|
|
165
166
|
count: 0,
|
|
166
167
|
at: t
|
|
167
168
|
});
|
|
168
|
-
let n =
|
|
169
|
+
let n = le[Math.min(T.current.count, le.length - 1)];
|
|
169
170
|
T.current = {
|
|
170
171
|
count: T.current.count + 1,
|
|
171
172
|
at: t
|
|
172
173
|
}, console.warn(`the media element failed; rebuilding the pipeline${n ? ` in ${n}ms` : ""}`, e), E.current && clearTimeout(E.current), E.current = setTimeout(() => w((e) => e + 1), n);
|
|
173
174
|
return;
|
|
174
175
|
}
|
|
175
|
-
console.error("playback failed", e), a.setSourceState({ playbackError: e }),
|
|
176
|
+
console.error("playback failed", e), a.setSourceState({ playbackError: e }), M.current?.(e);
|
|
176
177
|
};
|
|
177
178
|
return (async () => {
|
|
178
179
|
try {
|
|
179
180
|
let n = await i({
|
|
180
181
|
videoElement: e,
|
|
181
182
|
canvasElement: t,
|
|
182
|
-
read: (e, t) =>
|
|
183
|
+
read: (e, t) => A.current(e, t),
|
|
183
184
|
length: s,
|
|
184
185
|
publicPath: c,
|
|
185
186
|
libavWorkerUrl: l,
|
|
@@ -199,16 +200,16 @@ var ne = {
|
|
|
199
200
|
onRecovered: () => {
|
|
200
201
|
r || a.setSourceState({ playbackError: null });
|
|
201
202
|
},
|
|
202
|
-
onSeek: (e) =>
|
|
203
|
+
onSeek: (e) => j.current?.(e),
|
|
203
204
|
onSubtitleStreams: (e) => {
|
|
204
205
|
r || a.setSourceState({
|
|
205
|
-
subtitleTracks:
|
|
206
|
-
...
|
|
206
|
+
subtitleTracks: ce(e),
|
|
207
|
+
...k.current ? {} : { selectedSubtitleTrack: e[0]?.streamIndex }
|
|
207
208
|
});
|
|
208
209
|
},
|
|
209
210
|
onAudioStreams: (e, t) => {
|
|
210
211
|
r || a.setSourceState({
|
|
211
|
-
audioTracks:
|
|
212
|
+
audioTracks: ce(e),
|
|
212
213
|
selectedAudioTrack: t
|
|
213
214
|
});
|
|
214
215
|
}
|
|
@@ -245,13 +246,13 @@ var ne = {
|
|
|
245
246
|
y,
|
|
246
247
|
C
|
|
247
248
|
]);
|
|
248
|
-
},
|
|
249
|
+
}, me = 5e3, he = 6e4, B = ({ publicPath: e, workerUrl: t, length: n, read: i, downloadedRanges: a }) => {
|
|
249
250
|
let [o, s] = m([]), c = p(null), l = p(i);
|
|
250
251
|
l.current = i;
|
|
251
252
|
let u = f(() => a?.map(({ startByteOffset: e, endByteOffset: t }) => [e, t]), [a?.map(({ startByteOffset: e, endByteOffset: t }) => `${e}-${t}`).join(",")]), h = p(u);
|
|
252
253
|
return h.current = u, d(() => {
|
|
253
254
|
if (!n || !i || !e || !t) return;
|
|
254
|
-
let a = !1, o = null, u, d =
|
|
255
|
+
let a = !1, o = null, u, d = me, f = () => {
|
|
255
256
|
r({
|
|
256
257
|
publicPath: e,
|
|
257
258
|
workerUrl: t,
|
|
@@ -267,7 +268,7 @@ var ne = {
|
|
|
267
268
|
}
|
|
268
269
|
o = e, c.current = e, e.update(h.current);
|
|
269
270
|
}, () => {
|
|
270
|
-
a || (u = setTimeout(f, d), d = Math.min(d * 2,
|
|
271
|
+
a || (u = setTimeout(f, d), d = Math.min(d * 2, he));
|
|
271
272
|
});
|
|
272
273
|
};
|
|
273
274
|
return f(), () => {
|
|
@@ -280,7 +281,7 @@ var ne = {
|
|
|
280
281
|
]), d(() => {
|
|
281
282
|
c.current?.update(u);
|
|
282
283
|
}, [u]), o;
|
|
283
|
-
},
|
|
284
|
+
}, V = (e, n) => {
|
|
284
285
|
let r = p(null), [i, o] = m(!1), [s] = m(() => t());
|
|
285
286
|
d(() => {
|
|
286
287
|
if (!e || !n || !s) return;
|
|
@@ -308,7 +309,7 @@ var ne = {
|
|
|
308
309
|
mode: s,
|
|
309
310
|
burnedIn: i
|
|
310
311
|
};
|
|
311
|
-
},
|
|
312
|
+
}, H = {
|
|
312
313
|
headings: {
|
|
313
314
|
large: "\n font-weight: 600;\n font-size: calc(2.8 * var(--mp-unit));\n line-height: calc(3.4 * var(--mp-unit));\n @media (min-width: 960px) {\n font-size: calc(3.4 * var(--mp-unit));\n line-height: calc(4.1 * var(--mp-unit));\n }\n ",
|
|
314
315
|
medium: "\n font-weight: 600;\n font-size: calc(2.4 * var(--mp-unit));\n line-height: calc(2.9 * var(--mp-unit));\n @media (min-width: 960px) {\n font-size: calc(2.8 * var(--mp-unit));\n line-height: calc(3.4 * var(--mp-unit));\n }\n ",
|
|
@@ -350,7 +351,7 @@ var ne = {
|
|
|
350
351
|
padding: calc(1.2 * var(--mp-unit)) calc(1.6 * var(--mp-unit));
|
|
351
352
|
/* clears a notch once the player is fullscreen; resolves to zero everywhere else */
|
|
352
353
|
padding-top: calc(calc(1.2 * var(--mp-unit)) + env(safe-area-inset-top, 0px));
|
|
353
|
-
${
|
|
354
|
+
${H.headings.small}
|
|
354
355
|
color: white;
|
|
355
356
|
text-shadow: 0 0 4px rgba(0, 0, 0, 1);
|
|
356
357
|
z-index: 2;
|
|
@@ -398,11 +399,11 @@ var ne = {
|
|
|
398
399
|
padding: 0 calc(2 * var(--mp-unit));
|
|
399
400
|
text-align: center;
|
|
400
401
|
color: #fff;
|
|
401
|
-
${
|
|
402
|
+
${H.bLarge.regular}
|
|
402
403
|
text-shadow: 0 0 4px rgba(0, 0, 0, 1);
|
|
403
404
|
pointer-events: none;
|
|
404
405
|
`, be = (e) => e instanceof Error ? e.message : typeof e == "string" ? e : "Playback failed", xe = ({ onCanvasRef: e }) => {
|
|
405
|
-
let t =
|
|
406
|
+
let t = R((e) => e.title), n = R((e) => e.hideUI), r = R((e) => e.playbackError), i = R((e) => e.ready), a = R((e) => e.size), o = R((e) => e.waiting);
|
|
406
407
|
return /* @__PURE__ */ w(S, { children: [
|
|
407
408
|
t ? /* @__PURE__ */ C("div", {
|
|
408
409
|
className: "title",
|
|
@@ -423,11 +424,11 @@ var ne = {
|
|
|
423
424
|
css: ge
|
|
424
425
|
})
|
|
425
426
|
] });
|
|
426
|
-
},
|
|
427
|
+
}, U = 1e-4, W = 1, Se = (e) => Math.max(U, Math.min(W, e)) ** 2, G = (e) => Math.max(U, Math.min(W, e)) ** (W / 2), K = (e) => {
|
|
427
428
|
if (e === void 0) return "0:00";
|
|
428
429
|
let t = Math.floor(e / 3600), n = Math.floor(e % 3600 / 60), r = Math.floor(e % 60);
|
|
429
430
|
return t > 0 ? `${t}:${n < 10 ? "0" : ""}${n}:${r < 10 ? "0" : ""}${r}` : `${n}:${r < 10 ? "0" : ""}${r}`;
|
|
430
|
-
},
|
|
431
|
+
}, Ce = (e, t) => `${K(e)} / ${K(t)}`, we = (e) => h`
|
|
431
432
|
display: flex;
|
|
432
433
|
justify-content: flex-end;
|
|
433
434
|
|
|
@@ -437,7 +438,7 @@ var ne = {
|
|
|
437
438
|
z-index: 3;
|
|
438
439
|
|
|
439
440
|
* {
|
|
440
|
-
${
|
|
441
|
+
${H.bMedium.regular}
|
|
441
442
|
}
|
|
442
443
|
|
|
443
444
|
${e === "sm" && h`
|
|
@@ -457,8 +458,8 @@ var ne = {
|
|
|
457
458
|
"data-tooltip-delay-hide": i,
|
|
458
459
|
"data-tooltip-place": o,
|
|
459
460
|
children: n
|
|
460
|
-
}), !s && /* @__PURE__ */ C(
|
|
461
|
-
css:
|
|
461
|
+
}), !s && /* @__PURE__ */ C(ne, {
|
|
462
|
+
css: we(c),
|
|
462
463
|
id: e,
|
|
463
464
|
noArrow: !0,
|
|
464
465
|
children: t
|
|
@@ -471,11 +472,23 @@ var ne = {
|
|
|
471
472
|
let { left: a, right: o, top: s, bottom: c } = i.getBoundingClientRect(), l = n === "horizontal" ? (t - a) / (o - a) : (c - r) / (c - s);
|
|
472
473
|
return Math.min(Math.max(l, 0), 1);
|
|
473
474
|
}, [e, n]), l = u((e) => {
|
|
474
|
-
r || e.button > 0
|
|
475
|
+
if (!(r || e.button > 0)) {
|
|
476
|
+
s.current = e.pointerId;
|
|
477
|
+
try {
|
|
478
|
+
e.currentTarget.setPointerCapture?.(e.pointerId);
|
|
479
|
+
} catch {}
|
|
480
|
+
a(!0), o.current(c(e.clientX, e.clientY));
|
|
481
|
+
}
|
|
475
482
|
}, [r, c]), f = u((e) => {
|
|
476
483
|
s.current === e.pointerId && o.current(c(e.clientX, e.clientY));
|
|
477
484
|
}, [c]), h = u((e) => {
|
|
478
|
-
|
|
485
|
+
if (s.current === e.pointerId) {
|
|
486
|
+
s.current = null;
|
|
487
|
+
try {
|
|
488
|
+
e.currentTarget.releasePointerCapture?.(e.pointerId);
|
|
489
|
+
} catch {}
|
|
490
|
+
a(!1);
|
|
491
|
+
}
|
|
479
492
|
}, []);
|
|
480
493
|
return d(() => {
|
|
481
494
|
r && (s.current = null, a(!1));
|
|
@@ -489,7 +502,7 @@ var ne = {
|
|
|
489
502
|
style: { touchAction: "none" }
|
|
490
503
|
}
|
|
491
504
|
};
|
|
492
|
-
},
|
|
505
|
+
}, Te = h`
|
|
493
506
|
position: relative;
|
|
494
507
|
height: calc(.4 * var(--mp-unit));
|
|
495
508
|
|
|
@@ -543,7 +556,7 @@ var ne = {
|
|
|
543
556
|
box-shadow: 0 0 calc(1 * var(--mp-unit)) rgba(0, 0, 0, .5);
|
|
544
557
|
|
|
545
558
|
text-shadow: 0 0 4px rgba(0, 0, 0, 1);
|
|
546
|
-
${
|
|
559
|
+
${H.bMedium.bold}
|
|
547
560
|
|
|
548
561
|
position: absolute;
|
|
549
562
|
/* Anchored on its bottom edge rather than its top: now that it has a background its height
|
|
@@ -660,25 +673,36 @@ var ne = {
|
|
|
660
673
|
--thumbnail-width: calc(18 * var(--mp-unit));
|
|
661
674
|
--thumbnail-half: calc(9 * var(--mp-unit));
|
|
662
675
|
}
|
|
663
|
-
`, De = () => {
|
|
664
|
-
let e =
|
|
676
|
+
`, Ee = 4, De = () => {
|
|
677
|
+
let e = R(), t = R((e) => e.currentTime), n = R((e) => e.requestSeek), r = R((e) => e.duration), i = R((e) => e.size), a = R((e) => e.downloadedRanges), o = R((e) => e.indexes), s = R((e) => e.thumbnails), c = R((e) => e.thumbnailAt), l = p(null), [u, h] = m(void 0), [g, _] = m(void 0), v = p(void 0), y = p(0), b = p(void 0), x = p(void 0), S = p(!1), { dragging: T, handlers: E } = J({
|
|
665
678
|
ref: l,
|
|
666
679
|
onChange: (e) => {
|
|
680
|
+
if (y.current += 1, b.current = e, x.current === void 0) x.current = e;
|
|
681
|
+
else if (!S.current) {
|
|
682
|
+
let t = l.current?.getBoundingClientRect().width ?? 0;
|
|
683
|
+
Math.abs(e - x.current) * t > Ee && (S.current = !0);
|
|
684
|
+
}
|
|
667
685
|
h(e), v.current !== "mouse" && _(e * r);
|
|
668
686
|
}
|
|
669
|
-
}),
|
|
670
|
-
v.current = e.pointerType,
|
|
671
|
-
},
|
|
672
|
-
|
|
673
|
-
|
|
687
|
+
}), D = (e) => {
|
|
688
|
+
v.current = e.pointerType, y.current = 0, x.current = void 0, S.current = !1, E.onPointerDown(e);
|
|
689
|
+
}, O = (t) => {
|
|
690
|
+
E.onPointerUp(t);
|
|
691
|
+
let i = y.current > 0 ? b.current : void 0;
|
|
692
|
+
if (i !== void 0 && r) {
|
|
693
|
+
let t = i * r;
|
|
694
|
+
n ? n(t) : e.seek(t);
|
|
695
|
+
}
|
|
696
|
+
y.current = 0, S.current = !1, x.current = void 0, t.pointerType !== "mouse" && _(void 0);
|
|
697
|
+
}, k = (e) => {
|
|
674
698
|
if (!l.current) return;
|
|
675
699
|
let { left: t, right: n } = l.current.getBoundingClientRect();
|
|
676
700
|
return Math.min(Math.max((e - t) / (n - t), 0), 1) * r;
|
|
677
|
-
},
|
|
678
|
-
_(
|
|
679
|
-
},
|
|
701
|
+
}, A = (e) => {
|
|
702
|
+
_(k(e.clientX));
|
|
703
|
+
}, j = () => {
|
|
680
704
|
l.current && _(void 0);
|
|
681
|
-
},
|
|
705
|
+
}, M = (e) => r ? e / r * 100 : 0, N = f(() => a?.map((e, t) => {
|
|
682
706
|
if (!i || !r) return null;
|
|
683
707
|
let n = o.filter((t) => e.startByteOffset <= t.pos && t.pos <= e.endByteOffset), a = n.at(0), s = n.at(-1);
|
|
684
708
|
if (!a || !s) return null;
|
|
@@ -694,22 +718,20 @@ var ne = {
|
|
|
694
718
|
r,
|
|
695
719
|
o.length,
|
|
696
720
|
a?.map(({ startByteOffset: e, endByteOffset: t }) => `${e}/${t}`).join(",")
|
|
697
|
-
]),
|
|
721
|
+
]), P = f(() => {
|
|
698
722
|
if (!g || g < 0) return;
|
|
699
723
|
let e = Math.floor(g / 3600), t = Math.floor((g - e * 3600) / 60), n = Math.floor(g - e * 3600 - t * 60);
|
|
700
724
|
return `${e > 0 ? `${e}:` : ""}${t < 10 ? "0" : ""}${t}:${n < 10 ? "0" : ""}${n}`;
|
|
701
725
|
}, [g]);
|
|
702
726
|
d(() => {
|
|
703
|
-
|
|
704
|
-
let t = u * r;
|
|
705
|
-
n ? n(t) : e.seek(t);
|
|
727
|
+
u === void 0 || !r || !T || !S.current || e.seek(u * r);
|
|
706
728
|
}, [
|
|
707
729
|
e,
|
|
708
|
-
|
|
730
|
+
T,
|
|
709
731
|
u,
|
|
710
732
|
r
|
|
711
733
|
]);
|
|
712
|
-
let
|
|
734
|
+
let F = f(() => !r || typeof t != "number" ? 0 : t / r, [r, t]), I = f(() => {
|
|
713
735
|
if (g) {
|
|
714
736
|
if (c) return c(g);
|
|
715
737
|
if (s.length) return s.find(({ startTime: e, endTime: t }) => e <= g && g < t);
|
|
@@ -720,44 +742,44 @@ var ne = {
|
|
|
720
742
|
g
|
|
721
743
|
]);
|
|
722
744
|
return /* @__PURE__ */ w("div", {
|
|
723
|
-
css:
|
|
745
|
+
css: Te,
|
|
724
746
|
ref: l,
|
|
725
|
-
className:
|
|
726
|
-
onMouseMove:
|
|
727
|
-
onMouseOut:
|
|
747
|
+
className: T ? "progress-bar dragging" : "progress-bar",
|
|
748
|
+
onMouseMove: A,
|
|
749
|
+
onMouseOut: j,
|
|
728
750
|
children: [
|
|
729
751
|
/* @__PURE__ */ C("div", { className: "background-bar" }),
|
|
730
752
|
g ? /* @__PURE__ */ C("div", {
|
|
731
753
|
className: "cursor-time",
|
|
732
|
-
style: { left: `clamp(calc(3 * var(--mp-unit)), ${
|
|
733
|
-
children:
|
|
754
|
+
style: { left: `clamp(calc(3 * var(--mp-unit)), ${M(g)}%, calc(100% - calc(3 * var(--mp-unit))))` },
|
|
755
|
+
children: P
|
|
734
756
|
}) : void 0,
|
|
735
757
|
/* @__PURE__ */ C("div", { className: "progress" }),
|
|
736
758
|
/* @__PURE__ */ C("div", {
|
|
737
759
|
className: "loaded",
|
|
738
|
-
children:
|
|
760
|
+
children: N
|
|
739
761
|
}),
|
|
740
762
|
/* @__PURE__ */ C("div", { className: "hover" }),
|
|
741
763
|
/* @__PURE__ */ C("div", {
|
|
742
764
|
className: "play-container",
|
|
743
765
|
children: /* @__PURE__ */ C("div", {
|
|
744
766
|
className: "play",
|
|
745
|
-
style: { transform: `scaleX(${
|
|
767
|
+
style: { transform: `scaleX(${F})` }
|
|
746
768
|
})
|
|
747
769
|
}),
|
|
748
770
|
/* @__PURE__ */ C("div", { className: "chapters" }),
|
|
749
771
|
/* @__PURE__ */ C("div", { className: "scrubber" }),
|
|
750
772
|
/* @__PURE__ */ C("div", {
|
|
751
773
|
className: "padding",
|
|
752
|
-
...
|
|
753
|
-
onPointerDown:
|
|
754
|
-
onPointerUp:
|
|
755
|
-
onPointerCancel:
|
|
774
|
+
...E,
|
|
775
|
+
onPointerDown: D,
|
|
776
|
+
onPointerUp: O,
|
|
777
|
+
onPointerCancel: O
|
|
756
778
|
}),
|
|
757
779
|
/* @__PURE__ */ C("div", {
|
|
758
780
|
className: "thumbnail",
|
|
759
|
-
style: { left: `clamp(var(--thumbnail-half), ${
|
|
760
|
-
children:
|
|
781
|
+
style: { left: `clamp(var(--thumbnail-half), ${M(g ?? 1)}%, calc(100% - var(--thumbnail-half)))` },
|
|
782
|
+
children: I?.url ? /* @__PURE__ */ C("img", { src: I.url }) : void 0
|
|
761
783
|
})
|
|
762
784
|
]
|
|
763
785
|
});
|
|
@@ -856,7 +878,7 @@ var ne = {
|
|
|
856
878
|
|
|
857
879
|
border-radius: 8px;
|
|
858
880
|
background-color: rgba(28,28,28,0.95);
|
|
859
|
-
${
|
|
881
|
+
${H.bMedium.regular}
|
|
860
882
|
|
|
861
883
|
z-index: 4;
|
|
862
884
|
|
|
@@ -899,7 +921,7 @@ var ne = {
|
|
|
899
921
|
|
|
900
922
|
.secondary {
|
|
901
923
|
color: #eee;
|
|
902
|
-
${
|
|
924
|
+
${H.bSmall.regular}
|
|
903
925
|
}
|
|
904
926
|
}
|
|
905
927
|
}
|
|
@@ -941,7 +963,7 @@ var ne = {
|
|
|
941
963
|
.failed {
|
|
942
964
|
border-bottom: 1px solid #4D4D4E;
|
|
943
965
|
color: #f66;
|
|
944
|
-
${
|
|
966
|
+
${H.bSmall.regular}
|
|
945
967
|
}
|
|
946
968
|
}
|
|
947
969
|
`, Me = ({ title: e, tracks: t, selected: n, onSelect: r, onBack: i, offLabel: a, pending: o, failed: s }) => {
|
|
@@ -1056,7 +1078,7 @@ ${X}
|
|
|
1056
1078
|
|
|
1057
1079
|
color: #fff;
|
|
1058
1080
|
cursor: pointer;
|
|
1059
|
-
${
|
|
1081
|
+
${H.bSmall.regular}
|
|
1060
1082
|
|
|
1061
1083
|
&:hover {
|
|
1062
1084
|
background-color: rgba(255,255,255,.1);
|
|
@@ -1077,7 +1099,7 @@ ${X}
|
|
|
1077
1099
|
|
|
1078
1100
|
.when {
|
|
1079
1101
|
color: #bbb;
|
|
1080
|
-
${
|
|
1102
|
+
${H.bSmall.regular}
|
|
1081
1103
|
|
|
1082
1104
|
/* the one part of the line worth scanning for, so it is the one part at full brightness */
|
|
1083
1105
|
.count {
|
|
@@ -1096,7 +1118,7 @@ ${X}
|
|
|
1096
1118
|
color: #ddd;
|
|
1097
1119
|
overflow-wrap: anywhere;
|
|
1098
1120
|
white-space: pre-wrap;
|
|
1099
|
-
${
|
|
1121
|
+
${H.bSmall.regular}
|
|
1100
1122
|
}
|
|
1101
1123
|
}
|
|
1102
1124
|
}
|
|
@@ -1108,7 +1130,7 @@ ${X}
|
|
|
1108
1130
|
e.detail
|
|
1109
1131
|
].filter(Boolean).join("\n");
|
|
1110
1132
|
}).join("\n\n"), Le = () => {
|
|
1111
|
-
let e =
|
|
1133
|
+
let e = R((e) => e.playbackErrors), { open: t, toggle: n, containerRef: r } = Z(), [i, a] = m(!1);
|
|
1112
1134
|
if (e.length === 0) return null;
|
|
1113
1135
|
let o = () => {
|
|
1114
1136
|
navigator.clipboard?.writeText(Ie(e)).then(() => {
|
|
@@ -1223,7 +1245,7 @@ width: 100%;
|
|
|
1223
1245
|
}
|
|
1224
1246
|
}
|
|
1225
1247
|
`, ze = () => {
|
|
1226
|
-
let e =
|
|
1248
|
+
let e = R(), t = R((e) => e.playbackRate), n = p(null), r = p(null), i = .25, a = 3 - i, o = (e, t = .05) => Math.round(e / t) * t, s = o(t || 1), c = (e) => (e - i) / a * 100, l = (e) => o(i + e * a), { handlers: u } = J({
|
|
1227
1249
|
ref: r,
|
|
1228
1250
|
onChange: (t) => e.setPlaybackRate(l(t))
|
|
1229
1251
|
}), f = (t) => {
|
|
@@ -1317,7 +1339,7 @@ ${X}
|
|
|
1317
1339
|
}
|
|
1318
1340
|
|
|
1319
1341
|
`, Ve = () => {
|
|
1320
|
-
let e =
|
|
1342
|
+
let e = R(), t = R((e) => e.playbackRate), n = R((e) => e.audioTracks), r = R((e) => e.selectedAudioTrack), i = R((e) => e.selectAudioTrack), [a, o] = m(0), { open: s, toggle: c, containerRef: l, pending: u, failed: d, runSelect: f } = Z({ onReset: () => o(0) }), p = (t) => {
|
|
1321
1343
|
e.setPlaybackRate(t), o(0);
|
|
1322
1344
|
}, h = (e) => {
|
|
1323
1345
|
e !== void 0 && f(e, () => i(e));
|
|
@@ -1418,7 +1440,7 @@ position: static;
|
|
|
1418
1440
|
|
|
1419
1441
|
${X}
|
|
1420
1442
|
`, Ue = () => {
|
|
1421
|
-
let e =
|
|
1443
|
+
let e = R((e) => e.subtitleTracks), t = R((e) => e.selectedSubtitleTrack), n = R((e) => e.selectSubtitleTrack), r = R((e) => e.subtitleOffLabel), { open: i, toggle: a, containerRef: o, pending: s, failed: c, runSelect: l } = Z();
|
|
1422
1444
|
if (e.length === 0) return null;
|
|
1423
1445
|
let u = t !== void 0;
|
|
1424
1446
|
return /* @__PURE__ */ w("div", {
|
|
@@ -1498,7 +1520,7 @@ ${X}
|
|
|
1498
1520
|
height: 10px;
|
|
1499
1521
|
}
|
|
1500
1522
|
`, Ke = ({ value: e, onChange: t }) => {
|
|
1501
|
-
let n =
|
|
1523
|
+
let n = R((e) => e.volume), r = R((e) => e.muted), i = p(null), a = p(null), { handlers: o } = J({
|
|
1502
1524
|
ref: a,
|
|
1503
1525
|
onChange: t
|
|
1504
1526
|
}), s = (n) => {
|
|
@@ -1561,7 +1583,7 @@ ${X}
|
|
|
1561
1583
|
border-radius: 4px;
|
|
1562
1584
|
|
|
1563
1585
|
.volume-value {
|
|
1564
|
-
${
|
|
1586
|
+
${H.bMedium.regular};
|
|
1565
1587
|
color: #ffffff;
|
|
1566
1588
|
}
|
|
1567
1589
|
}
|
|
@@ -1600,7 +1622,7 @@ ${X}
|
|
|
1600
1622
|
}
|
|
1601
1623
|
|
|
1602
1624
|
`, Je = ({ ref: e }) => {
|
|
1603
|
-
let t =
|
|
1625
|
+
let t = R(), n = R((e) => e.volume), r = R((e) => e.muted), i = f(() => G(n), [n]);
|
|
1604
1626
|
return /* @__PURE__ */ w("div", {
|
|
1605
1627
|
css: qe,
|
|
1606
1628
|
children: [/* @__PURE__ */ C(q, {
|
|
@@ -1612,7 +1634,7 @@ ${X}
|
|
|
1612
1634
|
ref: e,
|
|
1613
1635
|
"aria-label": "Mute",
|
|
1614
1636
|
"aria-pressed": r || n === 0,
|
|
1615
|
-
children: C(r || n === 0 ?
|
|
1637
|
+
children: C(r || n === 0 ? te : n <= .5 ? I : ee, {
|
|
1616
1638
|
size: 18,
|
|
1617
1639
|
color: "#fff"
|
|
1618
1640
|
})
|
|
@@ -1625,7 +1647,7 @@ ${X}
|
|
|
1625
1647
|
children: /* @__PURE__ */ C(Ke, {
|
|
1626
1648
|
value: r ? 0 : i,
|
|
1627
1649
|
onChange: (e) => {
|
|
1628
|
-
t.setVolume(
|
|
1650
|
+
t.setVolume(Se(e));
|
|
1629
1651
|
}
|
|
1630
1652
|
})
|
|
1631
1653
|
})
|
|
@@ -1759,7 +1781,7 @@ ${X}
|
|
|
1759
1781
|
|
|
1760
1782
|
.left {
|
|
1761
1783
|
.time {
|
|
1762
|
-
${
|
|
1784
|
+
${H.bMedium.regular}
|
|
1763
1785
|
text-shadow: 0 0 4px rgba(0, 0, 0, 1);
|
|
1764
1786
|
}
|
|
1765
1787
|
}
|
|
@@ -1781,9 +1803,9 @@ ${X}
|
|
|
1781
1803
|
}
|
|
1782
1804
|
}
|
|
1783
1805
|
`, Qe = () => {
|
|
1784
|
-
let e =
|
|
1806
|
+
let e = R(), t = R((e) => e.paused), n = R((e) => e.currentTime), r = R((e) => e.duration), i = R((e) => e.fullscreen), a = R((e) => e.hideUI), o = R((e) => e.togglePictureInPicture), s = R((e) => e.pictureInPictureMode), c = R((e) => e.burnedInSubtitles), l = R((e) => e.subtitleTracks), f = R((e) => e.requestSeek), [p, h] = m(null), g = s === "burn-in", _ = l.length > 0, v = r > 0 && n === r, y = u(({ direction: t, stepSize: n }) => {
|
|
1785
1807
|
let r = G(e.volume), i = t === "up" ? n : -n, a = Math.max(0, Math.min(1, r + i)), o = e.muted;
|
|
1786
|
-
e.setVolume(
|
|
1808
|
+
e.setVolume(Se(a)), o && !e.muted && e.toggleMuted();
|
|
1787
1809
|
}, [e]);
|
|
1788
1810
|
d(() => {
|
|
1789
1811
|
let t = (t) => f ? f(t) : e.seek(t), n = (n) => {
|
|
@@ -1851,7 +1873,7 @@ ${X}
|
|
|
1851
1873
|
/* @__PURE__ */ C(Je, { ref: h }),
|
|
1852
1874
|
/* @__PURE__ */ C("div", {
|
|
1853
1875
|
className: "time",
|
|
1854
|
-
children:
|
|
1876
|
+
children: Ce(n, r)
|
|
1855
1877
|
})
|
|
1856
1878
|
]
|
|
1857
1879
|
}), /* @__PURE__ */ w("div", {
|
|
@@ -1941,12 +1963,12 @@ ${X}
|
|
|
1941
1963
|
}
|
|
1942
1964
|
|
|
1943
1965
|
.title {
|
|
1944
|
-
${
|
|
1966
|
+
${H.bMedium.bold}
|
|
1945
1967
|
color: #fff;
|
|
1946
1968
|
}
|
|
1947
1969
|
|
|
1948
1970
|
.body {
|
|
1949
|
-
${
|
|
1971
|
+
${H.bSmall.regular}
|
|
1950
1972
|
color: rgba(255, 255, 255, 0.75);
|
|
1951
1973
|
}
|
|
1952
1974
|
|
|
@@ -1958,7 +1980,7 @@ ${X}
|
|
|
1958
1980
|
color: #6EA8FE;
|
|
1959
1981
|
}
|
|
1960
1982
|
`, tt = () => {
|
|
1961
|
-
let e =
|
|
1983
|
+
let e = R((e) => e.burnedInSubtitles), t = R((e) => e.pictureInPictureMode), [n, r] = m(!1);
|
|
1962
1984
|
return d(() => {
|
|
1963
1985
|
if (t !== "burn-in" || !e) {
|
|
1964
1986
|
r(!1);
|
|
@@ -2039,7 +2061,7 @@ ${X}
|
|
|
2039
2061
|
item: e
|
|
2040
2062
|
}];
|
|
2041
2063
|
}), ot = ({ ref: e, onVideoRef: t, onCanvasRef: n, overlay: r, controls: i, children: a }) => {
|
|
2042
|
-
let o =
|
|
2064
|
+
let o = R(), s = R((e) => e.hideUI), c = R((e) => e.setHideUI), l = p(void 0), u = p("mouse");
|
|
2043
2065
|
d(() => () => clearTimeout(l.current), []);
|
|
2044
2066
|
let f = () => {
|
|
2045
2067
|
c(!1), clearTimeout(l.current), l.current = setTimeout(() => c(!0), nt);
|
|
@@ -2091,14 +2113,14 @@ ${X}
|
|
|
2091
2113
|
});
|
|
2092
2114
|
}, st = ({ options: e, children: t }) => {
|
|
2093
2115
|
let n = "media" in e ? e : null, r = n ? null : e, { title: i } = e, { size: a, downloadedRanges: o, publicPath: s, libavWorkerUrl: c, read: l, thumbnailRead: u, thumbnailsEnabled: f } = r ?? {}, p = y(), h = v(), [g, _] = m(null), [b, x] = m(null), S = n?.media ?? g;
|
|
2094
|
-
d(() => (p?.(S), () => p?.(null)), [S, p]),
|
|
2095
|
-
let w =
|
|
2116
|
+
d(() => (p?.(S), () => p?.(null)), [S, p]), pe(g, b, r);
|
|
2117
|
+
let w = B({
|
|
2096
2118
|
publicPath: s,
|
|
2097
2119
|
workerUrl: c,
|
|
2098
2120
|
length: f === !1 ? void 0 : a,
|
|
2099
2121
|
read: u ?? l,
|
|
2100
2122
|
downloadedRanges: o
|
|
2101
|
-
}), T = n?.thumbnails?.all ?? w, { toggle: E, mode: D, burnedIn: O } =
|
|
2123
|
+
}), T = n?.thumbnails?.all ?? w, { toggle: E, mode: D, burnedIn: O } = V(g, b), k = R((e) => e.setSourceState);
|
|
2102
2124
|
d(() => {
|
|
2103
2125
|
k({
|
|
2104
2126
|
title: i,
|
|
@@ -2230,7 +2252,7 @@ ${X}
|
|
|
2230
2252
|
overflow: hidden;
|
|
2231
2253
|
`, lt = (e) => /* @__PURE__ */ C("div", {
|
|
2232
2254
|
css: ct,
|
|
2233
|
-
children: /* @__PURE__ */ C(
|
|
2255
|
+
children: /* @__PURE__ */ C(L.Provider, { children: /* @__PURE__ */ C(st, {
|
|
2234
2256
|
options: e,
|
|
2235
2257
|
children: e.children
|
|
2236
2258
|
}) })
|
|
@@ -2273,4 +2295,4 @@ ${X}
|
|
|
2273
2295
|
throw Error(`Unknown source type: ${e}`);
|
|
2274
2296
|
};
|
|
2275
2297
|
//#endregion
|
|
2276
|
-
export { lt as MediaPlayer, lt as default,
|
|
2298
|
+
export { lt as MediaPlayer, lt as default, L as Player, e as SUBTITLES_OFF, a as createPictureInPicture, o as createSubtitleRenderer, r as createThumbnailGenerator, ht as inputToRemuxerInput, dt as isDelegatedTracks, ut as isExternalThumbnails, ie as sourceFeature, i as startPlayback, V as usePictureInPicture, R as usePlayer, B as useSeekThumbnails };
|