@scarlett-player/ui 1.7.0 → 1.8.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/README.md CHANGED
@@ -11,12 +11,13 @@ npm install @scarlett-player/core @scarlett-player/ui
11
11
  ## Usage
12
12
 
13
13
  ```typescript
14
- import { ScarlettPlayer } from '@scarlett-player/core';
14
+ import { createPlayer } from '@scarlett-player/core';
15
15
  import { createHLSPlugin } from '@scarlett-player/hls';
16
16
  import { uiPlugin } from '@scarlett-player/ui';
17
17
 
18
- const player = new ScarlettPlayer({
18
+ const player = await createPlayer({
19
19
  container: document.getElementById('player'),
20
+ src: 'https://example.com/video.m3u8',
20
21
  plugins: [
21
22
  createHLSPlugin(),
22
23
  uiPlugin({
@@ -28,7 +29,11 @@ const player = new ScarlettPlayer({
28
29
 
29
30
  ## Features
30
31
 
32
+ - Responsive control bar: measures itself and moves low-priority controls into
33
+ an overflow tray rather than rendering them past a narrow player's edge
31
34
  - Play/pause, seek, volume controls
35
+ - Big play button over the poster, shown until playback first starts and again
36
+ as Replay when it ends (`bigPlayButton: false` turns it off)
32
37
  - Fullscreen toggle
33
38
  - Picture-in-Picture toggle (disabled until media metadata is loaded; hidden
34
39
  when the browser has no PiP support; Safari webkit presentation mode
@@ -42,6 +47,85 @@ const player = new ScarlettPlayer({
42
47
  - Customizable theming
43
48
  - Auto-hide controls
44
49
 
50
+ ## Responsive control bar
51
+
52
+ The bar is a single non-wrapping row of fixed-width controls, and both known
53
+ hosts clip what does not fit. On a 390px phone with a 17-slot layout that meant
54
+ the whole right-hand group (settings, captions, cast, PiP, fullscreen) rendered
55
+ off canvas: captions and playback speed were not broken, they were unreachable.
56
+
57
+ The bar now measures itself and moves the least important controls into a tray
58
+ behind a "More controls" button. It runs at first paint, whenever the player is
59
+ resized, and whenever a control shows or hides itself.
60
+
61
+ ```typescript
62
+ uiPlugin({
63
+ responsive: true, // Default: true
64
+ priority: { share: 'never' }, // Pin a control, or re-rank one
65
+ });
66
+ ```
67
+
68
+ `responsive: false` restores the pre-1.8 behaviour exactly: no measuring, no
69
+ observer, no tray button, no extra DOM.
70
+
71
+ ### Priority
72
+
73
+ Lower ranks leave first. Ties go to the control that is later in the layout.
74
+
75
+ | Slot | Rank | Leaves to |
76
+ |---|---|---|
77
+ | `bandwidth-indicator` | 0 | hidden (a status glyph, not an action) |
78
+ | `skip-backward`, `skip-forward` | 1 | tray (gestures cover the same seek on touch) |
79
+ | `pip` | 2 | tray |
80
+ | any registered control (`share`, `chapters`, the playlist buttons, ...) | 3 | tray |
81
+ | `chromecast`, `airplay` | 4 | tray (AirPlay is how an iPhone reaches a television, so it is never hidden) |
82
+ | `volume` | 5 | tray (iOS `video.volume` is read only) |
83
+ | `captions` | 6 | tray (also lives inside the settings menu) |
84
+ | `quality` | 6 | hidden (its menu is anchored in the bar, and the settings menu carries a Quality row, so `quality` needs `settings` in the layout) |
85
+ | `time` | 7 | hidden (a readout in a tray says nothing; the scrub tooltip still shows position) |
86
+ | `play`, `live-indicator`, `settings`, `fullscreen`, `spacer` | never | stays |
87
+
88
+ Settings never moves, so playback speed and captions are at most two taps away
89
+ at every width.
90
+
91
+ Because `quality` hides, a layout with `quality` and no `settings` would lose
92
+ quality selection entirely below the width where the bar fits. `uiPlugin()`
93
+ throws on that layout unless `quality` is pinned
94
+ (`priority: { quality: 'never' }`) or `responsive` is off.
95
+
96
+ ### The floor
97
+
98
+ The controls that never move (play, settings, the tray button and fullscreen)
99
+ need 188px of inner width, which is about 212px of player width, or about 280px
100
+ on a live stream where the live indicator also stays. Below that the bar clips
101
+ again, exactly as it did before.
102
+
103
+ ### Menus
104
+
105
+ The settings and quality menus are bounded to the player's height
106
+ (`--sp-menu-max-height`, written by the plugin) and scroll inside it. Without
107
+ that, the Speed sub-panel is 253px tall against a 211px portrait phone player
108
+ and loses its Back header and its first three speeds to the host's
109
+ `overflow: hidden`.
110
+
111
+ ## Layout
112
+
113
+ `controls` is the order of slots in the bar. The default is:
114
+
115
+ ```typescript
116
+ uiPlugin({
117
+ controls: [
118
+ 'play', 'skip-backward', 'skip-forward', 'volume', 'time',
119
+ 'live-indicator', 'bandwidth-indicator', 'spacer', 'settings',
120
+ 'captions', 'chromecast', 'airplay', 'pip', 'fullscreen',
121
+ ],
122
+ });
123
+ ```
124
+
125
+ Any id a plugin registers through the control registry (`share`, `chapters`,
126
+ `playlist-previous`, `playlist-next`, ...) can be placed in the same list. A
127
+ control whose plugin is not loaded is skipped.
128
+
45
129
  ## Keyboard Shortcuts
46
130
 
47
131
  | Key | Action |
@@ -69,6 +153,24 @@ uiPlugin({
69
153
  });
70
154
  ```
71
155
 
156
+ ## Big Play Button
157
+
158
+ ```typescript
159
+ uiPlugin({
160
+ bigPlayButton: false, // Default: true
161
+ });
162
+ ```
163
+
164
+ On by default because it is the only play affordance on the picture itself: a
165
+ mouse click on the video surface only reveals the control bar, and touch taps
166
+ belong to `@scarlett-player/gestures`, so a poster with the button off leaves
167
+ the viewer hunting for the small button in the bar. It is a real `<button>`
168
+ with an `aria-label`, sized past the 44 px minimum target, coloured with
169
+ `--sp-accent`, and it sits above the gestures surface so a tap starts playback
170
+ instead of toggling the controls.
171
+
172
+ Turn it off when the host page draws its own play affordance over the player.
173
+
72
174
  ## License
73
175
 
74
176
  MIT