@banou/media-player 0.10.30 → 0.10.32

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.
Files changed (59) hide show
  1. package/README.md +23 -0
  2. package/dist/de-DphEdq0O.js +52 -0
  3. package/dist/engine/index.js +1 -1
  4. package/dist/engine/playback.d.ts +4 -3
  5. package/dist/engine/source-buffer.d.ts +0 -1
  6. package/dist/{engine-DeEY2qao.js → engine-BZDbaSfM.js} +211 -161
  7. package/dist/es-419-D6gsvnn8.js +52 -0
  8. package/dist/fr-BqAzAJX0.js +52 -0
  9. package/dist/index.js +942 -855
  10. package/dist/it-NTcUh3Gr.js +52 -0
  11. package/dist/ja-DSmX_bxj.js +52 -0
  12. package/dist/ko-DyPzWasj.js +52 -0
  13. package/dist/labels.d.ts +71 -0
  14. package/dist/pl-C6Ow4ra5.js +52 -0
  15. package/dist/pt-BR-wudK3giz.js +52 -0
  16. package/dist/react/labels.d.ts +28 -0
  17. package/dist/react/video-player.d.ts +9 -0
  18. package/dist/ru-D5kxBkik.js +52 -0
  19. package/dist/tr-CW7R7N9k.js +52 -0
  20. package/dist/utils/track-label.d.ts +9 -8
  21. package/dist/volume-normalizer-worklet.js +40 -26
  22. package/dist/zh-Hans-IhL1Pl78.js +52 -0
  23. package/dist/zh-Hant-C5YyFjEc.js +52 -0
  24. package/package.json +4 -2
  25. package/src/lib/audio/loudness-analysis.ts +3 -3
  26. package/src/lib/audio/playback-tap.ts +3 -3
  27. package/src/lib/audio/volume-normalizer-worklet.d.ts +1 -1
  28. package/src/lib/audio/volume-normalizer-worklet.js +40 -26
  29. package/src/lib/engine/playback.ts +21 -22
  30. package/src/lib/engine/source-buffer.ts +5 -7
  31. package/src/lib/labels.ts +75 -0
  32. package/src/lib/locales/de.json +49 -0
  33. package/src/lib/locales/es-419.json +49 -0
  34. package/src/lib/locales/fr.json +49 -0
  35. package/src/lib/locales/it.json +49 -0
  36. package/src/lib/locales/ja.json +49 -0
  37. package/src/lib/locales/ko.json +49 -0
  38. package/src/lib/locales/pl.json +49 -0
  39. package/src/lib/locales/pt-BR.json +49 -0
  40. package/src/lib/locales/ru.json +49 -0
  41. package/src/lib/locales/tr.json +49 -0
  42. package/src/lib/locales/zh-Hans.json +49 -0
  43. package/src/lib/locales/zh-Hant.json +49 -0
  44. package/src/lib/react/components/burn-in-hint.tsx +4 -1
  45. package/src/lib/react/components/chrome.tsx +9 -0
  46. package/src/lib/react/components/control-bar.tsx +15 -26
  47. package/src/lib/react/components/errors.tsx +11 -9
  48. package/src/lib/react/components/overlay.tsx +18 -5
  49. package/src/lib/react/components/playback-slider.tsx +4 -1
  50. package/src/lib/react/components/settings.tsx +23 -31
  51. package/src/lib/react/components/skip-chapter.tsx +5 -2
  52. package/src/lib/react/components/sound.tsx +5 -2
  53. package/src/lib/react/components/subtitles.tsx +7 -4
  54. package/src/lib/react/components/track-menu.tsx +8 -4
  55. package/src/lib/react/components/volume-slider.tsx +3 -1
  56. package/src/lib/react/hooks/use-playback.ts +12 -2
  57. package/src/lib/react/labels.tsx +125 -0
  58. package/src/lib/react/video-player.tsx +14 -1
  59. package/src/lib/utils/track-label.ts +16 -11
package/README.md CHANGED
@@ -94,6 +94,9 @@ reads as a browser bug rather than a missing asset. Serve both.
94
94
 
95
95
  `libavWorkerUrl` (`libav-wasm/build/worker.js`) is named individually and still copies fine.
96
96
 
97
+ Copy all three from the libav-wasm this package depends on. A worker from before libav-wasm 0.9.0 writes another
98
+ timeline and reports no `timestampOffset`, so playback fails at load.
99
+
97
100
  `cjkFontUrl` is this package's own `noto-sans-jp.otf` (`import cjkFontUrl from
