@banou/media-player 0.8.19 → 0.8.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +58 -0
- package/dist/index.js +123 -105
- package/dist/react/video-player.d.ts +10 -0
- package/dist/remote/index.d.ts +137 -0
- package/dist/remote/index.js +382 -0
- package/dist/remote/protocol.d.ts +91 -0
- package/package.json +10 -1
- package/src/lib/react/video-player.tsx +42 -1
- package/src/lib/remote/index.ts +629 -0
- package/src/lib/remote/protocol.ts +152 -0
package/dist/index.js
CHANGED
|
@@ -4,10 +4,10 @@ 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 L, VolumeX as R } from "react-feather";
|
|
8
|
+
import { Tooltip as z } from "react-tooltip";
|
|
9
9
|
//#region src/lib/react/source-feature.ts
|
|
10
|
-
var
|
|
10
|
+
var ee = {
|
|
11
11
|
indexes: [],
|
|
12
12
|
thumbnails: [],
|
|
13
13
|
subtitleTracks: [],
|
|
@@ -25,19 +25,19 @@ var re = {
|
|
|
25
25
|
playbackErrors: [],
|
|
26
26
|
ready: !1,
|
|
27
27
|
setSourceState: () => {}
|
|
28
|
-
},
|
|
28
|
+
}, te = b({
|
|
29
29
|
name: "source",
|
|
30
|
-
state: () => ({ ...
|
|
30
|
+
state: () => ({ ...ee }),
|
|
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
|
+
}), B = _({
|
|
38
|
+
features: [...x, te],
|
|
39
39
|
displayName: "MediaPlayer"
|
|
40
|
-
}),
|
|
40
|
+
}), V = B.usePlayer, ne = (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 re = {
|
|
|
46
46
|
} catch {
|
|
47
47
|
return;
|
|
48
48
|
}
|
|
49
|
-
},
|
|
50
|
-
let t = e.map((e) =>
|
|
49
|
+
}, re = (e) => e?.replace(/_/g, " ").trim() || void 0, ie = (e) => {
|
|
50
|
+
let t = e.map((e) => ne(e.language) ?? re(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 = re(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
|
+
}, ae = (e) => ie(e).map(({ track: e, label: t }) => ({
|
|
62
62
|
id: e.streamIndex,
|
|
63
63
|
label: t
|
|
64
|
-
})),
|
|
64
|
+
})), oe = [
|
|
65
65
|
0,
|
|
66
66
|
250,
|
|
67
67
|
1e3,
|
|
68
68
|
3e3,
|
|
69
69
|
1e4
|
|
70
|
-
],
|
|
70
|
+
], se = 6e4, ce = 500, le = (e) => e instanceof Error ? e.message : String(e), ue = (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(le(n)), n = n?.cause;
|
|
78
78
|
}
|
|
79
79
|
return t.length ? t.join("\n") : void 0;
|
|
80
|
-
},
|
|
81
|
-
let a =
|
|
80
|
+
}, de = (e, t, r) => {
|
|
81
|
+
let a = V(), { read: o, size: s, publicPath: c = "", libavWorkerUrl: l = "", jassubWorkerUrl: f = "", jassubWasmUrl: h = "", jassubLegacyWasmUrl: g, defaultFontUrl: _, bufferSize: v, autoplay: y = !1, seekPrepareBudgetMs: b = ce } = 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);
|
|
@@ -117,7 +117,7 @@ var re = {
|
|
|
117
117
|
});
|
|
118
118
|
}, [a, b]), F = u((e) => {
|
|
119
119
|
typeof e == "number" && (a.setSourceState({ selectedAudioTrack: e }), S(e));
|
|
120
|
-
}, [a]), I =
|
|
120
|
+
}, [a]), I = V((e) => e.setSourceState);
|
|
121
121
|
d(() => {
|
|
122
122
|
I({
|
|
123
123
|
selectSubtitleTrack: N,
|
|
@@ -137,7 +137,7 @@ var re = {
|
|
|
137
137
|
ready: !1
|
|
138
138
|
});
|
|
139
139
|
let u = (t, n) => {
|
|
140
|
-
let r = Date.now(), i =
|
|
140
|
+
let r = Date.now(), i = le(t), o = ue(t), s = a.playbackErrors, c = s[s.length - 1];
|
|
141
141
|
if (c && c.message === i && c.detail === o && c.recovered === n) {
|
|
142
142
|
let e = {
|
|
143
143
|
...c,
|
|
@@ -162,11 +162,11 @@ var re = {
|
|
|
162
162
|
let t = n(e);
|
|
163
163
|
if (u(e, t), t) {
|
|
164
164
|
let t = performance.now();
|
|
165
|
-
t - T.current.at >
|
|
165
|
+
t - T.current.at > se && (T.current = {
|
|
166
166
|
count: 0,
|
|
167
167
|
at: t
|
|
168
168
|
});
|
|
169
|
-
let n =
|
|
169
|
+
let n = oe[Math.min(T.current.count, oe.length - 1)];
|
|
170
170
|
T.current = {
|
|
171
171
|
count: T.current.count + 1,
|
|
172
172
|
at: t
|
|
@@ -203,13 +203,13 @@ var re = {
|
|
|
203
203
|
onSeek: (e) => j.current?.(e),
|
|
204
204
|
onSubtitleStreams: (e) => {
|
|
205
205
|
r || a.setSourceState({
|
|
206
|
-
subtitleTracks:
|
|
206
|
+
subtitleTracks: ae(e),
|
|
207
207
|
...k.current ? {} : { selectedSubtitleTrack: e[0]?.streamIndex }
|
|
208
208
|
});
|
|
209
209
|
},
|
|
210
210
|
onAudioStreams: (e, t) => {
|
|
211
211
|
r || a.setSourceState({
|
|
212
|
-
audioTracks:
|
|
212
|
+
audioTracks: ae(e),
|
|
213
213
|
selectedAudioTrack: t
|
|
214
214
|
});
|
|
215
215
|
}
|
|
@@ -246,13 +246,13 @@ var re = {
|
|
|
246
246
|
y,
|
|
247
247
|
C
|
|
248
248
|
]);
|
|
249
|
-
},
|
|
249
|
+
}, fe = 5e3, pe = 6e4, me = ({ publicPath: e, workerUrl: t, length: n, read: i, downloadedRanges: a }) => {
|
|
250
250
|
let [o, s] = m([]), c = p(null), l = p(i);
|
|
251
251
|
l.current = i;
|
|
252
252
|
let u = f(() => a?.map(({ startByteOffset: e, endByteOffset: t }) => [e, t]), [a?.map(({ startByteOffset: e, endByteOffset: t }) => `${e}-${t}`).join(",")]), h = p(u);
|
|
253
253
|
return h.current = u, d(() => {
|
|
254
254
|
if (!n || !i || !e || !t) return;
|
|
255
|
-
let a = !1, o = null, u, d =
|
|
255
|
+
let a = !1, o = null, u, d = fe, f = () => {
|
|
256
256
|
r({
|
|
257
257
|
publicPath: e,
|
|
258
258
|
workerUrl: t,
|
|
@@ -268,7 +268,7 @@ var re = {
|
|
|
268
268
|
}
|
|
269
269
|
o = e, c.current = e, e.update(h.current);
|
|
270
270
|
}, () => {
|
|
271
|
-
a || (u = setTimeout(f, d), d = Math.min(d * 2,
|
|
271
|
+
a || (u = setTimeout(f, d), d = Math.min(d * 2, pe));
|
|
272
272
|
});
|
|
273
273
|
};
|
|
274
274
|
return f(), () => {
|
|
@@ -281,7 +281,7 @@ var re = {
|
|
|
281
281
|
]), d(() => {
|
|
282
282
|
c.current?.update(u);
|
|
283
283
|
}, [u]), o;
|
|
284
|
-
},
|
|
284
|
+
}, he = (e, n) => {
|
|
285
285
|
let r = p(null), [i, o] = m(!1), [s] = m(() => t());
|
|
286
286
|
d(() => {
|
|
287
287
|
if (!e || !n || !s) return;
|
|
@@ -309,7 +309,7 @@ var re = {
|
|
|
309
309
|
mode: s,
|
|
310
310
|
burnedIn: i
|
|
311
311
|
};
|
|
312
|
-
},
|
|
312
|
+
}, H = {
|
|
313
313
|
headings: {
|
|
314
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 ",
|
|
315
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 ",
|
|
@@ -336,14 +336,14 @@ var re = {
|
|
|
336
336
|
medium: "\n font-weight: 500;\n font-size: calc(0.8 * var(--mp-unit));\n line-height: calc(1.1 * var(--mp-unit));\n @media (min-width: 960px) {\n font-size: calc(1 * var(--mp-unit));\n line-height: calc(1.4 * var(--mp-unit));\n }\n ",
|
|
337
337
|
regular: "\n font-weight: 400;\n font-size: calc(0.8 * var(--mp-unit));\n line-height: calc(1.1 * var(--mp-unit));\n @media (min-width: 960px) {\n font-size: calc(1 * var(--mp-unit));\n line-height: calc(1.4 * var(--mp-unit));\n }\n "
|
|
338
338
|
}
|
|
339
|
-
},
|
|
339
|
+
}, ge = h`
|
|
340
340
|
top: unset !important;
|
|
341
341
|
left: unset !important;
|
|
342
342
|
width: 100%;
|
|
343
343
|
height: 100%;
|
|
344
344
|
margin: auto;
|
|
345
345
|
pointer-events: none;
|
|
346
|
-
`,
|
|
346
|
+
`, _e = h`
|
|
347
347
|
position: absolute;
|
|
348
348
|
top: 0;
|
|
349
349
|
left: 0;
|
|
@@ -351,7 +351,7 @@ var re = {
|
|
|
351
351
|
padding: calc(1.2 * var(--mp-unit)) calc(1.6 * var(--mp-unit));
|
|
352
352
|
/* clears a notch once the player is fullscreen; resolves to zero everywhere else */
|
|
353
353
|
padding-top: calc(calc(1.2 * var(--mp-unit)) + env(safe-area-inset-top, 0px));
|
|
354
|
-
${
|
|
354
|
+
${H.headings.small}
|
|
355
355
|
color: white;
|
|
356
356
|
text-shadow: 0 0 4px rgba(0, 0, 0, 1);
|
|
357
357
|
z-index: 2;
|
|
@@ -372,7 +372,7 @@ var re = {
|
|
|
372
372
|
|
|
373
373
|
background: linear-gradient(180deg, rgba(0,0,0,0.4) 0%, rgba(0,0,0,0.3) 30%, rgba(0,0,0,0.2) 60%, rgba(0,0,0,0.1) 80%, transparent 100%);
|
|
374
374
|
transition: opacity 0.1s cubic-bezier(.4,0,1,1);
|
|
375
|
-
`,
|
|
375
|
+
`, ve = h`
|
|
376
376
|
position: absolute;
|
|
377
377
|
inset: 0;
|
|
378
378
|
z-index: 2;
|
|
@@ -392,39 +392,39 @@ var re = {
|
|
|
392
392
|
to { transform: rotate(360deg); }
|
|
393
393
|
`} 0.8s linear infinite;
|
|
394
394
|
}
|
|
395
|
-
`,
|
|
395
|
+
`, ye = h`
|
|
396
396
|
position: absolute;
|
|
397
397
|
inset: auto 0 20%;
|
|
398
398
|
z-index: 3;
|
|
399
399
|
padding: 0 calc(2 * var(--mp-unit));
|
|
400
400
|
text-align: center;
|
|
401
401
|
color: #fff;
|
|
402
|
-
${
|
|
402
|
+
${H.bLarge.regular}
|
|
403
403
|
text-shadow: 0 0 4px rgba(0, 0, 0, 1);
|
|
404
404
|
pointer-events: none;
|
|
405
|
-
`,
|
|
406
|
-
let t =
|
|
405
|
+
`, be = (e) => e instanceof Error ? e.message : typeof e == "string" ? e : "Playback failed", xe = ({ onCanvasRef: e }) => {
|
|
406
|
+
let t = V((e) => e.title), n = V((e) => e.hideUI), r = V((e) => e.playbackError), i = V((e) => e.ready), a = V((e) => e.size), o = V((e) => e.waiting);
|
|
407
407
|
return /* @__PURE__ */ w(S, { children: [
|
|
408
408
|
t ? /* @__PURE__ */ C("div", {
|
|
409
409
|
className: "title",
|
|
410
|
-
css:
|
|
410
|
+
css: _e,
|
|
411
411
|
style: { ...n ? {
|
|
412
412
|
opacity: "0",
|
|
413
413
|
pointerEvents: "none"
|
|
414
414
|
} : {} },
|
|
415
415
|
children: t
|
|
416
416
|
}) : void 0,
|
|
417
|
-
(a ? !i : o) && !r ? /* @__PURE__ */ C("div", { css:
|
|
417
|
+
(a ? !i : o) && !r ? /* @__PURE__ */ C("div", { css: ve }) : void 0,
|
|
418
418
|
r ? /* @__PURE__ */ C("div", {
|
|
419
|
-
css:
|
|
420
|
-
children:
|
|
419
|
+
css: ye,
|
|
420
|
+
children: be(r)
|
|
421
421
|
}) : void 0,
|
|
422
422
|
/* @__PURE__ */ C("canvas", {
|
|
423
423
|
ref: e,
|
|
424
|
-
css:
|
|
424
|
+
css: ge
|
|
425
425
|
})
|
|
426
426
|
] });
|
|
427
|
-
},
|
|
427
|
+
}, Se = 1e-4, U = 1, Ce = (e) => Math.max(Se, Math.min(U, e)) ** 2, W = (e) => Math.max(Se, Math.min(U, e)) ** (U / 2), G = (e) => {
|
|
428
428
|
if (e === void 0) return "0:00";
|
|
429
429
|
let t = Math.floor(e / 3600), n = Math.floor(e % 3600 / 60), r = Math.floor(e % 60);
|
|
430
430
|
return t > 0 ? `${t}:${n < 10 ? "0" : ""}${n}:${r < 10 ? "0" : ""}${r}` : `${n}:${r < 10 ? "0" : ""}${r}`;
|
|
@@ -460,7 +460,7 @@ var re = {
|
|
|
460
460
|
z-index: 3;
|
|
461
461
|
|
|
462
462
|
* {
|
|
463
|
-
${
|
|
463
|
+
${H.bMedium.regular}
|
|
464
464
|
}
|
|
465
465
|
|
|
466
466
|
${e === "sm" && h`
|
|
@@ -506,7 +506,7 @@ var re = {
|
|
|
506
506
|
"data-tooltip-delay-hide": i,
|
|
507
507
|
"data-tooltip-place": o,
|
|
508
508
|
children: n
|
|
509
|
-
}), !s && /* @__PURE__ */ C(
|
|
509
|
+
}), !s && /* @__PURE__ */ C(z, {
|
|
510
510
|
ref: u,
|
|
511
511
|
css: Te(c),
|
|
512
512
|
id: e,
|
|
@@ -606,7 +606,7 @@ var re = {
|
|
|
606
606
|
box-shadow: 0 0 calc(1 * var(--mp-unit)) rgba(0, 0, 0, .5);
|
|
607
607
|
|
|
608
608
|
text-shadow: 0 0 4px rgba(0, 0, 0, 1);
|
|
609
|
-
${
|
|
609
|
+
${H.bMedium.bold}
|
|
610
610
|
|
|
611
611
|
position: absolute;
|
|
612
612
|
/* Anchored on its bottom edge rather than its top: now that it has a background its height
|
|
@@ -724,7 +724,7 @@ var re = {
|
|
|
724
724
|
--thumbnail-half: calc(9 * var(--mp-unit));
|
|
725
725
|
}
|
|
726
726
|
`, ke = 4, Ae = () => {
|
|
727
|
-
let e =
|
|
727
|
+
let e = V(), t = V((e) => e.currentTime), n = V((e) => e.requestSeek), r = V((e) => e.duration), i = V((e) => e.size), a = V((e) => e.downloadedRanges), o = V((e) => e.indexes), s = V((e) => e.thumbnails), c = V((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({
|
|
728
728
|
ref: l,
|
|
729
729
|
onChange: (e) => {
|
|
730
730
|
if (y.current += 1, b.current = e, x.current === void 0) x.current = e;
|
|
@@ -943,7 +943,7 @@ var re = {
|
|
|
943
943
|
|
|
944
944
|
border-radius: 8px;
|
|
945
945
|
background-color: rgba(28,28,28,0.95);
|
|
946
|
-
${
|
|
946
|
+
${H.bMedium.regular}
|
|
947
947
|
|
|
948
948
|
z-index: 4;
|
|
949
949
|
|
|
@@ -986,7 +986,7 @@ var re = {
|
|
|
986
986
|
|
|
987
987
|
.secondary {
|
|
988
988
|
color: #eee;
|
|
989
|
-
${
|
|
989
|
+
${H.bSmall.regular}
|
|
990
990
|
}
|
|
991
991
|
}
|
|
992
992
|
}
|
|
@@ -1028,7 +1028,7 @@ var re = {
|
|
|
1028
1028
|
.failed {
|
|
1029
1029
|
border-bottom: 1px solid #4D4D4E;
|
|
1030
1030
|
color: #f66;
|
|
1031
|
-
${
|
|
1031
|
+
${H.bSmall.regular}
|
|
1032
1032
|
}
|
|
1033
1033
|
}
|
|
1034
1034
|
`, Ie = ({ title: e, tracks: t, selected: n, onSelect: r, onBack: i, offLabel: a, pending: o, failed: s }) => {
|
|
@@ -1143,7 +1143,7 @@ ${X}
|
|
|
1143
1143
|
|
|
1144
1144
|
color: #fff;
|
|
1145
1145
|
cursor: pointer;
|
|
1146
|
-
${
|
|
1146
|
+
${H.bSmall.regular}
|
|
1147
1147
|
|
|
1148
1148
|
&:hover {
|
|
1149
1149
|
background-color: rgba(255,255,255,.1);
|
|
@@ -1164,7 +1164,7 @@ ${X}
|
|
|
1164
1164
|
|
|
1165
1165
|
.when {
|
|
1166
1166
|
color: #bbb;
|
|
1167
|
-
${
|
|
1167
|
+
${H.bSmall.regular}
|
|
1168
1168
|
|
|
1169
1169
|
/* the one part of the line worth scanning for, so it is the one part at full brightness */
|
|
1170
1170
|
.count {
|
|
@@ -1183,7 +1183,7 @@ ${X}
|
|
|
1183
1183
|
color: #ddd;
|
|
1184
1184
|
overflow-wrap: anywhere;
|
|
1185
1185
|
white-space: pre-wrap;
|
|
1186
|
-
${
|
|
1186
|
+
${H.bSmall.regular}
|
|
1187
1187
|
}
|
|
1188
1188
|
}
|
|
1189
1189
|
}
|
|
@@ -1195,7 +1195,7 @@ ${X}
|
|
|
1195
1195
|
e.detail
|
|
1196
1196
|
].filter(Boolean).join("\n");
|
|
1197
1197
|
}).join("\n\n"), Ve = () => {
|
|
1198
|
-
let e =
|
|
1198
|
+
let e = V((e) => e.playbackErrors), { open: t, toggle: n, containerRef: r } = Z(), [i, a] = m(!1);
|
|
1199
1199
|
if (e.length === 0) return null;
|
|
1200
1200
|
let o = () => {
|
|
1201
1201
|
navigator.clipboard?.writeText(Be(e)).then(() => {
|
|
@@ -1310,7 +1310,7 @@ width: 100%;
|
|
|
1310
1310
|
}
|
|
1311
1311
|
}
|
|
1312
1312
|
`, Ue = () => {
|
|
1313
|
-
let e =
|
|
1313
|
+
let e = V(), t = V((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({
|
|
1314
1314
|
ref: r,
|
|
1315
1315
|
onChange: (t) => e.setPlaybackRate(l(t))
|
|
1316
1316
|
}), f = (t) => {
|
|
@@ -1404,7 +1404,7 @@ ${X}
|
|
|
1404
1404
|
}
|
|
1405
1405
|
|
|
1406
1406
|
`, Ge = () => {
|
|
1407
|
-
let e =
|
|
1407
|
+
let e = V(), t = V((e) => e.playbackRate), n = V((e) => e.audioTracks), r = V((e) => e.selectedAudioTrack), i = V((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) => {
|
|
1408
1408
|
e.setPlaybackRate(t), o(0);
|
|
1409
1409
|
}, h = (e) => {
|
|
1410
1410
|
e !== void 0 && f(e, () => i(e));
|
|
@@ -1505,7 +1505,7 @@ position: static;
|
|
|
1505
1505
|
|
|
1506
1506
|
${X}
|
|
1507
1507
|
`, qe = () => {
|
|
1508
|
-
let e =
|
|
1508
|
+
let e = V((e) => e.subtitleTracks), t = V((e) => e.selectedSubtitleTrack), n = V((e) => e.selectSubtitleTrack), r = V((e) => e.subtitleOffLabel), { open: i, toggle: a, containerRef: o, pending: s, failed: c, runSelect: l } = Z();
|
|
1509
1509
|
if (e.length === 0) return null;
|
|
1510
1510
|
let u = t !== void 0;
|
|
1511
1511
|
return /* @__PURE__ */ w("div", {
|
|
@@ -1584,7 +1584,7 @@ ${X}
|
|
|
1584
1584
|
height: 10px;
|
|
1585
1585
|
}
|
|
1586
1586
|
`, Xe = ({ value: e, onChange: t }) => {
|
|
1587
|
-
let n =
|
|
1587
|
+
let n = V((e) => e.volume), r = V((e) => e.muted), i = p(null), a = p(null), { handlers: o } = J({
|
|
1588
1588
|
ref: a,
|
|
1589
1589
|
onChange: t
|
|
1590
1590
|
}), s = (n) => {
|
|
@@ -1647,7 +1647,7 @@ ${X}
|
|
|
1647
1647
|
border-radius: 4px;
|
|
1648
1648
|
|
|
1649
1649
|
.volume-value {
|
|
1650
|
-
${
|
|
1650
|
+
${H.bMedium.regular};
|
|
1651
1651
|
color: #ffffff;
|
|
1652
1652
|
}
|
|
1653
1653
|
}
|
|
@@ -1686,7 +1686,7 @@ ${X}
|
|
|
1686
1686
|
}
|
|
1687
1687
|
|
|
1688
1688
|
`, Qe = ({ ref: e }) => {
|
|
1689
|
-
let t =
|
|
1689
|
+
let t = V(), n = V((e) => e.volume), r = V((e) => e.muted), i = f(() => W(n), [n]);
|
|
1690
1690
|
return /* @__PURE__ */ w("div", {
|
|
1691
1691
|
css: Ze,
|
|
1692
1692
|
children: [/* @__PURE__ */ C(q, {
|
|
@@ -1698,7 +1698,7 @@ ${X}
|
|
|
1698
1698
|
ref: e,
|
|
1699
1699
|
"aria-label": "Mute",
|
|
1700
1700
|
"aria-pressed": r || n === 0,
|
|
1701
|
-
children: C(r || n === 0 ?
|
|
1701
|
+
children: C(r || n === 0 ? R : n <= .5 ? I : L, {
|
|
1702
1702
|
size: 18,
|
|
1703
1703
|
color: "#fff"
|
|
1704
1704
|
})
|
|
@@ -1711,7 +1711,7 @@ ${X}
|
|
|
1711
1711
|
children: /* @__PURE__ */ C(Xe, {
|
|
1712
1712
|
value: r ? 0 : i,
|
|
1713
1713
|
onChange: (e) => {
|
|
1714
|
-
t.setVolume(
|
|
1714
|
+
t.setVolume(Ce(e));
|
|
1715
1715
|
}
|
|
1716
1716
|
})
|
|
1717
1717
|
})
|
|
@@ -1833,7 +1833,7 @@ ${X}
|
|
|
1833
1833
|
|
|
1834
1834
|
.left {
|
|
1835
1835
|
.time {
|
|
1836
|
-
${
|
|
1836
|
+
${H.bMedium.regular}
|
|
1837
1837
|
text-shadow: 0 0 4px rgba(0, 0, 0, 1);
|
|
1838
1838
|
}
|
|
1839
1839
|
}
|
|
@@ -1855,9 +1855,9 @@ ${X}
|
|
|
1855
1855
|
}
|
|
1856
1856
|
}
|
|
1857
1857
|
`, nt = () => {
|
|
1858
|
-
let e =
|
|
1858
|
+
let e = V(), t = V((e) => e.paused), n = V((e) => e.currentTime), r = V((e) => e.duration), i = V((e) => e.fullscreen), a = V((e) => e.hideUI), o = V((e) => e.togglePictureInPicture), s = V((e) => e.pictureInPictureMode), c = V((e) => e.burnedInSubtitles), l = V((e) => e.subtitleTracks), f = V((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 }) => {
|
|
1859
1859
|
let r = W(e.volume), i = t === "up" ? n : -n, a = Math.max(0, Math.min(1, r + i)), o = e.muted;
|
|
1860
|
-
e.setVolume(
|
|
1860
|
+
e.setVolume(Ce(a)), o && !e.muted && e.toggleMuted();
|
|
1861
1861
|
}, [e]);
|
|
1862
1862
|
d(() => {
|
|
1863
1863
|
let t = (t) => f ? f(t) : e.seek(t), n = (n) => {
|
|
@@ -2015,12 +2015,12 @@ ${X}
|
|
|
2015
2015
|
}
|
|
2016
2016
|
|
|
2017
2017
|
.title {
|
|
2018
|
-
${
|
|
2018
|
+
${H.bMedium.bold}
|
|
2019
2019
|
color: #fff;
|
|
2020
2020
|
}
|
|
2021
2021
|
|
|
2022
2022
|
.body {
|
|
2023
|
-
${
|
|
2023
|
+
${H.bSmall.regular}
|
|
2024
2024
|
color: rgba(255, 255, 255, 0.75);
|
|
2025
2025
|
}
|
|
2026
2026
|
|
|
@@ -2032,7 +2032,7 @@ ${X}
|
|
|
2032
2032
|
color: #fff;
|
|
2033
2033
|
}
|
|
2034
2034
|
`, at = () => {
|
|
2035
|
-
let e =
|
|
2035
|
+
let e = V((e) => e.burnedInSubtitles), t = V((e) => e.pictureInPictureMode), [n, r] = m(!1);
|
|
2036
2036
|
return d(() => {
|
|
2037
2037
|
if (t !== "burn-in" || !e) {
|
|
2038
2038
|
r(!1);
|
|
@@ -2113,7 +2113,7 @@ ${X}
|
|
|
2113
2113
|
item: e
|
|
2114
2114
|
}];
|
|
2115
2115
|
}), ut = ({ ref: e, onVideoRef: t, onCanvasRef: n, overlay: r, controls: i, children: a }) => {
|
|
2116
|
-
let o =
|
|
2116
|
+
let o = V(), s = V((e) => e.hideUI), c = V((e) => e.setHideUI), l = p(void 0), u = p("mouse"), f = p({
|
|
2117
2117
|
x: -1,
|
|
2118
2118
|
y: -1
|
|
2119
2119
|
}), m = p(null);
|
|
@@ -2155,7 +2155,7 @@ ${X}
|
|
|
2155
2155
|
},
|
|
2156
2156
|
className: s ? "hide" : "",
|
|
2157
2157
|
children: [
|
|
2158
|
-
/* @__PURE__ */ C(
|
|
2158
|
+
/* @__PURE__ */ C(xe, { onCanvasRef: n }),
|
|
2159
2159
|
lt(r).map(({ key: e, item: t }) => /* @__PURE__ */ C("div", {
|
|
2160
2160
|
css: st,
|
|
2161
2161
|
style: { ...s ? {
|
|
@@ -2184,70 +2184,88 @@ ${X}
|
|
|
2184
2184
|
]
|
|
2185
2185
|
});
|
|
2186
2186
|
}, dt = ({ options: e, children: t }) => {
|
|
2187
|
-
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 ?? {},
|
|
2188
|
-
d(() => (
|
|
2189
|
-
let
|
|
2187
|
+
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 ?? {}, h = y(), g = v(), [_, b] = m(null), [x, S] = m(null), w = n?.media ?? _;
|
|
2188
|
+
d(() => (h?.(w), () => h?.(null)), [w, h]);
|
|
2189
|
+
let { expose: T } = e, E = T === !0 ? {} : T || void 0, D = p(E);
|
|
2190
|
+
D.current = E;
|
|
2191
|
+
let O = E ? E.id : void 0, k = E ? E.origin : void 0, A = E ? E.channel : void 0;
|
|
2192
|
+
d(() => {
|
|
2193
|
+
if (!T || !w) return;
|
|
2194
|
+
let e, t = !1;
|
|
2195
|
+
return import("./remote/index.js").then(({ exposePlayer: n }) => {
|
|
2196
|
+
t || (e = n(w, D.current ?? {}));
|
|
2197
|
+
}).catch(() => {}), () => {
|
|
2198
|
+
t = !0, e?.();
|
|
2199
|
+
};
|
|
2200
|
+
}, [
|
|
2201
|
+
w,
|
|
2202
|
+
!!T,
|
|
2203
|
+
O,
|
|
2204
|
+
k,
|
|
2205
|
+
A
|
|
2206
|
+
]), de(_, x, r);
|
|
2207
|
+
let j = me({
|
|
2190
2208
|
publicPath: s,
|
|
2191
2209
|
workerUrl: c,
|
|
2192
2210
|
length: f === !1 ? void 0 : a,
|
|
2193
2211
|
read: u ?? l,
|
|
2194
2212
|
downloadedRanges: o
|
|
2195
|
-
}),
|
|
2213
|
+
}), M = n?.thumbnails?.all ?? j, { toggle: N, mode: P, burnedIn: F } = he(_, x), I = V((e) => e.setSourceState);
|
|
2196
2214
|
d(() => {
|
|
2197
|
-
|
|
2215
|
+
I({
|
|
2198
2216
|
title: i,
|
|
2199
2217
|
size: a,
|
|
2200
2218
|
downloadedRanges: o
|
|
2201
2219
|
});
|
|
2202
2220
|
}, [
|
|
2203
|
-
|
|
2221
|
+
I,
|
|
2204
2222
|
i,
|
|
2205
2223
|
a,
|
|
2206
2224
|
o
|
|
2207
2225
|
]);
|
|
2208
|
-
let
|
|
2226
|
+
let L = n?.thumbnails?.at;
|
|
2209
2227
|
d(() => {
|
|
2210
|
-
|
|
2211
|
-
thumbnails:
|
|
2212
|
-
thumbnailAt:
|
|
2213
|
-
togglePictureInPicture:
|
|
2214
|
-
pictureInPictureMode:
|
|
2215
|
-
burnedInSubtitles:
|
|
2228
|
+
I({
|
|
2229
|
+
thumbnails: M,
|
|
2230
|
+
thumbnailAt: L,
|
|
2231
|
+
togglePictureInPicture: N,
|
|
2232
|
+
pictureInPictureMode: P,
|
|
2233
|
+
burnedInSubtitles: F
|
|
2216
2234
|
});
|
|
2217
2235
|
}, [
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2236
|
+
I,
|
|
2237
|
+
M,
|
|
2238
|
+
L,
|
|
2239
|
+
N,
|
|
2240
|
+
P,
|
|
2241
|
+
F
|
|
2224
2242
|
]);
|
|
2225
|
-
let
|
|
2243
|
+
let R = n?.subtitles?.selection, z = n?.audioTracks?.selection;
|
|
2226
2244
|
return d(() => {
|
|
2227
|
-
|
|
2228
|
-
subtitleTracks:
|
|
2245
|
+
R && I({
|
|
2246
|
+
subtitleTracks: R.options.map(({ id: e, label: t, disabled: n }) => ({
|
|
2229
2247
|
id: e,
|
|
2230
2248
|
label: t,
|
|
2231
2249
|
disabled: n
|
|
2232
2250
|
})),
|
|
2233
|
-
selectedSubtitleTrack:
|
|
2234
|
-
selectSubtitleTrack: (e) =>
|
|
2235
|
-
subtitleOffLabel:
|
|
2251
|
+
selectedSubtitleTrack: R.selectedId ?? void 0,
|
|
2252
|
+
selectSubtitleTrack: (e) => R.select(e == null ? null : String(e)),
|
|
2253
|
+
subtitleOffLabel: R.offLabel
|
|
2236
2254
|
});
|
|
2237
|
-
}, [
|
|
2238
|
-
|
|
2239
|
-
audioTracks:
|
|
2255
|
+
}, [I, R]), d(() => {
|
|
2256
|
+
z && I({
|
|
2257
|
+
audioTracks: z.options.map(({ id: e, label: t, disabled: n }) => ({
|
|
2240
2258
|
id: e,
|
|
2241
2259
|
label: t,
|
|
2242
2260
|
disabled: n
|
|
2243
2261
|
})),
|
|
2244
|
-
selectedAudioTrack:
|
|
2245
|
-
selectAudioTrack: (e) =>
|
|
2262
|
+
selectedAudioTrack: z.selectedId ?? void 0,
|
|
2263
|
+
selectAudioTrack: (e) => z.select(String(e))
|
|
2246
2264
|
});
|
|
2247
|
-
}, [
|
|
2248
|
-
ref:
|
|
2249
|
-
onVideoRef: n ? void 0 :
|
|
2250
|
-
onCanvasRef:
|
|
2265
|
+
}, [I, z]), /* @__PURE__ */ C(ut, {
|
|
2266
|
+
ref: g,
|
|
2267
|
+
onVideoRef: n ? void 0 : b,
|
|
2268
|
+
onCanvasRef: S,
|
|
2251
2269
|
overlay: e.overlay,
|
|
2252
2270
|
controls: e.controls,
|
|
2253
2271
|
children: t
|
|
@@ -2324,7 +2342,7 @@ ${X}
|
|
|
2324
2342
|
overflow: hidden;
|
|
2325
2343
|
`, pt = (e) => /* @__PURE__ */ C("div", {
|
|
2326
2344
|
css: ft,
|
|
2327
|
-
children: /* @__PURE__ */ C(
|
|
2345
|
+
children: /* @__PURE__ */ C(B.Provider, { children: /* @__PURE__ */ C(dt, {
|
|
2328
2346
|
options: e,
|
|
2329
2347
|
children: e.children
|
|
2330
2348
|
}) })
|
|
@@ -2367,4 +2385,4 @@ ${X}
|
|
|
2367
2385
|
throw Error(`Unknown source type: ${e}`);
|
|
2368
2386
|
};
|
|
2369
2387
|
//#endregion
|
|
2370
|
-
export { pt as MediaPlayer, pt as default,
|
|
2388
|
+
export { pt as MediaPlayer, pt as default, B as Player, e as SUBTITLES_OFF, a as createPictureInPicture, o as createSubtitleRenderer, r as createThumbnailGenerator, yt as inputToRemuxerInput, ht as isDelegatedTracks, mt as isExternalThumbnails, te as sourceFeature, i as startPlayback, he as usePictureInPicture, V as usePlayer, me as useSeekThumbnails };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
2
|
import type { DownloadedRange } from './source-feature';
|
|
3
3
|
import type { DelegatedTracks, ExternalThumbnails, PlayerMedia } from './media';
|
|
4
|
+
import type { ExposePlayerOptions } from '../remote';
|
|
4
5
|
/**
|
|
5
6
|
* The source, read a range at a time: the player never downloads the whole file. Both fields travel
|
|
6
7
|
* together, so passing one without the other is a type error.
|
|
@@ -14,6 +15,15 @@ export type MediaPlayerSource = {
|
|
|
14
15
|
};
|
|
15
16
|
/** Shared by both arms: nothing here depends on who owns the media. */
|
|
16
17
|
type CommonOptions = {
|
|
18
|
+
/**
|
|
19
|
+
* Serve this player to the document that frames this one, so it can be read and driven from there
|
|
20
|
+
* through `mediaPlayer` (from `@banou/media-player/remote`). `true` serves the framing window and
|
|
21
|
+
* nothing else; an options object narrows the embedder by origin or replaces the transport, and may
|
|
22
|
+
* be written inline, since `id`, `origin` and `channel` are watched by value. A `transport` or
|
|
23
|
+
* `signal` is read when the player is served and changing either needs a remount. Off by default, and a
|
|
24
|
+
* no-op in a document nobody frames.
|
|
25
|
+
*/
|
|
26
|
+
expose?: boolean | ExposePlayerOptions;
|
|
17
27
|
/**
|
|
18
28
|
* Drawn across the top of the picture, in a layer of its own.
|
|
19
29
|
*
|