@banou/media-player 0.10.52 → 0.10.54
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-D_C7Ngyd.js → engine-DZ6BX5XH.js} +232 -189
- package/dist/index.js +144 -121
- package/package.json +2 -2
- package/src/lib/engine/playback.ts +100 -12
- package/src/lib/react/hooks/use-playback.ts +43 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as e, l as t, m as n, n as r, o as i, p as a, r as o, s, t as c, u as l } from "./engine-
|
|
1
|
+
import { c as e, l as t, m as n, n as r, o as i, p as a, r as o, s, t as c, u as l } from "./engine-DZ6BX5XH.js";
|
|
2
2
|
import { languageOf as u, playsIn as d, startingTracks as f } from "./language/index.js";
|
|
3
3
|
import { n as p, r as m, t as h } from "./chapters-EBYXcEml.js";
|
|
4
4
|
import { Children as g, Fragment as _, createContext as v, isValidElement as y, useCallback as b, useContext as x, useEffect as S, useMemo as C, useRef as w, useState as T, useSyncExternalStore as E } from "react";
|
|
@@ -8,10 +8,10 @@ import { definePlayerFeature as M, videoFeatures as N } from "@videojs/core/dom"
|
|
|
8
8
|
import { makeRemuxer as P } from "libav-wasm";
|
|
9
9
|
import { Fragment as F, jsx as I, jsxs as L } from "@emotion/react/jsx-runtime";
|
|
10
10
|
import { createMediaElementSource as R } from "@banou/ponyfill/web-audio";
|
|
11
|
-
import { Captions as z, CaptionsOff as B, Check as V, ChevronLeft as H, ChevronRight as U, Copy as
|
|
12
|
-
import { Tooltip as
|
|
11
|
+
import { Captions as z, CaptionsOff as B, Check as V, ChevronLeft as H, ChevronRight as U, Copy as W, Maximize as G, Minimize as ee, Pause as te, Play as K, RotateCcw as ne, Settings as q, TriangleAlert as re, Volume1 as ie, Volume2 as J, VolumeX as ae } from "lucide-react";
|
|
12
|
+
import { Tooltip as Y } from "react-tooltip";
|
|
13
13
|
//#region src/lib/react/source-feature.ts
|
|
14
|
-
var
|
|
14
|
+
var oe = {
|
|
15
15
|
indexes: [],
|
|
16
16
|
chapters: [],
|
|
17
17
|
thumbnails: [],
|
|
@@ -37,9 +37,9 @@ var se = {
|
|
|
37
37
|
playbackErrors: [],
|
|
38
38
|
ready: !1,
|
|
39
39
|
setSourceState: () => {}
|
|
40
|
-
},
|
|
40
|
+
}, se = M({
|
|
41
41
|
name: "source",
|
|
42
|
-
state: () => ({ ...
|
|
42
|
+
state: () => ({ ...oe }),
|
|
43
43
|
attach({ set: e }) {
|
|
44
44
|
e({
|
|
45
45
|
setSourceState: (t) => e(t),
|
|
@@ -47,7 +47,7 @@ var se = {
|
|
|
47
47
|
});
|
|
48
48
|
}
|
|
49
49
|
}), ce = k({
|
|
50
|
-
features: [...N,
|
|
50
|
+
features: [...N, se],
|
|
51
51
|
displayName: "MediaPlayer"
|
|
52
52
|
}), X = ce.usePlayer, le = {
|
|
53
53
|
ar: () => import("./ar-CWVutin3.js"),
|
|
@@ -195,50 +195,62 @@ var se = {
|
|
|
195
195
|
}), [c]);
|
|
196
196
|
let L = w(null), R = w(null), z = w(void 0), B = w(c);
|
|
197
197
|
B.current = c;
|
|
198
|
-
let V = w(
|
|
198
|
+
let V = w(null), H = w(!1);
|
|
199
|
+
S(() => {
|
|
200
|
+
if (!e) return;
|
|
201
|
+
let t = () => {
|
|
202
|
+
H.current = !1;
|
|
203
|
+
}, n = Object.getOwnPropertyDescriptor(e, "pause"), r = e.pause;
|
|
204
|
+
return e.pause = function() {
|
|
205
|
+
return V.current ? V.current() : H.current = !0, r.call(this);
|
|
206
|
+
}, e.addEventListener("play", t), () => {
|
|
207
|
+
e.removeEventListener("play", t), n ? Object.defineProperty(e, "pause", n) : delete e.pause;
|
|
208
|
+
};
|
|
209
|
+
}, [e]);
|
|
210
|
+
let U = w({
|
|
199
211
|
audio: [],
|
|
200
212
|
subtitles: []
|
|
201
|
-
}),
|
|
202
|
-
|
|
213
|
+
}), W = b(() => U.current.audio.find((e) => e.streamIndex === a.selectedAudioTrack), [a]), G = w(o);
|
|
214
|
+
G.current = o;
|
|
203
215
|
let ee = w(E);
|
|
204
216
|
ee.current = E;
|
|
205
|
-
let
|
|
217
|
+
let te = {
|
|
206
218
|
audio: n?.preferredAudioLanguage,
|
|
207
219
|
original: n?.originalLanguage,
|
|
208
220
|
subtitles: n?.preferredSubtitleLanguage,
|
|
209
221
|
alwaysSubtitles: n?.alwaysShowSubtitles
|
|
210
|
-
},
|
|
211
|
-
|
|
212
|
-
let
|
|
213
|
-
|
|
214
|
-
let
|
|
215
|
-
|
|
216
|
-
let
|
|
217
|
-
|
|
218
|
-
let
|
|
219
|
-
|
|
220
|
-
let
|
|
221
|
-
|
|
222
|
-
let
|
|
223
|
-
|
|
224
|
-
let
|
|
225
|
-
|
|
226
|
-
let { audio: e, subtitles: t } =
|
|
227
|
-
t.length && a.setSourceState({ subtitleTracks: Ce(t,
|
|
228
|
-
}, [a,
|
|
229
|
-
let
|
|
222
|
+
}, K = w(te);
|
|
223
|
+
K.current = te;
|
|
224
|
+
let ne = w(n?.onPreferredAudioLanguageChange);
|
|
225
|
+
ne.current = n?.onPreferredAudioLanguageChange;
|
|
226
|
+
let q = w(n?.onPreferredSubtitleLanguageChange);
|
|
227
|
+
q.current = n?.onPreferredSubtitleLanguageChange;
|
|
228
|
+
let re = w(n?.onAlwaysShowSubtitlesChange);
|
|
229
|
+
re.current = n?.onAlwaysShowSubtitlesChange;
|
|
230
|
+
let ie = w(n?.onSeek);
|
|
231
|
+
ie.current = n?.onSeek;
|
|
232
|
+
let J = w(n?.onPlaybackError);
|
|
233
|
+
J.current = n?.onPlaybackError;
|
|
234
|
+
let ae = w(r);
|
|
235
|
+
ae.current = r;
|
|
236
|
+
let Y = Q(), oe = w(Y);
|
|
237
|
+
oe.current = Y, S(() => {
|
|
238
|
+
let { audio: e, subtitles: t } = U.current;
|
|
239
|
+
t.length && a.setSourceState({ subtitleTracks: Ce(t, Y) }), e.length && a.setSourceState({ audioTracks: Ce(e, Y) });
|
|
240
|
+
}, [a, Y]);
|
|
241
|
+
let se = b((e) => {
|
|
230
242
|
let t = typeof e == "number" ? e : void 0, n = a.selectedSubtitleTrack === void 0;
|
|
231
243
|
z.current = B.current, a.setSourceState({ selectedSubtitleTrack: t }), L.current?.selectSubtitleStream(t);
|
|
232
|
-
let r =
|
|
233
|
-
i !== void 0 &&
|
|
234
|
-
}, [a,
|
|
235
|
-
let n = ++
|
|
244
|
+
let r = U.current.subtitles.find((e) => e.streamIndex === t), i = t === void 0 ? null : u(r) ?? (n ? r?.title?.trim() || "und" : void 0);
|
|
245
|
+
i !== void 0 && q.current?.(i), i && d(W(), i) && re.current?.(!0);
|
|
246
|
+
}, [a, W]), ce = w(0), le = b((e, t = !1) => {
|
|
247
|
+
let n = ++ce.current, r = L.current;
|
|
236
248
|
if (!r || O <= 0 || t) {
|
|
237
249
|
a.setSourceState({ seekingTo: void 0 }), a.seek(e);
|
|
238
250
|
return;
|
|
239
251
|
}
|
|
240
252
|
let i = typeof window < "u" && window.__mediaPlayerSeekDebug, o = performance.now(), s = !1, c = "prepared", l = () => {
|
|
241
|
-
if (!s && (s = !0, L.current === r &&
|
|
253
|
+
if (!s && (s = !0, L.current === r && ce.current === n && (a.seek(e), i))) {
|
|
242
254
|
let t = r.videoElement, n = 0;
|
|
243
255
|
if (t) for (let r = 0; r < t.buffered.length; r++) t.buffered.start(r) <= e + 1 && e < t.buffered.end(r) && (n = t.buffered.end(r) - e);
|
|
244
256
|
console.warn(`[media-player] seek to ${e.toFixed(2)} moved after ${Math.round(performance.now() - o)}ms via ${c}, runway ${n.toFixed(1)}s${c === "deadline" ? " (EXPOSED: moved before its data was ready)" : ""}`);
|
|
@@ -246,7 +258,7 @@ var se = {
|
|
|
246
258
|
};
|
|
247
259
|
a.setSourceState({ seekingTo: e });
|
|
248
260
|
let u = r.videoElement, d = () => {
|
|
249
|
-
u?.removeEventListener("seeked", f), clearTimeout(p),
|
|
261
|
+
u?.removeEventListener("seeked", f), clearTimeout(p), ce.current === n && a.setSourceState({ seekingTo: void 0 });
|
|
250
262
|
}, f = () => {
|
|
251
263
|
s && d();
|
|
252
264
|
}, p = setTimeout(d, De);
|
|
@@ -257,45 +269,56 @@ var se = {
|
|
|
257
269
|
r.prepareSeek(e).catch(() => {}).finally(() => {
|
|
258
270
|
clearTimeout(m), l();
|
|
259
271
|
});
|
|
260
|
-
}, [a, O]),
|
|
272
|
+
}, [a, O]), ue = b((e) => {
|
|
261
273
|
if (typeof e != "number" || B.current === void 0) return;
|
|
262
274
|
a.setSourceState({ selectedAudioTrack: e }), j({
|
|
263
275
|
size: B.current,
|
|
264
276
|
streamIndex: e
|
|
265
277
|
});
|
|
266
|
-
let t = u(
|
|
267
|
-
t !== void 0 &&
|
|
268
|
-
}, [a]),
|
|
278
|
+
let t = u(U.current.audio.find((t) => t.streamIndex === e));
|
|
279
|
+
t !== void 0 && ne.current?.(t);
|
|
280
|
+
}, [a]), de = X((e) => e.setSourceState);
|
|
269
281
|
S(() => {
|
|
270
|
-
|
|
271
|
-
selectSubtitleTrack:
|
|
272
|
-
selectAudioTrack:
|
|
273
|
-
requestSeek:
|
|
282
|
+
de({
|
|
283
|
+
selectSubtitleTrack: se,
|
|
284
|
+
selectAudioTrack: ue,
|
|
285
|
+
requestSeek: le
|
|
274
286
|
});
|
|
275
287
|
}, [
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
288
|
+
de,
|
|
289
|
+
se,
|
|
290
|
+
ue,
|
|
291
|
+
le
|
|
280
292
|
]), S(() => {
|
|
281
293
|
if (!e || !t || !c || !o) return;
|
|
282
294
|
R.current && R.current.size !== c && (R.current = null);
|
|
283
|
-
let n = !1, r = !1, u =
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
295
|
+
let n = !1, r = !1, u = H.current;
|
|
296
|
+
H.current = !1;
|
|
297
|
+
let d = !1, b = !1, S = !1, w = () => {
|
|
298
|
+
u = !1, d = !0, b = !1, S = !1, !r && R.current?.size === c && (R.current = {
|
|
299
|
+
...R.current,
|
|
300
|
+
play: !0
|
|
301
|
+
});
|
|
302
|
+
}, T = () => {
|
|
303
|
+
if (S) {
|
|
304
|
+
S = !1;
|
|
288
305
|
return;
|
|
289
306
|
}
|
|
290
|
-
|
|
291
|
-
},
|
|
292
|
-
|
|
307
|
+
d = !1, b = !1;
|
|
308
|
+
}, E = () => {
|
|
309
|
+
d && e.paused && (b = !0, S = !0);
|
|
310
|
+
}, D = () => {
|
|
311
|
+
d = !1, b = !1, S = !1, r || (u = !0, R.current = {
|
|
312
|
+
time: R.current?.size === c ? R.current.time : 0,
|
|
313
|
+
size: c,
|
|
314
|
+
play: !1
|
|
315
|
+
});
|
|
293
316
|
};
|
|
294
|
-
e.addEventListener("play",
|
|
317
|
+
V.current = D, e.addEventListener("play", w), e.addEventListener("pause", T), e.addEventListener("error", E), a.setSourceState({
|
|
295
318
|
playbackError: null,
|
|
296
319
|
ready: !1
|
|
297
320
|
});
|
|
298
|
-
let
|
|
321
|
+
let O = (t, n) => {
|
|
299
322
|
let r = Date.now(), i = Oe(t), o = ke(t), s = a.playbackErrors, c = s[s.length - 1];
|
|
300
323
|
if (c && c.message === i && c.detail === o && c.recovered === n) {
|
|
301
324
|
let e = {
|
|
@@ -316,10 +339,10 @@ var se = {
|
|
|
316
339
|
recovered: n
|
|
317
340
|
};
|
|
318
341
|
a.setSourceState({ playbackErrors: [...s, l] });
|
|
319
|
-
},
|
|
342
|
+
}, A = (e) => {
|
|
320
343
|
if (n) return;
|
|
321
344
|
let t = i(e);
|
|
322
|
-
if (
|
|
345
|
+
if (O(e, t), t) {
|
|
323
346
|
let t = performance.now();
|
|
324
347
|
t - F.current.at > Te && (F.current = {
|
|
325
348
|
count: 0,
|
|
@@ -332,14 +355,14 @@ var se = {
|
|
|
332
355
|
}, console.warn(`the media element failed; rebuilding the pipeline${n ? ` in ${n}ms` : ""}`, e), I.current && clearTimeout(I.current), I.current = setTimeout(() => P((e) => e + 1), n);
|
|
333
356
|
return;
|
|
334
357
|
}
|
|
335
|
-
console.error("playback failed", e), a.setSourceState({ playbackError: e }),
|
|
358
|
+
console.error("playback failed", e), a.setSourceState({ playbackError: e }), J.current?.(e);
|
|
336
359
|
};
|
|
337
360
|
return (async () => {
|
|
338
361
|
try {
|
|
339
362
|
let i = await s({
|
|
340
363
|
videoElement: e,
|
|
341
364
|
subtitleContainer: t,
|
|
342
|
-
read: (e, t) =>
|
|
365
|
+
read: (e, t) => G.current(e, t),
|
|
343
366
|
length: c,
|
|
344
367
|
publicPath: l,
|
|
345
368
|
libavWorkerUrl: p,
|
|
@@ -352,7 +375,7 @@ var se = {
|
|
|
352
375
|
cjkFontUrl: x,
|
|
353
376
|
bufferSize: C,
|
|
354
377
|
audioStreamIndex: M,
|
|
355
|
-
chooseAudioStream: (e) => e[f(e, [],
|
|
378
|
+
chooseAudioStream: (e) => e[f(e, [], K.current).audio]?.streamIndex,
|
|
356
379
|
onReady: () => {
|
|
357
380
|
if (n) return;
|
|
358
381
|
r = !0, a.setSourceState({ ready: !0 });
|
|
@@ -360,29 +383,29 @@ var se = {
|
|
|
360
383
|
R.current = null;
|
|
361
384
|
let i = !!t && t.size === c;
|
|
362
385
|
i && t.time > 0 ? e.currentTime = t.time : a.setSourceState({ seekingTo: void 0 });
|
|
363
|
-
let o = i ? t.play : ee.current;
|
|
364
|
-
|
|
365
|
-
e.paused && !
|
|
386
|
+
let o = !u && (i ? t.play : ee.current);
|
|
387
|
+
d = o, o && e.play().catch(() => {
|
|
388
|
+
e.paused && !b && (d = !1);
|
|
366
389
|
});
|
|
367
390
|
},
|
|
368
|
-
onError:
|
|
391
|
+
onError: A,
|
|
369
392
|
onRecovered: () => {
|
|
370
393
|
n || a.setSourceState({ playbackError: null });
|
|
371
394
|
},
|
|
372
|
-
onSeek: (e) =>
|
|
373
|
-
onOutput: (e) =>
|
|
395
|
+
onSeek: (e) => ie.current?.(e),
|
|
396
|
+
onOutput: (e) => ae.current?.(e),
|
|
374
397
|
onSubtitleStreams: (e) => {
|
|
375
398
|
if (n) return;
|
|
376
|
-
|
|
377
|
-
let t =
|
|
399
|
+
U.current.subtitles = e;
|
|
400
|
+
let t = W(), r = f(t ? [t] : [], e, K.current).subtitles;
|
|
378
401
|
a.setSourceState({
|
|
379
|
-
subtitleTracks: Ce(e,
|
|
402
|
+
subtitleTracks: Ce(e, oe.current),
|
|
380
403
|
...z.current === c ? {} : { selectedSubtitleTrack: r === null ? void 0 : e[Math.max(r, 0)]?.streamIndex }
|
|
381
404
|
});
|
|
382
405
|
},
|
|
383
406
|
onAudioStreams: (e, t) => {
|
|
384
|
-
n || (
|
|
385
|
-
audioTracks: Ce(e,
|
|
407
|
+
n || (U.current.audio = e, a.setSourceState({
|
|
408
|
+
audioTracks: Ce(e, oe.current),
|
|
386
409
|
selectedAudioTrack: t
|
|
387
410
|
}));
|
|
388
411
|
}
|
|
@@ -398,13 +421,13 @@ var se = {
|
|
|
398
421
|
let o = a.selectedSubtitleTrack;
|
|
399
422
|
i.selectSubtitleStream(typeof o == "number" ? o : void 0);
|
|
400
423
|
} catch (e) {
|
|
401
|
-
|
|
424
|
+
A(e);
|
|
402
425
|
}
|
|
403
426
|
})(), () => {
|
|
404
|
-
n = !0, e.removeEventListener("play",
|
|
427
|
+
n = !0, V.current === D && (V.current = null), e.removeEventListener("play", w), e.removeEventListener("pause", T), e.removeEventListener("error", E), r ? R.current = {
|
|
405
428
|
time: a.state.seekingTo ?? e.currentTime,
|
|
406
429
|
size: c,
|
|
407
|
-
play: !e.ended && (
|
|
430
|
+
play: !e.ended && (b ? d : !e.paused)
|
|
408
431
|
} : R.current?.size === c && a.state.seekingTo !== void 0 && (R.current = {
|
|
409
432
|
...R.current,
|
|
410
433
|
time: a.state.seekingTo
|
|
@@ -412,7 +435,7 @@ var se = {
|
|
|
412
435
|
};
|
|
413
436
|
}, [
|
|
414
437
|
a,
|
|
415
|
-
|
|
438
|
+
W,
|
|
416
439
|
e,
|
|
417
440
|
t,
|
|
418
441
|
c,
|
|
@@ -732,7 +755,7 @@ var se = {
|
|
|
732
755
|
}, g = 0, _ = /* @__PURE__ */ new Map(), v = (e, t) => new Promise((n) => _.set(`${e}:${t}`, n)), y = -1;
|
|
733
756
|
p.onmessage = ({ data: e }) => {
|
|
734
757
|
if (e.type === "unsupported") {
|
|
735
|
-
|
|
758
|
+
te();
|
|
736
759
|
return;
|
|
737
760
|
}
|
|
738
761
|
if (e.spans) {
|
|
@@ -800,7 +823,7 @@ var se = {
|
|
|
800
823
|
run: D,
|
|
801
824
|
data: e.data
|
|
802
825
|
}, [e.data]), await t;
|
|
803
|
-
},
|
|
826
|
+
}, W = async (t) => {
|
|
804
827
|
if (V = await P({
|
|
805
828
|
publicPath: t.publicPath,
|
|
806
829
|
workerUrl: t.libavWorkerUrl,
|
|
@@ -856,7 +879,7 @@ var se = {
|
|
|
856
879
|
}
|
|
857
880
|
a || await H(!1), !a && (e(V), V = void 0);
|
|
858
881
|
}
|
|
859
|
-
},
|
|
882
|
+
}, G = () => {}, ee = (e, t) => {
|
|
860
883
|
let n = !1, r = (e) => {
|
|
861
884
|
n && p.postMessage({
|
|
862
885
|
type: "end",
|
|
@@ -864,7 +887,7 @@ var se = {
|
|
|
864
887
|
finished: e
|
|
865
888
|
}), n = !1;
|
|
866
889
|
};
|
|
867
|
-
|
|
890
|
+
G = e.attach(t, (e, t) => {
|
|
868
891
|
if (e.type === "init") {
|
|
869
892
|
r(!1);
|
|
870
893
|
let t = e.data.slice(0);
|
|
@@ -891,22 +914,22 @@ var se = {
|
|
|
891
914
|
}, [t]);
|
|
892
915
|
}
|
|
893
916
|
});
|
|
894
|
-
},
|
|
917
|
+
}, te = () => {
|
|
895
918
|
if (!a) {
|
|
896
919
|
a = !0, f(!0), l(), clearInterval(C);
|
|
897
920
|
for (let e of w) n.removeEventListener(e, x);
|
|
898
|
-
n.removeEventListener("seeking", z), n.removeEventListener("seeked", B), n.removeEventListener("timeupdate", B),
|
|
921
|
+
n.removeEventListener("seeking", z), n.removeEventListener("seeked", B), n.removeEventListener("timeupdate", B), G(), V && e(V), p.terminate(), t.port.postMessage({ analysis: null });
|
|
899
922
|
for (let e of _.values()) e(h);
|
|
900
923
|
_.clear();
|
|
901
924
|
}
|
|
902
925
|
};
|
|
903
|
-
return "tap" in i ?
|
|
904
|
-
a || (console.warn("[media-player] the volume normalizer cannot analyse ahead:", e),
|
|
926
|
+
return "tap" in i ? ee(i.tap, i.audioStreamIndex) : W(i).catch((e) => {
|
|
927
|
+
a || (console.warn("[media-player] the volume normalizer cannot analyse ahead:", e), te());
|
|
905
928
|
}), S(), {
|
|
906
929
|
update: (e) => {
|
|
907
930
|
o = e, f(!1);
|
|
908
931
|
},
|
|
909
|
-
stop:
|
|
932
|
+
stop: te
|
|
910
933
|
};
|
|
911
934
|
}, nt = (e, t, n, r, i) => {
|
|
912
935
|
let a = w(null), [o, s] = T(!1), [c, l] = T(null);
|
|
@@ -1187,7 +1210,7 @@ var se = {
|
|
|
1187
1210
|
"data-tooltip-delay-hide": i,
|
|
1188
1211
|
"data-tooltip-place": o,
|
|
1189
1212
|
children: n
|
|
1190
|
-
}), !s && /* @__PURE__ */ I(
|
|
1213
|
+
}), !s && /* @__PURE__ */ I(Y, {
|
|
1191
1214
|
ref: u,
|
|
1192
1215
|
css: yt(c),
|
|
1193
1216
|
id: e,
|
|
@@ -1491,7 +1514,7 @@ var se = {
|
|
|
1491
1514
|
B.current !== "touch" && E(z(e.clientX));
|
|
1492
1515
|
}, U = () => {
|
|
1493
1516
|
_.current && E(void 0);
|
|
1494
|
-
},
|
|
1517
|
+
}, W = (e) => r ? e / r * 100 : 0, G = (e, t, n) => {
|
|
1495
1518
|
let r = Number((n - t).toFixed(4)), i = t * 100;
|
|
1496
1519
|
return /* @__PURE__ */ I("div", {
|
|
1497
1520
|
className: "loaded-part",
|
|
@@ -1500,10 +1523,10 @@ var se = {
|
|
|
1500
1523
|
marginLeft: `${i}%`
|
|
1501
1524
|
}
|
|
1502
1525
|
}, e);
|
|
1503
|
-
},
|
|
1526
|
+
}, ee = C(() => i === void 0 ? r ? o.map(([e, t], n) => G(n, e / r, t / r)) : [] : a?.map((e, t) => {
|
|
1504
1527
|
if (!i || !r) return null;
|
|
1505
1528
|
let n = s.filter((t) => e.startByteOffset <= t.pos && t.pos <= e.endByteOffset), a = n.at(0), o = n.at(-1);
|
|
1506
|
-
return !a || !o ? null :
|
|
1529
|
+
return !a || !o ? null : G(t, a.timestamp / r, o.timestamp / r);
|
|
1507
1530
|
}) ?? [], [
|
|
1508
1531
|
r,
|
|
1509
1532
|
i,
|
|
@@ -1520,7 +1543,7 @@ var se = {
|
|
|
1520
1543
|
v,
|
|
1521
1544
|
r
|
|
1522
1545
|
]);
|
|
1523
|
-
let
|
|
1546
|
+
let te = C(() => {
|
|
1524
1547
|
if (!r) return 0;
|
|
1525
1548
|
if (N && v !== void 0) return v;
|
|
1526
1549
|
let e = f ?? t;
|
|
@@ -1555,20 +1578,20 @@ var se = {
|
|
|
1555
1578
|
c,
|
|
1556
1579
|
l,
|
|
1557
1580
|
b
|
|
1558
|
-
]),
|
|
1581
|
+
]), Y = (e, t) => /* @__PURE__ */ L("div", {
|
|
1559
1582
|
className: e ? `track ${e}` : "track",
|
|
1560
1583
|
style: t ? { maskImage: t } : void 0,
|
|
1561
1584
|
children: [
|
|
1562
1585
|
/* @__PURE__ */ I("div", { className: "background-bar" }),
|
|
1563
1586
|
/* @__PURE__ */ I("div", {
|
|
1564
1587
|
className: "loaded",
|
|
1565
|
-
children:
|
|
1588
|
+
children: ee
|
|
1566
1589
|
}),
|
|
1567
1590
|
/* @__PURE__ */ I("div", {
|
|
1568
1591
|
className: "play-container",
|
|
1569
1592
|
children: /* @__PURE__ */ I("div", {
|
|
1570
1593
|
className: "play",
|
|
1571
|
-
style: { transform: `scaleX(${
|
|
1594
|
+
style: { transform: `scaleX(${te})` }
|
|
1572
1595
|
})
|
|
1573
1596
|
})
|
|
1574
1597
|
]
|
|
@@ -1586,11 +1609,11 @@ var se = {
|
|
|
1586
1609
|
onMouseMove: H,
|
|
1587
1610
|
onMouseOut: U,
|
|
1588
1611
|
children: [
|
|
1589
|
-
|
|
1612
|
+
Y(void 0, re),
|
|
1590
1613
|
b ? /* @__PURE__ */ L("div", {
|
|
1591
1614
|
className: "cursor-time",
|
|
1592
1615
|
style: {
|
|
1593
|
-
left: J ? `clamp(var(--thumbnail-half), ${
|
|
1616
|
+
left: J ? `clamp(var(--thumbnail-half), ${W(b)}%, calc(100% - var(--thumbnail-half)))` : `clamp(calc(3 * var(--mp-unit)), ${W(b)}%, calc(100% - calc(3 * var(--mp-unit))))`,
|
|
1594
1617
|
maxWidth: J ? "var(--thumbnail-width)" : void 0
|
|
1595
1618
|
},
|
|
1596
1619
|
children: [/* @__PURE__ */ I("span", {
|
|
@@ -1603,7 +1626,7 @@ var se = {
|
|
|
1603
1626
|
}) : void 0,
|
|
1604
1627
|
/* @__PURE__ */ I("div", { className: "progress" }),
|
|
1605
1628
|
/* @__PURE__ */ I("div", { className: "hover" }),
|
|
1606
|
-
ie ?
|
|
1629
|
+
ie ? Y("focus", ie) : void 0,
|
|
1607
1630
|
/* @__PURE__ */ I("div", { className: "scrubber" }),
|
|
1608
1631
|
/* @__PURE__ */ I("div", {
|
|
1609
1632
|
className: "padding",
|
|
@@ -1614,7 +1637,7 @@ var se = {
|
|
|
1614
1637
|
}),
|
|
1615
1638
|
/* @__PURE__ */ I("div", {
|
|
1616
1639
|
className: "thumbnail",
|
|
1617
|
-
style: { left: `clamp(var(--thumbnail-half), ${
|
|
1640
|
+
style: { left: `clamp(var(--thumbnail-half), ${W(b ?? 1)}%, calc(100% - var(--thumbnail-half)))` },
|
|
1618
1641
|
children: ae?.url ? /* @__PURE__ */ I("img", { src: ae.url }) : void 0
|
|
1619
1642
|
})
|
|
1620
1643
|
]
|
|
@@ -1983,7 +2006,7 @@ ${Nt}
|
|
|
1983
2006
|
type: "button",
|
|
1984
2007
|
onClick: l,
|
|
1985
2008
|
"aria-label": t(a.copyErrors),
|
|
1986
|
-
children: [I(s ? V :
|
|
2009
|
+
children: [I(s ? V : W, {}), /* @__PURE__ */ I("span", { children: t(s ? a.copied : a.copy) })]
|
|
1987
2010
|
})]
|
|
1988
2011
|
}), e.map((e, r) => /* @__PURE__ */ L("div", {
|
|
1989
2012
|
className: "entry no-hover",
|
|
@@ -2786,7 +2809,7 @@ ${Nt}
|
|
|
2786
2809
|
type: "button",
|
|
2787
2810
|
onClick: () => r.togglePaused(),
|
|
2788
2811
|
"aria-label": i(j ? a.replay : o ? a.play : a.pause),
|
|
2789
|
-
children: I(j ? ne : o ? K :
|
|
2812
|
+
children: I(j ? ne : o ? K : te, {})
|
|
2790
2813
|
}),
|
|
2791
2814
|
toolTipText: /* @__PURE__ */ I("span", { children: i(j ? a.replayKey : o ? a.playKey : a.pauseKey) })
|
|
2792
2815
|
}),
|
|
@@ -2846,7 +2869,7 @@ ${Nt}
|
|
|
2846
2869
|
onClick: P,
|
|
2847
2870
|
"aria-label": i(a.fullScreen),
|
|
2848
2871
|
"aria-pressed": d,
|
|
2849
|
-
children: I(d ?
|
|
2872
|
+
children: I(d ? ee : G, {})
|
|
2850
2873
|
}),
|
|
2851
2874
|
toolTipText: /* @__PURE__ */ I("span", { children: i(d ? a.exitFullScreenKey : a.fullScreenKey) })
|
|
2852
2875
|
})
|
|
@@ -3214,7 +3237,7 @@ ${Nt}
|
|
|
3214
3237
|
}
|
|
3215
3238
|
})), B = D === !0 ? {} : D || void 0, V = w(B);
|
|
3216
3239
|
V.current = B;
|
|
3217
|
-
let H = B ? B.id : void 0, U = B ? B.origin : void 0,
|
|
3240
|
+
let H = B ? B.id : void 0, U = B ? B.origin : void 0, W = B ? B.channel : void 0;
|
|
3218
3241
|
S(() => {
|
|
3219
3242
|
if (!D || !E) return;
|
|
3220
3243
|
let e, t = !1;
|
|
@@ -3231,16 +3254,16 @@ ${Nt}
|
|
|
3231
3254
|
!!D,
|
|
3232
3255
|
H,
|
|
3233
3256
|
U,
|
|
3234
|
-
|
|
3257
|
+
W
|
|
3235
3258
|
]);
|
|
3236
|
-
let
|
|
3259
|
+
let G = X((e) => e.chapters), ee = JSON.stringify(G);
|
|
3237
3260
|
S(() => {
|
|
3238
|
-
z.chapters =
|
|
3239
|
-
}, [
|
|
3240
|
-
let
|
|
3261
|
+
z.chapters = G, z.endingOffered = M, z.dispatchEvent(new Event("chapterschange"));
|
|
3262
|
+
}, [ee, M]);
|
|
3263
|
+
let te = e.autoplayNext;
|
|
3241
3264
|
S(() => {
|
|
3242
|
-
P === null && R(
|
|
3243
|
-
}, [
|
|
3265
|
+
P === null && R(te);
|
|
3266
|
+
}, [te, P]);
|
|
3244
3267
|
let K = w(e.onAutoplayNextChange);
|
|
3245
3268
|
K.current = e.onAutoplayNextChange, S(() => {
|
|
3246
3269
|
z.autoplayNext = L ?? null, z.dispatchEvent(new Event("autoplaynextchange"));
|
|
@@ -3256,33 +3279,33 @@ ${Nt}
|
|
|
3256
3279
|
}, [re]);
|
|
3257
3280
|
let ae = w(r?.onNormalizeVolumeChange);
|
|
3258
3281
|
ae.current = r?.onNormalizeVolumeChange;
|
|
3259
|
-
let
|
|
3260
|
-
|
|
3261
|
-
let
|
|
3282
|
+
let Y = r?.normalizerWorkletUrl, oe = w(p ?? f);
|
|
3283
|
+
oe.current = p ?? f;
|
|
3284
|
+
let se = X((e) => e.selectedAudioTrack), ce = !!f, { refused: le } = nt(v, Y, ie, C(() => ce && o && c && l && typeof se == "number" && se >= 0 ? h ? {
|
|
3262
3285
|
tap: q,
|
|
3263
|
-
audioStreamIndex:
|
|
3286
|
+
audioStreamIndex: se
|
|
3264
3287
|
} : {
|
|
3265
|
-
read: (e, t) =>
|
|
3288
|
+
read: (e, t) => oe.current(e, t),
|
|
3266
3289
|
length: o,
|
|
3267
3290
|
publicPath: c,
|
|
3268
3291
|
libavWorkerUrl: l,
|
|
3269
|
-
audioStreamIndex:
|
|
3292
|
+
audioStreamIndex: se
|
|
3270
3293
|
} : void 0, [
|
|
3271
3294
|
ce,
|
|
3272
3295
|
o,
|
|
3273
3296
|
c,
|
|
3274
3297
|
l,
|
|
3275
|
-
|
|
3298
|
+
se,
|
|
3276
3299
|
h,
|
|
3277
3300
|
q
|
|
3278
|
-
]), C(() => s?.map(({ startByteOffset: e, endByteOffset: t }) => [e, t]), [s?.map(({ startByteOffset: e, endByteOffset: t }) => `${e}-${t}`).join(",")])), ue = C(() =>
|
|
3301
|
+
]), C(() => s?.map(({ startByteOffset: e, endByteOffset: t }) => [e, t]), [s?.map(({ startByteOffset: e, endByteOffset: t }) => `${e}-${t}`).join(",")])), ue = C(() => Y && typeof AudioWorkletNode == "function" ? {
|
|
3279
3302
|
enabled: ie,
|
|
3280
3303
|
available: !le,
|
|
3281
3304
|
setEnabled: (e) => {
|
|
3282
3305
|
J(e), ae.current?.(e);
|
|
3283
3306
|
}
|
|
3284
3307
|
} : null, [
|
|
3285
|
-
|
|
3308
|
+
Y,
|
|
3286
3309
|
ie,
|
|
3287
3310
|
le
|
|
3288
3311
|
]), { thumbnails: de, requestThumbnail: fe } = ze({
|
|
@@ -3513,4 +3536,4 @@ ${Nt}
|
|
|
3513
3536
|
throw Error(`Unknown source type: ${e}`);
|
|
3514
3537
|
};
|
|
3515
3538
|
//#endregion
|
|
3516
|
-
export { En as MediaPlayer, En as default, ce as Player, t as SUBTITLES_OFF, c as createPictureInPicture, l as createSubtitleRenderer, o as createThumbnailGenerator, Mn as inputToRemuxerInput, On as isDelegatedTracks, Dn as isExternalThumbnails,
|
|
3539
|
+
export { En as MediaPlayer, En as default, ce as Player, t as SUBTITLES_OFF, c as createPictureInPicture, l as createSubtitleRenderer, o as createThumbnailGenerator, Mn as inputToRemuxerInput, On as isDelegatedTracks, Dn as isExternalThumbnails, se as sourceFeature, s as startPlayback, Be as usePictureInPicture, X as usePlayer, ze as useSeekThumbnails };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@banou/media-player",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.54",
|
|
4
4
|
"description": "A video player for containers and codecs the browser cannot play natively, remuxed on the fly",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"@videojs/react": "10.0.0-beta.26",
|
|
55
55
|
"ass-compiler": "^0.1.16",
|
|
56
56
|
"jassub": "^2.5.37",
|
|
57
|
-
"libav-wasm": "^0.8.
|
|
57
|
+
"libav-wasm": "^0.8.17",
|
|
58
58
|
"lucide-react": "^0.536.0",
|
|
59
59
|
"osra": "^0.6.12",
|
|
60
60
|
"react-tooltip": "^5.28.0"
|