98
101
  '@banou/media-player/noto-sans-jp.otf?no-inline&url'`), Noto Sans JP cut to the JIS X 0208 kanji. jassub's libass has no
99
102
  system font fallback, so without it Japanese in a style whose font has no Japanese, which is how releases set song
@@ -350,6 +353,25 @@ resolves, and its host applies the preference to its own tracks: `preferredSelec
350
353
  from the same module gives a pick's BCP 47 tag (`jpn` gives `ja`, `Português (Brasil)` gives `pt-BR`), or undefined for
351
354
  one naming no language, for code that reads tags.
352
355
 
356
+ ### Labels in the viewer's language
357
+
358
+ The controls, tooltips, menus, skip offers and failures are in English. Pass `language`, a BCP 47 tag such as the
359
+ host page shows, for another:
360
+
361
+ ```tsx
362
+ <MediaPlayer {...source} language="fr" />
363
+ ```
364
+
365
+ They are shown in the closest language the player has: Latin American Spanish (`es-419`, for every `es-*`), Brazilian
366
+ Portuguese (`pt-BR`, for every `pt-*`), French, German, Italian, Russian, Japanese, Korean, Simplified and Traditional
367
+ Chinese (`zh-Hans`, `zh-Hant`), Turkish and Polish, else English. The numbers in them are written as the tag writes them
368
+ (`es-AR` gives `0,5x`, `es-419` itself `0.5x`), and track languages are named in it, even when the labels are English
369
+ (`en-DE` gives `0,5x`). A language's text is fetched the first time a player shows it, with FormatJS (`@formatjs/intl`),
370
+ and the labels are English until it has arrived. A player given no `language`, or one it does not have, fetches neither.
371
+
372
+ Each language is `src/lib/locales/<tag>.json`, keyed by the English of `src/lib/labels.ts`; a unit test holds every
373
+ file to FormatJS's `verify` against that English.
374
+
353
375
  ## Layout
354
376
 
355
377
  One package. `src/` is the demo app, `src/lib` is the library it publishes, and the app imports it by
@@ -430,6 +452,7 @@ its published name so it stays an honest consumer.
430
452
  player.addEventListener('chapterschange', () => console.log(player.chapters))
