@banou/media-player 0.10.47 → 0.10.48
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/index.js
CHANGED
|
@@ -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 ee, Copy as
|
|
12
|
-
import { Tooltip as
|
|
11
|
+
import { Captions as z, CaptionsOff as B, Check as V, ChevronLeft as H, ChevronRight as ee, Copy as te, Maximize as ne, Minimize as re, Pause as ie, Play as U, RotateCcw as W, Settings as G, TriangleAlert as ae, Volume1 as K, Volume2 as q, VolumeX as oe } from "lucide-react";
|
|
12
|
+
import { Tooltip as J } from "react-tooltip";
|
|
13
13
|
//#region src/lib/react/source-feature.ts
|
|
14
14
|
var se = {
|
|
15
15
|
indexes: [],
|
|
@@ -200,58 +200,60 @@ var se = {
|
|
|
200
200
|
subtitles: []
|
|
201
201
|
}), H = b(() => V.current.audio.find((e) => e.streamIndex === a.selectedAudioTrack), [a]), ee = w(o);
|
|
202
202
|
ee.current = o;
|
|
203
|
-
let
|
|
203
|
+
let te = {
|
|
204
204
|
audio: n?.preferredAudioLanguage,
|
|
205
205
|
original: n?.originalLanguage,
|
|
206
206
|
subtitles: n?.preferredSubtitleLanguage,
|
|
207
207
|
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
|
-
|
|
208
|
+
}, ne = w(te);
|
|
209
|
+
ne.current = te;
|
|
210
|
+
let re = w(n?.onPreferredAudioLanguageChange);
|
|
211
|
+
re.current = n?.onPreferredAudioLanguageChange;
|
|
212
|
+
let ie = w(n?.onPreferredSubtitleLanguageChange);
|
|
213
|
+
ie.current = n?.onPreferredSubtitleLanguageChange;
|
|
214
|
+
let U = w(n?.onAlwaysShowSubtitlesChange);
|
|
215
|
+
U.current = n?.onAlwaysShowSubtitlesChange;
|
|
216
|
+
let W = w(n?.onSeek);
|
|
217
|
+
W.current = n?.onSeek;
|
|
218
|
+
let G = w(n?.onPlaybackError);
|
|
219
|
+
G.current = n?.onPlaybackError;
|
|
220
|
+
let ae = w(r);
|
|
221
|
+
ae.current = r;
|
|
222
|
+
let K = Q(), q = w(K);
|
|
223
|
+
q.current = K, S(() => {
|
|
224
224
|
let { audio: e, subtitles: t } = V.current;
|
|
225
|
-
t.length && a.setSourceState({ subtitleTracks: Ce(t,
|
|
226
|
-
}, [a,
|
|
227
|
-
let
|
|
225
|
+
t.length && a.setSourceState({ subtitleTracks: Ce(t, K) }), e.length && a.setSourceState({ audioTracks: Ce(e, K) });
|
|
226
|
+
}, [a, K]);
|
|
227
|
+
let oe = b((e) => {
|
|
228
228
|
let t = typeof e == "number" ? e : void 0, n = a.selectedSubtitleTrack === void 0;
|
|
229
229
|
z.current = B.current, a.setSourceState({ selectedSubtitleTrack: t }), L.current?.selectSubtitleStream(t);
|
|
230
230
|
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
|
|
234
|
-
if (!
|
|
235
|
-
a.seek(e);
|
|
231
|
+
i !== void 0 && ie.current?.(i), i && d(H(), i) && U.current?.(!0);
|
|
232
|
+
}, [a, H]), J = w(0), se = b((e, t = !1) => {
|
|
233
|
+
let n = ++J.current, r = L.current;
|
|
234
|
+
if (!r || O <= 0 || t) {
|
|
235
|
+
a.setSourceState({ seekingTo: void 0 }), a.seek(e);
|
|
236
236
|
return;
|
|
237
237
|
}
|
|
238
|
-
let
|
|
239
|
-
if (!
|
|
240
|
-
let t =
|
|
241
|
-
if (t) for (let
|
|
242
|
-
console.warn(`[media-player] seek to ${e.toFixed(2)} moved after ${Math.round(performance.now() -
|
|
238
|
+
let i = typeof window < "u" && window.__mediaPlayerSeekDebug, o = performance.now(), s = !1, c = "prepared", l = () => {
|
|
239
|
+
if (!s && (s = !0, L.current === r && J.current === n && (a.seek(e), i))) {
|
|
240
|
+
let t = r.videoElement, n = 0;
|
|
241
|
+
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
|
+
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)" : ""}`);
|
|
243
243
|
}
|
|
244
244
|
};
|
|
245
245
|
a.setSourceState({ seekingTo: e });
|
|
246
|
-
let
|
|
247
|
-
|
|
248
|
-
},
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
246
|
+
let u = r.videoElement, d = () => {
|
|
247
|
+
u?.removeEventListener("seeked", f), clearTimeout(p), J.current === n && a.setSourceState({ seekingTo: void 0 });
|
|
248
|
+
}, f = () => {
|
|
249
|
+
s && d();
|
|
250
|
+
}, p = setTimeout(d, De);
|
|
251
|
+
u?.addEventListener("seeked", f);
|
|
252
|
+
let m = setTimeout(() => {
|
|
253
|
+
c = "deadline", l();
|
|
252
254
|
}, O);
|
|
253
|
-
|
|
254
|
-
clearTimeout(
|
|
255
|
+
r.prepareSeek(e).catch(() => {}).finally(() => {
|
|
256
|
+
clearTimeout(m), l();
|
|
255
257
|
});
|
|
256
258
|
}, [a, O]), Y = b((e) => {
|
|
257
259
|
if (typeof e != "number" || B.current === void 0) return;
|
|
@@ -260,17 +262,17 @@ var se = {
|
|
|
260
262
|
streamIndex: e
|
|
261
263
|
});
|
|
262
264
|
let t = u(V.current.audio.find((t) => t.streamIndex === e));
|
|
263
|
-
t !== void 0 &&
|
|
265
|
+
t !== void 0 && re.current?.(t);
|
|
264
266
|
}, [a]), ce = X((e) => e.setSourceState);
|
|
265
267
|
S(() => {
|
|
266
268
|
ce({
|
|
267
|
-
selectSubtitleTrack:
|
|
269
|
+
selectSubtitleTrack: oe,
|
|
268
270
|
selectAudioTrack: Y,
|
|
269
271
|
requestSeek: se
|
|
270
272
|
});
|
|
271
273
|
}, [
|
|
272
274
|
ce,
|
|
273
|
-
|
|
275
|
+
oe,
|
|
274
276
|
Y,
|
|
275
277
|
se
|
|
276
278
|
]), S(() => {
|
|
@@ -317,7 +319,7 @@ var se = {
|
|
|
317
319
|
}, 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);
|
|
318
320
|
return;
|
|
319
321
|
}
|
|
320
|
-
console.error("playback failed", e), a.setSourceState({ playbackError: e }),
|
|
322
|
+
console.error("playback failed", e), a.setSourceState({ playbackError: e }), G.current?.(e);
|
|
321
323
|
};
|
|
322
324
|
return (async () => {
|
|
323
325
|
try {
|
|
@@ -337,7 +339,7 @@ var se = {
|
|
|
337
339
|
cjkFontUrl: x,
|
|
338
340
|
bufferSize: C,
|
|
339
341
|
audioStreamIndex: M,
|
|
340
|
-
chooseAudioStream: (e) => e[f(e, [],
|
|
342
|
+
chooseAudioStream: (e) => e[f(e, [], ne.current).audio]?.streamIndex,
|
|
341
343
|
onReady: () => {
|
|
342
344
|
if (n) return;
|
|
343
345
|
a.setSourceState({ ready: !0 });
|
|
@@ -348,20 +350,20 @@ var se = {
|
|
|
348
350
|
onRecovered: () => {
|
|
349
351
|
n || a.setSourceState({ playbackError: null });
|
|
350
352
|
},
|
|
351
|
-
onSeek: (e) =>
|
|
352
|
-
onOutput: (e) =>
|
|
353
|
+
onSeek: (e) => W.current?.(e),
|
|
354
|
+
onOutput: (e) => ae.current?.(e),
|
|
353
355
|
onSubtitleStreams: (e) => {
|
|
354
356
|
if (n) return;
|
|
355
357
|
V.current.subtitles = e;
|
|
356
|
-
let t = H(), r = f(t ? [t] : [], e,
|
|
358
|
+
let t = H(), r = f(t ? [t] : [], e, ne.current).subtitles;
|
|
357
359
|
a.setSourceState({
|
|
358
|
-
subtitleTracks: Ce(e,
|
|
360
|
+
subtitleTracks: Ce(e, q.current),
|
|
359
361
|
...z.current === c ? {} : { selectedSubtitleTrack: r === null ? void 0 : e[Math.max(r, 0)]?.streamIndex }
|
|
360
362
|
});
|
|
361
363
|
},
|
|
362
364
|
onAudioStreams: (e, t) => {
|
|
363
365
|
n || (V.current.audio = e, a.setSourceState({
|
|
364
|
-
audioTracks: Ce(e,
|
|
366
|
+
audioTracks: Ce(e, q.current),
|
|
365
367
|
selectedAudioTrack: t
|
|
366
368
|
}));
|
|
367
369
|
}
|
|
@@ -707,7 +709,7 @@ var se = {
|
|
|
707
709
|
}, g = 0, _ = /* @__PURE__ */ new Map(), v = (e, t) => new Promise((n) => _.set(`${e}:${t}`, n)), y = -1;
|
|
708
710
|
p.onmessage = ({ data: e }) => {
|
|
709
711
|
if (e.type === "unsupported") {
|
|
710
|
-
|
|
712
|
+
re();
|
|
711
713
|
return;
|
|
712
714
|
}
|
|
713
715
|
e.spans && ((JSON.stringify(e.spans) !== JSON.stringify(h.spans) || e.end !== h.end) && g++, h = {
|
|
@@ -825,7 +827,7 @@ var se = {
|
|
|
825
827
|
}
|
|
826
828
|
e(B), B = void 0;
|
|
827
829
|
}
|
|
828
|
-
},
|
|
830
|
+
}, te = () => {}, ne = (e, t) => {
|
|
829
831
|
let n = !1, r = (e) => {
|
|
830
832
|
n && p.postMessage({
|
|
831
833
|
type: "end",
|
|
@@ -833,7 +835,7 @@ var se = {
|
|
|
833
835
|
finished: e
|
|
834
836
|
}), n = !1;
|
|
835
837
|
};
|
|
836
|
-
|
|
838
|
+
te = e.attach(t, (e, t) => {
|
|
837
839
|
if (e.type === "init") {
|
|
838
840
|
r(!1);
|
|
839
841
|
let t = e.data.slice(0);
|
|
@@ -860,22 +862,22 @@ var se = {
|
|
|
860
862
|
}, [t]);
|
|
861
863
|
}
|
|
862
864
|
});
|
|
863
|
-
},
|
|
865
|
+
}, re = () => {
|
|
864
866
|
if (!a) {
|
|
865
867
|
a = !0, f(!0), l(), clearInterval(C);
|
|
866
868
|
for (let e of w) n.removeEventListener(e, x);
|
|
867
|
-
n.removeEventListener("seeking", R), n.removeEventListener("seeked", z), n.removeEventListener("timeupdate", z),
|
|
869
|
+
n.removeEventListener("seeking", R), n.removeEventListener("seeked", z), n.removeEventListener("timeupdate", z), te(), B && e(B), p.terminate(), t.port.postMessage({ analysis: null });
|
|
868
870
|
for (let e of _.values()) e(h);
|
|
869
871
|
_.clear();
|
|
870
872
|
}
|
|
871
873
|
};
|
|
872
|
-
return "tap" in i ?
|
|
873
|
-
a || (console.warn("[media-player] the volume normalizer cannot analyse ahead:", e),
|
|
874
|
+
return "tap" in i ? ne(i.tap, i.audioStreamIndex) : ee(i).catch((e) => {
|
|
875
|
+
a || (console.warn("[media-player] the volume normalizer cannot analyse ahead:", e), re());
|
|
874
876
|
}), S(), {
|
|
875
877
|
update: (e) => {
|
|
876
878
|
o = e, f(!1);
|
|
877
879
|
},
|
|
878
|
-
stop:
|
|
880
|
+
stop: re
|
|
879
881
|
};
|
|
880
882
|
}, nt = (e, t, n, r, i) => {
|
|
881
883
|
let a = w(null), [o, s] = T(!1), [c, l] = T(null);
|
|
@@ -1156,7 +1158,7 @@ var se = {
|
|
|
1156
1158
|
"data-tooltip-delay-hide": i,
|
|
1157
1159
|
"data-tooltip-place": o,
|
|
1158
1160
|
children: n
|
|
1159
|
-
}), !s && /* @__PURE__ */ I(
|
|
1161
|
+
}), !s && /* @__PURE__ */ I(J, {
|
|
1160
1162
|
ref: u,
|
|
1161
1163
|
css: yt(c),
|
|
1162
1164
|
id: e,
|
|
@@ -1460,7 +1462,7 @@ var se = {
|
|
|
1460
1462
|
B.current !== "touch" && E(z(e.clientX));
|
|
1461
1463
|
}, ee = () => {
|
|
1462
1464
|
_.current && E(void 0);
|
|
1463
|
-
},
|
|
1465
|
+
}, te = (e) => r ? e / r * 100 : 0, ne = (e, t, n) => {
|
|
1464
1466
|
let r = Number((n - t).toFixed(4)), i = t * 100;
|
|
1465
1467
|
return /* @__PURE__ */ I("div", {
|
|
1466
1468
|
className: "loaded-part",
|
|
@@ -1469,10 +1471,10 @@ var se = {
|
|
|
1469
1471
|
marginLeft: `${i}%`
|
|
1470
1472
|
}
|
|
1471
1473
|
}, e);
|
|
1472
|
-
},
|
|
1474
|
+
}, re = C(() => i === void 0 ? r ? o.map(([e, t], n) => ne(n, e / r, t / r)) : [] : a?.map((e, t) => {
|
|
1473
1475
|
if (!i || !r) return null;
|
|
1474
1476
|
let n = s.filter((t) => e.startByteOffset <= t.pos && t.pos <= e.endByteOffset), a = n.at(0), o = n.at(-1);
|
|
1475
|
-
return !a || !o ? null :
|
|
1477
|
+
return !a || !o ? null : ne(t, a.timestamp / r, o.timestamp / r);
|
|
1476
1478
|
}) ?? [], [
|
|
1477
1479
|
r,
|
|
1478
1480
|
i,
|
|
@@ -1481,14 +1483,15 @@ var se = {
|
|
|
1481
1483
|
a?.map(({ startByteOffset: e, endByteOffset: t }) => `${e}/${t}`).join(",")
|
|
1482
1484
|
]);
|
|
1483
1485
|
S(() => {
|
|
1484
|
-
v !== void 0 && r && N && M.current && e.seek(v * r);
|
|
1486
|
+
v !== void 0 && r && N && M.current && (n ? n(v * r, !0) : e.seek(v * r));
|
|
1485
1487
|
}, [
|
|
1486
1488
|
e,
|
|
1489
|
+
n,
|
|
1487
1490
|
N,
|
|
1488
1491
|
v,
|
|
1489
1492
|
r
|
|
1490
1493
|
]);
|
|
1491
|
-
let
|
|
1494
|
+
let ie = C(() => {
|
|
1492
1495
|
if (!r) return 0;
|
|
1493
1496
|
if (N && v !== void 0) return v;
|
|
1494
1497
|
let e = f ?? t;
|
|
@@ -1499,22 +1502,22 @@ var se = {
|
|
|
1499
1502
|
N,
|
|
1500
1503
|
v,
|
|
1501
1504
|
f
|
|
1502
|
-
]),
|
|
1503
|
-
if (!
|
|
1504
|
-
let e = b / r * 100, t =
|
|
1505
|
-
return t >= 0 ? t :
|
|
1505
|
+
]), U = C(() => p(d, r), [d, r]), W = U.length > 0, G = C(() => {
|
|
1506
|
+
if (!W || b === void 0 || !r) return -1;
|
|
1507
|
+
let e = b / r * 100, t = U.findIndex((t, n) => n < U.length - 1 && e >= t && e < U[n + 1]);
|
|
1508
|
+
return t >= 0 ? t : U.length - 2;
|
|
1506
1509
|
}, [
|
|
1507
|
-
G,
|
|
1508
1510
|
W,
|
|
1511
|
+
U,
|
|
1509
1512
|
b,
|
|
1510
1513
|
r
|
|
1511
|
-
]),
|
|
1512
|
-
G,
|
|
1514
|
+
]), ae = C(() => W ? m(U, (e) => e !== G) : void 0, [
|
|
1513
1515
|
W,
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
+
U,
|
|
1517
|
+
G
|
|
1518
|
+
]), K = C(() => G >= 0 ? m(U, (e) => e === G) : void 0, [U, G]), q = C(() => {
|
|
1516
1519
|
if (b !== void 0) return d.find(({ start: e, end: t }) => e <= b && b < t);
|
|
1517
|
-
}, [d, b]),
|
|
1520
|
+
}, [d, b]), oe = C(() => {
|
|
1518
1521
|
if (b) {
|
|
1519
1522
|
if (l) return l(b);
|
|
1520
1523
|
if (c.length) return c.find(({ startTime: e, endTime: t }) => e <= b && b < t);
|
|
@@ -1523,20 +1526,20 @@ var se = {
|
|
|
1523
1526
|
c,
|
|
1524
1527
|
l,
|
|
1525
1528
|
b
|
|
1526
|
-
]),
|
|
1529
|
+
]), J = (e, t) => /* @__PURE__ */ L("div", {
|
|
1527
1530
|
className: e ? `track ${e}` : "track",
|
|
1528
1531
|
style: t ? { maskImage: t } : void 0,
|
|
1529
1532
|
children: [
|
|
1530
1533
|
/* @__PURE__ */ I("div", { className: "background-bar" }),
|
|
1531
1534
|
/* @__PURE__ */ I("div", {
|
|
1532
1535
|
className: "loaded",
|
|
1533
|
-
children:
|
|
1536
|
+
children: re
|
|
1534
1537
|
}),
|
|
1535
1538
|
/* @__PURE__ */ I("div", {
|
|
1536
1539
|
className: "play-container",
|
|
1537
1540
|
children: /* @__PURE__ */ I("div", {
|
|
1538
1541
|
className: "play",
|
|
1539
|
-
style: { transform: `scaleX(${
|
|
1542
|
+
style: { transform: `scaleX(${ie})` }
|
|
1540
1543
|
})
|
|
1541
1544
|
})
|
|
1542
1545
|
]
|
|
@@ -1547,31 +1550,31 @@ var se = {
|
|
|
1547
1550
|
className: [
|
|
1548
1551
|
"progress-bar",
|
|
1549
1552
|
N ? "dragging" : "",
|
|
1550
|
-
|
|
1553
|
+
W ? "segmented" : ""
|
|
1551
1554
|
].filter(Boolean).join(" "),
|
|
1552
1555
|
onPointerDown: V,
|
|
1553
1556
|
onPointerMove: V,
|
|
1554
1557
|
onMouseMove: H,
|
|
1555
1558
|
onMouseOut: ee,
|
|
1556
1559
|
children: [
|
|
1557
|
-
|
|
1560
|
+
J(void 0, ae),
|
|
1558
1561
|
b ? /* @__PURE__ */ L("div", {
|
|
1559
1562
|
className: "cursor-time",
|
|
1560
1563
|
style: {
|
|
1561
|
-
left:
|
|
1562
|
-
maxWidth:
|
|
1564
|
+
left: q ? `clamp(var(--thumbnail-half), ${te(b)}%, calc(100% - var(--thumbnail-half)))` : `clamp(calc(3 * var(--mp-unit)), ${te(b)}%, calc(100% - calc(3 * var(--mp-unit))))`,
|
|
1565
|
+
maxWidth: q ? "var(--thumbnail-width)" : void 0
|
|
1563
1566
|
},
|
|
1564
1567
|
children: [/* @__PURE__ */ I("span", {
|
|
1565
1568
|
className: "cursor-time-value",
|
|
1566
1569
|
children: _t(b)
|
|
1567
|
-
}),
|
|
1570
|
+
}), q ? /* @__PURE__ */ I("span", {
|
|
1568
1571
|
className: "chapter-title",
|
|
1569
|
-
children:
|
|
1572
|
+
children: q.title
|
|
1570
1573
|
}) : void 0]
|
|
1571
1574
|
}) : void 0,
|
|
1572
1575
|
/* @__PURE__ */ I("div", { className: "progress" }),
|
|
1573
1576
|
/* @__PURE__ */ I("div", { className: "hover" }),
|
|
1574
|
-
|
|
1577
|
+
K ? J("focus", K) : void 0,
|
|
1575
1578
|
/* @__PURE__ */ I("div", { className: "scrubber" }),
|
|
1576
1579
|
/* @__PURE__ */ I("div", {
|
|
1577
1580
|
className: "padding",
|
|
@@ -1582,8 +1585,8 @@ var se = {
|
|
|
1582
1585
|
}),
|
|
1583
1586
|
/* @__PURE__ */ I("div", {
|
|
1584
1587
|
className: "thumbnail",
|
|
1585
|
-
style: { left: `clamp(var(--thumbnail-half), ${
|
|
1586
|
-
children:
|
|
1588
|
+
style: { left: `clamp(var(--thumbnail-half), ${te(b ?? 1)}%, calc(100% - var(--thumbnail-half)))` },
|
|
1589
|
+
children: oe?.url ? /* @__PURE__ */ I("img", { src: oe.url }) : void 0
|
|
1587
1590
|
})
|
|
1588
1591
|
]
|
|
1589
1592
|
});
|
|
@@ -1939,7 +1942,7 @@ ${Nt}
|
|
|
1939
1942
|
onClick: i,
|
|
1940
1943
|
"aria-label": u,
|
|
1941
1944
|
"aria-expanded": r,
|
|
1942
|
-
children: /* @__PURE__ */ I(
|
|
1945
|
+
children: /* @__PURE__ */ I(ae, { className: "alert-triangle" })
|
|
1943
1946
|
}),
|
|
1944
1947
|
toolTipText: /* @__PURE__ */ I("span", { children: u })
|
|
1945
1948
|
}), r && /* @__PURE__ */ L("div", {
|
|
@@ -1951,7 +1954,7 @@ ${Nt}
|
|
|
1951
1954
|
type: "button",
|
|
1952
1955
|
onClick: l,
|
|
1953
1956
|
"aria-label": t(a.copyErrors),
|
|
1954
|
-
children: [I(s ? V :
|
|
1957
|
+
children: [I(s ? V : te, {}), /* @__PURE__ */ I("span", { children: t(s ? a.copied : a.copy) })]
|
|
1955
1958
|
})]
|
|
1956
1959
|
}), e.map((e, r) => /* @__PURE__ */ L("div", {
|
|
1957
1960
|
className: "entry no-hover",
|
|
@@ -2197,7 +2200,7 @@ ${Nt}
|
|
|
2197
2200
|
onClick: m,
|
|
2198
2201
|
"aria-label": t(a.settings),
|
|
2199
2202
|
"aria-expanded": p,
|
|
2200
|
-
children: /* @__PURE__ */ I(
|
|
2203
|
+
children: /* @__PURE__ */ I(G, {})
|
|
2201
2204
|
}),
|
|
2202
2205
|
toolTipText: /* @__PURE__ */ I("span", { children: t(a.settings) })
|
|
2203
2206
|
}),
|
|
@@ -2499,7 +2502,7 @@ ${Nt}
|
|
|
2499
2502
|
ref: e,
|
|
2500
2503
|
"aria-label": n(a.mute),
|
|
2501
2504
|
"aria-pressed": i || r === 0,
|
|
2502
|
-
children: I(i || r === 0 ?
|
|
2505
|
+
children: I(i || r === 0 ? oe : r <= .5 ? K : q, {
|
|
2503
2506
|
size: 18,
|
|
2504
2507
|
color: "#fff"
|
|
2505
2508
|
})
|
|
@@ -2754,7 +2757,7 @@ ${Nt}
|
|
|
2754
2757
|
type: "button",
|
|
2755
2758
|
onClick: () => r.togglePaused(),
|
|
2756
2759
|
"aria-label": i(j ? a.replay : o ? a.play : a.pause),
|
|
2757
|
-
children: I(j ?
|
|
2760
|
+
children: I(j ? W : o ? U : ie, {})
|
|
2758
2761
|
}),
|
|
2759
2762
|
toolTipText: /* @__PURE__ */ I("span", { children: i(j ? a.replayKey : o ? a.playKey : a.pauseKey) })
|
|
2760
2763
|
}),
|
|
@@ -2814,7 +2817,7 @@ ${Nt}
|
|
|
2814
2817
|
onClick: P,
|
|
2815
2818
|
"aria-label": i(a.fullScreen),
|
|
2816
2819
|
"aria-pressed": d,
|
|
2817
|
-
children: I(d ?
|
|
2820
|
+
children: I(d ? re : ne, {})
|
|
2818
2821
|
}),
|
|
2819
2822
|
toolTipText: /* @__PURE__ */ I("span", { children: i(d ? a.exitFullScreenKey : a.fullScreenKey) })
|
|
2820
2823
|
})
|
|
@@ -3182,7 +3185,7 @@ ${Nt}
|
|
|
3182
3185
|
}
|
|
3183
3186
|
})), B = D === !0 ? {} : D || void 0, V = w(B);
|
|
3184
3187
|
V.current = B;
|
|
3185
|
-
let H = B ? B.id : void 0, ee = B ? B.origin : void 0,
|
|
3188
|
+
let H = B ? B.id : void 0, ee = B ? B.origin : void 0, te = B ? B.channel : void 0;
|
|
3186
3189
|
S(() => {
|
|
3187
3190
|
if (!D || !E) return;
|
|
3188
3191
|
let e, t = !1;
|
|
@@ -3199,35 +3202,35 @@ ${Nt}
|
|
|
3199
3202
|
!!D,
|
|
3200
3203
|
H,
|
|
3201
3204
|
ee,
|
|
3202
|
-
|
|
3205
|
+
te
|
|
3203
3206
|
]);
|
|
3204
|
-
let
|
|
3207
|
+
let ne = X((e) => e.chapters), re = JSON.stringify(ne);
|
|
3205
3208
|
S(() => {
|
|
3206
|
-
z.chapters =
|
|
3207
|
-
}, [
|
|
3208
|
-
let
|
|
3209
|
+
z.chapters = ne, z.endingOffered = M, z.dispatchEvent(new Event("chapterschange"));
|
|
3210
|
+
}, [re, M]);
|
|
3211
|
+
let ie = e.autoplayNext;
|
|
3209
3212
|
S(() => {
|
|
3210
|
-
P === null && R(
|
|
3211
|
-
}, [
|
|
3212
|
-
let
|
|
3213
|
-
|
|
3213
|
+
P === null && R(ie);
|
|
3214
|
+
}, [ie, P]);
|
|
3215
|
+
let U = w(e.onAutoplayNextChange);
|
|
3216
|
+
U.current = e.onAutoplayNextChange, S(() => {
|
|
3214
3217
|
z.autoplayNext = L ?? null, z.dispatchEvent(new Event("autoplaynextchange"));
|
|
3215
3218
|
}, [L]);
|
|
3216
|
-
let
|
|
3219
|
+
let W = e.fullscreen ?? (O === null ? void 0 : {
|
|
3217
3220
|
active: O,
|
|
3218
3221
|
request: () => z.dispatchEvent(new Event("fullscreenrequest"))
|
|
3219
|
-
}),
|
|
3220
|
-
Ae(v, b, r, h ?
|
|
3221
|
-
let
|
|
3222
|
+
}), G = C(() => rt(), [o]);
|
|
3223
|
+
Ae(v, b, r, h ? G.push : void 0);
|
|
3224
|
+
let ae = r?.normalizeVolume ?? !0, [K, q] = T(ae);
|
|
3222
3225
|
S(() => {
|
|
3223
|
-
|
|
3224
|
-
}, [
|
|
3225
|
-
let
|
|
3226
|
-
|
|
3227
|
-
let
|
|
3226
|
+
q(ae);
|
|
3227
|
+
}, [ae]);
|
|
3228
|
+
let oe = w(r?.onNormalizeVolumeChange);
|
|
3229
|
+
oe.current = r?.onNormalizeVolumeChange;
|
|
3230
|
+
let J = r?.normalizerWorkletUrl, se = w(p ?? f);
|
|
3228
3231
|
se.current = p ?? f;
|
|
3229
|
-
let Y = X((e) => e.selectedAudioTrack), ce = !!f, { refused: le } = nt(v,
|
|
3230
|
-
tap:
|
|
3232
|
+
let Y = X((e) => e.selectedAudioTrack), ce = !!f, { refused: le } = nt(v, J, K, C(() => ce && o && c && l && typeof Y == "number" && Y >= 0 ? h ? {
|
|
3233
|
+
tap: G,
|
|
3231
3234
|
audioStreamIndex: Y
|
|
3232
3235
|
} : {
|
|
3233
3236
|
read: (e, t) => se.current(e, t),
|
|
@@ -3242,16 +3245,16 @@ ${Nt}
|
|
|
3242
3245
|
l,
|
|
3243
3246
|
Y,
|
|
3244
3247
|
h,
|
|
3245
|
-
|
|
3246
|
-
]), C(() => s?.map(({ startByteOffset: e, endByteOffset: t }) => [e, t]), [s?.map(({ startByteOffset: e, endByteOffset: t }) => `${e}-${t}`).join(",")])), ue = C(() =>
|
|
3247
|
-
enabled:
|
|
3248
|
+
G
|
|
3249
|
+
]), C(() => s?.map(({ startByteOffset: e, endByteOffset: t }) => [e, t]), [s?.map(({ startByteOffset: e, endByteOffset: t }) => `${e}-${t}`).join(",")])), ue = C(() => J && typeof AudioWorkletNode == "function" ? {
|
|
3250
|
+
enabled: K,
|
|
3248
3251
|
available: !le,
|
|
3249
3252
|
setEnabled: (e) => {
|
|
3250
|
-
|
|
3253
|
+
q(e), oe.current?.(e);
|
|
3251
3254
|
}
|
|
3252
3255
|
} : null, [
|
|
3253
|
-
|
|
3254
|
-
|
|
3256
|
+
J,
|
|
3257
|
+
K,
|
|
3255
3258
|
le
|
|
3256
3259
|
]), { thumbnails: de, requestThumbnail: fe } = ze({
|
|
3257
3260
|
publicPath: c,
|
|
@@ -3298,7 +3301,7 @@ ${Nt}
|
|
|
3298
3301
|
Z({ autoplayNext: L === void 0 ? null : {
|
|
3299
3302
|
enabled: L,
|
|
3300
3303
|
setEnabled: (e) => {
|
|
3301
|
-
R(e),
|
|
3304
|
+
R(e), U.current?.(e);
|
|
3302
3305
|
}
|
|
3303
3306
|
} });
|
|
3304
3307
|
}, [Z, L]), S(() => {
|
|
@@ -3356,7 +3359,7 @@ ${Nt}
|
|
|
3356
3359
|
overlay: e.overlay,
|
|
3357
3360
|
controls: e.controls,
|
|
3358
3361
|
shortcuts: e.shortcuts,
|
|
3359
|
-
fullscreen:
|
|
3362
|
+
fullscreen: W,
|
|
3360
3363
|
endingOffered: M,
|
|
3361
3364
|
children: t
|
|
3362
3365
|
});
|
package/dist/react/player.d.ts
CHANGED
|
@@ -25,7 +25,7 @@ export declare const Player: import("@videojs/react").CreatePlayerResult<import(
|
|
|
25
25
|
burnedInSubtitles: boolean;
|
|
26
26
|
volumeNormalizer: import("./source-feature").VolumeNormalizerControl | null;
|
|
27
27
|
autoplayNext: import("./source-feature").AutoplayNextControl | null;
|
|
28
|
-
requestSeek?: (time: number) => void;
|
|
28
|
+
requestSeek?: (time: number, now?: boolean) => void;
|
|
29
29
|
stepFrame?: (direction: 1 | -1) => void;
|
|
30
30
|
playbackError: unknown;
|
|
31
31
|
playbackErrors: import("./source-feature").PlaybackErrorEntry[];
|
|
@@ -221,10 +221,13 @@ export type SourceState = {
|
|
|
221
221
|
* Waiting is bounded by a deadline, so a source that cannot answer in time costs that deadline and
|
|
222
222
|
* not the whole read.
|
|
223
223
|
*
|
|
224
|
+
* `now` moves at once without waiting, as a scrub following the pointer does. Any call replaces a seek still
|
|
225
|
+
* waiting for its data.
|
|
226
|
+
*
|
|
224
227
|
* Undefined for a media this player does not own, where there is no pipeline to prepare and the
|
|
225
228
|
* caller should seek directly.
|
|
226
229
|
*/
|
|
227
|
-
requestSeek?: (time: number) => void;
|
|
230
|
+
requestSeek?: (time: number, now?: boolean) => void;
|
|
228
231
|
/**
|
|
229
232
|
* One frame back or forward, pausing first. Undefined for a media whose frames this document cannot see, unless its
|
|
230
233
|
* host steps it (the remote arm's `stepFrame`).
|
|
@@ -375,10 +378,13 @@ export declare const sourceFeature: import("@videojs/react").PlayerFeature<{
|
|
|
375
378
|
* Waiting is bounded by a deadline, so a source that cannot answer in time costs that deadline and
|
|
376
379
|
* not the whole read.
|
|
377
380
|
*
|
|
381
|
+
* `now` moves at once without waiting, as a scrub following the pointer does. Any call replaces a seek still
|
|
382
|
+
* waiting for its data.
|
|
383
|
+
*
|
|
378
384
|
* Undefined for a media this player does not own, where there is no pipeline to prepare and the
|
|
379
385
|
* caller should seek directly.
|
|
380
386
|
*/
|
|
381
|
-
requestSeek?: (time: number) => void;
|
|
387
|
+
requestSeek?: (time: number, now?: boolean) => void;
|
|
382
388
|
/**
|
|
383
389
|
* One frame back or forward, pausing first. Undefined for a media whose frames this document cannot see, unless its
|
|
384
390
|
* host steps it (the remote arm's `stepFrame`).
|
package/package.json
CHANGED
|
@@ -425,8 +425,9 @@ export const ProgressBar = () => {
|
|
|
425
425
|
useEffect(() => {
|
|
426
426
|
if (seekFraction === undefined || !duration) return
|
|
427
427
|
if (!dragging || !isScrub.current) return
|
|
428
|
-
|
|
429
|
-
|
|
428
|
+
if (requestSeek) requestSeek(seekFraction * duration, true)
|
|
429
|
+
else player.seek(seekFraction * duration)
|
|
430
|
+
}, [player, requestSeek, dragging, seekFraction, duration])
|
|
430
431
|
|
|
431
432
|
/*
|
|
432
433
|
* Where the bar is drawn, which is not always where the element is.
|
|
@@ -198,11 +198,11 @@ export const usePlayback = (
|
|
|
198
198
|
}, [player, playingAudio])
|
|
199
199
|
|
|
200
200
|
/*
|
|
201
|
-
* Counts the seeks asked for, so a seek that a newer one replaced never moves the playhead
|
|
201
|
+
* Counts the seeks asked for, so a seek that a newer one replaced never moves the playhead, nor clears `seekingTo`.
|
|
202
202
|
*
|
|
203
|
-
* A newer remuxer task (the newer seek's prepare, or the engine seek its move starts) aborts the older
|
|
204
|
-
* prepare, which then resolves as if its data were in. Firefox 153 landed on the older seek; Chrome 156 moved
|
|
205
|
-
* first, into ground with no data (2026-11-21).
|
|
203
|
+
* A newer remuxer task (the newer seek's prepare, or the engine seek its move or a scrub starts) aborts the older
|
|
204
|
+
* seek's prepare, which then resolves as if its data were in. Firefox 153 landed on the older seek; Chrome 156 moved
|
|
205
|
+
* to it first, into ground with no data (2026-11-21).
|
|
206
206
|
*/
|
|
207
207
|
const seeks = useRef(0)
|
|
208
208
|
|
|
@@ -215,17 +215,21 @@ export const usePlayback = (
|
|
|
215
215
|
* is worse than the fault it avoids. So the playhead moves either when the data lands or when the
|
|
216
216
|
* budget runs out, once, whichever happens first.
|
|
217
217
|
*
|
|
218
|
-
* A seek into buffered ground resolves immediately,
|
|
218
|
+
* A seek into buffered ground resolves immediately, and a scrub (`now`) never waits.
|
|
219
219
|
*/
|
|
220
|
-
const requestSeek = useCallback((time: number) => {
|
|
220
|
+
const requestSeek = useCallback((time: number, now = false) => {
|
|
221
221
|
const seek = ++seeks.current
|
|
222
222
|
const controller = controllerRef.current
|
|
223
223
|
// no budget means the feature is off: seek at once and do not spend a read preparing something
|
|
224
|
-
// nobody is going to wait for
|
|
225
|
-
if (!controller || seekPrepareBudgetMs <= 0
|
|
224
|
+
// nobody is going to wait for. A seek that moves at once leaves none on its way.
|
|
225
|
+
if (!controller || seekPrepareBudgetMs <= 0 || now) {
|
|
226
|
+
player.setSourceState({ seekingTo: undefined })
|
|
227
|
+
player.seek(time)
|
|
228
|
+
return
|
|
229
|
+
}
|
|
226
230
|
|
|
227
231
|
/*
|
|
228
|
-
* Every
|
|
232
|
+
* Every settled seek gets the data first. There is deliberately no "this looks like a drag" shortcut.
|
|
229
233
|
*
|
|
230
234
|
* The first version of this guessed at drags from the gap between calls, and that is what let
|
|
231
235
|
* the fault through in production: the seek bar reports a change on the PRESS and again on every
|
|
@@ -233,9 +237,9 @@ export const usePlayback = (
|
|
|
233
237
|
* read as a drag, and the playhead jumped onto unbuffered ground before its data existed. Two
|
|
234
238
|
* quick taps of the arrow keys would have done the same.
|
|
235
239
|
*
|
|
236
|
-
* The chrome knows what gesture it is in and
|
|
237
|
-
* which is knowledge rather than inference. Rapid calls are safe here anyway: each
|
|
238
|
-
* the last through `seeks`.
|
|
240
|
+
* The chrome knows what gesture it is in and says so: a scrub passes `now`, and only a settled
|
|
241
|
+
* seek waits, which is knowledge rather than inference. Rapid calls are safe here anyway: each
|
|
242
|
+
* replaces the last through `seeks`.
|
|
239
243
|
*/
|
|
240
244
|
/*
|
|
241
245
|
* A debug trace, off unless asked for.
|
|
@@ -284,13 +288,16 @@ export const usePlayback = (
|
|
|
284
288
|
player.setSourceState({ seekingTo: time })
|
|
285
289
|
const video = controller.videoElement
|
|
286
290
|
const settled = () => {
|
|
287
|
-
video?.removeEventListener('seeked',
|
|
291
|
+
video?.removeEventListener('seeked', onSeeked)
|
|
288
292
|
clearTimeout(giveUp)
|
|
289
|
-
player.setSourceState({ seekingTo: undefined })
|
|
293
|
+
if (seeks.current === seek) player.setSourceState({ seekingTo: undefined })
|
|
290
294
|
}
|
|
295
|
+
// Before this seek has moved, a seeked is an earlier seek landing (Firefox 153, 2026-11-21). A pipeline going away
|
|
296
|
+
// ends the prepare, so a rebuild's resume at this seek comes after the move.
|
|
297
|
+
const onSeeked = () => { if (moved) settled() }
|
|
291
298
|
// a seek the element never completes must not leave the clock stuck on a time it never reached
|
|
292
299
|
const giveUp = setTimeout(settled, SEEK_DISPLAY_LIMIT_MS)
|
|
293
|
-
video?.addEventListener('seeked',
|
|
300
|
+
video?.addEventListener('seeked', onSeeked)
|
|
294
301
|
|
|
295
302
|
const deadline = setTimeout(() => { movedBecause = 'deadline'; move() }, seekPrepareBudgetMs)
|
|
296
303
|
void controller
|
|
@@ -242,10 +242,13 @@ export type SourceState = {
|
|
|
242
242
|
* Waiting is bounded by a deadline, so a source that cannot answer in time costs that deadline and
|
|
243
243
|
* not the whole read.
|
|
244
244
|
*
|
|
245
|
+
* `now` moves at once without waiting, as a scrub following the pointer does. Any call replaces a seek still
|
|
246
|
+
* waiting for its data.
|
|
247
|
+
*
|
|
245
248
|
* Undefined for a media this player does not own, where there is no pipeline to prepare and the
|
|
246
249
|
* caller should seek directly.
|
|
247
250
|
*/
|
|
248
|
-
requestSeek?: (time: number) => void
|
|
251
|
+
requestSeek?: (time: number, now?: boolean) => void
|
|
249
252
|
|
|
250
253
|
/**
|
|
251
254
|
* One frame back or forward, pausing first. Undefined for a media whose frames this document cannot see, unless its
|