@nomercy-entertainment/nomercy-video-player 2.8.3 → 2.9.1

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 (150) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/CONTRIBUTING.md +17 -23
  3. package/README.md +147 -28
  4. package/RELEASING.md +15 -34
  5. package/SECURITY.md +2 -2
  6. package/dist/adapters/thumbnail-source/vtt-sprite.d.ts +4 -0
  7. package/dist/adapters/thumbnail-source/vtt-sprite.js +6 -1
  8. package/dist/adapters/video-backend/IVideoBackend.d.ts +27 -21
  9. package/dist/adapters/video-backend/hls-caption-drain.js +4 -2
  10. package/dist/adapters/video-backend/hls-warm-cache.js +64 -25
  11. package/dist/adapters/video-backend/html5.d.ts +1 -0
  12. package/dist/adapters/video-backend/html5.js +252 -90
  13. package/dist/adapters/video-backend/source-outage.js +4 -4
  14. package/dist/index.d.ts +5 -208
  15. package/dist/index.js +99 -40
  16. package/dist/locales/af.json +18 -18
  17. package/dist/locales/ar.json +18 -18
  18. package/dist/locales/bg.json +18 -18
  19. package/dist/locales/bn.json +18 -18
  20. package/dist/locales/ca.json +18 -18
  21. package/dist/locales/cs.json +18 -18
  22. package/dist/locales/cy.json +18 -18
  23. package/dist/locales/da.json +18 -18
  24. package/dist/locales/de.json +18 -18
  25. package/dist/locales/el.json +18 -18
  26. package/dist/locales/en.json +18 -18
  27. package/dist/locales/es.json +18 -18
  28. package/dist/locales/et.json +18 -18
  29. package/dist/locales/eu.json +18 -18
  30. package/dist/locales/fa.json +18 -18
  31. package/dist/locales/fi.json +18 -18
  32. package/dist/locales/fr.json +18 -18
  33. package/dist/locales/ga.json +18 -18
  34. package/dist/locales/gl.json +18 -18
  35. package/dist/locales/gu.json +18 -18
  36. package/dist/locales/he.json +18 -18
  37. package/dist/locales/hi.json +18 -18
  38. package/dist/locales/hr.json +18 -18
  39. package/dist/locales/hu.json +18 -18
  40. package/dist/locales/hy.json +18 -18
  41. package/dist/locales/id.json +18 -18
  42. package/dist/locales/is.json +18 -18
  43. package/dist/locales/it.json +18 -18
  44. package/dist/locales/ja.json +18 -18
  45. package/dist/locales/ka.json +18 -18
  46. package/dist/locales/kk.json +18 -18
  47. package/dist/locales/km.json +18 -18
  48. package/dist/locales/kn.json +18 -18
  49. package/dist/locales/ko.json +18 -18
  50. package/dist/locales/ku.json +18 -18
  51. package/dist/locales/ky.json +18 -18
  52. package/dist/locales/lo.json +18 -18
  53. package/dist/locales/lt.json +18 -18
  54. package/dist/locales/lv.json +18 -18
  55. package/dist/locales/mk.json +18 -18
  56. package/dist/locales/ml.json +18 -18
  57. package/dist/locales/mn.json +18 -18
  58. package/dist/locales/mr.json +18 -18
  59. package/dist/locales/ms.json +18 -18
  60. package/dist/locales/my.json +18 -18
  61. package/dist/locales/nb.json +18 -18
  62. package/dist/locales/ne.json +18 -18
  63. package/dist/locales/nl.json +15 -15
  64. package/dist/locales/nn.json +18 -18
  65. package/dist/locales/no.json +18 -18
  66. package/dist/locales/oc.json +18 -18
  67. package/dist/locales/pa.json +18 -18
  68. package/dist/locales/pl.json +18 -18
  69. package/dist/locales/pt-BR.json +18 -18
  70. package/dist/locales/pt.json +18 -18
  71. package/dist/locales/ro.json +18 -18
  72. package/dist/locales/ru.json +18 -18
  73. package/dist/locales/si.json +18 -18
  74. package/dist/locales/sk.json +18 -18
  75. package/dist/locales/sl.json +18 -18
  76. package/dist/locales/sq.json +18 -18
  77. package/dist/locales/sr.json +18 -18
  78. package/dist/locales/sv.json +18 -18
  79. package/dist/locales/sw.json +18 -18
  80. package/dist/locales/ta.json +18 -18
  81. package/dist/locales/te.json +18 -18
  82. package/dist/locales/tg.json +18 -18
  83. package/dist/locales/th.json +18 -18
  84. package/dist/locales/tl.json +18 -18
  85. package/dist/locales/tr.json +18 -18
  86. package/dist/locales/uk.json +18 -18
  87. package/dist/locales/ur.json +18 -18
  88. package/dist/locales/uz.json +18 -18
  89. package/dist/locales/vi.json +18 -18
  90. package/dist/locales/xh.json +18 -18
  91. package/dist/locales/yo.json +18 -18
  92. package/dist/locales/zh-TW.json +18 -18
  93. package/dist/locales/zh.json +18 -18
  94. package/dist/locales/zu.json +18 -18
  95. package/dist/nomercy-video-player.iife.js +5 -5
  96. package/dist/player/next-item-warmup.js +2 -1
  97. package/dist/player/normalize-item.js +51 -21
  98. package/dist/player/preload.js +30 -6
  99. package/dist/player/start-selection.js +7 -2
  100. package/dist/player/track-language-memory.js +35 -13
  101. package/dist/plugins/cast-sender/index.js +7 -3
  102. package/dist/plugins/desktop-ui/data/buttons.js +53 -20
  103. package/dist/plugins/desktop-ui/data/language-names.js +10 -3
  104. package/dist/plugins/desktop-ui/helpers/activity.js +2 -1
  105. package/dist/plugins/desktop-ui/helpers/buttonState.js +26 -10
  106. package/dist/plugins/desktop-ui/helpers/chapters.js +1 -1
  107. package/dist/plugins/desktop-ui/helpers/dom.js +156 -38
  108. package/dist/plugins/desktop-ui/helpers/menuControl.js +34 -17
  109. package/dist/plugins/desktop-ui/helpers/menus.js +161 -54
  110. package/dist/plugins/desktop-ui/helpers/progressBar.js +10 -4
  111. package/dist/plugins/desktop-ui/helpers/responsive.js +67 -18
  112. package/dist/plugins/desktop-ui/helpers/sprite.js +29 -17
  113. package/dist/plugins/desktop-ui/helpers/tooltips.js +15 -9
  114. package/dist/plugins/desktop-ui/helpers/topBar.js +21 -7
  115. package/dist/plugins/desktop-ui/i18n/token-bundle.js +395 -79
  116. package/dist/plugins/desktop-ui/index.js +7 -6
  117. package/dist/plugins/desktop-ui/mixins/activityMethods.js +1 -1
  118. package/dist/plugins/desktop-ui/mixins/chapterMethods.js +5 -2
  119. package/dist/plugins/desktop-ui/mixins/domMethods.js +40 -19
  120. package/dist/plugins/desktop-ui/mixins/feedbackMethods.js +11 -4
  121. package/dist/plugins/desktop-ui/mixins/iconStateMethods.js +16 -8
  122. package/dist/plugins/desktop-ui/mixins/spriteMethods.js +17 -6
  123. package/dist/plugins/desktop-ui/mixins/transportStateMethods.js +52 -23
  124. package/dist/plugins/desktop-ui/styles.css +1578 -1578
  125. package/dist/plugins/drm/index.d.ts +1 -1
  126. package/dist/plugins/drm/index.js +17 -4
  127. package/dist/plugins/key-handler/index.js +34 -17
  128. package/dist/plugins/live-transcoding/index.js +11 -5
  129. package/dist/plugins/octopus/font-names.js +9 -4
  130. package/dist/plugins/octopus/index.js +37 -21
  131. package/dist/plugins/octopus/style-scale.js +4 -2
  132. package/dist/plugins/subtitle-overlay/index.js +43 -19
  133. package/dist/plugins/touch-zones/index.js +80 -8
  134. package/dist/plugins/tv-key-handler/index.js +8 -3
  135. package/dist/plugins/twitch/TwitchEmbedBackend.js +79 -26
  136. package/dist/plugins/twitch/TwitchPlugin.d.ts +2 -0
  137. package/dist/plugins/twitch/TwitchPlugin.js +84 -26
  138. package/dist/plugins/twitch/clip.d.ts +2 -1
  139. package/dist/plugins/twitch/clip.js +3 -3
  140. package/dist/plugins/twitch/gql.d.ts +8 -5
  141. package/dist/plugins/twitch/gql.js +7 -9
  142. package/dist/plugins/twitch/metadata.d.ts +2 -1
  143. package/dist/plugins/twitch/metadata.js +4 -4
  144. package/dist/plugins/twitch/stream.d.ts +2 -1
  145. package/dist/plugins/twitch/stream.js +11 -4
  146. package/dist/plugins/twitch/url.js +38 -9
  147. package/dist/plugins/v1-compat.js +34 -46
  148. package/dist/types.d.ts +16 -16
  149. package/dist/types.js +14 -4
  150. package/package.json +154 -177