431
453
  ```
432
454
  - `src/lib/react/` the player component, its chrome, and the hooks.
455
+ - `src/lib/labels.ts` the chrome's text in English, and `src/lib/locales/` its other languages.
433
456
 
434
457
  Built by `vite.lib.config.ts` into `dist/`, which is what npm publishes.
435
458
 
@@ -0,0 +1,52 @@
1
+ //#region src/lib/locales/de.json
2
+ var e = "Audio", t = "Kopiert", n = "Kopieren", r = "Aus", i = "Stummschalten", a = "Pause", o = "Wiedergabe", s = "Qualität", c = "Erneut abspielen", l = "Einstellungen", u = "Untertitel", d = "Nicht verfügbar", f = "behoben", p = {
3
+ "(Default)": "(Normal)",
4
+ Audio: e,
5
+ Copied: t,
6
+ Copy: n,
7
+ "Copy the errors": "Fehler kopieren",
8
+ "Could not switch. Try again.": "Wechsel fehlgeschlagen. Versuch es noch einmal.",
9
+ Disable: "Aus",
10
+ "Exit full screen (f)": "Vollbild beenden (f)",
11
+ "Exit picture in picture": "Bild-im-Bild beenden",
12
+ "Full screen": "Vollbild",
13
+ "Full screen (f)": "Vollbild (f)",
14
+ Mute: i,
15
+ "Mute (m)": "Stummschalten (m)",
16
+ "Normalize volume": "Lautstärke angleichen",
17
+ "Now click your browser's pop out button": "Klicke jetzt auf die Bild-im-Bild-Schaltfläche deines Browsers",
18
+ Pause: a,
19
+ "Pause (k)": "Pause (k)",
20
+ "Picture in picture": "Bild-im-Bild",
21
+ Play: o,
22
+ "Play (k)": "Wiedergabe (k)",
23
+ "Playback errors ({count})": "Wiedergabefehler ({count})",
24
+ "Playback failed": "Wiedergabe fehlgeschlagen",
25
+ "Playback speed": "Geschwindigkeit",
26
+ "Put the subtitles in the picture": "Untertitel ins Bild einbetten",
27
+ "Put the subtitles in the video": "Untertitel ins Video einbetten",
28
+ Quality: s,
29
+ "Reading the video file failed": "Die Videodatei konnte nicht gelesen werden",
30
+ Replay: c,
31
+ "Replay (k)": "Erneut abspielen (k)",
32
+ Settings: l,
33
+ "Skip Ending": "Abspann überspringen",
34
+ "Skip Opening": "Intro überspringen",
35
+ Subtitles: u,
36
+ "Subtitles are in the picture": "Die Untertitel sind im Bild",
37
+ "The MediaSource closed before a SourceBuffer could be created": "Die MediaSource wurde geschlossen, bevor ein SourceBuffer erstellt werden konnte",
38
+ "The MediaSource never opened": "Die MediaSource wurde nie geöffnet",
39
+ "The browser rejected a media segment": "Der Browser hat ein Mediensegment abgelehnt",
40
+ "The video codec in this file could not be identified": "Der Videocodec dieser Datei konnte nicht erkannt werden",
41
+ "This browser cannot play the codecs in this file: {codecs}": "Dieser Browser kann die Codecs dieser Datei nicht abspielen: {codecs}",
42
+ "This file has no subtitles": "Diese Datei hat keine Untertitel",
43
+ "Track {number}": "Spur {number}",
44
+ Unavailable: d,
45
+ "Unmute (m)": "Ton einschalten (m)",
46
+ "at {time}": "bei {time}",
47
+ recovered: f,
48
+ "{rate}x": "{rate}x",
49
+ "{start} to {end}": "von {start} bis {end}"
50
+ };
51
+ //#endregion
52
+ export { e as Audio, t as Copied, n as Copy, r as Disable, i as Mute, a as Pause, o as Play, s as Quality, c as Replay, l as Settings, u as Subtitles, d as Unavailable, p as default, f as recovered };
@@ -1,2 +1,2 @@
1
- import { a as e, c as t, d as n, f as r, i, l as a, n as o, o as s, r as c, s as l, t as u, u as d } from "../engine-DeEY2qao.js";
1
+ import { a as e, c as t, d as n, f as r, i, l as a, n as o, o as s, r as c, s as l, t as u, u as d } from "../engine-BZDbaSfM.js";
2
2
  export { i as DEFAULT_BUFFER_SIZE, e as MediaElementError, a as SUBTITLES_OFF, u as createPictureInPicture, d as createSubtitleRenderer, c as createThumbnailGenerator, n as getTimeRanges, s as isMediaElementError, o as pictureInPictureMode, l as startPlayback, t as terminateRemuxer, r as updateSourceBuffer };
@@ -23,9 +23,9 @@ export type MediaChapter = {
23
23
  };
24
24
  /**
25
25
  * What the remuxer produced, in the order it was appended: the init segment and the input audio stream it carries,
26
- * a run at load and at every remuxer seek (`pts` is the timestampOffset its fragments are appended at), each
27
- * fragment, and the end of the file once read. The buffers are playback's own and may be appended again, so a
28
- * consumer copies what it keeps.
26
+ * a run at load and at every remuxer seek (`pts` is the timestampOffset its fragments are appended at, the same for
27
+ * every run, and `from` the time the run starts at), each fragment, and the end of the file once read. The buffers
28
+ * are playback's own and may be appended again, so a consumer copies what it keeps.
29
29
  */
30
30
  export type PlaybackOutput = {
31
31
  type: 'init';
@@ -35,6 +35,7 @@ export type PlaybackOutput = {
35
35
  } | {
36
36
  type: 'run';
37
37
  pts: number;
38
+ from: number;
38
39
  } | {
39
40
  type: 'fragment';
40
41
  data: ArrayBuffer;
@@ -7,6 +7,5 @@ export declare const getTimeRanges: (sourceBuffer: SourceBuffer) => TimeRange[];
7
7
  export declare const updateSourceBuffer: (sourceBuffer: SourceBuffer, mediaSource: MediaSource) => {
8
8
  appendBuffer: (buffer: ArrayBuffer | Uint8Array) => Promise<void>;
9
9
  unbufferRange: (start: number, end: number) => Promise<void>;
10
- updateTimestampOffset: (timestampOffset: number) => Promise<void>;
11
10
  endOfStream: (allowed?: () => boolean) => Promise<void>;
12
11
  };