@banou/media-player 0.10.49 → 0.10.51
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-Cdwc76gM.js → engine-axDHKSp3.js} +195 -177
- package/dist/index.js +199 -170
- package/dist/volume-normalizer-worklet.js +12 -9
- package/package.json +1 -1
- package/src/lib/audio/loudness-analysis.ts +14 -5
- package/src/lib/audio/volume-normalizer-worklet.d.ts +2 -2
- package/src/lib/audio/volume-normalizer-worklet.js +12 -9
- package/src/lib/engine/picture-in-picture.ts +3 -0
- package/src/lib/engine/playback.ts +104 -86
- package/src/lib/react/hooks/use-playback.ts +61 -15
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-axDHKSp3.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,8 +8,8 @@ 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
|
|
12
|
-
import { Tooltip as
|
|
11
|
+
import { Captions as z, CaptionsOff as B, Check as V, ChevronLeft as H, ChevronRight as U, Copy as ee, Maximize as W, Minimize as te, Pause as G, 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 oe } from "react-tooltip";
|
|
13
13
|
//#region src/lib/react/source-feature.ts
|
|
14
14
|
var se = {
|
|
15
15
|
indexes: [],
|
|
@@ -198,45 +198,47 @@ var se = {
|
|
|
198
198
|
let V = w({
|
|
199
199
|
audio: [],
|
|
200
200
|
subtitles: []
|
|
201
|
-
}), H = b(() => V.current.audio.find((e) => e.streamIndex === a.selectedAudioTrack), [a]),
|
|
202
|
-
|
|
203
|
-
let
|
|
201
|
+
}), H = b(() => V.current.audio.find((e) => e.streamIndex === a.selectedAudioTrack), [a]), U = w(o);
|
|
202
|
+
U.current = o;
|
|
203
|
+
let ee = w(E);
|
|
204
|
+
ee.current = E;
|
|
205
|
+
let W = {
|
|
204
206
|
audio: n?.preferredAudioLanguage,
|
|
205
207
|
original: n?.originalLanguage,
|
|
206
208
|
subtitles: n?.preferredSubtitleLanguage,
|
|
207
209
|
alwaysSubtitles: n?.alwaysShowSubtitles
|
|
208
|
-
},
|
|
209
|
-
|
|
210
|
-
let
|
|
211
|
-
|
|
212
|
-
let
|
|
213
|
-
|
|
214
|
-
let
|
|
215
|
-
|
|
216
|
-
let
|
|
217
|
-
|
|
218
|
-
let
|
|
219
|
-
|
|
220
|
-
let
|
|
221
|
-
|
|
222
|
-
let
|
|
223
|
-
|
|
210
|
+
}, te = w(W);
|
|
211
|
+
te.current = W;
|
|
212
|
+
let G = w(n?.onPreferredAudioLanguageChange);
|
|
213
|
+
G.current = n?.onPreferredAudioLanguageChange;
|
|
214
|
+
let K = w(n?.onPreferredSubtitleLanguageChange);
|
|
215
|
+
K.current = n?.onPreferredSubtitleLanguageChange;
|
|
216
|
+
let ne = w(n?.onAlwaysShowSubtitlesChange);
|
|
217
|
+
ne.current = n?.onAlwaysShowSubtitlesChange;
|
|
218
|
+
let q = w(n?.onSeek);
|
|
219
|
+
q.current = n?.onSeek;
|
|
220
|
+
let re = w(n?.onPlaybackError);
|
|
221
|
+
re.current = n?.onPlaybackError;
|
|
222
|
+
let ie = w(r);
|
|
223
|
+
ie.current = r;
|
|
224
|
+
let J = Q(), ae = w(J);
|
|
225
|
+
ae.current = J, S(() => {
|
|
224
226
|
let { audio: e, subtitles: t } = V.current;
|
|
225
|
-
t.length && a.setSourceState({ subtitleTracks: Ce(t,
|
|
226
|
-
}, [a,
|
|
227
|
+
t.length && a.setSourceState({ subtitleTracks: Ce(t, J) }), e.length && a.setSourceState({ audioTracks: Ce(e, J) });
|
|
228
|
+
}, [a, J]);
|
|
227
229
|
let oe = b((e) => {
|
|
228
230
|
let t = typeof e == "number" ? e : void 0, n = a.selectedSubtitleTrack === void 0;
|
|
229
231
|
z.current = B.current, a.setSourceState({ selectedSubtitleTrack: t }), L.current?.selectSubtitleStream(t);
|
|
230
232
|
let r = V.current.subtitles.find((e) => e.streamIndex === t), i = t === void 0 ? null : u(r) ?? (n ? r?.title?.trim() || "und" : void 0);
|
|
231
|
-
i !== void 0 &&
|
|
232
|
-
}, [a, H]),
|
|
233
|
-
let n = ++
|
|
233
|
+
i !== void 0 && K.current?.(i), i && d(H(), i) && ne.current?.(!0);
|
|
234
|
+
}, [a, H]), se = w(0), Y = b((e, t = !1) => {
|
|
235
|
+
let n = ++se.current, r = L.current;
|
|
234
236
|
if (!r || O <= 0 || t) {
|
|
235
237
|
a.setSourceState({ seekingTo: void 0 }), a.seek(e);
|
|
236
238
|
return;
|
|
237
239
|
}
|
|
238
240
|
let i = typeof window < "u" && window.__mediaPlayerSeekDebug, o = performance.now(), s = !1, c = "prepared", l = () => {
|
|
239
|
-
if (!s && (s = !0, L.current === r &&
|
|
241
|
+
if (!s && (s = !0, L.current === r && se.current === n && (a.seek(e), i))) {
|
|
240
242
|
let t = r.videoElement, n = 0;
|
|
241
243
|
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);
|
|
242
244
|
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)" : ""}`);
|
|
@@ -244,7 +246,7 @@ var se = {
|
|
|
244
246
|
};
|
|
245
247
|
a.setSourceState({ seekingTo: e });
|
|
246
248
|
let u = r.videoElement, d = () => {
|
|
247
|
-
u?.removeEventListener("seeked", f), clearTimeout(p),
|
|
249
|
+
u?.removeEventListener("seeked", f), clearTimeout(p), se.current === n && a.setSourceState({ seekingTo: void 0 });
|
|
248
250
|
}, f = () => {
|
|
249
251
|
s && d();
|
|
250
252
|
}, p = setTimeout(d, De);
|
|
@@ -255,34 +257,45 @@ var se = {
|
|
|
255
257
|
r.prepareSeek(e).catch(() => {}).finally(() => {
|
|
256
258
|
clearTimeout(m), l();
|
|
257
259
|
});
|
|
258
|
-
}, [a, O]),
|
|
260
|
+
}, [a, O]), ce = b((e) => {
|
|
259
261
|
if (typeof e != "number" || B.current === void 0) return;
|
|
260
262
|
a.setSourceState({ selectedAudioTrack: e }), j({
|
|
261
263
|
size: B.current,
|
|
262
264
|
streamIndex: e
|
|
263
265
|
});
|
|
264
266
|
let t = u(V.current.audio.find((t) => t.streamIndex === e));
|
|
265
|
-
t !== void 0 &&
|
|
266
|
-
}, [a]),
|
|
267
|
+
t !== void 0 && G.current?.(t);
|
|
268
|
+
}, [a]), le = X((e) => e.setSourceState);
|
|
267
269
|
S(() => {
|
|
268
|
-
|
|
270
|
+
le({
|
|
269
271
|
selectSubtitleTrack: oe,
|
|
270
|
-
selectAudioTrack:
|
|
271
|
-
requestSeek:
|
|
272
|
+
selectAudioTrack: ce,
|
|
273
|
+
requestSeek: Y
|
|
272
274
|
});
|
|
273
275
|
}, [
|
|
274
|
-
|
|
276
|
+
le,
|
|
275
277
|
oe,
|
|
276
|
-
|
|
277
|
-
|
|
278
|
+
ce,
|
|
279
|
+
Y
|
|
278
280
|
]), S(() => {
|
|
279
281
|
if (!e || !t || !c || !o) return;
|
|
280
|
-
|
|
281
|
-
|
|
282
|
+
R.current && R.current.size !== c && (R.current = null);
|
|
283
|
+
let n = !1, r = !1, u = !1, d = !1, b = !1, S = () => {
|
|
284
|
+
u = !0, d = !1, b = !1;
|
|
285
|
+
}, w = () => {
|
|
286
|
+
if (b) {
|
|
287
|
+
b = !1;
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
290
|
+
u = !1, d = !1;
|
|
291
|
+
}, T = () => {
|
|
292
|
+
u && e.paused && (d = !0, b = !0);
|
|
293
|
+
};
|
|
294
|
+
e.addEventListener("play", S), e.addEventListener("pause", w), e.addEventListener("error", T), a.setSourceState({
|
|
282
295
|
playbackError: null,
|
|
283
296
|
ready: !1
|
|
284
297
|
});
|
|
285
|
-
let
|
|
298
|
+
let E = (t, n) => {
|
|
286
299
|
let r = Date.now(), i = Oe(t), o = ke(t), s = a.playbackErrors, c = s[s.length - 1];
|
|
287
300
|
if (c && c.message === i && c.detail === o && c.recovered === n) {
|
|
288
301
|
let e = {
|
|
@@ -303,10 +316,10 @@ var se = {
|
|
|
303
316
|
recovered: n
|
|
304
317
|
};
|
|
305
318
|
a.setSourceState({ playbackErrors: [...s, l] });
|
|
306
|
-
},
|
|
319
|
+
}, D = (e) => {
|
|
307
320
|
if (n) return;
|
|
308
321
|
let t = i(e);
|
|
309
|
-
if (
|
|
322
|
+
if (E(e, t), t) {
|
|
310
323
|
let t = performance.now();
|
|
311
324
|
t - F.current.at > Te && (F.current = {
|
|
312
325
|
count: 0,
|
|
@@ -319,14 +332,14 @@ var se = {
|
|
|
319
332
|
}, 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);
|
|
320
333
|
return;
|
|
321
334
|
}
|
|
322
|
-
console.error("playback failed", e), a.setSourceState({ playbackError: e }),
|
|
335
|
+
console.error("playback failed", e), a.setSourceState({ playbackError: e }), re.current?.(e);
|
|
323
336
|
};
|
|
324
337
|
return (async () => {
|
|
325
338
|
try {
|
|
326
|
-
let
|
|
339
|
+
let i = await s({
|
|
327
340
|
videoElement: e,
|
|
328
341
|
subtitleContainer: t,
|
|
329
|
-
read: (e, t) =>
|
|
342
|
+
read: (e, t) => U.current(e, t),
|
|
330
343
|
length: c,
|
|
331
344
|
publicPath: l,
|
|
332
345
|
libavWorkerUrl: p,
|
|
@@ -339,53 +352,63 @@ var se = {
|
|
|
339
352
|
cjkFontUrl: x,
|
|
340
353
|
bufferSize: C,
|
|
341
354
|
audioStreamIndex: M,
|
|
342
|
-
chooseAudioStream: (e) => e[f(e, [],
|
|
355
|
+
chooseAudioStream: (e) => e[f(e, [], te.current).audio]?.streamIndex,
|
|
343
356
|
onReady: () => {
|
|
344
357
|
if (n) return;
|
|
345
|
-
a.setSourceState({ ready: !0 });
|
|
358
|
+
r = !0, a.setSourceState({ ready: !0 });
|
|
346
359
|
let t = R.current;
|
|
347
|
-
R.current = null
|
|
360
|
+
R.current = null;
|
|
361
|
+
let i = !!t && t.size === c;
|
|
362
|
+
i && t.time > 0 ? e.currentTime = t.time : a.setSourceState({ seekingTo: void 0 });
|
|
363
|
+
let o = i ? t.play : ee.current;
|
|
364
|
+
u = o, o && e.play().catch(() => {
|
|
365
|
+
e.paused && !d && (u = !1);
|
|
366
|
+
});
|
|
348
367
|
},
|
|
349
|
-
onError:
|
|
368
|
+
onError: D,
|
|
350
369
|
onRecovered: () => {
|
|
351
370
|
n || a.setSourceState({ playbackError: null });
|
|
352
371
|
},
|
|
353
|
-
onSeek: (e) =>
|
|
354
|
-
onOutput: (e) =>
|
|
372
|
+
onSeek: (e) => q.current?.(e),
|
|
373
|
+
onOutput: (e) => ie.current?.(e),
|
|
355
374
|
onSubtitleStreams: (e) => {
|
|
356
375
|
if (n) return;
|
|
357
376
|
V.current.subtitles = e;
|
|
358
|
-
let t = H(), r = f(t ? [t] : [], e,
|
|
377
|
+
let t = H(), r = f(t ? [t] : [], e, te.current).subtitles;
|
|
359
378
|
a.setSourceState({
|
|
360
|
-
subtitleTracks: Ce(e,
|
|
379
|
+
subtitleTracks: Ce(e, ae.current),
|
|
361
380
|
...z.current === c ? {} : { selectedSubtitleTrack: r === null ? void 0 : e[Math.max(r, 0)]?.streamIndex }
|
|
362
381
|
});
|
|
363
382
|
},
|
|
364
383
|
onAudioStreams: (e, t) => {
|
|
365
384
|
n || (V.current.audio = e, a.setSourceState({
|
|
366
|
-
audioTracks: Ce(e,
|
|
385
|
+
audioTracks: Ce(e, ae.current),
|
|
367
386
|
selectedAudioTrack: t
|
|
368
387
|
}));
|
|
369
388
|
}
|
|
370
389
|
});
|
|
371
390
|
if (n) {
|
|
372
|
-
|
|
391
|
+
i.destroy();
|
|
373
392
|
return;
|
|
374
393
|
}
|
|
375
|
-
L.current =
|
|
376
|
-
indexes:
|
|
377
|
-
chapters: k.current ??
|
|
394
|
+
L.current = i, a.setSourceState({
|
|
395
|
+
indexes: i.indexes,
|
|
396
|
+
chapters: k.current ?? i.chapters
|
|
378
397
|
});
|
|
379
|
-
let
|
|
380
|
-
|
|
398
|
+
let o = a.selectedSubtitleTrack;
|
|
399
|
+
i.selectSubtitleStream(typeof o == "number" ? o : void 0);
|
|
381
400
|
} catch (e) {
|
|
382
|
-
|
|
401
|
+
D(e);
|
|
383
402
|
}
|
|
384
403
|
})(), () => {
|
|
385
|
-
n = !0, R.current = {
|
|
404
|
+
n = !0, e.removeEventListener("play", S), e.removeEventListener("pause", w), e.removeEventListener("error", T), r ? R.current = {
|
|
386
405
|
time: a.state.seekingTo ?? e.currentTime,
|
|
387
|
-
size: c
|
|
388
|
-
|
|
406
|
+
size: c,
|
|
407
|
+
play: !e.ended && (d ? u : !e.paused)
|
|
408
|
+
} : R.current?.size === c && a.state.seekingTo !== void 0 && (R.current = {
|
|
409
|
+
...R.current,
|
|
410
|
+
time: a.state.seekingTo
|
|
411
|
+
}), L.current?.destroy(), L.current = null, a.setSourceState({ ready: !1 });
|
|
389
412
|
};
|
|
390
413
|
}, [
|
|
391
414
|
a,
|
|
@@ -404,7 +427,6 @@ var se = {
|
|
|
404
427
|
x,
|
|
405
428
|
C,
|
|
406
429
|
M,
|
|
407
|
-
E,
|
|
408
430
|
N
|
|
409
431
|
]);
|
|
410
432
|
}, je = 1001 / 24e3, Me = (e, t) => new Promise((n) => {
|
|
@@ -705,17 +727,23 @@ var se = {
|
|
|
705
727
|
}, [m.port1]), t.port.postMessage({ analysis: m.port2 }, [m.port2]);
|
|
706
728
|
let h = {
|
|
707
729
|
spans: [],
|
|
730
|
+
start: null,
|
|
708
731
|
end: null
|
|
709
732
|
}, g = 0, _ = /* @__PURE__ */ new Map(), v = (e, t) => new Promise((n) => _.set(`${e}:${t}`, n)), y = -1;
|
|
710
733
|
p.onmessage = ({ data: e }) => {
|
|
711
734
|
if (e.type === "unsupported") {
|
|
712
|
-
|
|
735
|
+
G();
|
|
713
736
|
return;
|
|
714
737
|
}
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
738
|
+
if (e.spans) {
|
|
739
|
+
let t = e.start ?? null;
|
|
740
|
+
(JSON.stringify(e.spans) !== JSON.stringify(h.spans) || t !== h.start || e.end !== h.end) && g++, h = {
|
|
741
|
+
spans: e.spans,
|
|
742
|
+
start: t,
|
|
743
|
+
end: e.end
|
|
744
|
+
};
|
|
745
|
+
}
|
|
746
|
+
e.type === "merged" && (y = e.run), _.get(`${e.type}:${e.run}`)?.(h), _.delete(`${e.type}:${e.run}`), l();
|
|
719
747
|
};
|
|
720
748
|
let b = t.context, x = () => t.port.postMessage({
|
|
721
749
|
media: n.currentTime,
|
|
@@ -737,24 +765,25 @@ var se = {
|
|
|
737
765
|
];
|
|
738
766
|
for (let e of w) n.addEventListener(e, x);
|
|
739
767
|
let T = Infinity, E = !1, D = 0, O = !1, k = 0, A = 0, j = /* @__PURE__ */ new Map(), M = (e) => {
|
|
740
|
-
let t = e;
|
|
768
|
+
let t = Math.max(e, h.start ?? 0);
|
|
741
769
|
for (let [e, n] of h.spans) e <= t && t < n && (t = n);
|
|
742
770
|
return t >= (h.end ?? T) - .05 ? null : t;
|
|
743
|
-
}, N = (e) => j.get(Math.round(e * 10)) === g ? "idle" : e, F = () => {
|
|
771
|
+
}, N = (e) => j.get(Math.round(e * 10)) === g ? "idle" : e, F = () => h.start !== null && h.end !== null && h.spans.length === 1 && h.spans[0][0] <= h.start && h.spans[0][1] >= h.end, I = () => {
|
|
772
|
+
if (F()) return "done";
|
|
744
773
|
let e = n.currentTime, t = M(e), r = O && y !== D;
|
|
745
774
|
if (t !== null && t < e + Ze) return r && k <= t + 1 && t <= A + Qe ? "read" : N(t);
|
|
746
775
|
if (r) return "read";
|
|
747
776
|
let i = t ?? M(0);
|
|
748
777
|
return i === null ? "done" : N(i);
|
|
749
|
-
},
|
|
750
|
-
|
|
751
|
-
})])),
|
|
752
|
-
S(), E && s.size && typeof
|
|
753
|
-
},
|
|
778
|
+
}, L = () => {}, R = (e) => (e.catch(() => {}), Promise.race([e, new Promise((e) => {
|
|
779
|
+
L = () => e(void 0);
|
|
780
|
+
})])), z = () => {
|
|
781
|
+
S(), E && s.size && typeof I() == "number" && L(), l();
|
|
782
|
+
}, B = () => {
|
|
754
783
|
S(), l();
|
|
755
784
|
};
|
|
756
|
-
n.addEventListener("seeking",
|
|
757
|
-
let
|
|
785
|
+
n.addEventListener("seeking", z), n.addEventListener("seeked", B), n.addEventListener("timeupdate", B);
|
|
786
|
+
let V, H = async (e) => {
|
|
758
787
|
if (!O) return;
|
|
759
788
|
O = !1;
|
|
760
789
|
let t = v("ended", D);
|
|
@@ -763,7 +792,7 @@ var se = {
|
|
|
763
792
|
run: D,
|
|
764
793
|
finished: e
|
|
765
794
|
}), await t;
|
|
766
|
-
},
|
|
795
|
+
}, U = async (e) => {
|
|
767
796
|
if (A = e.pts + e.duration, !e.data.byteLength) return;
|
|
768
797
|
let t = v("ack", D);
|
|
769
798
|
p.postMessage({
|
|
@@ -772,15 +801,15 @@ var se = {
|
|
|
772
801
|
data: e.data
|
|
773
802
|
}, [e.data]), await t;
|
|
774
803
|
}, ee = async (t) => {
|
|
775
|
-
if (
|
|
804
|
+
if (V = await P({
|
|
776
805
|
publicPath: t.publicPath,
|
|
777
806
|
workerUrl: t.libavWorkerUrl,
|
|
778
807
|
workerOptions: { type: "module" },
|
|
779
808
|
length: t.length,
|
|
780
809
|
read: (e, n) => d(t, e, n),
|
|
781
810
|
audioStreamIndex: t.audioStreamIndex
|
|
782
|
-
}), a) return e(
|
|
783
|
-
let n = await
|
|
811
|
+
}), a) return e(V);
|
|
812
|
+
let n = await V.init();
|
|
784
813
|
if (!a) {
|
|
785
814
|
for (T = n.info.input.duration || Infinity, p.postMessage({
|
|
786
815
|
type: "init",
|
|
@@ -793,7 +822,7 @@ var se = {
|
|
|
793
822
|
from: 0,
|
|
794
823
|
start: !0
|
|
795
824
|
}); !a;) {
|
|
796
|
-
let e =
|
|
825
|
+
let e = I();
|
|
797
826
|
if (e === "done") break;
|
|
798
827
|
if (e === "idle") {
|
|
799
828
|
await u();
|
|
@@ -801,15 +830,15 @@ var se = {
|
|
|
801
830
|
}
|
|
802
831
|
try {
|
|
803
832
|
if (e === "read") {
|
|
804
|
-
let e = await
|
|
833
|
+
let e = await R(V.read());
|
|
805
834
|
if (a) return;
|
|
806
835
|
if (!e) continue;
|
|
807
|
-
await
|
|
836
|
+
await U(e), e.finished && await H(!0);
|
|
808
837
|
} else {
|
|
809
|
-
await
|
|
810
|
-
let t =
|
|
838
|
+
await H(!1), j.set(Math.round(e * 10), g);
|
|
839
|
+
let t = V.seek(Math.max(0, e - $e));
|
|
811
840
|
f(!0);
|
|
812
|
-
let r = await
|
|
841
|
+
let r = await R(t);
|
|
813
842
|
if (a) return;
|
|
814
843
|
if (!r) continue;
|
|
815
844
|
D++, O = !0, k = r.pts, p.postMessage({
|
|
@@ -818,16 +847,16 @@ var se = {
|
|
|
818
847
|
pts: n.timestampOffset,
|
|
819
848
|
from: r.pts,
|
|
820
849
|
start: r.pts <= 0
|
|
821
|
-
}), await
|
|
850
|
+
}), await U(r), r.finished && await H(!0);
|
|
822
851
|
}
|
|
823
852
|
} catch {
|
|
824
853
|
if (a) return;
|
|
825
|
-
await
|
|
854
|
+
await H(!1), typeof I() != "number" && await u();
|
|
826
855
|
}
|
|
827
856
|
}
|
|
828
|
-
e(
|
|
857
|
+
a || await H(!1), !a && (e(V), V = void 0);
|
|
829
858
|
}
|
|
830
|
-
},
|
|
859
|
+
}, W = () => {}, te = (e, t) => {
|
|
831
860
|
let n = !1, r = (e) => {
|
|
832
861
|
n && p.postMessage({
|
|
833
862
|
type: "end",
|
|
@@ -835,7 +864,7 @@ var se = {
|
|
|
835
864
|
finished: e
|
|
836
865
|
}), n = !1;
|
|
837
866
|
};
|
|
838
|
-
|
|
867
|
+
W = e.attach(t, (e, t) => {
|
|
839
868
|
if (e.type === "init") {
|
|
840
869
|
r(!1);
|
|
841
870
|
let t = e.data.slice(0);
|
|
@@ -862,22 +891,22 @@ var se = {
|
|
|
862
891
|
}, [t]);
|
|
863
892
|
}
|
|
864
893
|
});
|
|
865
|
-
},
|
|
894
|
+
}, G = () => {
|
|
866
895
|
if (!a) {
|
|
867
896
|
a = !0, f(!0), l(), clearInterval(C);
|
|
868
897
|
for (let e of w) n.removeEventListener(e, x);
|
|
869
|
-
n.removeEventListener("seeking",
|
|
898
|
+
n.removeEventListener("seeking", z), n.removeEventListener("seeked", B), n.removeEventListener("timeupdate", B), W(), V && e(V), p.terminate(), t.port.postMessage({ analysis: null });
|
|
870
899
|
for (let e of _.values()) e(h);
|
|
871
900
|
_.clear();
|
|
872
901
|
}
|
|
873
902
|
};
|
|
874
|
-
return "tap" in i ?
|
|
875
|
-
a || (console.warn("[media-player] the volume normalizer cannot analyse ahead:", e),
|
|
903
|
+
return "tap" in i ? te(i.tap, i.audioStreamIndex) : ee(i).catch((e) => {
|
|
904
|
+
a || (console.warn("[media-player] the volume normalizer cannot analyse ahead:", e), G());
|
|
876
905
|
}), S(), {
|
|
877
906
|
update: (e) => {
|
|
878
907
|
o = e, f(!1);
|
|
879
908
|
},
|
|
880
|
-
stop:
|
|
909
|
+
stop: G
|
|
881
910
|
};
|
|
882
911
|
}, nt = (e, t, n, r, i) => {
|
|
883
912
|
let a = w(null), [o, s] = T(!1), [c, l] = T(null);
|
|
@@ -1158,7 +1187,7 @@ var se = {
|
|
|
1158
1187
|
"data-tooltip-delay-hide": i,
|
|
1159
1188
|
"data-tooltip-place": o,
|
|
1160
1189
|
children: n
|
|
1161
|
-
}), !s && /* @__PURE__ */ I(
|
|
1190
|
+
}), !s && /* @__PURE__ */ I(oe, {
|
|
1162
1191
|
ref: u,
|
|
1163
1192
|
css: yt(c),
|
|
1164
1193
|
id: e,
|
|
@@ -1460,9 +1489,9 @@ var se = {
|
|
|
1460
1489
|
B.current = e.pointerType;
|
|
1461
1490
|
}, H = (e) => {
|
|
1462
1491
|
B.current !== "touch" && E(z(e.clientX));
|
|
1463
|
-
},
|
|
1492
|
+
}, U = () => {
|
|
1464
1493
|
_.current && E(void 0);
|
|
1465
|
-
},
|
|
1494
|
+
}, ee = (e) => r ? e / r * 100 : 0, W = (e, t, n) => {
|
|
1466
1495
|
let r = Number((n - t).toFixed(4)), i = t * 100;
|
|
1467
1496
|
return /* @__PURE__ */ I("div", {
|
|
1468
1497
|
className: "loaded-part",
|
|
@@ -1471,10 +1500,10 @@ var se = {
|
|
|
1471
1500
|
marginLeft: `${i}%`
|
|
1472
1501
|
}
|
|
1473
1502
|
}, e);
|
|
1474
|
-
},
|
|
1503
|
+
}, te = C(() => i === void 0 ? r ? o.map(([e, t], n) => W(n, e / r, t / r)) : [] : a?.map((e, t) => {
|
|
1475
1504
|
if (!i || !r) return null;
|
|
1476
1505
|
let n = s.filter((t) => e.startByteOffset <= t.pos && t.pos <= e.endByteOffset), a = n.at(0), o = n.at(-1);
|
|
1477
|
-
return !a || !o ? null :
|
|
1506
|
+
return !a || !o ? null : W(t, a.timestamp / r, o.timestamp / r);
|
|
1478
1507
|
}) ?? [], [
|
|
1479
1508
|
r,
|
|
1480
1509
|
i,
|
|
@@ -1491,7 +1520,7 @@ var se = {
|
|
|
1491
1520
|
v,
|
|
1492
1521
|
r
|
|
1493
1522
|
]);
|
|
1494
|
-
let
|
|
1523
|
+
let G = C(() => {
|
|
1495
1524
|
if (!r) return 0;
|
|
1496
1525
|
if (N && v !== void 0) return v;
|
|
1497
1526
|
let e = f ?? t;
|
|
@@ -1502,22 +1531,22 @@ var se = {
|
|
|
1502
1531
|
N,
|
|
1503
1532
|
v,
|
|
1504
1533
|
f
|
|
1505
|
-
]),
|
|
1506
|
-
if (!
|
|
1507
|
-
let e = b / r * 100, t =
|
|
1508
|
-
return t >= 0 ? t :
|
|
1534
|
+
]), K = C(() => p(d, r), [d, r]), ne = K.length > 0, q = C(() => {
|
|
1535
|
+
if (!ne || b === void 0 || !r) return -1;
|
|
1536
|
+
let e = b / r * 100, t = K.findIndex((t, n) => n < K.length - 1 && e >= t && e < K[n + 1]);
|
|
1537
|
+
return t >= 0 ? t : K.length - 2;
|
|
1509
1538
|
}, [
|
|
1510
|
-
|
|
1511
|
-
|
|
1539
|
+
ne,
|
|
1540
|
+
K,
|
|
1512
1541
|
b,
|
|
1513
1542
|
r
|
|
1514
|
-
]),
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
]),
|
|
1543
|
+
]), re = C(() => ne ? m(K, (e) => e !== q) : void 0, [
|
|
1544
|
+
ne,
|
|
1545
|
+
K,
|
|
1546
|
+
q
|
|
1547
|
+
]), ie = C(() => q >= 0 ? m(K, (e) => e === q) : void 0, [K, q]), J = C(() => {
|
|
1519
1548
|
if (b !== void 0) return d.find(({ start: e, end: t }) => e <= b && b < t);
|
|
1520
|
-
}, [d, b]),
|
|
1549
|
+
}, [d, b]), ae = C(() => {
|
|
1521
1550
|
if (b) {
|
|
1522
1551
|
if (l) return l(b);
|
|
1523
1552
|
if (c.length) return c.find(({ startTime: e, endTime: t }) => e <= b && b < t);
|
|
@@ -1526,20 +1555,20 @@ var se = {
|
|
|
1526
1555
|
c,
|
|
1527
1556
|
l,
|
|
1528
1557
|
b
|
|
1529
|
-
]),
|
|
1558
|
+
]), oe = (e, t) => /* @__PURE__ */ L("div", {
|
|
1530
1559
|
className: e ? `track ${e}` : "track",
|
|
1531
1560
|
style: t ? { maskImage: t } : void 0,
|
|
1532
1561
|
children: [
|
|
1533
1562
|
/* @__PURE__ */ I("div", { className: "background-bar" }),
|
|
1534
1563
|
/* @__PURE__ */ I("div", {
|
|
1535
1564
|
className: "loaded",
|
|
1536
|
-
children:
|
|
1565
|
+
children: te
|
|
1537
1566
|
}),
|
|
1538
1567
|
/* @__PURE__ */ I("div", {
|
|
1539
1568
|
className: "play-container",
|
|
1540
1569
|
children: /* @__PURE__ */ I("div", {
|
|
1541
1570
|
className: "play",
|
|
1542
|
-
style: { transform: `scaleX(${
|
|
1571
|
+
style: { transform: `scaleX(${G})` }
|
|
1543
1572
|
})
|
|
1544
1573
|
})
|
|
1545
1574
|
]
|
|
@@ -1550,31 +1579,31 @@ var se = {
|
|
|
1550
1579
|
className: [
|
|
1551
1580
|
"progress-bar",
|
|
1552
1581
|
N ? "dragging" : "",
|
|
1553
|
-
|
|
1582
|
+
ne ? "segmented" : ""
|
|
1554
1583
|
].filter(Boolean).join(" "),
|
|
1555
1584
|
onPointerDown: V,
|
|
1556
1585
|
onPointerMove: V,
|
|
1557
1586
|
onMouseMove: H,
|
|
1558
|
-
onMouseOut:
|
|
1587
|
+
onMouseOut: U,
|
|
1559
1588
|
children: [
|
|
1560
|
-
|
|
1589
|
+
oe(void 0, re),
|
|
1561
1590
|
b ? /* @__PURE__ */ L("div", {
|
|
1562
1591
|
className: "cursor-time",
|
|
1563
1592
|
style: {
|
|
1564
|
-
left:
|
|
1565
|
-
maxWidth:
|
|
1593
|
+
left: J ? `clamp(var(--thumbnail-half), ${ee(b)}%, calc(100% - var(--thumbnail-half)))` : `clamp(calc(3 * var(--mp-unit)), ${ee(b)}%, calc(100% - calc(3 * var(--mp-unit))))`,
|
|
1594
|
+
maxWidth: J ? "var(--thumbnail-width)" : void 0
|
|
1566
1595
|
},
|
|
1567
1596
|
children: [/* @__PURE__ */ I("span", {
|
|
1568
1597
|
className: "cursor-time-value",
|
|
1569
1598
|
children: _t(b)
|
|
1570
|
-
}),
|
|
1599
|
+
}), J ? /* @__PURE__ */ I("span", {
|
|
1571
1600
|
className: "chapter-title",
|
|
1572
|
-
children:
|
|
1601
|
+
children: J.title
|
|
1573
1602
|
}) : void 0]
|
|
1574
1603
|
}) : void 0,
|
|
1575
1604
|
/* @__PURE__ */ I("div", { className: "progress" }),
|
|
1576
1605
|
/* @__PURE__ */ I("div", { className: "hover" }),
|
|
1577
|
-
|
|
1606
|
+
ie ? oe("focus", ie) : void 0,
|
|
1578
1607
|
/* @__PURE__ */ I("div", { className: "scrubber" }),
|
|
1579
1608
|
/* @__PURE__ */ I("div", {
|
|
1580
1609
|
className: "padding",
|
|
@@ -1585,8 +1614,8 @@ var se = {
|
|
|
1585
1614
|
}),
|
|
1586
1615
|
/* @__PURE__ */ I("div", {
|
|
1587
1616
|
className: "thumbnail",
|
|
1588
|
-
style: { left: `clamp(var(--thumbnail-half), ${
|
|
1589
|
-
children:
|
|
1617
|
+
style: { left: `clamp(var(--thumbnail-half), ${ee(b ?? 1)}%, calc(100% - var(--thumbnail-half)))` },
|
|
1618
|
+
children: ae?.url ? /* @__PURE__ */ I("img", { src: ae.url }) : void 0
|
|
1590
1619
|
})
|
|
1591
1620
|
]
|
|
1592
1621
|
});
|
|
@@ -1942,7 +1971,7 @@ ${Nt}
|
|
|
1942
1971
|
onClick: i,
|
|
1943
1972
|
"aria-label": u,
|
|
1944
1973
|
"aria-expanded": r,
|
|
1945
|
-
children: /* @__PURE__ */ I(
|
|
1974
|
+
children: /* @__PURE__ */ I(re, { className: "alert-triangle" })
|
|
1946
1975
|
}),
|
|
1947
1976
|
toolTipText: /* @__PURE__ */ I("span", { children: u })
|
|
1948
1977
|
}), r && /* @__PURE__ */ L("div", {
|
|
@@ -1954,7 +1983,7 @@ ${Nt}
|
|
|
1954
1983
|
type: "button",
|
|
1955
1984
|
onClick: l,
|
|
1956
1985
|
"aria-label": t(a.copyErrors),
|
|
1957
|
-
children: [I(s ? V :
|
|
1986
|
+
children: [I(s ? V : ee, {}), /* @__PURE__ */ I("span", { children: t(s ? a.copied : a.copy) })]
|
|
1958
1987
|
})]
|
|
1959
1988
|
}), e.map((e, r) => /* @__PURE__ */ L("div", {
|
|
1960
1989
|
className: "entry no-hover",
|
|
@@ -2200,7 +2229,7 @@ ${Nt}
|
|
|
2200
2229
|
onClick: m,
|
|
2201
2230
|
"aria-label": t(a.settings),
|
|
2202
2231
|
"aria-expanded": p,
|
|
2203
|
-
children: /* @__PURE__ */ I(
|
|
2232
|
+
children: /* @__PURE__ */ I(q, {})
|
|
2204
2233
|
}),
|
|
2205
2234
|
toolTipText: /* @__PURE__ */ I("span", { children: t(a.settings) })
|
|
2206
2235
|
}),
|
|
@@ -2215,14 +2244,14 @@ ${Nt}
|
|
|
2215
2244
|
}) : null,
|
|
2216
2245
|
i.length > 1 ? /* @__PURE__ */ L("div", {
|
|
2217
2246
|
onClick: w(2),
|
|
2218
|
-
children: [/* @__PURE__ */ I("div", { children: t(a.audio) }), /* @__PURE__ */ I("div", { children: /* @__PURE__ */ I(
|
|
2247
|
+
children: [/* @__PURE__ */ I("div", { children: t(a.audio) }), /* @__PURE__ */ I("div", { children: /* @__PURE__ */ I(U, {}) })]
|
|
2219
2248
|
}) : null,
|
|
2220
2249
|
S > 1 ? /* @__PURE__ */ L("div", {
|
|
2221
2250
|
onClick: w(3),
|
|
2222
2251
|
children: [/* @__PURE__ */ I("div", { children: t(a.quality) }), /* @__PURE__ */ L("div", { children: [C ? /* @__PURE__ */ I("span", {
|
|
2223
2252
|
className: "secondary",
|
|
2224
2253
|
children: C
|
|
2225
|
-
}) : null, /* @__PURE__ */ I(
|
|
2254
|
+
}) : null, /* @__PURE__ */ I(U, {})] })]
|
|
2226
2255
|
}) : null,
|
|
2227
2256
|
/* @__PURE__ */ L("div", {
|
|
2228
2257
|
onClick: w(1),
|
|
@@ -2232,7 +2261,7 @@ ${Nt}
|
|
|
2232
2261
|
minimumFractionDigits: 2,
|
|
2233
2262
|
maximumFractionDigits: 2
|
|
2234
2263
|
})
|
|
2235
|
-
}), /* @__PURE__ */ I(
|
|
2264
|
+
}), /* @__PURE__ */ I(U, {})] })]
|
|
2236
2265
|
}),
|
|
2237
2266
|
l ? /* @__PURE__ */ L("div", {
|
|
2238
2267
|
role: "switch",
|
|
@@ -2502,7 +2531,7 @@ ${Nt}
|
|
|
2502
2531
|
ref: e,
|
|
2503
2532
|
"aria-label": n(a.mute),
|
|
2504
2533
|
"aria-pressed": i || r === 0,
|
|
2505
|
-
children: I(i || r === 0 ?
|
|
2534
|
+
children: I(i || r === 0 ? ae : r <= .5 ? ie : J, {
|
|
2506
2535
|
size: 18,
|
|
2507
2536
|
color: "#fff"
|
|
2508
2537
|
})
|
|
@@ -2757,7 +2786,7 @@ ${Nt}
|
|
|
2757
2786
|
type: "button",
|
|
2758
2787
|
onClick: () => r.togglePaused(),
|
|
2759
2788
|
"aria-label": i(j ? a.replay : o ? a.play : a.pause),
|
|
2760
|
-
children: I(j ?
|
|
2789
|
+
children: I(j ? ne : o ? K : G, {})
|
|
2761
2790
|
}),
|
|
2762
2791
|
toolTipText: /* @__PURE__ */ I("span", { children: i(j ? a.replayKey : o ? a.playKey : a.pauseKey) })
|
|
2763
2792
|
}),
|
|
@@ -2817,7 +2846,7 @@ ${Nt}
|
|
|
2817
2846
|
onClick: P,
|
|
2818
2847
|
"aria-label": i(a.fullScreen),
|
|
2819
2848
|
"aria-pressed": d,
|
|
2820
|
-
children: I(d ?
|
|
2849
|
+
children: I(d ? te : W, {})
|
|
2821
2850
|
}),
|
|
2822
2851
|
toolTipText: /* @__PURE__ */ I("span", { children: i(d ? a.exitFullScreenKey : a.fullScreenKey) })
|
|
2823
2852
|
})
|
|
@@ -3185,7 +3214,7 @@ ${Nt}
|
|
|
3185
3214
|
}
|
|
3186
3215
|
})), B = D === !0 ? {} : D || void 0, V = w(B);
|
|
3187
3216
|
V.current = B;
|
|
3188
|
-
let H = B ? B.id : void 0,
|
|
3217
|
+
let H = B ? B.id : void 0, U = B ? B.origin : void 0, ee = B ? B.channel : void 0;
|
|
3189
3218
|
S(() => {
|
|
3190
3219
|
if (!D || !E) return;
|
|
3191
3220
|
let e, t = !1;
|
|
@@ -3201,36 +3230,36 @@ ${Nt}
|
|
|
3201
3230
|
E,
|
|
3202
3231
|
!!D,
|
|
3203
3232
|
H,
|
|
3204
|
-
|
|
3205
|
-
|
|
3233
|
+
U,
|
|
3234
|
+
ee
|
|
3206
3235
|
]);
|
|
3207
|
-
let
|
|
3236
|
+
let W = X((e) => e.chapters), te = JSON.stringify(W);
|
|
3208
3237
|
S(() => {
|
|
3209
|
-
z.chapters =
|
|
3210
|
-
}, [
|
|
3211
|
-
let
|
|
3238
|
+
z.chapters = W, z.endingOffered = M, z.dispatchEvent(new Event("chapterschange"));
|
|
3239
|
+
}, [te, M]);
|
|
3240
|
+
let G = e.autoplayNext;
|
|
3212
3241
|
S(() => {
|
|
3213
|
-
P === null && R(
|
|
3214
|
-
}, [
|
|
3215
|
-
let
|
|
3216
|
-
|
|
3242
|
+
P === null && R(G);
|
|
3243
|
+
}, [G, P]);
|
|
3244
|
+
let K = w(e.onAutoplayNextChange);
|
|
3245
|
+
K.current = e.onAutoplayNextChange, S(() => {
|
|
3217
3246
|
z.autoplayNext = L ?? null, z.dispatchEvent(new Event("autoplaynextchange"));
|
|
3218
3247
|
}, [L]);
|
|
3219
|
-
let
|
|
3248
|
+
let ne = e.fullscreen ?? (O === null ? void 0 : {
|
|
3220
3249
|
active: O,
|
|
3221
3250
|
request: () => z.dispatchEvent(new Event("fullscreenrequest"))
|
|
3222
|
-
}),
|
|
3223
|
-
Ae(v, b, r, h ?
|
|
3224
|
-
let
|
|
3251
|
+
}), q = C(() => rt(), [o]);
|
|
3252
|
+
Ae(v, b, r, h ? q.push : void 0);
|
|
3253
|
+
let re = r?.normalizeVolume ?? !0, [ie, J] = T(re);
|
|
3225
3254
|
S(() => {
|
|
3226
|
-
|
|
3227
|
-
}, [
|
|
3228
|
-
let
|
|
3229
|
-
|
|
3230
|
-
let
|
|
3255
|
+
J(re);
|
|
3256
|
+
}, [re]);
|
|
3257
|
+
let ae = w(r?.onNormalizeVolumeChange);
|
|
3258
|
+
ae.current = r?.onNormalizeVolumeChange;
|
|
3259
|
+
let oe = r?.normalizerWorkletUrl, se = w(p ?? f);
|
|
3231
3260
|
se.current = p ?? f;
|
|
3232
|
-
let Y = X((e) => e.selectedAudioTrack), ce = !!f, { refused: le } = nt(v,
|
|
3233
|
-
tap:
|
|
3261
|
+
let Y = X((e) => e.selectedAudioTrack), ce = !!f, { refused: le } = nt(v, oe, ie, C(() => ce && o && c && l && typeof Y == "number" && Y >= 0 ? h ? {
|
|
3262
|
+
tap: q,
|
|
3234
3263
|
audioStreamIndex: Y
|
|
3235
3264
|
} : {
|
|
3236
3265
|
read: (e, t) => se.current(e, t),
|
|
@@ -3245,16 +3274,16 @@ ${Nt}
|
|
|
3245
3274
|
l,
|
|
3246
3275
|
Y,
|
|
3247
3276
|
h,
|
|
3248
|
-
|
|
3249
|
-
]), C(() => s?.map(({ startByteOffset: e, endByteOffset: t }) => [e, t]), [s?.map(({ startByteOffset: e, endByteOffset: t }) => `${e}-${t}`).join(",")])), ue = C(() =>
|
|
3250
|
-
enabled:
|
|
3277
|
+
q
|
|
3278
|
+
]), C(() => s?.map(({ startByteOffset: e, endByteOffset: t }) => [e, t]), [s?.map(({ startByteOffset: e, endByteOffset: t }) => `${e}-${t}`).join(",")])), ue = C(() => oe && typeof AudioWorkletNode == "function" ? {
|
|
3279
|
+
enabled: ie,
|
|
3251
3280
|
available: !le,
|
|
3252
3281
|
setEnabled: (e) => {
|
|
3253
|
-
|
|
3282
|
+
J(e), ae.current?.(e);
|
|
3254
3283
|
}
|
|
3255
3284
|
} : null, [
|
|
3256
|
-
|
|
3257
|
-
|
|
3285
|
+
oe,
|
|
3286
|
+
ie,
|
|
3258
3287
|
le
|
|
3259
3288
|
]), { thumbnails: de, requestThumbnail: fe } = ze({
|
|
3260
3289
|
publicPath: c,
|
|
@@ -3301,7 +3330,7 @@ ${Nt}
|
|
|
3301
3330
|
Z({ autoplayNext: L === void 0 ? null : {
|
|
3302
3331
|
enabled: L,
|
|
3303
3332
|
setEnabled: (e) => {
|
|
3304
|
-
R(e),
|
|
3333
|
+
R(e), K.current?.(e);
|
|
3305
3334
|
}
|
|
3306
3335
|
} });
|
|
3307
3336
|
}, [Z, L]), S(() => {
|
|
@@ -3359,7 +3388,7 @@ ${Nt}
|
|
|
3359
3388
|
overlay: e.overlay,
|
|
3360
3389
|
controls: e.controls,
|
|
3361
3390
|
shortcuts: e.shortcuts,
|
|
3362
|
-
fullscreen:
|
|
3391
|
+
fullscreen: ne,
|
|
3363
3392
|
endingOffered: M,
|
|
3364
3393
|
children: t
|
|
3365
3394
|
});
|