nanoplayer 0.1.6 → 2.0.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.
package/CHANGELOG.md ADDED
@@ -0,0 +1,16 @@
1
+ # Changelog
2
+
3
+ ## 2.0.0 — Unreleased
4
+
5
+ - Replace the legacy UI with six scoped themes, SVG controls, responsive layout and reduced-motion support.
6
+ - Add public playback/source/quality/subtitle APIs, events, plugins and deterministic teardown.
7
+ - Add chapters, buffered timeline, optional VTT/image previews, playlist, repeat and keyboard/touch shortcuts.
8
+ - Add feature-detected fullscreen/PiP, theater mode and optional native/hls.js playback.
9
+ - Add React 18+ adapter, TypeScript declarations, ESM/UMD/CJS exports and CSS export.
10
+ - Add interactive product demo, CI, package/browser tests and publication documentation.
11
+ - Correct package license metadata to Apache-2.0, matching the unchanged LICENSE.
12
+ - Migration: legacy construction options remain supported; internal DOM/CSS is redesigned. No automatic global side effect from ESM; use UMD for window.NanoPlayer. Auto-frame poster seeking is removed to avoid interrupting playback; supply a poster.
13
+
14
+ ## 0.1.7
15
+
16
+ Original published baseline: basic HTML5 player, speed menu, volume, fullscreen and Vite ESM/UMD bundles.
package/LICENSE CHANGED
@@ -1,21 +1,201 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 Swift
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 SWIFTMESSAGE.ORG RU
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md CHANGED
@@ -1,147 +1,290 @@
1
- # NanoPlayer 🎬
1
+ <div align="center">
2
+ <img src="https://capsule-render.vercel.app/api?type=waving&amp;color=0:161b33,55:6463ad,100:c1a0df&amp;height=160&amp;section=header&amp;text=NanoPlayer&amp;fontSize=46&amp;fontColor=ffffff" alt="NanoPlayer" />
2
3
 
3
- NanoPlayer — лёгкий, dependency-free HTML5 видеоплеер на чистом JavaScript
4
- с интерфейсом в стиле YouTube.
4
+ ### Small player. Big atmosphere.
5
5
 
6
- Проект создаётся как open-source и подходит как для личных,
7
- так и для коммерческих проектов.
6
+ A considered HTML5 video experience. Vanilla JavaScript at the core. React when you need it.
8
7
 
