@banou/media-player 0.10.45 → 0.10.46

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
@@ -2678,10 +2678,12 @@ ${Nt}
2678
2678
  direction: "down",
2679
2679
  stepSize: en
2680
2680
  });
2681
- else if (a.key === "ArrowRight") {
2682
- if (!r.duration) return;
2683
- n(Math.min(r.currentTime + tn, r.duration));
2684
- } else a.key === "ArrowLeft" ? n(Math.max(r.currentTime - tn, 0)) : (a.key === "<" || a.key === ">") && x ? x(a.key === ">" ? 1 : -1) : l = !1;
2681
+ else if (a.key === "ArrowRight" || a.key === "ArrowLeft") {
2682
+ let e = r.target?.media, t = a.key === "ArrowRight";
2683
+ if (!e?.readyState || t && !r.duration) return;
2684
+ let i = r.state.seekingTo ?? e.currentTime;
2685
+ n(t ? Math.min(i + tn, r.duration) : Math.max(i - tn, 0));
2686
+ } else (a.key === "<" || a.key === ">") && x ? x(a.key === ">" ? 1 : -1) : l = !1;
2685
2687
  l && a.preventDefault();
2686
2688
  };
2687
2689
  return window.addEventListener("keydown", o), window.addEventListener("pointerdown", a, !0), window.addEventListener("focusin", a, !0), () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@banou/media-player",
3
- "version": "0.10.45",
3
+ "version": "0.10.46",
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",
@@ -1,5 +1,6 @@
1
1
  /// <reference types="@emotion/react/types/css-prop" />
2
2
  import type { RefObject } from 'react'
3
+ import type { PlayerMedia } from '../media'
3
4
  import type { HostFullscreen } from '../video-player'
4
5
 
5
6
  import { useCallback, useEffect, useRef, useState } from 'react'
@@ -252,12 +253,17 @@ export const ControlBar = (
252
253
  else if (ev.key === 'ArrowDown') {
253
254
  modifyVolume({ direction: 'down', stepSize: VOLUME_STEP })
254
255
  }
255
- else if (ev.key === 'ArrowRight') {
256
- if (!player.duration) return
257
- seek(Math.min(player.currentTime + SEEK_STEP, player.duration))
258
- }
259
- else if (ev.key === 'ArrowLeft') {
260
- seek(Math.max(player.currentTime - SEEK_STEP, 0))
256
+ else if (ev.key === 'ArrowRight' || ev.key === 'ArrowLeft') {
257
+ const media = player.target?.media as PlayerMedia | undefined
258
+ const forward = ev.key === 'ArrowRight'
259
+ // Nothing to seek from while a new media or a rebuild has emptied the element: it reads 0, and Chrome 156 lands
260
+ // the seek after the rebuild has resumed (2026-11-21)
261
+ if (!media?.readyState || (forward && !player.duration)) return
262
+ // Where the playhead is going. A seek waiting for its data is only in `seekingTo`, and the store hears of a seek
263
+ // set in this task on the element's queued `seeking`, while the element already reads its target (Chrome 156
264
+ // and Firefox 153, 2026-11-21). Off `state`: the store has a getter only for the fields it was created with.
265
+ const from = player.state.seekingTo ?? media.currentTime
266
+ seek(forward ? Math.min(from + SEEK_STEP, player.duration) : Math.max(from - SEEK_STEP, 0))
261
267
  }
262
268
  else if ((ev.key === '<' || ev.key === '>') && stepFrame) stepFrame(ev.key === '>' ? 1 : -1)
263
269
  else {