pict-section-video 0.0.0-stage → 1.1.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Steven Velozo
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.
package/README.md CHANGED
@@ -1,3 +1,234 @@
1
- # Temporary Holding Version
1
+ # pict-section-video
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ A bespoke, responsive **video player** section for the Retold/Pict ecosystem. Point it at a video URL and it fits
4
+ the whole frame to its stage on phones, tablets, desktops, TVs, and projected displays — with its own control bar
5
+ (play/pause, a seek scrubber with a buffered bar, a time readout, mute + volume, a playback-rate cycle, a quality
6
+ menu, download, and fullscreen). Seeking rides the browser's native HTTP **Range** requests, so a range-served file
7
+ (an [`orator-file-service`](https://github.com/fable-retold/orator-file-service) route, a Sluice depot, a bare 206
8
+ URL) scrubs without downloading the whole clip.
9
+
10
+ It also plays **adaptive (HLS) streams**: natively on Safari (AirPlay, PiP, the lock screen and native fullscreen
11
+ come free) and through a **host-supplied [hls.js](https://github.com/video-dev/hls.js) 1.7.4 light** build
12
+ everywhere else, with an Auto / per-rung / Data-saver quality menu that remembers the reader's pick.
13
+
14
+ It is a single [`pict-view`](https://github.com/fable-retold/pict-view) in the lightweight single-view shape
15
+ (like `pict-section-image`): a stub container template, with the player DOM built imperatively — a `<video>` is
16
+ inherently imperative (its `src`, buffered/seekable ranges, and the `loadedmetadata`/`timeupdate`/`play`/`pause`
17
+ events have no template equivalent).
18
+
19
+ Usable on its own, or driven as the video renderer inside
20
+ [`pict-section-fileview`](https://github.com/fable-retold/pict-section-fileview).
21
+
22
+ ## Install
23
+
24
+ ```bash
25
+ npm install pict-section-video
26
+ ```
27
+
28
+ The only hard dependency is `pict-view`. **hls.js is never bundled or required** — see
29
+ [Adaptive streaming](#adaptive-streaming-hls) for how a host supplies it.
30
+
31
+ ## Usage
32
+
33
+ ```javascript
34
+ const libPictSectionVideo = require('pict-section-video');
35
+
36
+ pict.addView('MyVideo', Object.assign({}, libPictSectionVideo.default_configuration,
37
+ {
38
+ DefaultDestinationAddress: '#SomeDiv',
39
+ TargetElementAddress: '#SomeDiv',
40
+ VideoURL: 'https://host/clip.mp4'
41
+ }), libPictSectionVideo);
42
+
43
+ pict.views.MyVideo.render();
44
+
45
+ // …or point it at a video later:
46
+ pict.views.MyVideo.setVideo('https://host/other.webm');
47
+ pict.views.MyVideo.setSource({ URL: 'https://host/talk.mp4', Title: 'The Talk', PosterURL: 'https://host/art.jpg' });
48
+ ```
49
+
50
+ ## Adaptive streaming (HLS)
51
+
52
+ Hand `setSource()` a descriptor with a `Stream` (the shape `pict-section-fileview`'s `descriptorFromMediaPackage()`
53
+ builds from a `retold-media-ladder` package):
54
+
55
+ ```javascript
56
+ pict.views.MyVideo.setSource(
57
+ {
58
+ URL: '/media/1a2b3c4d/master.m3u8',
59
+ Title: 'Coast flight',
60
+ PosterURL: '/media/1a2b3c4d/poster.jpg',
61
+ Duration: 312, // seconds; shown until metadata loads
62
+ DownloadURL: null, // null = no download affordance anywhere
63
+ Stream:
64
+ {
65
+ Type: 'hls',
66
+ Manifest: '/media/1a2b3c4d/master.m3u8',
67
+ Renditions: [ { Name: '1080p', ShortSide: 1080, Width: 1920, Height: 1080, Bandwidth: 6234000,
68
+ Playlist: '/media/1a2b3c4d/v0/index.m3u8' } /* … */ ],
69
+ ProgressiveURL: null // '/media/1a2b3c4d/download.mp4' when downloads are allowed
70
+ }
71
+ });
72
+ ```
73
+
74
+ ### Supplying hls.js (host-side)
75
+
76
+ hls.js **1.7.4, light build** (`hls.light.min.js`, ~120 KB gzip) is the supported version. The host loads it and
77
+ either passes the class in config or leaves it on the page global:
78
+
79
+ ```html
80
+ <script src="./hls.light.min.js"></script> <!-- copied from node_modules/hls.js/dist/ -->
81
+ ```
82
+
83
+ ```javascript
84
+ // Either: config (wins) …
85
+ pict.addView('MyVideo', Object.assign({}, libPictSectionVideo.default_configuration,
86
+ { HlsLibrary: window.Hls, HlsConfig: { maxBufferLength: 20 } }), libPictSectionVideo);
87
+ // … or: nothing — the player falls back to window.Hls.
88
+ ```
89
+
90
+ The light build is enough because ladder packages mux audio into each rung (no alternate audio groups) and need no
91
+ `EXT-X-DEFINE`. Without hls.js the player still plays HLS where the browser does natively, and otherwise falls
92
+ back to `Stream.ProgressiveURL`.
93
+
94
+ ### How a playback path is chosen
95
+
96
+ `source/Pict-Section-Video-Strategy.js` is a pure resolver (`resolveStrategy(source, video, Hls, window)`):
97
+
98
+ | Browser | Strategy |
99
+ |---|---|
100
+ | `canPlayType('application/vnd.apple.mpegurl')` **and** `'ManagedMediaSource' in window` (Safari) | `native-hls` |
101
+ | hls.js present and `Hls.isSupported()` (Chrome, Firefox, Edge) | `hls.js` |
102
+ | `canPlayType` passes, no MMS, no hls.js (iOS before 17.1) | `native-hls` |
103
+ | No HLS path but `Stream.ProgressiveURL` — or a plain (non-`Stream`) source | `progressive` |
104
+ | Nothing | `unsupported` (error state) |
105
+
106
+ Under hls.js the player merges `HlsConfig` over `{ autoStartLoad:false, maxBufferLength:30, maxMaxBufferLength:60,
107
+ capLevelToPlayerSize:true }`: the manifest loads on mount, fragments only on the first play (from the play button,
108
+ the `<video>` itself, autoplay or the OS media keys). A first visit leaves `startLevel` unset (hls.js starts on the
109
+ master's first variant — the ladder puts the ~540p rung there); once a fragment has been measured over the
110
+ network the bandwidth estimate is saved beside the quality pick and later visits start with
111
+ `{ startLevel:-1, testBandwidth:false, abrEwmaDefaultEstimate:<saved> }`. A fragment served from the HTTP cache or
112
+ over loopback is not a measurement (hls.js reads one as ~800 Mbps), and the saved value never exceeds the fastest
113
+ fragment that actually crossed the network.
114
+
115
+ The `<video>` box fills the stage and letterboxes the frame (`width/height:100%; object-fit:contain`), so
116
+ `capLevelToPlayerSize` measures the player, not the rung being decoded, and Auto can climb past its starting rung.
117
+
118
+ ### Quality menu
119
+
120
+ A **Quality** button after the speed button opens a `role=menu` popover (arrow keys, Home/End, `Esc`):
121
+
122
+ - **Auto (720p)** — adaptive; the label follows hls.js `LEVEL_SWITCHED`, or the `<video>`'s `videoHeight` on
123
+ `resize` under native HLS.
124
+ - **One entry per rung** — `1080p · 6 Mbps`, named by the short side (a portrait 1080×1920 rung is `1080p`).
125
+ Under hls.js a pick sets `hls.nextLevel` while playing (the next fragment switches — no restart) or
126
+ `hls.currentLevel` while paused. Under native HLS it loads that rung's `Playlist` at the same position.
127
+ - **Data saver** — caps hls.js `autoLevelCapping` at the rung `<= SaverMaxHeight` (540), or loads that rung's
128
+ playlist under native HLS.
129
+
130
+ The pick persists in `localStorage` under `QualityStorageKey` (every access guarded — private mode and disabled
131
+ storage just keep the pick in memory). The button hides when a source has fewer than two rungs, for a progressive
132
+ file, or with `ShowQuality:false`.
133
+
134
+ ### Errors and fallback
135
+
136
+ | Failure | Response |
137
+ |---|---|
138
+ | hls.js `NETWORK_ERROR` with HTTP 401 / 403 / 404 / 410 | Error state: "This link has expired or been revoked." |
139
+ | Other fatal hls.js network error | Retry (`startLoad()`, or `loadSource()` before the manifest parsed) up to 3×, then fall back |
140
+ | Fatal hls.js `MEDIA_ERROR` (or a `<video>` error under hls.js) | `recoverMediaError()` once, then fall back |
141
+ | Anything else, or retries exhausted | Native HLS (if `canPlayType` passes) → `Stream.ProgressiveURL` → error state |
142
+
143
+ The reader's position carries across every fallback step. `destroy()` calls `hls.destroy()`.
144
+
145
+ ### Download links
146
+
147
+ | `DownloadURL` | Control bar + error state |
148
+ |---|---|
149
+ | absent / `''` / `false` | The playing URL — for an HLS source, `Stream.ProgressiveURL` (never the playlist), else nothing |
150
+ | `null` | **No download affordance anywhere** (control bar and error-state link) |
151
+ | a non-empty string | That URL |
152
+
153
+ ## Mobile
154
+
155
+ - **Fullscreen** is real: `requestFullscreen()` on the player root (desktop, Android, iPad), `webkitEnterFullscreen()`
156
+ on the `<video>` on iPhone (the native player), and the fill-the-viewport CSS maximize where neither exists (or
157
+ the request is refused). `fullscreenchange` / `webkitendfullscreen` keep `isFullscreen()` honest — including an
158
+ exit made while the `requestFullscreen()` is still in flight, which is undone as soon as the request lands.
159
+ - **Buffering**: `waiting` / `seeking` raise a spinner, `playing` / `canplay` / `seeked` lower it, and `progress`
160
+ grows a buffered bar under the seek track.
161
+ - **Volume**: iOS ignores scripted volume writes, so the volume slider hides there (mute still works).
162
+ - `playsinline` keeps iPhone playback inline until the reader asks for fullscreen.
163
+
164
+ ## Configuration
165
+
166
+ | Key | Meaning |
167
+ |---|---|
168
+ | `VideoURL` | Initial video URL (or `false` for an empty player until `setSource()` / `setVideo()`). |
169
+ | `PosterURL` | A poster image shown before playback (`<video poster>`). |
170
+ | `Title` | A human title (used as the download filename hint). |
171
+ | `DownloadURL` / `DownloadName` | Explicit download href + filename hint. Absent falls back to the playing URL; `null` = no download anywhere. |
172
+ | `AutoPlay` / `Loop` / `Muted` | Mapped onto the `<video>` element (defaults off). |
173
+ | `Preload` | `'metadata'` (default), `'none'` (share pages: nothing loads before play), or `'auto'` (also starts hls.js loading at once). |
174
+ | `ShowToolbar` | Render the control bar (default on). Set `false` when a host owns the chrome. |
175
+ | `ShowDownload` | Show the download affordance in the control bar (default on). |
176
+ | `ShowFullscreen` | Show the fullscreen button (default on). |
177
+ | `ClickToPlay` | Clicking the video toggles play/pause (default on). |
178
+ | `PlaybackRates` | The rate cycle the speed button steps through (default `[0.5, 1, 1.25, 1.5, 2]`). |
179
+ | `Volume` | Initial volume `0..1` (default `1`). |
180
+ | `HlsLibrary` | The hls.js class (default `null` → `window.Hls`). Never bundled. |
181
+ | `HlsConfig` | Merged over the player's hls.js defaults (default `{}`; host keys win). |
182
+ | `ShowQuality` | Show the quality menu (default on; hidden anyway with fewer than two rungs). |
183
+ | `ShowDataSaver` | Offer the Data saver entry (default on). |
184
+ | `QualityStorageKey` | `localStorage` key for the pick + bandwidth estimate (default `'pict-section-video-quality'`; `''` disables). |
185
+ | `SaverMaxHeight` | Data saver ceiling as a short side in pixels (default `540`). |
186
+ | `TargetElementAddress`, `DefaultDestinationAddress`, `RenderOnLoad` | Standard pict-view placement. |
187
+
188
+ ## Public API
189
+
190
+ | Method | Does |
191
+ |---|---|
192
+ | `setSource(descriptor)` | Point the player at `{ URL, Stream?, PosterURL?, Title?, Name?, DownloadURL?, DownloadName?, Duration? }` and pick its playback path; resets to the start. For HLS the played URL is `Stream.Manifest \|\| URL`. |
193
+ | `setVideo(urlOrDescriptor)` | Shorthand: a string → `setSource({ URL })`, an object → `setSource(object)`. |
194
+ | `getStrategy()` | `'native-hls'`, `'hls.js'`, `'progressive'`, `'unsupported'` (`''` before a load). |
195
+ | `getQualityLevels()` | `[{ Index, Height (short side), Width, PixelHeight, Bandwidth, Label }]`, highest first; `[]` for progressive. |
196
+ | `setQuality('auto' \| 'saver' \| shortSide)` / `getQuality()` | Pick (and persist) a quality. |
197
+ | `toggleQualityMenu()` | Open / close the quality menu. |
198
+ | `play()` / `pause()` / `togglePlay()` | Playback control. |
199
+ | `seekTo(seconds)` | Seek to an absolute time (clamped to the duration). |
200
+ | `setVolume(0..1)` / `toggleMute()` | Volume control. |
201
+ | `setPlaybackRate(rate)` / `cyclePlaybackRate()` | Playback speed. |
202
+ | `enterFullscreen()` / `exitFullscreen()` / `toggleFullscreen()` / `isFullscreen()` | Real fullscreen (see Mobile); `enterFullscreen()` returns `true` when it acted (or already is fullscreen). |
203
+ | `getState()` | `{ URL, Loaded, Error, ErrorMessage, Playing, Duration, CurrentTime, Muted, Volume, PlaybackRate, Fullscreen, Strategy, Quality, PlayingHeight, Levels, Buffered, Waiting }`. |
204
+ | `destroy()` | Detach handlers, tear down hls.js, leave fullscreen and clear the player. |
205
+
206
+ The strategy module is also exported as `require('pict-section-video').Strategy` (`resolveStrategy`,
207
+ `progressiveURL`, `HLS_MIME`, the quality-ladder helpers, and the saved-estimate helpers `fragmentNetworkBandwidth`
208
+ and `persistableEstimate`).
209
+
210
+ ## Formats
211
+
212
+ A progressive source goes straight to a `<video>` element, so it plays whatever the host browser plays — the safe
213
+ web set is MP4 (H.264/AAC), WebM and Ogg. A container a browser cannot decode (AVI, MKV, WMV, …) is the host's
214
+ problem to transcode; inside `pict-section-fileview` such a file degrades to the download card rather than a dead
215
+ player. Adaptive sources are HLS with fMP4 segments (see above).
216
+
217
+ ## Examples
218
+
219
+ `example_applications/video_player` is a runnable demo: standalone players for a couple of clips, each with the
220
+ full control bar, independent on one page.
221
+
222
+ ```bash
223
+ cd example_applications/video_player && npm run build # build the example's browser bundle
224
+ npm run example-serve # (from the module root) serve at http://localhost:<port>/video_player/dist/index.html
225
+ ```
226
+
227
+ ## Development
228
+
229
+ ```bash
230
+ npm test # Mocha TDD via quackage (real jsdom document; a FakeHls stands in for hls.js)
231
+ npm run build # browser bundle via quackage
232
+ ```
233
+
234
+ MIT © Steven Velozo
package/package.json CHANGED
@@ -1,6 +1,60 @@
1
1
  {
2
- "name": "pict-section-video",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
2
+ "name": "pict-section-video",
3
+ "version": "1.1.0",
4
+ "description": "Pict video player section — a bespoke, responsive video player (play/seek/time/volume/rate/fullscreen) that scrubs over native HTTP Range and renders well on phones, tablets, desktops and projected displays. Standalone, or driven as the video renderer inside pict-section-fileview.",
5
+ "main": "source/Pict-Section-Video.js",
6
+ "scripts": {
7
+ "start": "node source/Pict-Section-Video.js",
8
+ "build": "npx quack build",
9
+ "test": "npx quack test",
10
+ "tests": "npx quack test -g",
11
+ "coverage": "npx quack coverage",
12
+ "docs": "npx quack prepare-docs ./docs -d ./modules",
13
+ "docs-serve": "npx quack docs-serve ./docs",
14
+ "example": "npx quack examples",
15
+ "example-serve": "npx quack examples-serve"
16
+ },
17
+ "quackageExamples": {
18
+ "mode": "static"
19
+ },
20
+ "files": [
21
+ "source"
22
+ ],
23
+ "directories": {
24
+ "test": "test"
25
+ },
26
+ "repository": {
27
+ "type": "git",
28
+ "url": "git+https://github.com/fable-retold/pict-section-video.git"
29
+ },
30
+ "author": "steven velozo <steven@velozo.com>",
31
+ "license": "MIT",
32
+ "bugs": {
33
+ "url": "https://github.com/fable-retold/pict-section-video/issues"
34
+ },
35
+ "homepage": "https://github.com/fable-retold/pict-section-video#readme",
36
+ "devDependencies": {
37
+ "browser-env": "^3.3.0",
38
+ "chai": "^4.3.0",
39
+ "pict": "^1.0.372",
40
+ "quackage": "^1.3.0"
41
+ },
42
+ "mocha": {
43
+ "diff": true,
44
+ "extension": [
45
+ "js"
46
+ ],
47
+ "package": "./package.json",
48
+ "reporter": "spec",
49
+ "slow": "75",
50
+ "timeout": "5000",
51
+ "ui": "tdd",
52
+ "watch-files": [
53
+ "source/**/*.js",
54
+ "test/**/*.js"
55
+ ]
56
+ },
57
+ "dependencies": {
58
+ "pict-view": "^1.0.68"
59
+ }
60
+ }
@@ -0,0 +1,229 @@
1
+ module.exports = (
2
+ {
3
+ "RenderOnLoad": true,
4
+
5
+ "DefaultRenderable": "VideoPlayer-Wrap",
6
+ "DefaultDestinationAddress": "#VideoPlayer-Container-Div",
7
+
8
+ "Templates":
9
+ [
10
+ {
11
+ "Hash": "VideoPlayer-Container",
12
+ // A stub — the player DOM is built imperatively in onAfterInitialRender (a <video> is an inherently
13
+ // imperative element: its src, buffered/seekable ranges and the load/timeupdate/play/pause/error events
14
+ // have no template equivalent). This mirrors pict-section-image / pict-section-code.
15
+ "Template": "<!-- VideoPlayer-Container rendering soon -->"
16
+ }
17
+ ],
18
+
19
+ "Renderables":
20
+ [
21
+ {
22
+ "RenderableHash": "VideoPlayer-Wrap",
23
+ "TemplateHash": "VideoPlayer-Container",
24
+ "DestinationAddress": "#VideoPlayer-Container-Div"
25
+ }
26
+ ],
27
+
28
+ // The element the player DOM is built into (defaults to the same div the stub renders into).
29
+ "TargetElementAddress": "#VideoPlayer-Container-Div",
30
+
31
+ // The initial video: a URL string, or false for an empty player until setVideo() is called.
32
+ "VideoURL": false,
33
+ // A poster image shown before playback (the <video poster> attribute).
34
+ "PosterURL": false,
35
+ // A human title shown by the player and used as the download filename hint.
36
+ "Title": "",
37
+ // An explicit download href + filename hint. Absent / false / '' falls back to the playing URL (for an HLS source,
38
+ // its Stream.ProgressiveURL); null means NO download affordance anywhere (control bar and error state).
39
+ "DownloadURL": false,
40
+ "DownloadName": "",
41
+
42
+ // Playback toggles (mapped straight onto the <video> element).
43
+ "AutoPlay": false,
44
+ "Loop": false,
45
+ "Muted": false,
46
+ // 'metadata' fetches just enough to learn duration + dimensions (the right default for a range-served file);
47
+ // 'none' defers all network until play; 'auto' lets the browser buffer ahead.
48
+ "Preload": "metadata",
49
+
50
+ // Chrome + behavior toggles.
51
+ "ShowToolbar": true, // the bespoke control bar (play / seek / time / volume / rate / download)
52
+ "ShowDownload": true, // the download affordance in the control bar
53
+ "ShowFullscreen": true, // the maximize/restore button (fills the browser viewport and back; Esc exits)
54
+ "ClickToPlay": true, // clicking the video toggles play/pause
55
+
56
+ // The playback-rate cycle the rate button steps through (1x is the resting value).
57
+ "PlaybackRates": [ 0.5, 1, 1.25, 1.5, 2 ],
58
+ // Initial volume (0..1).
59
+ "Volume": 1,
60
+
61
+ // Adaptive streaming (HLS). A source carrying Stream:{ Type:'hls', Manifest, Renditions, ProgressiveURL } plays
62
+ // natively on Safari and through hls.js elsewhere. hls.js is NEVER bundled or required: the host supplies it
63
+ // (hls.js 1.7.4 light, `hls.light.min.js`) either here or as the page global window.Hls.
64
+ "HlsLibrary": null,
65
+ // Merged over the player's hls.js defaults ({ autoStartLoad:false, maxBufferLength:30, maxMaxBufferLength:60,
66
+ // capLevelToPlayerSize:true }); host keys win.
67
+ "HlsConfig": {},
68
+ // The quality menu (Auto / one entry per rung / Data saver) — hidden anyway when a source has fewer than two rungs.
69
+ "ShowQuality": true,
70
+ // Offer the Data saver entry (caps adaptive playback at SaverMaxHeight).
71
+ "ShowDataSaver": true,
72
+ // localStorage key the quality pick (and the last bandwidth estimate) persist under; '' / false disables it.
73
+ "QualityStorageKey": "pict-section-video-quality",
74
+ // Data saver ceiling, as a short side in pixels (540 → the 540p rung or the closest one below it).
75
+ "SaverMaxHeight": 540,
76
+
77
+ "CSS": `.psv-root
78
+ {
79
+ display: flex;
80
+ flex-direction: column;
81
+ min-height: 0;
82
+ height: 100%;
83
+ width: 100%;
84
+ box-sizing: border-box;
85
+ background: var(--theme-color-background-panel, #ffffff);
86
+ color: var(--theme-color-text-primary, #1f2733);
87
+ }
88
+ /* Maximized: the player leaves its host box and fills the browser viewport. Esc or the toolbar button restores it. */
89
+ .psv-root.psv-fullscreen
90
+ {
91
+ position: fixed;
92
+ top: 0;
93
+ right: 0;
94
+ bottom: 0;
95
+ left: 0;
96
+ width: 100vw;
97
+ height: 100vh;
98
+ border-radius: 0;
99
+ z-index: 2147483000;
100
+ }
101
+ .psv-stage
102
+ {
103
+ position: relative;
104
+ flex: 1 1 auto;
105
+ min-height: 0;
106
+ display: flex;
107
+ align-items: center;
108
+ justify-content: center;
109
+ overflow: hidden;
110
+ background: #000;
111
+ }
112
+ /* The <video> box fills the stage and letterboxes the frame inside it (object-fit). A width/height:auto box would be
113
+ exactly as big as the rung it decodes (300x150 before metadata), so hls.js capLevelToPlayerSize would measure the
114
+ frame, not the player, and pin Auto at the starting rung; it would also leave the frame unscaled in fullscreen. */
115
+ .psv-video { display: block; width: 100%; height: 100%; object-fit: contain; background: #000; cursor: pointer; }
116
+ .psv-loading, .psv-error
117
+ {
118
+ position: absolute;
119
+ margin: auto;
120
+ text-align: center;
121
+ color: var(--theme-color-text-on-dark, #e8ebf0);
122
+ padding: 1.6rem 1rem;
123
+ font-size: 0.9rem;
124
+ display: flex;
125
+ flex-direction: column;
126
+ align-items: center;
127
+ gap: 0.55rem;
128
+ }
129
+ .psv-error-glyph { font-size: 1.8rem; opacity: 0.7; }
130
+ .psv-controls
131
+ {
132
+ display: flex;
133
+ align-items: center;
134
+ gap: 0.5rem;
135
+ flex: 0 0 auto;
136
+ padding: 0.45rem 0.7rem;
137
+ border-top: 1px solid var(--theme-color-border-light, #e8ebf0);
138
+ background: var(--theme-color-background-secondary, #f7f9fb);
139
+ }
140
+ .psv-spacer { flex: 1 1 auto; }
141
+ .psv-btn
142
+ {
143
+ font-size: 0.8rem;
144
+ font-weight: 600;
145
+ padding: 0.3rem 0.5rem;
146
+ min-width: 2rem;
147
+ border-radius: 6px;
148
+ border: 1px solid var(--theme-color-border-medium, #d5dbe3);
149
+ background: var(--theme-color-background-panel, #ffffff);
150
+ color: var(--theme-color-text-secondary, #45505f);
151
+ cursor: pointer;
152
+ display: inline-flex;
153
+ align-items: center;
154
+ justify-content: center;
155
+ gap: 0.3rem;
156
+ text-decoration: none;
157
+ line-height: 1;
158
+ }
159
+ .psv-btn:hover { border-color: var(--theme-color-brand-primary, #5650e6); color: var(--theme-color-text-primary, #1f2733); text-decoration: none; }
160
+ .psv-btn[disabled] { opacity: 0.45; cursor: default; }
161
+ .psv-rate { font-variant-numeric: tabular-nums; min-width: 2.6rem; }
162
+ .psv-time { font-size: 0.74rem; color: var(--theme-color-text-muted, #6b7686); font-variant-numeric: tabular-nums; min-width: 2.8rem; text-align: center; user-select: none; }
163
+ .psv-seek-wrap { position: relative; flex: 1 1 auto; min-width: 4rem; display: flex; align-items: center; }
164
+ .psv-seek { flex: 1 1 auto; min-width: 4rem; width: 100%; accent-color: var(--theme-color-brand-primary, #5650e6); cursor: pointer; }
165
+ /* The buffered bar: a thin strip along the bottom of the seek track, as wide as the buffered range ahead of the playhead. */
166
+ .psv-buffer-track { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; border-radius: 2px; background: var(--theme-color-border-light, #e8ebf0); pointer-events: none; overflow: hidden; }
167
+ .psv-buffered { display: block; height: 100%; width: 0; background: var(--theme-color-text-muted, #9aa3b0); opacity: 0.6; }
168
+ .psv-volume { width: 4.5rem; flex: 0 0 auto; accent-color: var(--theme-color-brand-primary, #5650e6); cursor: pointer; }
169
+ /* Buffering spinner, centred on the stage while the media waits for data. It fades in after a short delay so a quick
170
+ seek into buffered media never flashes it. */
171
+ .psv-spinner
172
+ {
173
+ position: absolute;
174
+ top: 50%;
175
+ left: 50%;
176
+ width: 2.4rem;
177
+ height: 2.4rem;
178
+ margin: -1.2rem 0 0 -1.2rem;
179
+ border-radius: 50%;
180
+ border: 3px solid rgba(255, 255, 255, 0.25);
181
+ border-top-color: var(--theme-color-text-on-dark, #e8ebf0);
182
+ opacity: 0;
183
+ animation: psv-spin 0.9s linear infinite, psv-spinner-in 0.2s ease-out 0.35s forwards;
184
+ pointer-events: none;
185
+ }
186
+ @keyframes psv-spin { to { transform: rotate(360deg); } }
187
+ @keyframes psv-spinner-in { to { opacity: 1; } }
188
+ /* Quality menu: a button after the rate button that opens a role=menu popover above the control bar. */
189
+ .psv-quality-wrap { position: relative; display: inline-flex; flex: 0 0 auto; }
190
+ .psv-quality-btn { font-variant-numeric: tabular-nums; min-width: 3rem; }
191
+ .psv-quality-menu
192
+ {
193
+ position: absolute;
194
+ right: 0;
195
+ bottom: calc(100% + 6px);
196
+ z-index: 5;
197
+ min-width: 11rem;
198
+ padding: 0.3rem;
199
+ display: flex;
200
+ flex-direction: column;
201
+ gap: 0.1rem;
202
+ border-radius: 8px;
203
+ border: 1px solid var(--theme-color-border-medium, #d5dbe3);
204
+ background: var(--theme-color-background-panel, #ffffff);
205
+ box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18);
206
+ }
207
+ .psv-quality-item
208
+ {
209
+ display: flex;
210
+ align-items: center;
211
+ gap: 0.45rem;
212
+ width: 100%;
213
+ text-align: left;
214
+ font-size: 0.8rem;
215
+ padding: 0.4rem 0.55rem;
216
+ border: 0;
217
+ border-radius: 5px;
218
+ background: transparent;
219
+ color: var(--theme-color-text-secondary, #45505f);
220
+ cursor: pointer;
221
+ white-space: nowrap;
222
+ font-variant-numeric: tabular-nums;
223
+ }
224
+ .psv-quality-item::before { content: ''; width: 0.45rem; height: 0.45rem; border-radius: 50%; flex: 0 0 auto; }
225
+ .psv-quality-item[aria-checked="true"] { color: var(--theme-color-text-primary, #1f2733); font-weight: 600; }
226
+ .psv-quality-item[aria-checked="true"]::before { background: var(--theme-color-brand-primary, #5650e6); }
227
+ .psv-quality-item:hover, .psv-quality-item:focus { background: var(--theme-color-background-secondary, #f2f4f7); outline: none; }
228
+ `
229
+ });