package/CHANGELOG.md CHANGED
@@ -2,6 +2,26 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [2.9.1] — 2026-11-18
6
+
7
+ ### Changed
8
+
9
+ - Released at the trio version with core 2.9.2 (sidecar subtitles and chapters keep the `baseUrl` path). No video player changes.
10
+
11
+ ## [2.9.0] — 2026-11-14
12
+
13
+ ### Fixed
14
+
15
+ - The html5 backend reports when an audio track switch is applied (`reportsAudioTrackApplied`, from hls.js `AUDIO_TRACK_SWITCHED`), so `audioTrack` fires once the new track plays. Needs core 2.9.0.
16
+
17
+ ### Changed
18
+
19
+ - `./plugins/twitch`: the Twitch GQL calls go through `Plugin.fetch` with `auth: false`, so they use the configured transport and abort on dispose, and the player's token still never reaches Twitch.
20
+
21
+ ### Added
22
+
23
+ - `VttSpriteThumbnailSource.useFetchers(fetchers)` sets the fetchers, so a sprite server that needs auth can be reached with a token.
24
+
5
25
  ## [2.8.3] — 2026-11-09
6
26
 
7
27
  ### Fixed
package/CONTRIBUTING.md CHANGED
@@ -1,47 +1,41 @@
1
1
  # Contributing
2
2
 
3
- Thanks for your interest in `@nomercy-entertainment/nomercy-video-player`. This package is the v2 video player package built on the NoMercy player kit.
3
+ Thanks for your interest in the NoMercy web player packages. The [README](./README.md) explains the layout and the daily commands.
4
4
 
5
5
  ## Reporting issues
6
6
 