9
- ---
8
+ [![npm](https://img.shields.io/npm/v/nanoplayer?color=9699ef)](https://www.npmjs.com/package/nanoplayer)
9
+ [![License](https://img.shields.io/badge/license-Apache--2.0-b5a0df)](LICENSE)
10
+ [![Build tool](https://img.shields.io/badge/build-Vite-8c93ef)](https://vite.dev)
11
+ [![GitHub](https://img.shields.io/badge/GitHub-swiftmessage-30364e?logo=github)](https://github.com/swiftmessage/NanoPlayer)
10
12
 
11
- ## Возможности
13
+ **English** · [Русский](README.ru.md)
12
14
 
13
- - Play / Pause (кнопка и пробел)
14
- - Превью видео (poster или первый кадр автоматически)
15
- - Прогресс и перемотка
16
- - Громкость (выпадающее меню)
17
- - Скорость воспроизведения
18
- - Информация о плеере
19
- - Полноэкранный режим
20
- - Управление с клавиатуры
21
- - Кастомный UI (без native controls)
22
- - Без зависимостей
15
+ [Explore the local demo](#live-demo) · [API](#api) · [Publishing](PUBLISHING.md)
16
+ </div>
23
17
 
24
- ---
18
+ > **Release status:** this checkout is the unpublished **2.0.0** release candidate. The npm registry currently serves **0.1.7** (verified 2026-11-29). The React entry and new features below require this checkout or the eventual 2.0 release. No publication is performed automatically.
25
19
 
26
- ## Установка
20
+ ## Preview
27
21
 
28
- Через npm:
29
- ```
22
+ ![NanoPlayer playground, captured in Chromium](docs/demo-chromium.png)
23
+
24
+ ## Live demo
25
+
26
+ Run `npm install`, then `npm run dev`, and open the URL Vite prints. The product playground includes six themes, two videos, MP4/WebM source switching, captions, repeat, controls and copyable integration examples. `npm run build:demo` writes a portable site to `demo-dist/`. The manual Pages workflow deploys it after GitHub Pages is configured for Actions. No hosted demo URL is advertised until deployment succeeds.
27
+
28
+ Demo media: [MDN flower (CC0)](https://interactive-examples.mdn.mozilla.net/media/cc0-videos/flower.mp4), [Big Buck Bunny (Blender Foundation, CC BY 3.0)](https://peach.blender.org/). The landscape poster is an original SVG illustration included in `public/poster.svg`. MP4/WebM choices demonstrate source switching, not different resolutions; supply your own bitrate/resolution sources for a quality ladder.
29
+
30
+ ## Features
31
+
32
+ - Six complete themes: dark, light, midnight, ocean, purple and gold; scoped CSS variables.
33
+ - Play/pause, seek, restart, loop, playlist advance, 0.25–4× speed, configurable frame stepping.
34
+ - Buffered ranges, chapter marks and selection, time preview, optional image/VTT sprite thumbnails.
35
+ - Volume, mute and opt-in volume persistence. Native/HLS audio selection when available.
36
+ - Source quality selection, MP4/WebM, native HLS or explicitly supplied hls.js.
37
+ - WebVTT subtitles, fullscreen, Picture-in-Picture and theater mode with feature detection.
38
+ - Focus-scoped keyboard shortcuts, double click fullscreen, double tap seeking, retry UI.
39
+ - Independent instances, deterministic teardown and small cleanup-based plugins.
40
+ - ESM, CommonJS, browser UMD, TypeScript declarations and optional React 18+ adapter.
41
+
42
+ ## Installation
43
+
44
+ ```sh
45
+ # Existing public release (0.1.7, legacy API):
30
46
  npm install nanoplayer
31
- ```
32
47
 
33
- В html
34
- ```
35
- <link rel="stylesheet" href="https://unpkg.com/nanoplayer@latest/dist/nanoplayer.css">
36
- <script src="https://unpkg.com/nanoplayer@latest/dist/nanoplayer.umd.js"></script>
37
- ```
38
- Допольнительный cdn
39
- ```
40
- https://cdn.jsdelivr.net/npm/nanoplayer@latest/dist/nanoplayer.umd.js
41
- https://cdn.jsdelivr.net/npm/nanoplayer@latest/dist/nanoplayer.css
48
+ # Try this unpublished release from a local checkout:
49
+ npm install
50
+ npm pack
51
+ # In your consuming application:
52
+ npm install /absolute/path/to/nanoplayer-2.0.0.tgz
42
53
  ```
43
- ES модули
44
- ```
45
- https://cdn.jsdelivr.net/npm/nanoplayer@latest/dist/nanoplayer.es.js
46
- https://cdn.jsdelivr.net/npm/nanoplayer@latest/dist/nanoplayer.css
47
54
 
48
- https:/unpkg.com/nanoplayer@latest/dist/nanoplayer.es.js
49
- https:/unpkg.com/nanoplayer@latest/dist/nanoplayer.css
50
- ```
51
- ---
55
+ ## CDN / plain HTML
52
56
 
53
- ## Быстрый старт
57
+ The **currently published legacy** release has these pinned paths. It does not contain the 2.0 React adapter or themes:
54
58
 
55
- HTML (UMD):
59
+ ```html
60
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/nanoplayer@0.1.7/dist/nanoplayer.css">
61
+ <div id="player"></div>
62
+ <script src="https://cdn.jsdelivr.net/npm/nanoplayer@0.1.7/dist/nanoplayer.umd.js"></script>
63
+ <script>new NanoPlayer('#player', { src: '/video.mp4' });</script>
56
64
  ```
57
- <link rel="stylesheet" href="dist/style.css">
58
65
 
59
- <div id="player"></div>
66
+ Legacy ESM: `https://cdn.jsdelivr.net/npm/nanoplayer@0.1.7/dist/nanoplayer.es.js`.
60
67
 
61
- <script src="dist/nanoplayer.umd.js"></script>
62
- <script>
63
- new NanoPlayer('#player', {
64
- src: 'video.mp4',
65
- poster: 'poster.jpg' // необязательно
66
- })
67
- </script>
68
+ For **this 2.0 build**, serve the output locally over HTTP:
69
+
70
+ ```html
71
+ <link rel="stylesheet" href="./dist/nanoplayer.css">
72
+ <div id="player"></div>
73
+ <script src="./dist/nanoplayer.umd.js"></script>
74
+ <script>const player = new NanoPlayer('#player', { src: '/video.mp4', theme: 'midnight' });</script>
68
75
  ```
69
- ---
70
76
 
71
- ES Modules:
77
+ Or use `<script type="module">` and `import NanoPlayer from './dist/nanoplayer.es.js'`. Both files are emitted by `npm run build`. After publishing, verify all three CDN paths before replacing the pinned legacy version; see [PUBLISHING.md](PUBLISHING.md).
78
+
79
+ ## Vanilla JavaScript
80
+
81
+ ```js
82
+ import NanoPlayer from 'nanoplayer';
83
+ import 'nanoplayer/dist/nanoplayer.css';
84
+
85
+ const player = new NanoPlayer('#player', {
86
+ src: '/video.mp4', poster: '/poster.jpg', theme: 'dark', autoplay: false
87
+ });
88
+ player.on('timeupdate', seconds => console.log(seconds));
89
+ // When the owning view is removed:
90
+ player.destroy();
72
91
  ```
73
- import NanoPlayer from 'nanoplayer'
74
- import 'nanoplayer/dist/style.css'
75
92
 
76
- new NanoPlayer('#player', {
77
- src: 'video.mp4'
78
- })
93
+ Pass a selector or an HTMLElement. Existing container children are preserved. The constructor attaches one wrapper; importing the package never touches the DOM.
94
+
95
+ ## React
96
+
97
+ React and React DOM are optional peers, never included in the core bundle. Install React in the consuming app. Import the CSS once:
98
+
99
+ ```tsx
100
+ 'use client'; // only needed at a Next.js client boundary
101
+ import { useRef } from 'react';
102
+ import { NanoPlayer } from 'nanoplayer/react';
103
+ import type Player from 'nanoplayer';
104
+ import 'nanoplayer/dist/nanoplayer.css';
105
+
106
+ export default function App() {
107
+ const ref = useRef<Player>(null);
108
+ return <NanoPlayer ref={ref} src="/video.mp4" theme="midnight"
109
+ controls autoplay={false} onPlay={() => console.log('Playing')}
110
+ onReady={player => console.log(player.video)} />;
111
+ }
79
112
  ```
80
- Важно: ES-модули должны запускаться через HTTP-сервер, не file://
81
113
 
82
- ---
114
+ The adapter updates changed options without replacing the player, reads the latest event callbacks, and cleans up on unmount and StrictMode remount. Keep arrays/objects stable with `useMemo` when possible. `useNanoPlayer(options, ref?)` returns `{ containerRef, playerRef }` for a custom host. Imports and server rendering are safe; construction occurs in an effect. `onReady` runs for every mount, including StrictMode's development remount. A ref is available after the mount effect.
83
115
 
84
- ## Параметры
116
+ ## TypeScript
85
117
 
86
- new NanoPlayer(selector, options)
118
+ ```ts
119
+ import NanoPlayer, { type Options, type Plugin } from 'nanoplayer';
120
+ const options: Options = { src: '/movie.webm', theme: 'ocean' };
121
+ const player = new NanoPlayer(document.getElementById('player')!, options);
122
+ player.on('timeupdate', seconds => seconds.toFixed(1));
123
+ ```
87
124
 
88
- options:
125
+ ## Configuration
126
+
127
+ | Option | Default | Purpose |
128
+ | --- | --- | --- |
129
+ | `src` | `''` | URL or `{ src, type?, label?, poster?, tracks? }` |
130
+ | `name`, `poster` | empty | Title (text only), poster URL |
131
+ | `theme` | `dark` | One of the six themes |
132
+ | `controls`, `autoplay`, `muted`, `loop` | true, false, false, false | Playback/UI behavior |
133
+ | `volume`, `persistVolume` | 1, false | 0–1; opt-in localStorage persistence |
134
+ | `playbackRate` | 1 | 0.25–4 |
135
+ | `playbackRates` | .25, .5, .75, 1, 1.25, 1.5, 2, 3, 4 | Speed menu |
136
+ | `seekStep`, `frameRate`, `autoHide` | 5, 30, 2500 | Seconds, estimated FPS, milliseconds |
137
+ | `sources` | [] | Labeled quality/source alternatives |
138
+ | `tracks` | [] | `{ src, label, srclang, default? }` WebVTT subtitles |
139
+ | `chapters` | [] | Ordered `{ time, title }` markers, time in seconds |
140
+ | `thumbnails` | none | VTT URL or `{ start, end, src, xywh? }[]` |
141
+ | `playlist` | [] | Sources in playback order; starts at first if `src` is empty |
142
+ | `hls` | none | Explicit hls.js constructor; never downloaded automatically |
143
+ | `plugins` | [] | Setup functions or `{ setup(player) }` objects |
144
+
145
+ `src` takes priority over `sources[0]`, then `playlist[0]`. Playlist auto-advance uses the ordered playlist and stops at the end; repeat loops the current video. Source changes preserve volume/speed; `setQuality()` also restores time and playing state after metadata. Use absolute or relative HTTP(S), blob or file media URLs; javascript/data URLs are rejected. Cross-origin subtitles, thumbnails and HLS need appropriate server CORS headers.
146
+
147
+ ### HLS, subtitles and previews
148
+
149
+ ```js
150
+ import Hls from 'hls.js'; // npm install hls.js, only if needed
151
+ new NanoPlayer('#player', {
152
+ src: '/stream.m3u8', hls: Hls,
153
+ sources: [{ src: '/720.mp4', label: '720p' }, { src: '/1080.mp4', label: '1080p' }],
154
+ tracks: [{ src: '/en.vtt', label: 'English', srclang: 'en' }],
155
+ chapters: [{ time: 0, title: 'Intro' }, { time: 60, title: 'Chapter two' }],
156
+ thumbnails: '/thumbnails.vtt'
157
+ });
158
+ ```
89
159
 
90
- - src (string) — путь к видео
91
- - poster (string | null) — превью (если не указано, берётся первый кадр)
92
- - autoplay (boolean) — автозапуск
93
- - volume (number) — громкость (0–1)
94
- - playbackRates (number[]) — доступные скорости
160
+ Thumbnail VTT cue text is an image URL, optionally followed by `#xywh=0,90,160,90`. Preview generation is never required. HLS uses native support first, then the supplied constructor. Adaptive HLS quality remains automatic; the quality menu switches explicit sources. Audio selection appears only for multiple exposed tracks.
161
+
162
+ ## API
163
+
164
+ | Method | Result / behavior |
165
+ | --- | --- |
166
+ | `play()`, `togglePlay()` | Promise; playback rejection is observable by the caller |
167
+ | `pause()` | Pause immediately |
168
+ | `seek(seconds)`, `skip(delta)` | Absolute/clamped or relative seek |
169
+ | `frame(direction = 1)` | Step by configured FPS while paused |
170
+ | `setVolume(value)`, `toggleMute()` | Volume and mute |
171
+ | `setPlaybackRate(rate)` | Clamp to 0.25–4 |
172
+ | `setSource(source, { preserveTime? })` | Replace source and dispose old HLS engine |
173
+ | `setQuality(index)` | Switch `sources[index]`, preserve position |
174
+ | `setSubtitle(index)` | Track index, or -1 for off |
175
+ | `setAudioTrack(index)` | Select exposed audio track |
176
+ | `restart()`, `retry()` | Promise; replay from start / reload current source |
177
+ | `next()` | Advance playlist; boolean indicates whether item exists |
178
+ | `enterFullscreen()`, `exitFullscreen()`, `toggleFullscreen()` | Promise; supported browser API |
179
+ | `togglePiP()` | Promise; no-op if unsupported |
180
+ | `toggleTheater()` | Toggle wide aspect ratio; return boolean |
181
+ | `updateOptions(options)` | Update options; changing source-related options reloads media |
182
+ | `on(event, fn)`, `off(event, fn)` | Subscribe/unsubscribe; chainable |
183
+ | `use(plugin)`, `removePlugin(plugin)` | Attach/cleanup; chainable |
184
+ | `destroy()` | Idempotent teardown of listeners, timers, requests, engine and wrapper |
185
+
186
+ `video`, `wrapper` and `container` expose the underlying elements. Only `destroy()` is guaranteed safe to call after destruction. `formatTime()` and `toggleFullscreen()` remain compatible with 0.1.7. Internal DOM/class structure has changed; custom legacy CSS needs migration.
187
+
188
+ ## Events
189
+
190
+ | Event | Callback argument |
191
+ | --- | --- |
192
+ | `play`, `pause`, `ended` | undefined |
193
+ | `timeupdate` | Current seconds (number) |
194
+ | `volumechange`, `ratechange` | Current volume / playback rate (number) |
195
+ | `sourcechange`, `qualitychange` | Source object |
196
+ | `subtitlechange` | Track index (-1 means off) |
197
+ | `theaterchange` | Boolean |
198
+ | `error`, `warning` | Error; thumbnail failures are nonblocking warnings |
199
+ | `loadedmetadata`, `durationchange`, `progress`, `waiting`, `playing`, `canplay`, `seeking`, `seeked` | undefined |
200
+
201
+ React supports `onPlay`, `onPause`, `onEnded`, `onTimeUpdate`, `onError`, `onVolumeChange`, `onRateChange`, `onSourceChange`, `onTheaterChange` and `onReady`. Use the instance for other events. `play()` rejection is not automatically emitted as an error for API calls; handle its Promise. Built-in buttons handle rejection in the UI.
202
+
203
+ ## Keyboard shortcuts
204
+
205
+ Shortcuts apply only inside the focused player. Text fields, selects, contenteditable and modifier-key combinations are ignored. Native button Space/Enter behavior is preserved.
206
+
207
+ | Key | Action |
208
+ | --- | --- |
209
+ | Space / K | Play/pause |
210
+ | Left / Right | Seek by configured interval (5/10/30 seconds) |
211
+ | Up / Down | Volume ±5% |
212
+ | J / L | Seek ±10 seconds |
213
+ | 0–9 | Seek to 0–90% |
214
+ | M / F / P / T / C | Mute / fullscreen / PiP / theater / subtitles |
215
+ | , / . | Previous / next approximate frame while paused |
216
+ | Escape | Close settings and return focus |
217
+
218
+ ## Themes and customization
219
+
220
+ ```css
221
+ /* Load after nanoplayer.css; custom variables override theme defaults. */
222
+ .my-player .nano-player {
223
+ --nano-primary: #a7b4ff;
224
+ --nano-secondary: #dcc298;
225
+ --nano-background: #09090f;
226
+ --nano-controls-bg: rgba(10, 10, 20, .9);
227
+ --nano-text: #f5f6ff;
228
+ --nano-muted: #b6bdd5;
229
+ --nano-border: rgba(170,180,230,.2);
230
+ --nano-radius: 16px;
231
+ }
232
+ ```
95
233
 
96
- ---
234
+ Each palette changes backgrounds, controls, text, borders and accents. Focus outlines, accessible labels, range inputs and reduced-motion styles are included. Theater mode changes the player aspect ratio; host layouts can respond to `theaterchange` to expand the container.
235
+
236
+ ## Plugins
237
+
238
+ ```js
239
+ function progressLogger() {
240
+ return player => {
241
+ const report = seconds => console.log('Watched to', seconds);
242
+ player.on('timeupdate', report);
243
+ return () => player.off('timeupdate', report);
244
+ };
245
+ }
246
+ const plugin = progressLogger();
247
+ const player = new NanoPlayer('#player', { src: '/video.mp4', plugins: [plugin] });
248
+ player.removePlugin(plugin);
249
+ ```
97
250
 
98
- ## Управление с клавиатуры
251
+ Cleanup is called on removal and destruction. Plugins own their resources; return a cleanup function. No plugin registry or global player state is required.
99
252
 
100
- - Space — Play / Pause
101
- - Esc — выход из fullscreen
253
+ ## Browser compatibility and limits
102
254
 
103
- Пробел не перехватывается, если фокус находится в input, textarea или select.
255
+ Target modern evergreen Chromium, Firefox and Safari. Actual codecs, PiP, fullscreen, audio track exposure and autoplay policy depend on the browser/device. Unsupported capability buttons are hidden. iOS uses its video fullscreen fallback where available; volume may be OS-controlled. Live streams without a finite duration disable absolute timeline seeking. Frame stepping is time-based, not decoder-frame-accurate. Native HLS and actual iOS/Safari behavior need device validation before a release. Remote demo media require network access.
104
256
 
105
- ---
257
+ ## Development / Build
106
258
 
107
- ## Стилизация
259
+ Node 22.12+ (Node 24 recommended).
108
260
 
109
- NanoPlayer не влияет на глобальные стили страницы.
110
- Все CSS-классы имеют префикс nano-.
261
+ ```sh
262
+ npm ci
263
+ npm run dev
264
+ npm run build
265
+ npm test
266
+ npm run test:types
267
+ npm run test:package
268
+ npx playwright install chromium
269
+ npm run test:e2e
270
+ npm run build:demo
271
+ npm pack --dry-run
272
+ ```
111
273
 
112
- Можно:
113
- - переопределять стили
114
- - писать собственные темы
115
- - полностью заменить style.css
274
+ Core: `src/NanoPlayer.js`; safe DOM/URL/time/VTT helpers: `src/utils.js`; icons: `src/icons.js`; scoped themes/styles: `src/style.css`; optional adapter: `src/react.js`; declarations: `types/`. Vite emits ESM/UMD/CSS and a separate React entry. `.cjs` copies preserve CommonJS use while browser UMD keeps its requested `.js` name.
116
275
 
117
- ---
276
+ ## Publishing
118
277
 
119
- ## Архитектура
278
+ Read [the Russian first-time publishing guide](PUBLISHING.md). `npm pack` builds first. `npm publish` runs validation; it is an explicit maintainer action. The optional release workflow is manual and requires an approved `npm` environment plus a configured npm trusted publisher. It never runs merely because a PR is opened.
120
279
 
121
- .nano-player
122
- ├── video
123
- ├── overlay (big play + info)
124
- ├── controls
125
- │ ├── left (play)
126
- │ ├── center (progress)
127
- │ └── right (menus)
128
- │ ├── volume
129
- │ ├── settings
130
- │ └── info
280
+ ## Contributing
131
281
 
132
- Каждое меню — отдельный popover, как в YouTube.
282
+ See [CONTRIBUTING.md](CONTRIBUTING.md). Report browser/version, source type and reproduction steps. Do not add heavy runtime dependencies to the core.
133
283
 
134
- ---
284
+ ## License / Author
135
285
 
136
- ## Структура проекта
286
+ [Apache License 2.0](LICENSE), preserved from the original LICENSE file. The previous package.json MIT label was incorrect and has been corrected without changing the license text.
137
287
 
138
- nanoplayer/
139
- ├── src/
140
- │ ├── NanoPlayer.js
141
- │ └── index.js
142
- │ └── style.css
143
- ├── dist/
144
- │ ├── nanoplayer.umd.js
145
- │ └── nanoplayer.es.js
146
- │ └── nanoplayer.umd.js
288
+ Created by **[SWIFTMESSAGE](https://github.com/swiftmessage)** · [swiftmessage.org](https://www.swiftmessage.org)
147
289
 
290
+ <div align="center">Built for the moments worth watching.<br>✦ NanoPlayer · SwiftMessage</div>