@banou/media-player 0.10.13 → 0.10.14

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
@@ -2123,15 +2123,6 @@ ${gt}
2123
2123
  })]
2124
2124
  });
2125
2125
  }, It = .05, Lt = 5, Rt = 50, zt = 1e3, Bt = g`
2126
- display: flex;
2127
- flex-direction: column;
2128
- gap: calc(0.4 * var(--mp-unit));
2129
-
2130
- .hint {
2131
- opacity: 0.72;
2132
- font-size: 0.9em;
2133
- }
2134
- `, Vt = g`
2135
2126
  position: absolute;
2136
2127
  bottom: 0;
2137
2128
  width: 100%;
@@ -2261,7 +2252,7 @@ ${gt}
2261
2252
  }
2262
2253
  }
2263
2254
  }
2264
- `, Ht = () => {
2255
+ `, Vt = () => {
2265
2256
  let e = G(), t = G((e) => e.paused), n = G((e) => e.currentTime), r = G((e) => e.duration), i = G((e) => e.seekingTo), a = G((e) => e.fullscreen), o = G((e) => e.hideUI), s = G((e) => e.togglePictureInPicture), c = G((e) => e.pictureInPictureMode), l = G((e) => e.burnedInSubtitles), f = G((e) => e.passThroughPictureInPicture), h = G((e) => e.subtitleTracks), g = G((e) => e.requestSeek), [_, v] = m(null), y = p(null), b = p(void 0), x = c === "burn-in", S = h.length > 0, C = r > 0 && n === r, w = u(({ direction: t, stepSize: n }) => {
2266
2257
  let r = Ne(e.volume), i = t === "up" ? n : -n, a = Math.max(0, Math.min(1, r + i)), o = e.muted;
2267
2258
  e.setVolume(Me(a)), o && !e.muted && e.toggleMuted();
@@ -2332,7 +2323,7 @@ ${gt}
2332
2323
  e = Date.now() + zt;
2333
2324
  };
2334
2325
  }, [k]), d(() => () => clearInterval(b.current), []), /* @__PURE__ */ E("div", {
2335
- css: Vt,
2326
+ css: Bt,
2336
2327
  style: { ...o ? {
2337
2328
  opacity: "0",
2338
2329
  pointerEvents: "none"
@@ -2399,16 +2390,7 @@ ${gt}
2399
2390
  alt: ""
2400
2391
  })
2401
2392
  }),
2402
- toolTipText: /* @__PURE__ */ E("span", {
2403
- css: Bt,
2404
- children: [/* @__PURE__ */ T("span", {
2405
- className: "lead",
2406
- children: x ? S ? l ? "Subtitles are in the picture" : "Put the subtitles in the picture" : "This file has no subtitles" : "Picture in picture"
2407
- }), x && S ? /* @__PURE__ */ T("span", {
2408
- className: "hint",
2409
- children: "Then hover the video and click your browser's own pop out button"
2410
- }) : null]
2411
- })
2393
+ toolTipText: /* @__PURE__ */ T("span", { children: x ? S ? l ? "Subtitles are in the picture" : "Put the subtitles in the picture" : "This file has no subtitles" : "Picture in picture" })
2412
2394
  }) : null,
2413
2395
  /* @__PURE__ */ T($, {
2414
2396
  id: "full-screen",
@@ -2427,7 +2409,7 @@ ${gt}
2427
2409
  })]
2428
2410
  })]
2429
2411
  });
2430
- }, Ut = 9e3, Wt = g`
2412
+ }, Ht = 9e3, Ut = g`
2431
2413
  position: absolute;
2432
2414
  inset: 0;
2433
2415
  z-index: 2;
@@ -2458,22 +2440,11 @@ ${gt}
2458
2440
  opacity: 1;
2459
2441
  }
2460
2442
 
2461
- .words {
2462
- display: flex;
2463
- flex-direction: column;
2464
- gap: calc(0.3 * var(--mp-unit));
2465
- }
2466
-
2467
- .title {
2468
- ${Z.bMedium.bold}
2443
+ .text {
2444
+ ${Z.bMedium.medium}
2469
2445
  color: #fff;
2470
2446
  }
2471
2447
 
2472
- .body {
2473
- ${Z.bSmall.regular}
2474
- color: rgba(255, 255, 255, 0.75);
2475
- }
2476
-
2477
2448
  /* Points at the edge the browser's control lives on, which is the whole message. */
2478
2449
  .arrow {
2479
2450
  flex: none;
@@ -2481,7 +2452,7 @@ ${gt}
2481
2452
  line-height: 1;
2482
2453
  color: #fff;
2483
2454
  }
2484
- `, Gt = () => {
2455
+ `, Wt = () => {
2485
2456
  let e = G((e) => e.burnedInSubtitles), t = G((e) => e.pictureInPictureMode), [n, r] = m(!1);
2486
2457
  return d(() => {
2487
2458
  if (t !== "burn-in" || !e) {
@@ -2489,23 +2460,17 @@ ${gt}
2489
2460
  return;
2490
2461
  }
2491
2462
  r(!0);
2492
- let n = setTimeout(() => r(!1), Ut);
2463
+ let n = setTimeout(() => r(!1), Ht);
2493
2464
  return () => clearTimeout(n);
2494
2465
  }, [t, e]), t !== "burn-in" || !e ? null : /* @__PURE__ */ T("div", {
2495
- css: Wt,
2466
+ css: Ut,
2496
2467
  className: n ? "show" : "",
2497
2468
  role: "status",
2498
2469
  children: /* @__PURE__ */ E("div", {
2499
2470
  className: "card",
2500
- children: [/* @__PURE__ */ E("div", {
2501
- className: "words",
2502
- children: [/* @__PURE__ */ T("div", {
2503
- className: "title",
2504
- children: "Subtitles are in the picture"
2505
- }), /* @__PURE__ */ T("div", {
2506
- className: "body",
2507
- children: "Now hover the video and click your browser's own pop out button"
2508
- })]
2471
+ children: [/* @__PURE__ */ T("div", {
2472
+ className: "text",
2473
+ children: "Now click your browser's pop out button"
2509
2474
  }), /* @__PURE__ */ T("div", {
2510
2475
  className: "arrow",
2511
2476
  "aria-hidden": "true",
@@ -2513,10 +2478,10 @@ ${gt}
2513
2478
  })]
2514
2479
  })
2515
2480
  });
2516
- }, Kt = 1, qt = 6e3, Jt = 1, Yt = {
2481
+ }, Gt = 1, Kt = 6e3, qt = 1, Jt = {
2517
2482
  opening: "Skip Opening",
2518
2483
  ending: "Skip Ending"
2519
- }, Xt = g`
2484
+ }, Yt = g`
2520
2485
  position: absolute;
2521
2486
  inset: 0;
2522
2487
  z-index: 2;
@@ -2567,10 +2532,10 @@ ${gt}
2567
2532
  bottom: calc(9 * var(--mp-unit));
2568
2533
  }
2569
2534
  }
2570
- `, Zt = () => {
2535
+ `, Xt = () => {
2571
2536
  let e = G((e) => e.chapters), t = G((e) => e.currentTime), n = G((e) => e.requestSeek), r = G((e) => e.seekPreview), i = G(), a = f(() => ct(e), [e]), o = f(() => {
2572
2537
  if (typeof t != "number") return;
2573
- let n = e.findIndex((e, n) => a[n] !== void 0 && e.start - Kt <= t && t < e.end), r = n >= 0 ? a[n] : void 0;
2538
+ let n = e.findIndex((e, n) => a[n] !== void 0 && e.start - Gt <= t && t < e.end), r = n >= 0 ? a[n] : void 0;
2574
2539
  return r ? {
2575
2540
  kind: r,
2576
2541
  end: e[n].end
@@ -2582,7 +2547,7 @@ ${gt}
2582
2547
  ]), s = p(0), [c, l] = m(0);
2583
2548
  d(() => {
2584
2549
  let e = typeof t == "number" ? t : 0, n = s.current;
2585
- s.current = e, e < n - Jt && l((e) => e + 1);
2550
+ s.current = e, e < n - qt && l((e) => e + 1);
2586
2551
  }, [t]);
2587
2552
  let [u, h] = m(!1), g = o ? `${o.kind}@${o.end}` : "";
2588
2553
  return d(() => {
@@ -2591,12 +2556,12 @@ ${gt}
2591
2556
  return;
2592
2557
  }
2593
2558
  h(!0);
2594
- let e = setTimeout(() => h(!1), qt);
2559
+ let e = setTimeout(() => h(!1), Kt);
2595
2560
  return () => clearTimeout(e);
2596
2561
  }, [g, c]), d(() => {
2597
2562
  o || h(!1);
2598
2563
  }, [o]), o ? /* @__PURE__ */ T("div", {
2599
- css: Xt,
2564
+ css: Yt,
2600
2565
  className: u && !r ? "show" : "",
2601
2566
  children: /* @__PURE__ */ T("button", {
2602
2567
  type: "button",
@@ -2604,10 +2569,10 @@ ${gt}
2604
2569
  onClick: () => {
2605
2570
  h(!1), n ? n(o.end) : i.seek(o.end);
2606
2571
  },
2607
- children: Yt[o.kind]
2572
+ children: Jt[o.kind]
2608
2573
  })
2609
2574
  }) : null;
2610
- }, Qt = 3e3, $t = g`
2575
+ }, Zt = 3e3, Qt = g`
2611
2576
  position: absolute;
2612
2577
  inset: 0;
2613
2578
  z-index: 2;
@@ -2618,10 +2583,10 @@ ${gt}
2618
2583
  hoverable while faded out, popping a tooltip over nothing. It cascades where pointer-events does
2619
2584
  not, and transitioning it holds the item on screen for the length of the fade. */
2620
2585
  transition: opacity 0.1s cubic-bezier(.4,0,1,1), visibility 0.1s;
2621
- `, en = (e, t) => {
2586
+ `, $t = (e, t) => {
2622
2587
  let n = e.left - t.left, r = e.top - t.top;
2623
2588
  return `path(evenodd, 'M0 0H${t.width}V${t.height}H0Z M${n} ${r}H${n + e.width}V${r + e.height}H${n}Z')`;
2624
- }, tn = g`
2589
+ }, en = g`
2625
2590
  position: relative;
2626
2591
  background-color: black;
2627
2592
  display: flex;
@@ -2675,13 +2640,13 @@ ${gt}
2675
2640
  &.hide {
2676
2641
  cursor: none;
2677
2642
  }
2678
- `, nn = (e, t = "") => s.toArray(e).flatMap((e, n) => {
2643
+ `, tn = (e, t = "") => s.toArray(e).flatMap((e, n) => {
2679
2644
  let r = `${t}${l(e) && e.key != null ? e.key : n}`;
2680
- return l(e) && e.type === c ? nn(e.props.children, `${r}/`) : [{
2645
+ return l(e) && e.type === c ? tn(e.props.children, `${r}/`) : [{
2681
2646
  key: r,
2682
2647
  item: e
2683
2648
  }];
2684
- }), rn = ({ ref: e, onVideoRef: t, onSubtitleRef: n, overlay: r, controls: i, children: a }) => {
2649
+ }), nn = ({ ref: e, onVideoRef: t, onSubtitleRef: n, overlay: r, controls: i, children: a }) => {
2685
2650
  let o = G(), s = G((e) => e.hideUI), c = G((e) => e.setHideUI), l = G((e) => e.hasMedia), u = G((e) => e.passThroughPictureInPicture), f = p(void 0), m = p("mouse"), h = p({
2686
2651
  x: -1,
2687
2652
  y: -1
@@ -2702,15 +2667,15 @@ ${gt}
2702
2667
  return !!n && g.current.contains(n) && !n.closest(".video");
2703
2668
  }, b = () => {
2704
2669
  if (y()) {
2705
- f.current = setTimeout(b, Qt);
2670
+ f.current = setTimeout(b, Zt);
2706
2671
  return;
2707
2672
  }
2708
2673
  _();
2709
2674
  }, x = () => {
2710
- c(!1), clearTimeout(f.current), f.current = setTimeout(b, Qt);
2675
+ c(!1), clearTimeout(f.current), f.current = setTimeout(b, Zt);
2711
2676
  };
2712
2677
  return /* @__PURE__ */ E("div", {
2713
- css: tn,
2678
+ css: en,
2714
2679
  ref: v,
2715
2680
  onPointerMove: (e) => {
2716
2681
  m.current = e.pointerType, e.pointerType === "mouse" && (h.current = {
@@ -2730,8 +2695,8 @@ ${gt}
2730
2695
  className: s ? "hide" : "",
2731
2696
  children: [
2732
2697
  /* @__PURE__ */ T(ke, { onSubtitleRef: n }),
2733
- nn(r).map(({ key: e, item: t }) => /* @__PURE__ */ T("div", {
2734
- css: $t,
2698
+ tn(r).map(({ key: e, item: t }) => /* @__PURE__ */ T("div", {
2699
+ css: Qt,
2735
2700
  style: { ...s ? {
2736
2701
  opacity: "0",
2737
2702
  visibility: "hidden",
@@ -2739,12 +2704,12 @@ ${gt}
2739
2704
  } : {} },
2740
2705
  children: t
2741
2706
  }, e)),
2742
- i === !1 ? null : /* @__PURE__ */ T(Ht, {}),
2743
- /* @__PURE__ */ T(Gt, {}),
2744
- /* @__PURE__ */ T(Zt, {}),
2707
+ i === !1 ? null : /* @__PURE__ */ T(Vt, {}),
2708
+ /* @__PURE__ */ T(Wt, {}),
2709
+ /* @__PURE__ */ T(Xt, {}),
2745
2710
  u?.armed && g.current ? /* @__PURE__ */ T("div", {
2746
2711
  className: "pass-through",
2747
- style: { clipPath: en(u.armed, g.current.getBoundingClientRect()) },
2712
+ style: { clipPath: $t(u.armed, g.current.getBoundingClientRect()) },
2748
2713
  onPointerOver: u.disarm
2749
2714
  }) : null,
2750
2715
  /* @__PURE__ */ E("div", {
@@ -2763,7 +2728,7 @@ ${gt}
2763
2728
  })
2764
2729
  ]
2765
2730
  });
2766
- }, an = ({ options: e, children: t }) => {
2731
+ }, rn = ({ options: e, children: t }) => {
2767
2732
  let n = "media" in e ? e : null, r = n ? null : e, { title: i, chapters: a } = e, { size: o, downloadedRanges: s, publicPath: c, libavWorkerUrl: l, read: u, thumbnailRead: h, thumbnailsEnabled: g } = r ?? {}, _ = b(), v = y(), [x, S] = m(null), [C, w] = m(null), E = n?.media ?? x;
2768
2733
  d(() => (_?.(E), () => _?.(null)), [E, _]);
2769
2734
  let { expose: D } = e, O = D === !0 ? {} : D || void 0, k = p(O);
@@ -2868,7 +2833,7 @@ ${gt}
2868
2833
  });
2869
2834
  }, [K, X]), d(() => {
2870
2835
  a && K({ chapters: a });
2871
- }, [K, a]), /* @__PURE__ */ T(rn, {
2836
+ }, [K, a]), /* @__PURE__ */ T(nn, {
2872
2837
  ref: v,
2873
2838
  onVideoRef: n ? void 0 : S,
2874
2839
  onSubtitleRef: w,
@@ -2876,7 +2841,7 @@ ${gt}
2876
2841
  controls: e.controls,
2877
2842
  children: t
2878
2843
  });
2879
- }, on = g`
2844
+ }, an = g`
2880
2845
  /**
2881
2846
  * The chrome's whole scale, in one place.
2882
2847
  *
@@ -2946,17 +2911,17 @@ ${gt}
2946
2911
  height: 100%;
2947
2912
  width: 100%;
2948
2913
  overflow: hidden;
2949
- `, sn = (e) => /* @__PURE__ */ T("div", {
2950
- css: on,
2951
- children: /* @__PURE__ */ T(W.Provider, { children: /* @__PURE__ */ T(an, {
2914
+ `, on = (e) => /* @__PURE__ */ T("div", {
2915
+ css: an,
2916
+ children: /* @__PURE__ */ T(W.Provider, { children: /* @__PURE__ */ T(rn, {
2952
2917
  options: e,
2953
2918
  children: e.children
2954
2919
  }) })
2955
- }), cn = (e) => !!e && typeof e == "object" && "at" in e, ln = (e) => !!e && typeof e == "object" && "selection" in e, un = ({ blob: e, name: t }) => ({
2920
+ }), sn = (e) => !!e && typeof e == "object" && "at" in e, cn = (e) => !!e && typeof e == "object" && "selection" in e, ln = ({ blob: e, name: t }) => ({
2956
2921
  length: e.size,
2957
2922
  name: t ?? (e instanceof File ? e.name : void 0),
2958
2923
  read: (t, n) => e.slice(t, t + n).arrayBuffer()
2959
- }), dn = async (e, t) => {
2924
+ }), un = async (e, t) => {
2960
2925
  let n = await fetch(e, {
2961
2926
  headers: { Range: "bytes=0-1" },
2962
2927
  credentials: t
@@ -2966,8 +2931,8 @@ ${gt}
2966
2931
  if (!Number.isFinite(i) || i <= 0) throw Error("The source did not report its length");
2967
2932
  if (!r && n.status !== 206) throw Error("The source does not support range requests");
2968
2933
  return i;
2969
- }, fn = async ({ url: e, length: t, name: n, credentials: r }) => {
2970
- let i = t ?? await dn(e, r);
2934
+ }, dn = async ({ url: e, length: t, name: n, credentials: r }) => {
2935
+ let i = t ?? await un(e, r);
2971
2936
  return {
2972
2937
  length: i,
2973
2938
  name: n,
@@ -2982,9 +2947,9 @@ ${gt}
2982
2947
  return o.arrayBuffer();
2983
2948
  }
2984
2949
  };
2985
- }, pn = async (e) => {
2986
- if ("blob" in e) return un(e);
2987
- if ("url" in e) return fn(e);
2950
+ }, fn = async (e) => {
2951
+ if ("blob" in e) return ln(e);
2952
+ if ("url" in e) return dn(e);
2988
2953
  if ("read" in e) return {
2989
2954
  length: e.length,
2990
2955
  name: e.name,
@@ -2993,4 +2958,4 @@ ${gt}
2993
2958
  throw Error(`Unknown source type: ${e}`);
2994
2959
  };
2995
2960
  //#endregion
2996
- export { sn as MediaPlayer, sn as default, W as Player, e as SUBTITLES_OFF, a as createPictureInPicture, o as createSubtitleRenderer, r as createThumbnailGenerator, pn as inputToRemuxerInput, ln as isDelegatedTracks, cn as isExternalThumbnails, U as sourceFeature, i as startPlayback, de as usePictureInPicture, G as usePlayer, ue as useSeekThumbnails };
2961
+ export { on as MediaPlayer, on as default, W as Player, e as SUBTITLES_OFF, a as createPictureInPicture, o as createSubtitleRenderer, r as createThumbnailGenerator, fn as inputToRemuxerInput, cn as isDelegatedTracks, sn as isExternalThumbnails, U as sourceFeature, i as startPlayback, de as usePictureInPicture, G as usePlayer, ue as useSeekThumbnails };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@banou/media-player",
3
- "version": "0.10.13",
3
+ "version": "0.10.14",
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",
@@ -4,7 +4,6 @@ import { css } from '@emotion/react'
4
4
  import { fonts } from '../../utils/fonts'
5
5
  import { usePlayer } from '../player'
6
6
 
7
- /** Long enough to read twice, short enough not to sit over the picture. */
8
7
  const VISIBLE_MS = 9000
9
8
 
10
9
  const style = css`
@@ -38,22 +37,11 @@ const style = css`
38
37
  opacity: 1;
39
38
  }
40
39
 
41
- .words {
42
- display: flex;
43
- flex-direction: column;
44
- gap: calc(0.3 * var(--mp-unit));
45
- }
46
-
47
- .title {
48
- ${fonts.bMedium.bold}
40
+ .text {
41
+ ${fonts.bMedium.medium}
49
42
  color: #fff;
50
43
  }
51
44
 
52
- .body {
53
- ${fonts.bSmall.regular}
54
- color: rgba(255, 255, 255, 0.75);
55
- }
56
-
57
45
  /* Points at the edge the browser's control lives on, which is the whole message. */
58
46
  .arrow {
59
47
  flex: none;
@@ -90,12 +78,7 @@ export const BurnInHint = () => {
90
78
  return (
91
79
  <div css={style} className={show ? 'show' : ''} role='status'>
92
80
  <div className='card'>
93
- <div className='words'>
94
- <div className='title'>Subtitles are in the picture</div>
95
- <div className='body'>
96
- Now hover the video and click your browser&apos;s own pop out button
97
- </div>
98
- </div>
81
+ <div className='text'>Now click your browser&apos;s pop out button</div>
99
82
  <div className='arrow' aria-hidden='true'>&rarr;</div>
100
83
  </div>
101
84
  </div>
@@ -25,23 +25,6 @@ const SEEK_STEP = 5
25
25
  const REFOCUS_POLL = 50
26
26
  const REFOCUS_AFTER = 1_000
27
27
 
28
- /**
29
- * Two stacked lines inside a tooltip.
30
- *
31
- * The width to wrap against is no longer here: TooltipDisplay bounds every chip it draws, at the
32
- * same 26 units this had imposed by hand, so a call site only says what its content is.
33
- */
34
- const tooltipLinesStyle = css`
35
- display: flex;
36
- flex-direction: column;
37
- gap: calc(0.4 * var(--mp-unit));
38
-
39
- .hint {
40
- opacity: 0.72;
41
- font-size: 0.9em;
42
- }
43
- `
44
-
45
28
  const style = css`
46
29
  position: absolute;
47
30
  bottom: 0;
@@ -384,7 +367,6 @@ export const ControlBar = () => {
384
367
  ? (
385
368
  <TooltipDisplay
386
369
  id='picture-in-picture'
387
- // anchored to its end, or the two-line burn-in copy runs off the right of the player
388
370
  tooltipPlace='top-end'
389
371
  text={
390
372
  <button
@@ -409,26 +391,14 @@ export const ControlBar = () => {
409
391
  </button>
410
392
  }
411
393
  toolTipText={
412
- // The chip is drawn in its own subtree, where the control bar's rules never
413
- // reach it: a bare `small` stays inline and runs straight on from the line above
414
- // it. Both lines carry their layout themselves.
415
- <span css={tooltipLinesStyle}>
416
- <span className='lead'>
417
- {!burnIn
418
- ? 'Picture in picture'
419
- : !hasSubtitles
420
- ? 'This file has no subtitles'
421
- : burnedInSubtitles
422
- ? 'Subtitles are in the picture'
423
- : 'Put the subtitles in the picture'}
424
- </span>
425
- {burnIn && hasSubtitles
426
- ? (
427
- <span className='hint'>
428
- Then hover the video and click your browser&apos;s own pop out button
429
- </span>
430
- )
431
- : null}
394
+ <span>
395
+ {!burnIn
396
+ ? 'Picture in picture'
397
+ : !hasSubtitles
398
+ ? 'This file has no subtitles'
399
+ : burnedInSubtitles
400
+ ? 'Subtitles are in the picture'
401
+ : 'Put the subtitles in the picture'}
432
402
  </span>
433
403
  }
434
404
  />