7
- - Bug? File a [GitHub issue](https://github.com/NoMercy-Entertainment/nomercy-video-player/issues) with a minimal reproduction. Include kit version, browser, and a stack trace if you have one.
8
- - Security? Do not file a public issue — see [SECURITY.md](./SECURITY.md).
7
+ - Bug? File a [GitHub issue](https://github.com/NoMercy-Entertainment/nomercy-player-web/issues) with a minimal reproduction. Include the package, its version, the browser, and a stack trace if you have one.
8
+ - Security? Do not file a public issue. See [SECURITY.md](./SECURITY.md).
9
9
  - Question? The full docs live at [docs.nomercy.tv/player/](https://docs.nomercy.tv/player/).
10
10
 
11
11
  ## Local development
12
12
 
13
13
  ```bash
14
- git clone https://github.com/NoMercy-Entertainment/nomercy-video-player.git
15
- cd nomercy-video-player
16
- corepack enable # once; picks yarn 4 from package.json
14
+ git clone https://github.com/NoMercy-Entertainment/nomercy-player-web.git
15
+ cd nomercy-player-web
16
+ corepack enable
17
17
  yarn install
18
- yarn test # vitest run (unit tests must pass)
19
- yarn typecheck # tsc --noEmit
20
- yarn build # writes dist/
18
+ yarn build
19
+ yarn typecheck
20
+ yarn lint
21
+ yarn test
22
+ yarn test:e2e # video and music; generates its fixtures with the NoMercy ffmpeg fork
21
23
  ```
22
24
 
23
- The package also has a real-browser e2e suite built with Playwright:
24
-
25
- ```bash
26
- yarn test:e2e # runs pretest:e2e (generates fixtures via the NoMercy ffmpeg fork) then playwright test
27
- ```
28
-
29
- The `pretest:e2e` step downloads and runs the NoMercy ffmpeg fork to produce short test media files. The generated fixtures go into `e2e/media/` and are not committed. Running `test:e2e` for the first time may take a few minutes on a slow connection.
30
-
31
25
  ## Pull requests
32
26
 
33
27
  - Branch off `master`. Feature branches: `feat/<short-description>`. Fixes: `fix/<short-description>`.
34
28
  - Commit messages follow [Conventional Commits](https://www.conventionalcommits.org/) (`feat`, `fix`, `chore`, `docs`, `refactor`, `test`, `perf`, `ci`). Imperative, lowercase subject, no trailing period.
35
- - Tests required for new features. Bug fixes should include a regression test.
36
- - Run `yarn lint:fix` before pushing. CI rejects lint failures.
37
- - No `Co-Authored-By` trailers unless we paired live.
29
+ - New features need tests. Bug fixes need a regression test.
30
+ - Run `yarn lint:fix` before you push. CI rejects lint failures.
31
+ - No `Co-Authored-By` trailers unless you paired live.
38
32
 
39
33
  ## Plugin contributions
40
34
 
41
- Built-in plugins live in `src/plugins/`. New plugins are welcome — but most plugins belong in consumer packages, not the kit itself. The kit ships only plugins that are universal (event-bus, logger, retry-policy, etc.). Domain-specific plugins (Spotify scrobbler, custom DRM, etc.) belong in their own packages.
35
+ Built-in plugins live in `packages/<package>/src/plugins/`. Most plugins belong in consumer packages, not in the kit. The kit ships only plugins that are universal (event bus, logger, retry policy). A domain-specific plugin (a scrobbler, a custom DRM) belongs in its own package.
42
36
 
43
- If you have a domain-specific plugin you'd like to host alongside the kit, open a discussion first.
37
+ If you would like to host a domain-specific plugin alongside the kit, open a discussion first.
44
38
 
45
39
  ## Releases
46
40
 
47
- Releases are coordinated across the v2 trio (kit, video, music). Each pre-release publishes to npm under the `rc` dist-tag. The final `latest` release happens once consumer apps (nomercy-app-web, nomercy-cast-player) confirm a clean migration.
41
+ See [RELEASING.md](./RELEASING.md).
package/README.md CHANGED
@@ -1,31 +1,33 @@
1
1
  [![npm](https://img.shields.io/npm/v/@nomercy-entertainment/nomercy-video-player/latest?label=latest)](https://www.npmjs.com/package/@nomercy-entertainment/nomercy-video-player)
2
- [![license](https://img.shields.io/npm/l/@nomercy-entertainment/nomercy-video-player)](./LICENSE)
2
+ [![license](https://img.shields.io/npm/l/@nomercy-entertainment/nomercy-video-player)](https://www.apache.org/licenses/LICENSE-2.0)
3
3
  [![bundlephobia](https://img.shields.io/bundlephobia/minzip/@nomercy-entertainment/nomercy-video-player)](https://bundlephobia.com/package/@nomercy-entertainment/nomercy-video-player)
4
4
 
5
- Full documentation: https://docs.nomercy.tv/nomercy-video-player/
6
-
7
5
  # nomercy-video-player
8
6
 
9
- The headless HLS video engine behind NoMercy TV.
7
+ A headless video player for the web, with HLS built in and every feature beyond playback a plugin you opt into.
10
8
 
11
- It handles the hard parts of video and hands you plain events and methods.
9
+ It ships no interface by default. You get the transport, the queue, subtitle and audio track selection, and a typed event bus. You build the UI yourself, or add the prebuilt `DesktopUiPlugin`.
12
10
 
13
- You stay in control of the interface.
11
+ What sets it apart:
14
12
 
15
- - Adaptive bitrate streaming over HLS, with HDR-aware quality
16
- - Multi-format subtitles (VTT, ASS, SSA), chapters, and skip markers
17
- - Chromecast, a full keyboard and touch input layer, a typed event bus
18
- - A built-in `DesktopUiPlugin` for full controls, or bring your own UI
13
+ - **Headless by design.** The player owns playback and state. The controls are yours.
14
+ - **Everything is a plugin.** Keyboard, touch, Chromecast, DRM, ASS subtitles and the rest are separate imports. You only ship what you register.
15
+ - **Typed end to end.** Methods, events and plugin options are TypeScript types.
16
+ - **Swappable parts.** Pass your own storage, URL resolver, logger or retry policy to `setup()`. No subclassing.
19
17
 
20
- Built on [`nomercy-player-core`](https://www.npmjs.com/package/@nomercy-entertainment/nomercy-player-core), the shared engine for the queue, auth, plugins, i18n, and storage.
18
+ It is built on [`nomercy-player-core`](https://www.npmjs.com/package/@nomercy-entertainment/nomercy-player-core), the shared engine for the queue, auth, plugins, i18n and storage. The music sibling is [`nomercy-music-player`](https://www.npmjs.com/package/@nomercy-entertainment/nomercy-music-player).
21
19
 
22
20
  ## Install
23
21
 
24
- ```
22
+ ```sh
25
23
  npm install @nomercy-entertainment/nomercy-video-player
26
24
  ```
27
25
 
28
- HLS support is built in. `hls.js` ships with the player core, so `.m3u8` streams work out of the box with nothing extra to install.
26
+ `nomercy-player-core` is a regular dependency, so it installs with the player. So does `hls.js`, which the core package depends on. There is no peer dependency to add.
27
+
28
+ ### Script tag
29
+
30
+ The published package carries a prebuilt bundle at `dist/nomercy-video-player.iife.js`. It defines one global, `nmplayer`, which is the player factory. Use it when your page loads scripts by tag instead of importing modules.
29
31
 
30
32
  ## Quick start
31
33
 
@@ -52,32 +54,149 @@ player.on('ready', () => {
52
54
  });
53
55
  ```
54
56
 
55
- That mounts a working player with the full built-in UI.
57
+ `'player'` is the id of the element the player mounts into. This gives you a working player with the full built-in UI. Drop `DesktopUiPlugin` and you get playback with no controls.
58
+
59
+ ## Common tasks
60
+
61
+ ### Load and move through a playlist
62
+
63
+ ```ts
64
+ player.queue([
65
+ { id: 'a', title: 'Episode 1', url: '/show/s01e01.m3u8', duration: 1320 },
66
+ { id: 'b', title: 'Episode 2', url: '/show/s01e02.m3u8', duration: 1290 },
67
+ ]);
68
+
69
+ player.item('b'); // jump by id, by index, or by item
70
+ await player.next();
71
+ await player.previous();
72
+ ```
73
+
74
+ `queueAppend()` adds to the end of the queue. `repeatState()` and `shuffleState()` read and set repeat and shuffle.
75
+
76
+ ### Listen to events
77
+
78
+ ```ts
79
+ player.on('time', ({ position, duration }) => {
80
+ console.log(position, duration);
81
+ });
82
+
83
+ player.on('item', ({ item, index }) => {
84
+ console.log('now playing', index, item?.title);
85
+ });
86
+
87
+ player.on('fatal', error => console.error(error));
88
+ ```
89
+
90
+ Every event is typed. `once()` and `off()` work the same way.
91
+
92
+ ### Add a plugin
93
+
94
+ ```ts
95
+ import { KeyHandlerPlugin, TouchZonesPlugin } from '@nomercy-entertainment/nomercy-video-player/plugins';
96
+
97
+ player.addPlugin(KeyHandlerPlugin).addPlugin(TouchZonesPlugin);
98
+ ```
99
+
100
+ `addPlugin` returns the player, so calls chain. Each plugin also has its own subpath import, such as `@nomercy-entertainment/nomercy-video-player/plugins/octopus`.
101
+
102
+ ### Subtitles
103
+
104
+ ```ts
105
+ import { OctopusPlugin, SubtitleOverlayPlugin } from '@nomercy-entertainment/nomercy-video-player/plugins';
106
+
107
+ player.addPlugin(SubtitleOverlayPlugin).addPlugin(OctopusPlugin);
108
+
109
+ player.queue([
110
+ {
111
+ id: 'sintel',
112
+ title: 'Sintel',
113
+ url: '/Sintel.m3u8',
114
+ subtitles: [
115
+ { id: 'en', label: 'English', language: 'en', url: '/Sintel.en.vtt' },
116
+ { id: 'en-ass', label: 'English (styled)', language: 'en', url: '/Sintel.en.ass' },
117
+ ],
118
+ },
119
+ ]);
120
+
121
+ await player.subtitle(0); // pick a track by its position in subtitles()
122
+ await player.subtitle(null); // captions off
123
+ ```
124
+
125
+ The player parses the tracks and emits `subtitleCue` events. It paints nothing itself, so register a renderer. `SubtitleOverlayPlugin` draws WebVTT as DOM. `OctopusPlugin` renders ASS and SSA through libass, including embedded fonts. Register both if your library holds both formats. `cycleSubtitles()` steps through the tracks and back to off.
126
+
127
+ ### The built-in UI
128
+
129
+ `DesktopUiPlugin` is a top bar, a center play button, a scrubber with sprite previews, seven menu panes and an auto-hide cycle. It calls the same public methods your own code can call, and you restyle it with plain CSS. Pass `DesktopUiOptions` as the second argument of `addPlugin` to configure it.
130
+
131
+ ## Built-in plugins
132
+
133
+ 21 plugin classes are exported from `@nomercy-entertainment/nomercy-video-player/plugins`. 11 are written in this package. 10 are re-exported from `nomercy-player-core`.
134
+
135
+ | Plugin | What it does |
136
+ | --- | --- |
137
+ | `DesktopUiPlugin` | The prebuilt overlay: top bar, scrubber, menu panes. |
138
+ | `SubtitleOverlayPlugin` | Draws WebVTT cues as a positioned DOM tree over the video. |
139
+ | `OctopusPlugin` | Renders ASS and SSA subtitles with libass, with embedded fonts. |
140
+ | `KeyHandlerPlugin` | The keyboard binding set, with each group overridable. |
141
+ | `TvKeyHandlerPlugin` | Adapts the keyboard set for a TV remote. |
142
+ | `TouchZonesPlugin` | A tap grid over the picture: tap to toggle controls or playback, double tap to seek. |
143
+ | `CastSenderPlugin` | Chromecast sender with video metadata. |
144
+ | `MediaSessionPlugin` | Fills the OS Now Playing text and controls from the current item. |
145
+ | `DrmPlugin` | Key-system probing and license requests for Widevine, PlayReady and FairPlay. |
146
+ | `LiveTranscodingPlugin` | Coordinates playback with a server that transcodes segment by segment on demand. |
147
+ | `TwitchPlugin` | Plays Twitch clip, VOD and live links. |
148
+ | `EmbedPlugin` | A `postMessage` bridge between a host page and a player in an iframe. |
149
+ | `MessagePlugin` | Toast messages and persistent overlays on the player container. |
150
+ | `TabLeaderPlugin` | Keeps playback to one tab at a time, using the Web Locks API. |
151
+ | `AudioGraphPlugin` | Owns the `AudioContext` and the signal chain the audio plugins share. |
152
+ | `EqualizerPlugin` | Ten peaking filters and a pre-gain, with presets. Needs `AudioGraphPlugin`. |
153
+ | `MixerPlugin` | Master gain in decibels and stereo pan. |
154
+ | `SpectrumPlugin` | Emits spectrum, waveform and band-energy frames. |
155
+ | `CanvasPlugin` | A shared canvas mount and render loop for visualizers. |
156
+ | `VisualizationPlugin` | Abstract base for canvas visualizers. |
157
+ | `VolumeMemoryPlugin` | Restores the volume and mute state a viewer chose. |
158
+
159
+ Per-plugin pages are in the [plugin docs](https://docs.nomercy.tv/nomercy-video-player/plugins-adapters/desktop-ui).
160
+
161
+ ## API overview
162
+
163
+ The surface is shared with the core package, plus the video additions. Most methods read when called with no argument and write when called with one.
164
+
165
+ | Purpose | Methods |
166
+ | --- | --- |
167
+ | Playback | `play()`, `pause()`, `stop()`, `time()`, `forward()`, `rewind()`, `restart()`, `volume()`, `mute()`, `unmute()`, `playbackRate()` |
168
+ | Queue | `queue()`, `queueAppend()`, `item()`, `next()`, `previous()`, `backlog()`, `repeatState()`, `shuffleState()` |
169
+ | Tracks | `subtitles()`, `subtitle()`, `cycleSubtitles()`, `audioTracks()`, `audioTrack()`, `qualityLevels()`, `quality()`, `chapters()`, `seekToChapter()` |
170
+ | Display | `fullscreen()`, `aspectRatio()`, `cycleAspectRatio()`, `videoRect()` |
171
+ | Events | `on()`, `once()`, `off()` |
172
+ | Plugins | `addPlugin()`, `getPlugin()` |
56
173
 
57
- ## Bring your own UI
174
+ The full list is in the [API methods reference](https://docs.nomercy.tv/nomercy-video-player/reference/player-methods) and the [events reference](https://docs.nomercy.tv/nomercy-video-player/reference/events).
58
175
 
59
- No UI is bundled. Nothing is forced on you.
176
+ ## HLS and formats
60
177
 
61
- The controls, the input handling, every feature beyond playback is a plugin you opt into with `addPlugin`. Drop `DesktopUiPlugin` from the quick start above and you build your own interface from the player's events, the path the [Build a Player tutorial](https://docs.nomercy.tv/nomercy-video-player/build/shell) walks one control at a time.
178
+ A URL counts as HLS when it contains `.m3u8` followed by `?`, `#` or the end of the string. HLS plays through the browser's own support when it has it, and through `hls.js` otherwise. `hls.js` loads only when it is needed.
62
179
 
63
- You can also swap any built-in behavior. Pass your own storage, URL resolver, logger, or retry policy to `setup()`. No subclassing.
180
+ Any other URL goes straight to the video element. The playable formats, such as `.mp4` and `.webm`, are whatever the browser can decode.
64
181
 
65
- ## Upgrading from v1
182
+ ## Documentation and examples
66
183
 
67
- See [MIGRATION.md](./MIGRATION.md) for the full breaking-change list, including renamed methods, changed event payloads, and the `item.file` to `item.url` rename that breaks silently if missed.
184
+ - [Introduction](https://docs.nomercy.tv/nomercy-video-player/introduction) and [Quick Start](https://docs.nomercy.tv/nomercy-video-player/quickstart)
185
+ - [Guided Tour](https://docs.nomercy.tv/nomercy-video-player/tour/transport): transport, volume, queue, [subtitles](https://docs.nomercy.tv/nomercy-video-player/tour/subtitles), quality and chapters. Most pages include a running example.
186
+ - [Build a Player](https://docs.nomercy.tv/nomercy-video-player/build/shell): a tutorial that builds your own UI plugin
187
+ - Recipes for [Vue](https://docs.nomercy.tv/nomercy-video-player/recipes/vue-integration), [React](https://docs.nomercy.tv/nomercy-video-player/recipes/react-integration), [Svelte](https://docs.nomercy.tv/nomercy-video-player/recipes/svelte-integration) and [vanilla JS](https://docs.nomercy.tv/nomercy-video-player/recipes/vanilla-integration)
188
+ - Reference: [Configuration](https://docs.nomercy.tv/nomercy-video-player/reference/config), [Playlist item](https://docs.nomercy.tv/nomercy-video-player/reference/playlist-item), [Streams](https://docs.nomercy.tv/nomercy-video-player/reference/streams)
68
189
 
69
- ## Documentation
190
+ Upgrading from v1: see [MIGRATION.md](https://github.com/NoMercy-Entertainment/nomercy-player-web/blob/master/packages/video-player/MIGRATION.md). It lists renamed methods, changed event payloads, and the `item.file` to `item.url` rename.
70
191
 
71
- The [docs site](https://docs.nomercy.tv/nomercy-video-player/) is the full reference, ordered from first player to plugin author:
192
+ ## Related packages
72
193
 
73
- - [Introduction](https://docs.nomercy.tv/nomercy-video-player/introduction) and [Quick Start](https://docs.nomercy.tv/nomercy-video-player/quickstart), install and first player
74
- - The [Guided Tour](https://docs.nomercy.tv/nomercy-video-player/tour/transport) over transport, volume, queue, subtitles, quality, and chapters, method by method
75
- - [Build a Player](https://docs.nomercy.tv/nomercy-video-player/build/shell), a ten-step tutorial that builds your own UI plugin from scratch
76
- - Framework recipes for [Vue](https://docs.nomercy.tv/nomercy-video-player/recipes/vue-integration), [React](https://docs.nomercy.tv/nomercy-video-player/recipes/react-integration), [Svelte](https://docs.nomercy.tv/nomercy-video-player/recipes/svelte-integration), and [vanilla JS](https://docs.nomercy.tv/nomercy-video-player/recipes/vanilla-integration)
77
- - [Configuration](https://docs.nomercy.tv/nomercy-video-player/reference/config), [API Methods](https://docs.nomercy.tv/nomercy-video-player/reference/player-methods), and [Events](https://docs.nomercy.tv/nomercy-video-player/reference/events)
194
+ - [`nomercy-player-core`](https://www.npmjs.com/package/@nomercy-entertainment/nomercy-player-core): the shared engine
195
+ - [`nomercy-music-player`](https://www.npmjs.com/package/@nomercy-entertainment/nomercy-music-player): the audio sibling
196
+ - [`media-session`](https://www.npmjs.com/package/@nomercy-entertainment/media-session): framework-free Media Session wiring
78
197
 
79
198
  ## License
80
199
 
81
200
  Apache-2.0
82
201
 
83
- Repository: [github.com/NoMercy-Entertainment/nomercy-video-player](https://github.com/NoMercy-Entertainment/nomercy-video-player)
202
+ Source: [packages/video-player in nomercy-player-web](https://github.com/NoMercy-Entertainment/nomercy-player-web/tree/master/packages/video-player). Version history: [CHANGELOG.md](https://github.com/NoMercy-Entertainment/nomercy-player-web/blob/master/packages/video-player/CHANGELOG.md).
package/RELEASING.md CHANGED
@@ -1,43 +1,24 @@
1
- # Releasing @nomercy-entertainment/nomercy-video-player
1
+ # Releasing
2
2
 
3
- ## RC publish (current)
3
+ Each package releases on its own version from this repository.
4
4
 
5
- Published under the `rc` dist-tag via `publishConfig.tag: "rc"`. Install the rc:
5
+ ## How a release works
6
6
 
7
- ```
8
- npm install @nomercy-entertainment/nomercy-video-player@rc
9
- ```
7
+ 1. Bump `version` in `packages/<dir>/package.json` and add a `CHANGELOG.md` entry.
8
+ 2. Push to `master`. A push never publishes.
9
+ 3. Create a GitHub release tagged `<short>-v<semver>`. `<short>` is `core`, `video`, `music`, `media-session` or `eslint-plugin`, for example `core-v2.6.1`.
10
+ 4. `.github/workflows/publish.yml` checks the tag against `package.json`, runs the gates, packs with `yarn pack` (which rewrites `workspace:*` to the exact version), and publishes with npm provenance on a GitHub-hosted runner.
10
11
 
11
- Watch out: a plain `npm install` without the tag does not fail. It resolves the old
12
- v1 line, which is what `latest` points at until `2.0.0` is published to it. Always
13
- install with an explicit tag or version during the rc phase.
12
+ A manual run of `publish.yml` with `dry_run` stops before `npm publish`. A prerelease version (one with a `-`) publishes under the `rc` dist-tag; any other version publishes under `latest`.
14
13
 
15
- ## Build
14
+ To withdraw a release, run `.github/workflows/retract.yml`.
16
15
 
17
- The package ships two artifacts from one `dist/`: the ESM build from `tsc` and the
18
- IIFE CDN bundle from Vite (`vite.iife.config.ts`). `yarn build` wipes `dist/` before
19
- it compiles, so the bundle must always be produced after it, never before.
16
+ ## Order across packages
20
17
 
21
- ```
22
- yarn build # tsc ESM dist + translation and asset passes
23
- yarn build:iife # Vite IIFE bundle into the same dist/
24
- yarn build:all # both, in the right order
25
- ```
18
+ Video and music depend on an exact core version. When core changes, release core first and confirm it is on npm; the publish workflow refuses a video or music release whose core version is not there yet. `core`, `video` and `music` follow this order.
26
19
 
27
- The `prepublishOnly` hook runs `build:all`, so a publish from any environment packs
28
- the complete artifact set. `dist/` is gitignored.
20
+ ## What each package ships
29
21
 
30
- ## Stable 2.0.0 flip
31
-
32
- The full trio choreography (publish order, lockfile refresh, docs flip, outside-in
33
- verification) lives in the core repo's RELEASING.md. Steps specific to this package:
34
-
35
- 1. Bump the version to `2.0.0` in `package.json`.
36
- 2. Remove `"tag": "rc"` from `publishConfig`.
37
- 3. Update the `@nomercy-entertainment/nomercy-player-core` range (currently
38
- `^2.0.0-rc.24`) to `^2.0.0`. The rc range already matches stable, so this is
39
- convention, not mechanics.
40
- 4. Add a `[2.0.0]` entry to `CHANGELOG.md` summarizing changes since the last rc.
41
- 5. After core `2.0.0` is on the registry, run
42
- `yarn up @nomercy-entertainment/nomercy-player-core` before publishing so the
43
- build scripts and lockfile come from the stable core.
22
+ - `core`: ESM from `tsc` plus `scripts/`, which video and music run at build time.
23
+ - `video` and `music`: ESM from `tsc` plus a CDN bundle, `dist/*.iife.js`, from Vite (`vite.iife.config.ts`). `yarn build` wipes `dist/`, so `build:iife` runs after it; `build:all` does both.
24
+ - Every package gets `LICENSE`, and the trio also gets the contributor documents from the repository root. `scripts/pack-files.mjs` copies them in while packing and removes them afterward.
package/SECURITY.md CHANGED
@@ -12,7 +12,7 @@ Please include:
12
12
 
13
13
  - A description of the issue and its impact
14
14
  - Steps to reproduce, with a minimal proof of concept
15
- - The kit version (`@nomercy-entertainment/nomercy-video-player`) and any consumer package versions you tested against
15
+ - The package and its version (for example `@nomercy-entertainment/nomercy-player-core`) and any consumer package versions you tested against
16
16
  - Your preferred contact for follow-up
17
17
 
18
18
  We aim to acknowledge reports within 48 hours and to coordinate a fix and disclosure timeline with you.
@@ -25,7 +25,7 @@ Only the latest `2.x` pre-release / release line receives security updates. v1 p
25
25
 
26
26
  In scope:
27
27
 
28
- - The kit itself (`@nomercy-entertainment/nomercy-video-player`)
28
+ - Every package in this repository, including the kit (`@nomercy-entertainment/nomercy-player-core`)
29
29
  - Adapter ports + built-in plugins shipped from this package
30
30
  - Cross-package vulnerabilities in `nomercy-video-player` or `nomercy-music-player` rooted in the kit
31
31
 
@@ -1,4 +1,5 @@
1
1
  import type { BasePlaylistItem } from '@nomercy-entertainment/nomercy-player-core';
2
+ import type { SpriteFetchers } from '../../plugins/desktop-ui/helpers/sprite.js';
2
3
  import type { IThumbnailSource, ThumbnailFrame } from './IThumbnailSource.js';
3
4
  /**
4
5
  * Default thumbnail source. Fetches a WebVTT sprite manifest from
@@ -14,6 +15,9 @@ import type { IThumbnailSource, ThumbnailFrame } from './IThumbnailSource.js';
14
15
  */
15
16
  export declare class VttSpriteThumbnailSource implements IThumbnailSource {
16
17
  private _cache;
18
+ private _fetchers;
19
+ /** Call with `fetchers` when the sprite server needs auth; without them the VTT is fetched with no token. */
20
+ useFetchers(fetchers: SpriteFetchers): void;
17
21
  load(item: BasePlaylistItem): Promise<boolean>;
18
22
  lookup(timeSeconds: number): ThumbnailFrame | null;
19
23
  unload(): void;
@@ -20,12 +20,17 @@ import { loadSpriteSet, lookupCue } from '../../plugins/desktop-ui/helpers/sprit
20
20
  */
21
21
  export class VttSpriteThumbnailSource {
22
22
  _cache = null;
23
+ _fetchers;
24
+ /** Call with `fetchers` when the sprite server needs auth; without them the VTT is fetched with no token. */
25
+ useFetchers(fetchers) {
26
+ this._fetchers = fetchers;
27
+ }
23
28
  async load(item) {
24
29
  this._cache = null;
25
30
  const spriteUrl = this._resolveSpriteUrl(item);
26
31
  if (!spriteUrl)
27
32
  return false;
28
- const spriteSet = await loadSpriteSet(spriteUrl);
33
+ const spriteSet = await loadSpriteSet(spriteUrl, this._fetchers);
29
34
  if (!spriteSet)
30
35
  return false;
31
36
  this._cache = spriteSet;
@@ -20,49 +20,49 @@ export type StreamResolver = (url: string, contentType?: string) => IStreamSourc
20
20
  * to the minimal contract) accepts this map directly.
21
21
  */
22
22
  export interface BackendEventPayload extends MinimalBackendEventPayload {
23
- 'loadstart': Event;
24
- 'loadedmetadata': {
23
+ loadstart: Event;
24
+ loadedmetadata: {
25
25
  url: string;
26
26
  kind: string;
27
27
  duration: number;
28
28
  };
29
29
  /** The subtitle track list changed after load, for example hls.js added an embedded caption track on its first cue. */
30
- 'subtitleTracks': {
30
+ subtitleTracks: {
31
31
  tracks: SubtitleTrack[];
32
32
  };
33
33
  /** The source turned live or stopped being live. Emit it on every change, never twice in a row for the same value. */
34
- 'live': {
34
+ live: {
35
35
  live: boolean;
36
36
  };
37
- 'loadeddata': Event;
38
- 'canplay': Event;
39
- 'play': Event;
37
+ loadeddata: Event;
38
+ canplay: Event;
39
+ play: Event;
40
40
  /**
41
41
  * Fires when media is actually rendering — after buffering resolves, not
42
42
  * just on element.play(). Use this to hide buffering spinners.
43
43
  */
44
- 'playing': Event;
45
- 'pause': Event;
46
- 'ended': Event;
47
- 'timeupdate': Event;
48
- 'waiting': Event;
49
- 'stalled': Event;
50
- 'ratechange': Event;
51
- 'resize': Event;
52
- 'encrypted': Event;
53
- 'error': Event;
44
+ playing: Event;
45
+ pause: Event;
46
+ ended: Event;
47
+ timeupdate: Event;
48
+ waiting: Event;
49
+ stalled: Event;
50
+ ratechange: Event;
51
+ resize: Event;
52
+ encrypted: Event;
53
+ error: Event;
54
54
  /**
55
55
  * Element src cleared (manual unload, HMR remount). Listeners use
56
56
  * this to reset "we're playing" state — element is paused at
57
57
  * currentTime=0 after this fires.
58
58
  */
59
- 'emptied': Event;
59
+ emptied: Event;
60
60
  /**
61
61
  * Active subtitle cues changed. Payload mirrors the kit's
62
62
  * `SubtitleCueChange`. Fires with `cues: []` when subtitles are
63
63
  * turned off / between cues.
64
64
  */
65
- 'subtitleCue': SubtitleCueChange;
65
+ subtitleCue: SubtitleCueChange;
66
66
  /**
67
67
  * A non-fatal or escalated HLS error. `fatal: false` means the stream
68
68
  * is continuing; `fatal: true` means recovery was attempted but all
@@ -93,7 +93,7 @@ export interface BackendEventPayload extends MinimalBackendEventPayload {
93
93
  * subscribe here instead of polling `qualityLevels()` at `mediaReady`
94
94
  * because the list may not be populated until after the manifest is parsed.
95
95
  */
96
- 'levels': {
96
+ levels: {
97
97
  levels: QualityLevel[];
98
98
  };
99
99
  /**
@@ -107,9 +107,13 @@ export interface BackendEventPayload extends MinimalBackendEventPayload {
107
107
  * Audio track list became available. Fires after MANIFEST_PARSED when the
108
108
  * manifest declares multiple audio renditions.
109
109
  */
110
- 'audioTracks': {
110
+ audioTracks: {
111
111
  tracks: AudioTrack[];
112
112
  };
113
+ /** The engine now plays audio track `index` (hls.js: the new rendition is buffered). */
114
+ 'audio-track-switched': {
115
+ index: number;
116
+ };
113
117
  }
114
118
  /** Backend-internal events forwarded to the player's eventTarget. */
115
119
  export type BackendEvent = keyof BackendEventPayload;
@@ -220,6 +224,8 @@ export interface IVideoBackend {
220
224
  videoHeight(): number;
221
225
  audioTracks(): AudioTrack[];
222
226
  setAudioTrack(idx: number): void;
227
+ /** Set when the backend emits `audio-track-switched` once a switch is applied; the player's `audioTrack` waits for it. */
228
+ readonly reportsAudioTrackApplied?: true;
223
229
  subtitleTracks(): SubtitleTrack[];
224
230
  setSubtitleTrack(idx: number | null): void;
225
231
  qualityLevels(): QualityLevel[];
@@ -22,8 +22,9 @@ export function drainCaptionCache(hls) {
22
22
  const track = timeline.captionsTracks[channel]?.track;
23
23
  if (track) {
24
24
  const mode = track.mode;
25
- if (mode === 'disabled')
25
+ if (mode === 'disabled') {
26
26
  track.mode = 'hidden';
27
+ }
27
28
  for (const cue of timeline.cueCache[channel]) {
28
29
  if (track.cues && !track.cues.getCueById(cue.id)) {
29
30
  try {
@@ -32,8 +33,9 @@ export function drainCaptionCache(hls) {
32
33
  catch { /* a cue the engine refuses is dropped, as hls.js drops it */ }
33
34
  }
34
35
  }
35
- if (mode === 'disabled')
36
+ if (mode === 'disabled') {
36
37
  track.mode = mode;
38
+ }
37
39
  }
38
40
  delete timeline.cueCache[channel];
39
41
  }