@mattebox/player 0.15.0 → 0.16.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.
Files changed (112) hide show
  1. package/dist/cdn/mattebox-player.min.js +3 -3
  2. package/dist/controls/chapters.d.ts +2 -8
  3. package/dist/controls/chapters.d.ts.map +1 -1
  4. package/dist/controls/chapters.js.map +1 -1
  5. package/dist/controls/cues.d.ts.map +1 -1
  6. package/dist/controls/cues.js +2 -2
  7. package/dist/controls/cues.js.map +1 -1
  8. package/dist/controls/icons.d.ts +1 -1
  9. package/dist/controls/icons.d.ts.map +1 -1
  10. package/dist/controls/icons.js +2 -0
  11. package/dist/controls/icons.js.map +1 -1
  12. package/dist/element.d.ts +19 -2
  13. package/dist/element.d.ts.map +1 -1
  14. package/dist/element.js +46 -6
  15. package/dist/element.js.map +1 -1
  16. package/dist/elements/casting.d.ts +3 -0
  17. package/dist/elements/casting.d.ts.map +1 -1
  18. package/dist/elements/casting.js +12 -15
  19. package/dist/elements/casting.js.map +1 -1
  20. package/dist/elements/control-bar.d.ts +16 -2
  21. package/dist/elements/control-bar.d.ts.map +1 -1
  22. package/dist/elements/control-bar.js +23 -2
  23. package/dist/elements/control-bar.js.map +1 -1
  24. package/dist/elements/drm-badge.js +1 -1
  25. package/dist/elements/error-screen.js +1 -1
  26. package/dist/elements/live-button.js +1 -1
  27. package/dist/elements/shared.js +3 -3
  28. package/dist/elements/speed-menu.d.ts.map +1 -1
  29. package/dist/elements/speed-menu.js +1 -1
  30. package/dist/elements/speed-menu.js.map +1 -1
  31. package/dist/elements/subtitles-menu.d.ts.map +1 -1
  32. package/dist/elements/subtitles-menu.js +29 -6
  33. package/dist/elements/subtitles-menu.js.map +1 -1
  34. package/dist/es2015/controls/cues.js +2 -2
  35. package/dist/es2015/controls/icons.js +2 -0
  36. package/dist/es2015/element.js +63 -25
  37. package/dist/es2015/elements/casting.js +13 -15
  38. package/dist/es2015/elements/control-bar.js +23 -2
  39. package/dist/es2015/elements/drm-badge.js +1 -1
  40. package/dist/es2015/elements/error-screen.js +1 -1
  41. package/dist/es2015/elements/live-button.js +1 -1
  42. package/dist/es2015/elements/shared.js +3 -3
  43. package/dist/es2015/elements/speed-menu.js +1 -1
  44. package/dist/es2015/elements/subtitles-menu.js +29 -6
  45. package/dist/es2015/locales/ar.js +2 -0
  46. package/dist/es2015/locales/ca.js +2 -0
  47. package/dist/es2015/locales/de.js +2 -0
  48. package/dist/es2015/locales/es.js +2 -0
  49. package/dist/es2015/locales/fr.js +2 -0
  50. package/dist/es2015/locales/hi.js +2 -0
  51. package/dist/es2015/locales/it.js +2 -0
  52. package/dist/es2015/locales/ja.js +2 -0
  53. package/dist/es2015/locales/ko.js +2 -0
  54. package/dist/es2015/locales/pt.js +2 -0
  55. package/dist/es2015/locales/zh.js +2 -0
  56. package/dist/es2015/presets.js +2 -1
  57. package/dist/es2015/style.js +1 -1
  58. package/dist/host.d.ts +13 -1
  59. package/dist/host.d.ts.map +1 -1
  60. package/dist/host.js.map +1 -1
  61. package/dist/index.d.ts +2 -2
  62. package/dist/index.d.ts.map +1 -1
  63. package/dist/locales/ar.d.ts +2 -0
  64. package/dist/locales/ar.d.ts.map +1 -1
  65. package/dist/locales/ar.js +2 -0
  66. package/dist/locales/ar.js.map +1 -1
  67. package/dist/locales/ca.d.ts +2 -0
  68. package/dist/locales/ca.d.ts.map +1 -1
  69. package/dist/locales/ca.js +2 -0
  70. package/dist/locales/ca.js.map +1 -1
  71. package/dist/locales/de.d.ts +2 -0
  72. package/dist/locales/de.d.ts.map +1 -1
  73. package/dist/locales/de.js +2 -0
  74. package/dist/locales/de.js.map +1 -1
  75. package/dist/locales/es.d.ts +2 -0
  76. package/dist/locales/es.d.ts.map +1 -1
  77. package/dist/locales/es.js +2 -0
  78. package/dist/locales/es.js.map +1 -1
  79. package/dist/locales/fr.d.ts +2 -0
  80. package/dist/locales/fr.d.ts.map +1 -1
  81. package/dist/locales/fr.js +2 -0
  82. package/dist/locales/fr.js.map +1 -1
  83. package/dist/locales/hi.d.ts +2 -0
  84. package/dist/locales/hi.d.ts.map +1 -1
  85. package/dist/locales/hi.js +2 -0
  86. package/dist/locales/hi.js.map +1 -1
  87. package/dist/locales/it.d.ts +2 -0
  88. package/dist/locales/it.d.ts.map +1 -1
  89. package/dist/locales/it.js +2 -0
  90. package/dist/locales/it.js.map +1 -1
  91. package/dist/locales/ja.d.ts +2 -0
  92. package/dist/locales/ja.d.ts.map +1 -1
  93. package/dist/locales/ja.js +2 -0
  94. package/dist/locales/ja.js.map +1 -1
  95. package/dist/locales/ko.d.ts +2 -0
  96. package/dist/locales/ko.d.ts.map +1 -1
  97. package/dist/locales/ko.js +2 -0
  98. package/dist/locales/ko.js.map +1 -1
  99. package/dist/locales/pt.d.ts +2 -0
  100. package/dist/locales/pt.d.ts.map +1 -1
  101. package/dist/locales/pt.js +2 -0
  102. package/dist/locales/pt.js.map +1 -1
  103. package/dist/locales/zh.d.ts +2 -0
  104. package/dist/locales/zh.d.ts.map +1 -1
  105. package/dist/locales/zh.js +2 -0
  106. package/dist/locales/zh.js.map +1 -1
  107. package/dist/messages.d.ts +4 -0
  108. package/dist/messages.d.ts.map +1 -1
  109. package/dist/presets.js +2 -1
  110. package/dist/presets.js.map +1 -1
  111. package/dist/style.js +1 -1
  112. package/package.json +3 -3
@@ -73,6 +73,8 @@ var MbxControlBar = class extends Component {
73
73
  super();
74
74
  this.timer = void 0;
75
75
  this.keyboard = false;
76
+ this.touch = false;
77
+ this.shownAtPress = false;
76
78
  this.cues = null;
77
79
  this.screen = null;
78
80
  this.resizer = null;
@@ -152,6 +154,7 @@ var MbxControlBar = class extends Component {
152
154
  }
153
155
  held(player) {
154
156
  if (shownPaused(player, ["switching"])) return true;
157
+ if (player.hasAttribute("casting")) return true;
155
158
  if (this.querySelector("[open]") !== null) return true;
156
159
  if (!this.keyboard) return false;
157
160
  const active = this.getRootNode().activeElement;
@@ -171,6 +174,12 @@ var MbxControlBar = class extends Component {
171
174
  }
172
175
  this.idle(player, true);
173
176
  }
177
+ /** Hides the bar now, as a tap asks: the next input shows it again. */
178
+ rest(player) {
179
+ clearTimeout(this.timer);
180
+ this.timer = void 0;
181
+ this.idle(player, true);
182
+ }
174
183
  wake(player) {
175
184
  clearTimeout(this.timer);
176
185
  this.idle(player, false);
@@ -192,6 +201,7 @@ var MbxControlBar = class extends Component {
192
201
  }
193
202
  key(player, event) {
194
203
  this.keyboard = true;
204
+ this.touch = false;
195
205
  this.wake(player);
196
206
  if (event.defaultPrevented || event.altKey || event.ctrlKey || event.metaKey) return;
197
207
  const video = player.media;
@@ -262,13 +272,24 @@ var MbxControlBar = class extends Component {
262
272
  this.keyboard = false;
263
273
  this.wake(player);
264
274
  };
275
+ const press = (event) => {
276
+ this.touch = event.pointerType === "touch";
277
+ this.shownAtPress = !this.hasAttribute("idle");
278
+ pointer();
279
+ };
265
280
  const key = (event) => {
266
281
  this.key(player, event);
267
282
  };
268
283
  const click = (event) => {
269
- if (event.composedPath()[0] === videoOf(player)) toggle(video);
284
+ if (event.composedPath()[0] !== videoOf(player)) return;
285
+ if (this.touch && !this.hasAttribute("tap-plays") && !player.hasAttribute("casting")) {
286
+ if (this.shownAtPress) this.rest(player);
287
+ return;
288
+ }
289
+ toggle(video);
270
290
  };
271
- this.listen(player, ["pointermove", "pointerdown"], pointer);
291
+ this.listen(player, ["pointermove"], pointer);
292
+ this.listen(player, ["pointerdown"], press);
272
293
  player.addEventListener("keydown", key);
273
294
  player.addEventListener("click", click);
274
295
  this.keep(() => {
@@ -1 +1 @@
1
- {"version":3,"file":"control-bar.js","names":[],"sources":["../../src/elements/control-bar.ts"],"sourcesContent":["/**\n * <mbx-control-bar>: an overlay over the bottom of the video that lays its\n * children out in two rows, the seek row over the buttons row. A child\n * with `slot=\"seek\"` sits in the seek row; everything else in the buttons\n * row, in its order, and an <mbx-spacer> pushes what follows to the right.\n *\n * The bar owns what no one control can: the idle fade, the shortcuts, the\n * click on the video, and the subtitles lifted above it. It sets `idle` on\n * itself and on the player while it hides.\n *\n * The fade is one timer. Any activity, a pointer moving or pressing, a\n * key, playback starting, re-arms it for `idle-ms`, and when it fires the\n * bar hides unless something it can know for certain holds it: the video\n * is paused, a descendant carries `open`, or keyboard focus is inside it,\n * where keyboard means the last input was a key and not a pointer.\n * Whether the pointer is over the player is never tracked: that goes\n * stale when the pointer leaves without a move the player sees.\n *\n * The shortcuts listen on the player, so they hear every key pressed\n * inside it, and only there: Space and `k` toggle play, `m` mutes, `f`\n * toggles fullscreen, the arrows seek by `seek-step`. The media keys a\n * remote or a keyboard sends do the same: play and pause, Stop pauses,\n * fast forward and rewind seek by `seek-step`. A seeking key fires\n * `seekkey` on the player first, which a seek bar may take to aim instead.\n * The bar is the one owner of the keys that work anywhere in the player:\n * it listens last, so the focused control, and a spatial navigation in\n * the capture phase, decide before it. Space is left to a\n * focused button, which is its own. A key another handler prevented is\n * left alone. A click on the video toggles play.\n * Fullscreen goes on the player itself, so the bar comes along.\n *\n * A narrow bar collapses the buttons row by `priority`: each child carries\n * a number, its own attribute or the default for its tag, and the bar\n * marks the highest numbers `collapsed` one at a time until the row fits\n * with a little slack, from the right among equals. Zero, the default for\n * anything unlisted, never collapses: play and fullscreen stay whatever\n * the width. The mark is an attribute and the hiding is one `::slotted`\n * rule here, so a page styles or overrides it by the tag. The volume's\n * slider is a candidate of its own, and counts at its unfolded width, so\n * the row is sized for what the pointer will make of it.\n */\n\nimport type { CueLift } from '../controls/cues.js';\nimport { cueLift, cueStyle } from '../controls/cues.js';\nimport type { Fullscreen } from '../controls/fullscreen.js';\nimport { fullscreen } from '../controls/fullscreen.js';\nimport type { PlayerHost } from '../host.js';\nimport { videoOf } from '../host.js';\nimport {\n AIRPLAY_BUTTON,\n AUDIO_MENU,\n CHAPTERS_MENU,\n DRM_BADGE,\n MUTE_BUTTON,\n PIP_BUTTON,\n QUALITY_MENU,\n SCAN_BUTTON,\n SKIP_BUTTON,\n SPACER,\n SPEED_MENU,\n SUBTITLES_MENU,\n VIDEO_MENU,\n VOLUME,\n VOLUME_SLIDER,\n} from '../tags.js';\nimport { Component } from './component.js';\nimport STYLE from './control-bar.css?inline';\nimport { number, shownPaused, style } from './shared.js';\n\nconst IDLE_MS = 3000;\nconst SEEK_STEP = 5;\n\n/**\n * What goes first when the row is too narrow, by tag: the scans, which\n * suit a TV remote more than a small screen; then the slider, which takes\n * the most room for the least; then the diagnostics, the lock and the\n * menus a viewer rarely opens; then the menus for the picture and the\n * sound; then the skips; then the mute, the subtitles and the video\n * menu. The subtitles and video menus go last of the menus because a\n * viewer may need them: the video menu holds the sign-language version.\n * The diagnostics is another package's, named here as a string. A\n * `priority` attribute on the control replaces its default.\n */\nconst PRIORITY: Readonly<Record<string, number>> = {\n [SCAN_BUTTON]: 6,\n [VOLUME_SLIDER]: 5,\n 'mbx-diagnostics': 4,\n [DRM_BADGE]: 4,\n [SPEED_MENU]: 4,\n [CHAPTERS_MENU]: 4,\n [AUDIO_MENU]: 3,\n [QUALITY_MENU]: 3,\n [PIP_BUTTON]: 3,\n [AIRPLAY_BUTTON]: 2,\n [SKIP_BUTTON]: 2,\n [SUBTITLES_MENU]: 1,\n [VIDEO_MENU]: 1,\n [VOLUME]: 1,\n [MUTE_BUTTON]: 1,\n};\n\n/** The width the volume group unfolds its slider to, in em, from volume.css: what a folded slider is counted at. */\nconst SLIDER_WIDTH = 5;\n\n/** Room kept between the last button and the edge, in em, so nothing sits flush against it. */\nconst SLACK = 0.5;\n\ninterface Candidate {\n readonly node: Element;\n /** The bar child it sits in, for the order among equals. */\n readonly index: number;\n readonly priority: number;\n}\n\nfunction shown(node: Element): boolean {\n return node.getClientRects().length > 0;\n}\n\n/** The slider inside a volume group child, when it has one. */\nfunction slider(child: Element): Element | null {\n return child.localName === VOLUME ? child.querySelector(VOLUME_SLIDER) : null;\n}\n\n/** A child's priority: its attribute, else its tag's default, else zero. */\nfunction priority(child: Element): number {\n const own = child.getAttribute('priority');\n if (own !== null) {\n const value = Number(own);\n return Number.isFinite(value) && value > 0 ? value : 0;\n }\n return PRIORITY[child.localName] ?? 0;\n}\n\nfunction end(video: HTMLVideoElement): number {\n if (Number.isFinite(video.duration)) return video.duration;\n const ranges = video.seekable;\n return ranges.length > 0 ? ranges.end(ranges.length - 1) : video.currentTime;\n}\n\nfunction toggle(video: HTMLVideoElement): void {\n if (video.paused) video.play().catch(() => undefined);\n else video.pause();\n}\n\nexport class MbxControlBar extends Component {\n static get observedAttributes(): readonly string[] {\n return ['idle-ms', 'seek-step'];\n }\n\n declare private readonly seekRow: HTMLDivElement;\n declare private readonly buttonsRow: HTMLDivElement;\n declare private readonly buttons: HTMLSlotElement;\n declare private timer: ReturnType<typeof setTimeout> | undefined;\n /** Fires on a width change of the buttons row, so the collapse follows the page's layout. */\n declare private resizer: ResizeObserver | null;\n /** Whether the last input was a key, so focus inside holds the bar. */\n declare private keyboard: boolean;\n declare private cues: CueLift | null;\n declare private screen: Fullscreen | null;\n\n constructor() {\n super();\n this.timer = undefined;\n this.keyboard = false;\n this.cues = null;\n this.screen = null;\n this.resizer = null;\n const root = this.attachShadow({ mode: 'open' });\n this.seekRow = document.createElement('div');\n this.seekRow.setAttribute('part', 'row seek-row');\n const seek = document.createElement('slot');\n seek.name = 'seek';\n this.seekRow.append(seek);\n this.buttonsRow = document.createElement('div');\n this.buttonsRow.setAttribute('part', 'row buttons-row');\n this.buttons = document.createElement('slot');\n this.buttonsRow.append(this.buttons);\n root.append(style(STYLE), this.seekRow, this.buttonsRow);\n }\n\n /**\n * What the buttons need: their widths and their margins, which are the\n * gaps between them, the spacer aside since it takes what is left, and a\n * folded slider at the width it unfolds to. The row's own width says nothing, because the\n * spacer fills it whatever the buttons take.\n */\n /** The bar's em in pixels: its sizes follow the player's font size. */\n private em(): number {\n return Number.parseFloat(getComputedStyle(this).fontSize) || 16;\n }\n\n private needed(children: readonly Element[]): number {\n let sum = 0;\n for (const child of children) {\n if (child.localName === SPACER || !shown(child)) continue;\n const margins = getComputedStyle(child);\n sum += child.getBoundingClientRect().width;\n sum += Number.parseFloat(margins.marginLeft) + Number.parseFloat(margins.marginRight);\n const folded = slider(child);\n if (folded !== null && shown(folded)) {\n sum += Math.max(0, SLIDER_WIDTH * this.em() - folded.getBoundingClientRect().width);\n }\n }\n return sum;\n }\n\n /**\n * Collapses the buttons row to its width. Everything is shown first, so\n * a wider bar gets its controls back, then the highest priorities go one\n * at a time while the buttons need more than the row has, less the\n * slack. Each step lays the row out again; a bar carries a dozen\n * controls, so that is cheap.\n */\n private collapse(): void {\n const children = this.buttons.assignedElements();\n const candidates: Candidate[] = [];\n for (const [index, child] of children.entries()) {\n child.removeAttribute('collapsed');\n const inner = slider(child);\n inner?.removeAttribute('collapsed');\n // A nested slider goes before its group, so it sorts as if it sat\n // after it. What is not shown, by its own `hidden` or a page's rule,\n // takes no room, so marking it would hide nothing and say something\n // false.\n if (inner !== null && shown(inner)) {\n candidates.push({ node: inner, index: index + 0.5, priority: priority(inner) });\n }\n if (shown(child)) candidates.push({ node: child, index, priority: priority(child) });\n }\n candidates.sort((a, b) => b.priority - a.priority || b.index - a.index);\n const room = this.buttonsRow.clientWidth - SLACK * this.em();\n for (const { node, priority: level } of candidates) {\n if (level === 0) return;\n if (this.needed(children) <= room) return;\n node.setAttribute('collapsed', '');\n }\n }\n\n /** From the first row's top to the bar's bottom: what the bar covers of the picture. */\n private covered(): { top: number; bottom: number } {\n return {\n top: this.seekRow.getBoundingClientRect().top,\n bottom: this.getBoundingClientRect().bottom,\n };\n }\n\n private held(player: PlayerHost): boolean {\n if (shownPaused(player, ['switching'])) return true;\n if (this.querySelector('[open]') !== null) return true;\n if (!this.keyboard) return false;\n const active = (this.getRootNode() as Document | ShadowRoot).activeElement;\n return active !== null && this.contains(active);\n }\n\n private idle(player: PlayerHost, on: boolean): void {\n if (this.hasAttribute('idle') === on) return;\n this.toggleAttribute('idle', on);\n player.toggleAttribute('idle', on);\n this.cues?.lifted(!on);\n }\n\n private sleep(player: PlayerHost): void {\n this.timer = undefined;\n // A hold is checked again later: a menu closes and a pause ends without\n // an event the bar hears.\n if (this.held(player)) {\n this.timer = setTimeout(() => this.sleep(player), number(this, 'idle-ms', IDLE_MS));\n return;\n }\n this.idle(player, true);\n }\n\n private wake(player: PlayerHost): void {\n clearTimeout(this.timer);\n this.idle(player, false);\n this.timer = setTimeout(() => this.sleep(player), number(this, 'idle-ms', IDLE_MS));\n }\n\n /**\n * A seeking key: `seekkey` on the player first, cancellable, with the\n * seconds in `detail.by`. A seek bar under `key-mode=\"preview\"` takes it\n * to aim instead. Nobody took it: the playhead moves now.\n */\n private seekBy(player: PlayerHost, by: number): void {\n const asked = new CustomEvent('seekkey', { detail: { by }, cancelable: true });\n if (!player.dispatchEvent(asked)) return;\n const video = player.media;\n video.currentTime = Math.min(end(video), Math.max(0, video.currentTime + by));\n }\n\n private key(player: PlayerHost, event: KeyboardEvent): void {\n this.keyboard = true;\n this.wake(player);\n if (event.defaultPrevented || event.altKey || event.ctrlKey || event.metaKey) return;\n const video = player.media;\n const onButton = event.composedPath()[0] instanceof HTMLButtonElement;\n switch (event.key) {\n case ' ':\n if (onButton) return;\n toggle(video);\n break;\n case 'k':\n case 'K':\n toggle(video);\n break;\n case 'm':\n case 'M':\n video.muted = !video.muted;\n break;\n case 'f':\n case 'F':\n this.screen?.toggle();\n break;\n // The media keys, which remotes and many keyboards send. UI Events\n // KeyboardEvent key values, Multimedia keys.\n case 'MediaPlayPause':\n toggle(video);\n break;\n case 'MediaPlay':\n void video.play().catch(() => undefined);\n break;\n // Stop pauses: the source stays, as a viewer expects on a remote.\n case 'MediaPause':\n case 'MediaStop':\n video.pause();\n break;\n case 'ArrowLeft':\n case 'MediaRewind':\n this.seekBy(player, -number(this, 'seek-step', SEEK_STEP));\n break;\n case 'ArrowRight':\n case 'MediaFastForward':\n this.seekBy(player, number(this, 'seek-step', SEEK_STEP));\n break;\n default:\n return;\n }\n event.preventDefault();\n }\n\n protected override attach(player: PlayerHost): void {\n const video = player.media;\n cueStyle();\n this.cues = cueLift(video, player, () => this.covered());\n const screen = fullscreen(player, video);\n this.screen = screen;\n const reflect = (): void => {\n player.toggleAttribute('fullscreen', screen.active());\n };\n this.keep(screen.watch(reflect));\n reflect();\n // `menu` while one of the bar's menus is open, by its `open` attribute:\n // the bar then stacks above the screens and hides its tooltips.\n const menus = new MutationObserver(() => {\n this.toggleAttribute('menu', this.querySelector('[open]') !== null);\n });\n menus.observe(this, { subtree: true, attributes: true, attributeFilter: ['open'] });\n this.keep(() => {\n menus.disconnect();\n this.removeAttribute('menu');\n });\n\n const pointer = (): void => {\n this.keyboard = false;\n this.wake(player);\n };\n const key = (event: Event): void => {\n this.key(player, event as KeyboardEvent);\n };\n const click = (event: Event): void => {\n // The video and nothing else: a control handles its own click.\n if (event.composedPath()[0] === videoOf(player)) toggle(video);\n };\n this.listen(player, ['pointermove', 'pointerdown'], pointer);\n player.addEventListener('keydown', key);\n player.addEventListener('click', click);\n this.keep(() => {\n player.removeEventListener('keydown', key);\n player.removeEventListener('click', click);\n });\n this.listen(video, ['play', 'pause', 'ended'], () => {\n // The load of a switch pauses and plays the video, and the viewer did neither.\n if (!player.hasAttribute('switching')) this.wake(player);\n });\n this.wake(player);\n this.cues.lifted(true);\n\n // The row's width, its children, and what they hide or reprioritise on\n // their own: each can change what fits. `collapsed` is left out of the\n // filter, since the bar writes it.\n const collapse = (): void => {\n this.collapse();\n };\n this.listen(this.buttons, ['slotchange'], collapse);\n this.observe(this, ['hidden', 'priority', 'slot'], collapse, true);\n if (typeof ResizeObserver !== 'undefined') {\n this.resizer = new ResizeObserver(collapse);\n this.resizer.observe(this.buttonsRow);\n }\n collapse();\n }\n\n protected override detach(player: PlayerHost): void {\n clearTimeout(this.timer);\n this.timer = undefined;\n this.resizer?.disconnect();\n this.resizer = null;\n for (const child of this.buttons.assignedElements()) {\n child.removeAttribute('collapsed');\n slider(child)?.removeAttribute('collapsed');\n }\n this.cues?.dispose();\n this.cues = null;\n this.screen = null;\n this.removeAtt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KAAK,MAAM;EAChB,KAAK,KAAK,OAAO,IAAI;EAKrB,MAAM,iBAAuB;GAC3B,KAAK,SAAS;EAChB;EACA,KAAK,OAAO,KAAK,SAAS,CAAC,YAAY,GAAG,QAAQ;EAClD,KAAK,QAAQ,MAAM;GAAC;GAAU;GAAY;EAAM,GAAG,UAAU,IAAI;EACjE,IAAI,OAAO,mBAAmB,aAAa;GACzC,KAAK,UAAU,IAAI,eAAe,QAAQ;GAC1C,KAAK,QAAQ,QAAQ,KAAK,UAAU;EACtC;EACA,SAAS;CACX;CAEmB,OAAO,QAA0B;EAClD,aAAa,KAAK,KAAK;EACvB,KAAK,QAAQ,KAAA;EACb,KAAK,SAAS,WAAW;EACzB,KAAK,UAAU;EACf,KAAK,MAAM,SAAS,KAAK,QAAQ,iBAAiB,GAAG;GACnD,MAAM,gBAAgB,WAAW;GACjC,OAAO,KAAK,CAAC,EAAE,gBAAgB,WAAW;EAC5C;EACA,KAAK,MAAM,QAAQ;EACnB,KAAK,OAAO;EACZ,KAAK,SAAS;EACd,KAAK,gBAAgB,MAAM;EAC3B,OAAO,gBAAgB,MAAM;EAC7B,OAAO,gBAAgB,YAAY;CACrC;AACF"}
1
+ {"version":3,"file":"control-bar.js","names":[],"sources":["../../src/elements/control-bar.ts"],"sourcesContent":["/**\n * <mbx-control-bar>: an overlay over the bottom of the video that lays its\n * children out in two rows, the seek row over the buttons row. A child\n * with `slot=\"seek\"` sits in the seek row; everything else in the buttons\n * row, in its order, and an <mbx-spacer> pushes what follows to the right.\n *\n * The bar owns what no one control can: the idle fade, the shortcuts, the\n * click on the video, and the subtitles lifted above it. It sets `idle` on\n * itself and on the player while it hides.\n *\n * The fade is one timer. Any activity, a pointer moving or pressing, a\n * key, playback starting, re-arms it for `idle-ms`, and when it fires the\n * bar hides unless something it can know for certain holds it: the video\n * is paused, a device plays in its place, a descendant carries `open`, or\n * keyboard focus is inside it, where keyboard means the last input was a\n * key and not a pointer.\n * Whether the pointer is over the player is never tracked: that goes\n * stale when the pointer leaves without a move the player sees.\n *\n * The shortcuts listen on the player, so they hear every key pressed\n * inside it, and only there: Space and `k` toggle play, `m` mutes, `f`\n * toggles fullscreen, the arrows seek by `seek-step`. The media keys a\n * remote or a keyboard sends do the same: play and pause, Stop pauses,\n * fast forward and rewind seek by `seek-step`. A seeking key fires\n * `seekkey` on the player first, which a seek bar may take to aim instead.\n * The bar is the one owner of the keys that work anywhere in the player:\n * it listens last, so the focused control, and a spatial navigation in\n * the capture phase, decide before it. Space is left to a\n * focused button, which is its own. A key another handler prevented is\n * left alone. A click on the video toggles play.\n *\n * A tap is not a click. A finger on the picture shows the bar while it is\n * hidden and hides it while it shows, and never plays or pauses, as on a\n * phone's own players. The pointer's `pointerType` tells the two apart,\n * not the device, since a laptop can have both. `tap-plays` gives a tap\n * the click's play and pause back. During a cast the bar stays, so a tap\n * plays and pauses there too.\n * Fullscreen goes on the player itself, so the bar comes along.\n *\n * A narrow bar collapses the buttons row by `priority`: each child carries\n * a number, its own attribute or the default for its tag, and the bar\n * marks the highest numbers `collapsed` one at a time until the row fits\n * with a little slack, from the right among equals. Zero, the default for\n * anything unlisted, never collapses: play and fullscreen stay whatever\n * the width. The mark is an attribute and the hiding is one `::slotted`\n * rule here, so a page styles or overrides it by the tag. The volume's\n * slider is a candidate of its own, and counts at its unfolded width, so\n * the row is sized for what the pointer will make of it.\n */\n\nimport type { CueLift } from '../controls/cues.js';\nimport { cueLift, cueStyle } from '../controls/cues.js';\nimport type { Fullscreen } from '../controls/fullscreen.js';\nimport { fullscreen } from '../controls/fullscreen.js';\nimport type { PlayerHost } from '../host.js';\nimport { videoOf } from '../host.js';\nimport {\n AIRPLAY_BUTTON,\n AUDIO_MENU,\n CHAPTERS_MENU,\n DRM_BADGE,\n MUTE_BUTTON,\n PIP_BUTTON,\n QUALITY_MENU,\n SCAN_BUTTON,\n SKIP_BUTTON,\n SPACER,\n SPEED_MENU,\n SUBTITLES_MENU,\n VIDEO_MENU,\n VOLUME,\n VOLUME_SLIDER,\n} from '../tags.js';\nimport { Component } from './component.js';\nimport STYLE from './control-bar.css?inline';\nimport { number, shownPaused, style } from './shared.js';\n\nconst IDLE_MS = 3000;\nconst SEEK_STEP = 5;\n\n/**\n * What goes first when the row is too narrow, by tag: the scans, which\n * suit a TV remote more than a small screen; then the slider, which takes\n * the most room for the least; then the diagnostics, the lock and the\n * menus a viewer rarely opens; then the menus for the picture and the\n * sound; then the skips; then the mute, the subtitles and the video\n * menu. The subtitles and video menus go last of the menus because a\n * viewer may need them: the video menu holds the sign-language version.\n * The diagnostics is another package's, named here as a string. A\n * `priority` attribute on the control replaces its default.\n */\nconst PRIORITY: Readonly<Record<string, number>> = {\n [SCAN_BUTTON]: 6,\n [VOLUME_SLIDER]: 5,\n 'mbx-diagnostics': 4,\n [DRM_BADGE]: 4,\n [SPEED_MENU]: 4,\n [CHAPTERS_MENU]: 4,\n [AUDIO_MENU]: 3,\n [QUALITY_MENU]: 3,\n [PIP_BUTTON]: 3,\n [AIRPLAY_BUTTON]: 2,\n [SKIP_BUTTON]: 2,\n [SUBTITLES_MENU]: 1,\n [VIDEO_MENU]: 1,\n [VOLUME]: 1,\n [MUTE_BUTTON]: 1,\n};\n\n/** The width the volume group unfolds its slider to, in em, from volume.css: what a folded slider is counted at. */\nconst SLIDER_WIDTH = 5;\n\n/** Room kept between the last button and the edge, in em, so nothing sits flush against it. */\nconst SLACK = 0.5;\n\ninterface Candidate {\n readonly node: Element;\n /** The bar child it sits in, for the order among equals. */\n readonly index: number;\n readonly priority: number;\n}\n\nfunction shown(node: Element): boolean {\n return node.getClientRects().length > 0;\n}\n\n/** The slider inside a volume group child, when it has one. */\nfunction slider(child: Element): Element | null {\n return child.localName === VOLUME ? child.querySelector(VOLUME_SLIDER) : null;\n}\n\n/** A child's priority: its attribute, else its tag's default, else zero. */\nfunction priority(child: Element): number {\n const own = child.getAttribute('priority');\n if (own !== null) {\n const value = Number(own);\n return Number.isFinite(value) && value > 0 ? value : 0;\n }\n return PRIORITY[child.localName] ?? 0;\n}\n\nfunction end(video: HTMLVideoElement): number {\n if (Number.isFinite(video.duration)) return video.duration;\n const ranges = video.seekable;\n return ranges.length > 0 ? ranges.end(ranges.length - 1) : video.currentTime;\n}\n\nfunction toggle(video: HTMLVideoElement): void {\n if (video.paused) video.play().catch(() => undefined);\n else video.pause();\n}\n\nexport class MbxControlBar extends Component {\n static get observedAttributes(): readonly string[] {\n return ['idle-ms', 'seek-step'];\n }\n\n declare private readonly seekRow: HTMLDivElement;\n declare private readonly buttonsRow: HTMLDivElement;\n declare private readonly buttons: HTMLSlotElement;\n declare private timer: ReturnType<typeof setTimeout> | undefined;\n /** Fires on a width change of the buttons row, so the collapse follows the page's layout. */\n declare private resizer: ResizeObserver | null;\n /** Whether the last input was a key, so focus inside holds the bar. */\n declare private keyboard: boolean;\n /** Whether the last press was a finger: its click on the video is a tap. */\n declare private touch: boolean;\n /** Whether the bar showed when that press began, before the press woke it. */\n declare private shownAtPress: boolean;\n declare private cues: CueLift | null;\n declare private screen: Fullscreen | null;\n\n constructor() {\n super();\n this.timer = undefined;\n this.keyboard = false;\n this.touch = false;\n this.shownAtPress = false;\n this.cues = null;\n this.screen = null;\n this.resizer = null;\n const root = this.attachShadow({ mode: 'open' });\n this.seekRow = document.createElement('div');\n this.seekRow.setAttribute('part', 'row seek-row');\n const seek = document.createElement('slot');\n seek.name = 'seek';\n this.seekRow.append(seek);\n this.buttonsRow = document.createElement('div');\n this.buttonsRow.setAttribute('part', 'row buttons-row');\n this.buttons = document.createElement('slot');\n this.buttonsRow.append(this.buttons);\n root.append(style(STYLE), this.seekRow, this.buttonsRow);\n }\n\n /**\n * What the buttons need: their widths and their margins, which are the\n * gaps between them, the spacer aside since it takes what is left, and a\n * folded slider at the width it unfolds to. The row's own width says nothing, because the\n * spacer fills it whatever the buttons take.\n */\n /** The bar's em in pixels: its sizes follow the player's font size. */\n private em(): number {\n return Number.parseFloat(getComputedStyle(this).fontSize) || 16;\n }\n\n private needed(children: readonly Element[]): number {\n let sum = 0;\n for (const child of children) {\n if (child.localName === SPACER || !shown(child)) continue;\n const margins = getComputedStyle(child);\n sum += child.getBoundingClientRect().width;\n sum += Number.parseFloat(margins.marginLeft) + Number.parseFloat(margins.marginRight);\n const folded = slider(child);\n if (folded !== null && shown(folded)) {\n sum += Math.max(0, SLIDER_WIDTH * this.em() - folded.getBoundingClientRect().width);\n }\n }\n return sum;\n }\n\n /**\n * Collapses the buttons row to its width. Everything is shown first, so\n * a wider bar gets its controls back, then the highest priorities go one\n * at a time while the buttons need more than the row has, less the\n * slack. Each step lays the row out again; a bar carries a dozen\n * controls, so that is cheap.\n */\n private collapse(): void {\n const children = this.buttons.assignedElements();\n const candidates: Candidate[] = [];\n for (const [index, child] of children.entries()) {\n child.removeAttribute('collapsed');\n const inner = slider(child);\n inner?.removeAttribute('collapsed');\n // A nested slider goes before its group, so it sorts as if it sat\n // after it. What is not shown, by its own `hidden` or a page's rule,\n // takes no room, so marking it would hide nothing and say something\n // false.\n if (inner !== null && shown(inner)) {\n candidates.push({ node: inner, index: index + 0.5, priority: priority(inner) });\n }\n if (shown(child)) candidates.push({ node: child, index, priority: priority(child) });\n }\n candidates.sort((a, b) => b.priority - a.priority || b.index - a.index);\n const room = this.buttonsRow.clientWidth - SLACK * this.em();\n for (const { node, priority: level } of candidates) {\n if (level === 0) return;\n if (this.needed(children) <= room) return;\n node.setAttribute('collapsed', '');\n }\n }\n\n /** From the first row's top to the bar's bottom: what the bar covers of the picture. */\n private covered(): { top: number; bottom: number } {\n return {\n top: this.seekRow.getBoundingClientRect().top,\n bottom: this.getBoundingClientRect().bottom,\n };\n }\n\n private held(player: PlayerHost): boolean {\n if (shownPaused(player, ['switching'])) return true;\n // The device's controls are these: they stay while it plays.\n if (player.hasAttribute('casting')) return true;\n if (this.querySelector('[open]') !== null) return true;\n if (!this.keyboard) return false;\n const active = (this.getRootNode() as Document | ShadowRoot).activeElement;\n return active !== null && this.contains(active);\n }\n\n private idle(player: PlayerHost, on: boolean): void {\n if (this.hasAttribute('idle') === on) return;\n this.toggleAttribute('idle', on);\n player.toggleAttribute('idle', on);\n this.cues?.lifted(!on);\n }\n\n private sleep(player: PlayerHost): void {\n this.timer = undefined;\n // A hold is checked again later: a menu closes and a pause ends without\n // an event the bar hears.\n if (this.held(player)) {\n this.timer = setTimeout(() => this.sleep(player), number(this, 'idle-ms', IDLE_MS));\n return;\n }\n this.idle(player, true);\n }\n\n /** Hides the bar now, as a tap asks: the next input shows it again. */\n private rest(player: PlayerHost): void {\n clearTimeout(this.timer);\n this.timer = undefined;\n this.idle(player, true);\n }\n\n private wake(player: PlayerHost): void {\n clearTimeout(this.timer);\n this.idle(player, false);\n this.timer = setTimeout(() => this.sleep(player), number(this, 'idle-ms', IDLE_MS));\n }\n\n /**\n * A seeking key: `seekkey` on the player first, cancellable, with the\n * seconds in `detail.by`. A seek bar under `key-mode=\"preview\"` takes it\n * to aim instead. Nobody took it: the playhead moves now.\n */\n private seekBy(player: PlayerHost, by: number): void {\n const asked = new CustomEvent('seekkey', { detail: { by }, cancelable: true });\n if (!player.dispatchEvent(asked)) return;\n const video = player.media;\n video.currentTime = Math.min(end(video), Math.max(0, video.currentTime + by));\n }\n\n private key(player: PlayerHost, event: KeyboardEvent): void {\n this.keyboard = true;\n this.touch = false;\n this.wake(player);\n if (event.defaultPrevented || event.altKey || event.ctrlKey || event.metaKey) return;\n const video = player.media;\n const onButton = event.composedPath()[0] instanceof HTMLButtonElement;\n switch (event.key) {\n case ' ':\n if (onButton) return;\n toggle(video);\n break;\n case 'k':\n case 'K':\n toggle(video);\n break;\n case 'm':\n case 'M':\n video.muted = !video.muted;\n break;\n case 'f':\n case 'F':\n this.screen?.toggle();\n break;\n // The media keys, which remotes and many keyboards send. UI Events\n // KeyboardEvent key values, Multimedia keys.\n case 'MediaPlayPause':\n toggle(video);\n break;\n case 'MediaPlay':\n void video.play().catch(() => undefined);\n break;\n // Stop pauses: the source stays, as a viewer expects on a remote.\n case 'MediaPause':\n case 'MediaStop':\n video.pause();\n break;\n case 'ArrowLeft':\n case 'MediaRewind':\n this.seekBy(player, -number(this, 'seek-step', SEEK_STEP));\n break;\n case 'ArrowRight':\n case 'MediaFastForward':\n this.seekBy(player, number(this, 'seek-step', SEEK_STEP));\n break;\n default:\n return;\n }\n event.preventDefault();\n }\n\n protected override attach(player: PlayerHost): void {\n const video = player.media;\n cueStyle();\n this.cues = cueLift(video, player, () => this.covered());\n const screen = fullscreen(player, video);\n this.screen = screen;\n const reflect = (): void => {\n player.toggleAttribute('fullscreen', screen.active());\n };\n this.keep(screen.watch(reflect));\n reflect();\n // `menu` while one of the bar's menus is open, by its `open` attribute:\n // the bar then stacks above the screens and hides its tooltips.\n const menus = new MutationObserver(() => {\n this.toggleAttribute('menu', this.querySelector('[open]') !== null);\n });\n menus.observe(this, { subtree: true, attributes: true, attributeFilter: ['open'] });\n this.keep(() => {\n menus.disconnect();\n this.removeAttribute('menu');\n });\n\n const pointer = (): void => {\n this.keyboard = false;\n this.wake(player);\n };\n const press = (event: Event): void => {\n this.touch = (event as PointerEvent).pointerType === 'touch';\n this.shownAtPress = !this.hasAttribute('idle');\n pointer();\n };\n const key = (event: Event): void => {\n this.key(player, event as KeyboardEvent);\n };\n const click = (event: Event): void => {\n // The video and nothing else: a control handles its own click.\n if (event.composedPath()[0] !== videoOf(player)) return;\n if (this.touch && !this.hasAttribute('tap-plays') && !player.hasAttribute('casting')) {\n // The press showed a hidden bar already; a tap on a shown one hides it.\n if (this.shownAtPress) this.rest(player);\n return;\n }\n toggle(video);\n };\n this.listen(player, ['pointermove'], pointer);\n this.listen(player, ['pointerdown'], press);\n player.addEventListener('keydown', key);\n player.addEventListener('click', click);\n this.keep(() => {\n player.removeEventListener('keydown', key);\n player.removeEventListener('click', click);\n });\n this.listen(video, ['play', 'pause', 'ended'], () => {\n // The load of a switch pauses and plays the video, and the viewer did neither.\n if (!player.hasAttribute('switching')) this.wake(player);\n });\n this.wake(player);\n this.cues.lifted(true);\n\n // The row's width, its children, and what they hide or reprioritise on\n // their own: each can change what fits. `collapsed` is left out of the\n // filter, since the bar writes it.\n const collapse = (): void => {\n this.collapse();\n };\n this.listen(this.buttons, ['slotchange'], collapse);\n this.observe(this, ['hidden', 'priority', 'slot'], collapse, true);\n if (typeof ResizeObserver !== 'undefined') {\n this.resizer = new ResizeObserver(collapse);\n this.resizer.observe(this.buttonsRow);\n }\n collapse();\n }\n\n protected override detach(player: PlayerHost): void {\n clearTimeout(this.timer);\n this.timer = undefined;\n this.resizer?.disconnect();\n this.resizer = null;\n for (const child of this.buttons.assignedElements()) {\n child.removeAttribute('collapsed');\n slider(child)?.removeAttribute('collapsed');\n }\n this.cues?.dispose();\n this.cues = null;\n this.screen = null;\n this.removeAttribute('idle');\n player.removeAttribute('idle');\n player.removeAttribute('fullscreen');\n }\n}\n"],"mappings":";;;;;;;AA0EA,MAAA,QAAA;AAGA,MAAM,UAAU;AAChB,MAAM,YAAY;;;;;;;;;;;;AAalB,MAAM,WAA6C;EAChD,cAAc;EACd,gBAAgB;CACjB,mBAAmB;EAClB,YAAY;EACZ,aAAa;EACb,gBAAgB;EAChB,aAAa;EACb,eAAe;EACf,aAAa;EACb,iBAAiB;EACjB,cAAc;EACd,iBAAiB;EACjB,aAAa;EACb,SAAS;EACT,cAAc;AACjB;;AAGA,MAAM,eAAe;;AAGrB,MAAM,QAAQ;AASd,SAAS,MAAM,MAAwB;CACrC,OAAO,KAAK,eAAe,CAAC,CAAC,SAAS;AACxC;;AAGA,SAAS,OAAO,OAAgC;CAC9C,OAAO,MAAM,cAAA,eAAuB,MAAM,cAAc,aAAa,IAAI;AAC3E;;AAGA,SAAS,SAAS,OAAwB;CACxC,MAAM,MAAM,MAAM,aAAa,UAAU;CACzC,IAAI,QAAQ,MAAM;EAChB,MAAM,QAAQ,OAAO,GAAG;EACxB,OAAO,OAAO,SAAS,KAAK,KAAK,QAAQ,IAAI,QAAQ;CACvD;CACA,OAAO,SAAS,MAAM,cAAc;AACtC;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AU,IAAI,eAAe,QAAQ;GAC1C,KAAK,QAAQ,QAAQ,KAAK,UAAU;EACtC;EACA,SAAS;CACX;CAEmB,OAAO,QAA0B;EAClD,aAAa,KAAK,KAAK;EACvB,KAAK,QAAQ,KAAA;EACb,KAAK,SAAS,WAAW;EACzB,KAAK,UAAU;EACf,KAAK,MAAM,SAAS,KAAK,QAAQ,iBAAiB,GAAG;GACnD,MAAM,gBAAgB,WAAW;GACjC,OAAO,KAAK,CAAC,EAAE,gBAAgB,WAAW;EAC5C;EACA,KAAK,MAAM,QAAQ;EACnB,KAAK,OAAO;EACZ,KAAK,SAAS;EACd,KAAK,gBAAgB,MAAM;EAC3B,OAAO,gBAAgB,MAAM;EAC7B,OAAO,gBAAgB,YAAY;CACrC;AACF"}
@@ -5,7 +5,7 @@ import { namespaces } from "../namespaces.js";
5
5
  import { Component } from "./component.js";
6
6
  import { style } from "./shared.js";
7
7
  // src/elements/drm-badge.ts
8
- const STYLE = ":host{width:2.5em;height:2.5em;color:var(--mbx-muted);border-radius:var(--mbx-radius);cursor:default;justify-content:center;align-items:center;display:inline-flex;position:relative}:host([hidden]){display:none}:host(:focus){outline:2px solid var(--mbx-accent);outline-offset:-2px}:host(:focus:not(:focus-visible)){outline:none}[part~=icon],::slotted(*){fill:currentColor;width:1.75em;height:1.75em}[part~=tooltip]{border-radius:var(--mbx-radius);color:var(--mbx-text);text-align:left;white-space:nowrap;pointer-events:none;background:#1c1c20f2;margin-bottom:.6154em;padding:.6154em .7692em;font-size:.8125em;line-height:1.4;position:absolute;bottom:100%;right:0;box-shadow:0 4px 16px #00000080}[part~=tooltip][hidden]{display:none}[part~=tooltip-title]{font-weight:600}[part~=tooltip-text]{color:var(--mbx-muted)}";
8
+ const STYLE = ":host{width:2.5em;height:2.5em;color:var(--mbx-muted);border-radius:var(--mbx-radius);cursor:default;justify-content:center;align-items:center;display:inline-flex;position:relative}:host([hidden]){display:none}:host(:focus){outline:2px solid var(--mbx-accent);outline-offset:-2px}:host(:focus:not(:focus-visible)){outline-style:var(--mbx-focus-ring,none)}[part~=icon],::slotted(*){fill:currentColor;width:1.75em;height:1.75em}[part~=tooltip]{border-radius:var(--mbx-radius);color:var(--mbx-text);text-align:left;white-space:nowrap;pointer-events:none;background:#1c1c20f2;margin-bottom:.6154em;padding:.6154em .7692em;font-size:.8125em;line-height:1.4;position:absolute;bottom:100%;right:0;box-shadow:0 4px 16px #00000080}[part~=tooltip][hidden]{display:none}[part~=tooltip-title]{font-weight:600}[part~=tooltip-text]{color:var(--mbx-muted)}";
9
9
  /** The name a viewer knows a key system by. */
10
10
  function keySystemName(id) {
11
11
  if (id.startsWith("com.widevine")) return "Widevine";
@@ -2,7 +2,7 @@ import { el } from "../dom.js";
2
2
  import { Component } from "./component.js";
3
3
  import { style } from "./shared.js";
4
4
  // src/elements/error-screen.ts
5
- const STYLE = ":host{color:var(--mbx-text);font:400 .9375em / 1.4 var(--mbx-font);text-align:center;background:#000000bf;justify-content:center;align-items:center;padding:1.0667em;display:flex;position:absolute;top:0;bottom:0;left:0;right:0}:host([hidden]){display:none}[part~=box]{flex-direction:column;align-items:center;display:flex}[part~=box]>:not([hidden])~:not([hidden]){margin-top:.5333em}[part~=title]{font-size:1.2em;font-weight:600}[part~=detail]{color:var(--mbx-error);font-family:monospace;font-size:.8667em}[part~=message]{max-width:32em}[part~=actions]>:not([hidden])~:not([hidden]){margin-left:.5333em}[part~=action]{height:2.4em;font:inherit;color:inherit;border-radius:var(--mbx-radius);cursor:pointer;background:0 0;border:1px solid;padding:0 1.0667em;font-weight:600}[part~=action]:focus{outline:2px solid var(--mbx-accent);outline-offset:-2px}[part~=action]:focus:not(:focus-visible){outline:none}";
5
+ const STYLE = ":host{color:var(--mbx-text);font:400 .9375em / 1.4 var(--mbx-font);text-align:center;background:#000000bf;justify-content:center;align-items:center;padding:1.0667em;display:flex;position:absolute;top:0;bottom:0;left:0;right:0}:host([hidden]){display:none}[part~=box]{flex-direction:column;align-items:center;display:flex}[part~=box]>:not([hidden])~:not([hidden]){margin-top:.5333em}[part~=title]{font-size:1.2em;font-weight:600}[part~=detail]{color:var(--mbx-error);font-family:monospace;font-size:.8667em}[part~=message]{max-width:32em}[part~=actions]>:not([hidden])~:not([hidden]){margin-left:.5333em}[part~=action]{height:2.4em;font:inherit;color:inherit;border-radius:var(--mbx-radius);cursor:pointer;background:0 0;border:1px solid;padding:0 1.0667em;font-weight:600}[part~=action]:focus{outline:2px solid var(--mbx-accent);outline-offset:-2px}[part~=action]:focus:not(:focus-visible){outline-style:var(--mbx-focus-ring,none)}";
6
6
  /** The diagnostics element, another package's, named here as a string. */
7
7
  const DIAGNOSTICS = "mbx-diagnostics";
8
8
  var MbxErrorScreen = class extends Component {
@@ -16,7 +16,7 @@ import { seekRow, style } from "./shared.js";
16
16
  * `text`, the name from `label-live` and `label-at-edge`. It sits in the
17
17
  * bar's seek row unless the page says otherwise.
18
18
  */
19
- const STYLE = ":host{display:inline-flex}:host([hidden]){display:none}[part~=button]{height:2.5em;font:inherit;letter-spacing:.06em;color:inherit;border-radius:var(--mbx-radius);cursor:pointer;opacity:.9;background:0 0;border:0;align-items:center;padding:0 .5em;font-size:.75em;font-weight:700;display:inline-flex}[part~=button]:hover{opacity:1}[part~=button]:disabled{cursor:default;opacity:1}[part~=button]:focus{outline:2px solid var(--mbx-accent);outline-offset:-2px}[part~=button]:focus:not(:focus-visible){outline:none}[part~=dot]{background:var(--mbx-muted);border-radius:50%;width:.625em;height:.625em;margin-right:.375em;transition:background .2s}:host([at-edge]) [part~=dot]{background:var(--mbx-live);box-shadow:0 0 6px var(--mbx-live)}@media (prefers-reduced-motion:reduce){[part~=dot]{transition:none}}";
19
+ const STYLE = ":host{display:inline-flex}:host([hidden]){display:none}[part~=button]{height:2.5em;font:inherit;letter-spacing:.06em;color:inherit;border-radius:var(--mbx-radius);cursor:pointer;opacity:.9;background:0 0;border:0;align-items:center;padding:0 .5em;font-size:.75em;font-weight:700;display:inline-flex}[part~=button]:hover{opacity:1}[part~=button]:disabled{cursor:default;opacity:1}[part~=button]:focus{outline:2px solid var(--mbx-accent);outline-offset:-2px}[part~=button]:focus:not(:focus-visible){outline-style:var(--mbx-focus-ring,none)}[part~=dot]{background:var(--mbx-muted);border-radius:50%;width:.625em;height:.625em;margin-right:.375em;transition:background .2s}:host([at-edge]) [part~=dot]{background:var(--mbx-live);box-shadow:0 0 6px var(--mbx-live)}@media (prefers-reduced-motion:reduce){[part~=dot]{transition:none}}";
20
20
  var MbxLiveButton = class extends Component {
21
21
  static get observedAttributes() {
22
22
  return [
@@ -1,6 +1,6 @@
1
1
  // src/elements/shared.ts
2
- const BUTTON_STYLE_CSS = ":host{display:inline-flex}:host([hidden]),:host([away]){display:none}[part~=button]{width:2.5em;height:2.5em;font:inherit;color:inherit;border-radius:var(--mbx-radius);cursor:pointer;opacity:.9;background:0 0;border:0;flex:none;justify-content:center;align-items:center;padding:0;display:inline-flex;position:relative}[part~=button][aria-label]:after{content:attr(aria-label);display:var(--mbx-tooltip,block);background:var(--mbx-surface);border-radius:var(--mbx-radius);white-space:nowrap;pointer-events:none;opacity:0;margin-bottom:.4615em;padding:.3077em .6154em;font-size:.8125em;transition:opacity .1s;position:absolute;bottom:100%;left:50%;transform:translate(-50%)}[part~=button][aria-label]:focus:after{opacity:1;transition-delay:.4s}[part~=button][aria-label]:focus:not(:focus-visible):after{opacity:0;transition-delay:0s}@media (hover:hover){[part~=button][aria-label]:hover:after{opacity:1;transition-delay:.4s}}:host(:last-child) [part~=button][aria-label]:after{left:auto;right:0;transform:none}[part~=button]:hover{opacity:1}[part~=button]:focus{outline:2px solid var(--mbx-accent);outline-offset:-2px}[part~=button]:focus:not(:focus-visible){outline:none}[part~=icon],::slotted(*){fill:currentColor;width:1.75em;height:1.75em}slot[hidden]{display:none}";
3
- const SLIDER_STYLE_CSS = ":host{display:block}:host([hidden]){display:none}[part~=slider]{border-radius:var(--mbx-radius);cursor:pointer;touch-action:none;height:2.5em;position:relative}[part~=slider]:focus{outline:2px solid var(--mbx-accent);outline-offset:-2px}[part~=slider]:focus:not(:focus-visible){outline:none}[part~=rail]{position:absolute;top:0;bottom:0;left:.5em;right:.5em}[part~=track]{background:#ffffff59;border-radius:2px;height:.25em;position:absolute;top:50%;left:0;right:0;overflow:hidden;transform:translateY(-50%)}[part~=fill]{background:var(--mbx-accent);position:absolute;top:0;bottom:0;left:0}[part~=thumb]{background:var(--mbx-text);pointer-events:none;border-radius:50%;width:.75em;height:.75em;margin:-.375em 0 0 -.375em;position:absolute;top:50%}";
2
+ const BUTTON_STYLE_CSS = ":host{display:inline-flex}:host([hidden]),:host([away]){display:none}[part~=button]{width:2.5em;height:2.5em;font:inherit;color:inherit;border-radius:var(--mbx-radius);cursor:pointer;opacity:.9;background:0 0;border:0;flex:none;justify-content:center;align-items:center;padding:0;display:inline-flex;position:relative}[part~=button][aria-label]:after{content:attr(aria-label);display:var(--mbx-tooltip,block);background:var(--mbx-surface);border-radius:var(--mbx-radius);white-space:nowrap;pointer-events:none;opacity:0;margin-bottom:.4615em;padding:.3077em .6154em;font-size:.8125em;transition:opacity .1s;position:absolute;bottom:100%;left:50%;transform:translate(-50%)}[part~=button][aria-label]:focus:after{opacity:1;transition-delay:.4s}[part~=button][aria-label]:focus:not(:focus-visible):after{opacity:var(--mbx-focus-tooltip,0);transition-delay:0s}@media (hover:hover){[part~=button][aria-label]:hover:after{opacity:1;transition-delay:.4s}}:host(:last-child) [part~=button][aria-label]:after{left:auto;right:0;transform:none}[part~=button]:hover{opacity:1}[part~=button]:focus{outline:2px solid var(--mbx-accent);outline-offset:-2px}[part~=button]:focus:not(:focus-visible){outline-style:var(--mbx-focus-ring,none)}[part~=icon],::slotted(*){fill:currentColor;width:1.75em;height:1.75em}slot[hidden]{display:none}";
3
+ const SLIDER_STYLE_CSS = ":host{display:block}:host([hidden]){display:none}[part~=slider]{border-radius:var(--mbx-radius);cursor:pointer;touch-action:none;height:2.5em;position:relative}[part~=slider]:focus{outline:2px solid var(--mbx-accent);outline-offset:-2px}[part~=slider]:focus:not(:focus-visible){outline-style:var(--mbx-focus-ring,none)}[part~=rail]{position:absolute;top:0;bottom:0;left:.5em;right:.5em}[part~=track]{background:#ffffff59;border-radius:2px;height:.25em;position:absolute;top:50%;left:0;right:0;overflow:hidden;transform:translateY(-50%)}[part~=fill]{background:var(--mbx-accent);position:absolute;top:0;bottom:0;left:0}[part~=thumb]{background:var(--mbx-text);pointer-events:none;border-radius:50%;width:.75em;height:.75em;margin:-.375em 0 0 -.375em;position:absolute;top:50%}";
4
4
  const BUTTON_STYLE = BUTTON_STYLE_CSS;
5
5
  /** The style of a slider: the rail, the track with its fill, and the thumb. */
6
6
  const SLIDER_STYLE = SLIDER_STYLE_CSS;
@@ -11,7 +11,7 @@ function number(node, name, fallback) {
11
11
  return Number.isFinite(value) && value >= 0 ? value : fallback;
12
12
  }
13
13
  /** The style of a menu: the button from BUTTON_STYLE, and the popup above it with its items. */
14
- const MENU_STYLE = ":host{display:inline-flex}:host([hidden]),:host([away]){display:none}[part~=button]{width:2.5em;height:2.5em;font:inherit;color:inherit;border-radius:var(--mbx-radius);cursor:pointer;opacity:.9;background:0 0;border:0;flex:none;justify-content:center;align-items:center;padding:0;display:inline-flex;position:relative}[part~=button][aria-label]:after{content:attr(aria-label);display:var(--mbx-tooltip,block);background:var(--mbx-surface);border-radius:var(--mbx-radius);white-space:nowrap;pointer-events:none;opacity:0;margin-bottom:.4615em;padding:.3077em .6154em;font-size:.8125em;transition:opacity .1s;position:absolute;bottom:100%;left:50%;transform:translate(-50%)}[part~=button][aria-label]:focus:after{opacity:1;transition-delay:.4s}[part~=button][aria-label]:focus:not(:focus-visible):after{opacity:0;transition-delay:0s}@media (hover:hover){[part~=button][aria-label]:hover:after{opacity:1;transition-delay:.4s}}:host(:last-child) [part~=button][aria-label]:after{left:auto;right:0;transform:none}[part~=button]:hover{opacity:1}[part~=button]:focus{outline:2px solid var(--mbx-accent);outline-offset:-2px}[part~=button]:focus:not(:focus-visible){outline:none}[part~=icon],::slotted(*){fill:currentColor;width:1.75em;height:1.75em}slot[hidden]{display:none}:host{position:relative}[part~=popup]{box-sizing:border-box;overscroll-behavior:contain;border-radius:var(--mbx-radius);background:#1c1c20f2;flex-direction:column;min-width:16em;margin-bottom:.5714em;padding:.4286em;font-size:.875em;display:flex;position:absolute;bottom:100%;right:0;overflow-y:auto;box-shadow:0 4px 16px #00000080}[part~=popup][hidden]{display:none}[part~=section]{flex-direction:column;display:flex}[part~=section]+[part~=section]{border-top:1px solid #ffffff1f;margin-top:.4286em;padding-top:.4286em}[part~=section-label]{letter-spacing:.06em;text-transform:uppercase;color:var(--mbx-muted);padding:.3636em 1.0909em .1818em;font-size:.7857em;font-weight:600}[part~=glyph-item]{padding-left:1em}[part~=glyph-item]>svg{margin-right:.75em}[part~=item]{width:100%;font:inherit;color:inherit;text-align:left;white-space:nowrap;border-radius:var(--mbx-radius);cursor:pointer;background:0 0;border:0;align-items:center;padding:.7857em 1em .7857em 2.2857em;display:flex}[part~=item]:hover{background:#ffffff1f}[part~=item-text]{white-space:normal;-webkit-line-clamp:2;-webkit-box-orient:vertical;min-width:0;max-width:16em;display:-webkit-box;overflow:hidden}[part~=item-image]{object-fit:cover;background:#ffffff14;border-radius:2px;flex:none;width:4.5714em;height:2.5714em;margin-right:.8571em}[part~=item-badge]{border:1px solid;border-radius:2px;flex:none;margin-left:auto;padding:0 .381em;font-size:.75em;font-weight:600;line-height:1.5}[part~=item-glyph]{border:0;padding:0;font-size:1em;display:inline-flex}[part~=item-glyph] svg,[part~=glyph-item]>svg{fill:currentColor;flex:none;width:1.5em;height:1.5em}[part~=badge-text]{clip:rect(0 0 0 0);white-space:nowrap;width:1px;height:1px;position:absolute;overflow:hidden}[part~=item-detail]{color:var(--mbx-muted);font-variant-numeric:tabular-nums;margin-left:auto;padding-left:.8571em}[part~=item-badge]~[part~=item-badge],[part~=item-badge]~[part~=item-detail]{margin-left:.7619em}[part~=item]:focus{outline:2px solid var(--mbx-accent);outline-offset:-2px}[part~=item]:focus:not(:focus-visible){outline:none}[part~=page-item]{padding-right:2em;position:relative}[part~=page-item]:after{content:\"\";opacity:.7;border:1.5px solid;border-width:1.5px 1.5px 0 0;width:.5em;height:.5em;margin-top:-.2857em;position:absolute;top:50%;right:.8571em;transform:rotate(45deg)}[part~=title],[part~=back-item]{letter-spacing:.06em;text-transform:uppercase;color:var(--mbx-muted);font-size:.8125em;font-weight:600}[part~=title]{border-bottom:1px solid #ffffff1f;margin:-.5275em -.5275em .5275em;padding:.9231em 1.4066em}[part~=back-item]{border-bottom:1px solid #ffffff1f;border-radius:0;margin-bottom:.5275em;padding:.9231em 1.2308em .9231em 2.4615em;position:relative}[part~=back-item]:before{content:\"\";opacity:.7;border:0 solid;border-width:1.5px 0 0 1.5px;width:.5em;height:.5em;margin-top:-.2857em;position:absolute;top:50%;left:1em;transform:rotate(-45deg)}[part~=checked]{background:#ffffff14;position:relative}[part~=checked]:before{content:\"\";background:var(--mbx-accent);border-radius:50%;width:.4286em;height:.4286em;margin-top:-.2143em;position:absolute;top:50%;left:1em}:host([layout=compact]) [part~=popup]{z-index:1000;padding-bottom:calc(.4286em + env(safe-area-inset-bottom,0px));box-shadow:none;background:#1c1c20;border-radius:.75em .75em 0 0;margin:0;font-size:1em;right:auto}[part~=backdrop]{z-index:999;background:#00000080;position:absolute}[part~=backdrop][hidden]{display:none}";
14
+ const MENU_STYLE = ":host{display:inline-flex}:host([hidden]),:host([away]){display:none}[part~=button]{width:2.5em;height:2.5em;font:inherit;color:inherit;border-radius:var(--mbx-radius);cursor:pointer;opacity:.9;background:0 0;border:0;flex:none;justify-content:center;align-items:center;padding:0;display:inline-flex;position:relative}[part~=button][aria-label]:after{content:attr(aria-label);display:var(--mbx-tooltip,block);background:var(--mbx-surface);border-radius:var(--mbx-radius);white-space:nowrap;pointer-events:none;opacity:0;margin-bottom:.4615em;padding:.3077em .6154em;font-size:.8125em;transition:opacity .1s;position:absolute;bottom:100%;left:50%;transform:translate(-50%)}[part~=button][aria-label]:focus:after{opacity:1;transition-delay:.4s}[part~=button][aria-label]:focus:not(:focus-visible):after{opacity:var(--mbx-focus-tooltip,0);transition-delay:0s}@media (hover:hover){[part~=button][aria-label]:hover:after{opacity:1;transition-delay:.4s}}:host(:last-child) [part~=button][aria-label]:after{left:auto;right:0;transform:none}[part~=button]:hover{opacity:1}[part~=button]:focus{outline:2px solid var(--mbx-accent);outline-offset:-2px}[part~=button]:focus:not(:focus-visible){outline-style:var(--mbx-focus-ring,none)}[part~=icon],::slotted(*){fill:currentColor;width:1.75em;height:1.75em}slot[hidden]{display:none}:host{position:relative}[part~=popup]{box-sizing:border-box;overscroll-behavior:contain;border-radius:var(--mbx-radius);background:#1c1c20f2;flex-direction:column;min-width:16em;margin-bottom:.5714em;padding:.4286em;font-size:.875em;display:flex;position:absolute;bottom:100%;right:0;overflow-y:auto;box-shadow:0 4px 16px #00000080}[part~=popup][hidden]{display:none}[part~=section]{flex-direction:column;display:flex}[part~=section]+[part~=section]{border-top:1px solid #ffffff1f;margin-top:.4286em;padding-top:.4286em}[part~=section-label]{letter-spacing:.06em;text-transform:uppercase;color:var(--mbx-muted);padding:.3636em 1.0909em .1818em;font-size:.7857em;font-weight:600}[part~=glyph-item]{padding-left:1em}[part~=glyph-item]>svg{margin-right:.75em}[part~=item]{width:100%;font:inherit;color:inherit;text-align:left;white-space:nowrap;border-radius:var(--mbx-radius);cursor:pointer;background:0 0;border:0;align-items:center;padding:.7857em 1em .7857em 2.2857em;display:flex}[part~=item]:hover{background:#ffffff1f}[part~=item-text]{white-space:normal;-webkit-line-clamp:2;-webkit-box-orient:vertical;min-width:0;max-width:16em;display:-webkit-box;overflow:hidden}[part~=item-image]{object-fit:cover;background:#ffffff14;border-radius:2px;flex:none;width:4.5714em;height:2.5714em;margin-right:.8571em}[part~=item-badge]{border:1px solid;border-radius:2px;flex:none;margin-left:auto;padding:0 .381em;font-size:.75em;font-weight:600;line-height:1.5}[part~=item-glyph]{border:0;padding:0;font-size:1em;display:inline-flex}[part~=item-glyph] svg,[part~=glyph-item]>svg{fill:currentColor;flex:none;width:1.5em;height:1.5em}[part~=badge-text]{clip:rect(0 0 0 0);white-space:nowrap;width:1px;height:1px;position:absolute;overflow:hidden}[part~=item-detail]{color:var(--mbx-muted);font-variant-numeric:tabular-nums;margin-left:auto;padding-left:.8571em}[part~=item-badge]~[part~=item-badge],[part~=item-badge]~[part~=item-detail]{margin-left:.7619em}[part~=item]:focus{outline:2px solid var(--mbx-accent);outline-offset:-2px}[part~=item]:focus:not(:focus-visible){outline-style:var(--mbx-focus-ring,none)}[part~=page-item]{padding-right:2em;position:relative}[part~=page-item]:after{content:\"\";opacity:.7;border:1.5px solid;border-width:1.5px 1.5px 0 0;width:.5em;height:.5em;margin-top:-.2857em;position:absolute;top:50%;right:.8571em;transform:rotate(45deg)}[part~=title],[part~=back-item]{letter-spacing:.06em;text-transform:uppercase;color:var(--mbx-muted);font-size:.8125em;font-weight:600}[part~=title]{border-bottom:1px solid #ffffff1f;margin:-.5275em -.5275em .5275em;padding:.9231em 1.4066em}[part~=back-item]{border-bottom:1px solid #ffffff1f;border-radius:0;margin-bottom:.5275em;padding:.9231em 1.2308em .9231em 2.4615em;position:relative}[part~=back-item]:before{content:\"\";opacity:.7;border:0 solid;border-width:1.5px 0 0 1.5px;width:.5em;height:.5em;margin-top:-.2857em;position:absolute;top:50%;left:1em;transform:rotate(-45deg)}[part~=checked]{background:#ffffff14;position:relative}[part~=checked]:before{content:\"\";background:var(--mbx-accent);border-radius:50%;width:.4286em;height:.4286em;margin-top:-.2143em;position:absolute;top:50%;left:1em}:host([layout=compact]) [part~=popup]{z-index:1000;padding-bottom:calc(.4286em + env(safe-area-inset-bottom,0px));box-shadow:none;background:#1c1c20;border-radius:.75em .75em 0 0;margin:0;font-size:1em;right:auto}[part~=backdrop]{z-index:999;background:#00000080;position:absolute}[part~=backdrop][hidden]{display:none}";
15
15
  /** Puts a control in the bar's seek row when it is in a bar, unless the page wrote a `slot` of its own. */
16
16
  function seekRow(node) {
17
17
  if (node.parentElement?.localName === "mbx-control-bar" && !node.hasAttribute("slot")) node.slot = "seek";
@@ -1 +1 @@
1
- {"version":3,"file":"speed-menu.d.ts","sourceRoot":"","sources":["../../src/elements/speed-menu.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAU,MAAM,mBAAmB,CAAC;AAKxD,qBAAa,YAAa,SAAQ,WAAW;IAC3C,MAAM,KAAK,kBAAkB,IAAI,SAAS,MAAM,EAAE,CAEjD;;cASkB,IAAI,IAAI,SAAS,CAAC,MAAM,QAAQ,EAAE,MAAM,CAAC;IAI5D,OAAO,CAAC,KAAK;cAUM,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;cAOhC,MAAM,IAAI,IAAI;CAsBlC"}
1
+ {"version":3,"file":"speed-menu.d.ts","sourceRoot":"","sources":["../../src/elements/speed-menu.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAU,MAAM,mBAAmB,CAAC;AAKxD,qBAAa,YAAa,SAAQ,WAAW;IAC3C,MAAM,KAAK,kBAAkB,IAAI,SAAS,MAAM,EAAE,CAEjD;;cAUkB,IAAI,IAAI,SAAS,CAAC,MAAM,QAAQ,EAAE,MAAM,CAAC;IAI5D,OAAO,CAAC,KAAK;cAUM,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;cAOhC,MAAM,IAAI,IAAI;CAsBlC"}
@@ -20,7 +20,7 @@ var MbxSpeedMenu = class extends MenuElement {
20
20
  }
21
21
  constructor() {
22
22
  super(...single("playback-speed"));
23
- this.leaves = "remote";
23
+ this.leaves = "device";
24
24
  show(this.slots, "default");
25
25
  }
26
26
  name() {
@@ -1 +1 @@
1
- {"version":3,"file":"speed-menu.js","names":[],"sources":["../../src/elements/speed-menu.ts"],"sourcesContent":["/**\n * <mbx-speed-menu>: the rate over `video.playbackRate`. Video-only, so it\n * works for every session, native included. The rates come from `rates`,\n * space-separated, and the video's own value is the truth, read on\n * `ratechange` and listed even when it is not one of them. The name comes\n * from `label`, the word for one from `label-normal`.\n */\nimport type { PlayerHost } from '../host.js';\nimport type { Messages } from '../messages.js';\nimport { MenuElement, single } from './menu-element.js';\nimport { show } from './shared.js';\n\nconst RATES = [0.5, 0.75, 1, 1.25, 1.5, 2];\n\nexport class MbxSpeedMenu extends MenuElement {\n static get observedAttributes(): readonly string[] {\n return ['rates', 'label', 'label-normal', 'label-back'];\n }\n\n constructor() {\n super(...single('playback-speed'));\n // It would change the engine of the page, which a device does not play.\n this.leaves = 'remote';\n show(this.slots, 'default');\n }\n\n protected override name(): readonly [keyof Messages, string] {\n return ['speed', 'Playback speed'];\n }\n\n private rates(): number[] {\n const raw = this.getAttribute('rates');\n if (raw === null) return RATES;\n const out = raw\n .split(/\\s+/)\n .map(Number)\n .filter((rate) => Number.isFinite(rate) && rate > 0);\n return out.length === 0 ? RATES : out;\n }\n\n protected override attach(player: PlayerHost): void {\n this.listen(player.media, ['ratechange'], () => {\n this.render();\n });\n this.render();\n }\n\n protected override render(): void {\n super.render();\n const video = this.player?.media;\n if (video === undefined) return;\n const normal = this.word('label-normal', 'speedNormal', 'Normal');\n const items: Array<readonly [string, string]> = this.rates().map((rate) => [\n String(rate),\n rate === 1 ? normal : `${rate}×`,\n ]);\n const current = String(video.playbackRate);\n if (!items.some(([id]) => id === current)) items.push([current, `${current}×`]);\n this.menu.fill([\n {\n name: 'rate',\n items,\n value: current,\n onSelect: (value) => {\n video.playbackRate = Number(value);\n },\n },\n ]);\n }\n}\n"],"mappings":";;;AAYA,MAAM,QAAQ;C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":"speed-menu.js","names":[],"sources":["../../src/elements/speed-menu.ts"],"sourcesContent":["/**\n * <mbx-speed-menu>: the rate over `video.playbackRate`. Video-only, so it\n * works for every session, native included. The rates come from `rates`,\n * space-separated, and the video's own value is the truth, read on\n * `ratechange` and listed even when it is not one of them. The name comes\n * from `label`, the word for one from `label-normal`.\n */\nimport type { PlayerHost } from '../host.js';\nimport type { Messages } from '../messages.js';\nimport { MenuElement, single } from './menu-element.js';\nimport { show } from './shared.js';\n\nconst RATES = [0.5, 0.75, 1, 1.25, 1.5, 2];\n\nexport class MbxSpeedMenu extends MenuElement {\n static get observedAttributes(): readonly string[] {\n return ['rates', 'label', 'label-normal', 'label-back'];\n }\n\n constructor() {\n super(...single('playback-speed'));\n // A Chromecast plays its own engine, and an AirPlay target ignores the\n // video's rate: the speed would change nothing, under either.\n this.leaves = 'device';\n show(this.slots, 'default');\n }\n\n protected override name(): readonly [keyof Messages, string] {\n return ['speed', 'Playback speed'];\n }\n\n private rates(): number[] {\n const raw = this.getAttribute('rates');\n if (raw === null) return RATES;\n const out = raw\n .split(/\\s+/)\n .map(Number)\n .filter((rate) => Number.isFinite(rate) && rate > 0);\n return out.length === 0 ? RATES : out;\n }\n\n protected override attach(player: PlayerHost): void {\n this.listen(player.media, ['ratechange'], () => {\n this.render();\n });\n this.render();\n }\n\n protected override render(): void {\n super.render();\n const video = this.player?.media;\n if (video === undefined) return;\n const normal = this.word('label-normal', 'speedNormal', 'Normal');\n const items: Array<readonly [string, string]> = this.rates().map((rate) => [\n String(rate),\n rate === 1 ? normal : `${rate}×`,\n ]);\n const current = String(video.playbackRate);\n if (!items.some(([id]) => id === current)) items.push([current, `${current}×`]);\n this.menu.fill([\n {\n name: 'rate',\n items,\n value: current,\n onSelect: (value) => {\n video.playbackRate = Number(value);\n },\n },\n ]);\n }\n}\n"],"mappings":";;;AAYA,MAAM,QAAQ;CAAC;CAAK;CAAM;CAAG;CAAM;CAAK;AAAC;AAEzC,IAAa,eAAb,cAAkC,Y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AAM,QAAQ,EAAE,MAAM,CAAC;IAI5D;;;;OAIG;IACH,OAAO,CAAC,KAAK;cAqCM,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;IAgBnD,8EAA8E;IAC9E,OAAO,CAAC,MAAM;cAeK,MAAM,IAAI,IAAI;CA6GlC"}
@@ -7,6 +7,10 @@ import { show } from "./shared.js";
7
7
  import { isSdh } from "mattebox";
8
8
  // src/elements/subtitles-menu.ts
9
9
  const OFF = "off";
10
+ /** The live captions' item, a value no track id or native index takes. */
11
+ const LIVE = "live-captions";
12
+ /** The player's attribute a live captions package sets: absent, `off` or `on`. */
13
+ const LIVE_CAPTIONS = "live-captions";
10
14
  const SUBTITLE_SIZE = "subtitle-size";
11
15
  const SUBTITLE_BACKGROUND = "subtitle-background";
12
16
  const SIZES = [
@@ -61,6 +65,8 @@ var MbxSubtitlesMenu = class extends MenuElement {
61
65
  "label-background",
62
66
  "label-sdh",
63
67
  "label-cc",
68
+ "label-live",
69
+ "label-generated",
64
70
  ...SIZES.map(([id]) => `label-${id}`),
65
71
  ...BACKGROUNDS.map(([id]) => `label-${id}`)
66
72
  ];
@@ -103,6 +109,9 @@ var MbxSubtitlesMenu = class extends MenuElement {
103
109
  };
104
110
  }
105
111
  attach(player) {
112
+ this.observe(player, [LIVE_CAPTIONS], () => {
113
+ this.render();
114
+ });
106
115
  this.follow(player, (engine) => {
107
116
  this.engine = engine;
108
117
  this.render();
@@ -138,7 +147,19 @@ var MbxSubtitlesMenu = class extends MenuElement {
138
147
  const sdh = this.word("label-sdh", "sdh", "SDH");
139
148
  const [tracks, active] = listed !== void 0 ? this.native(listed) : trackItems(engine, "text", (track) => [...track.instreamId !== void 0 ? [cc] : [], ...isSdh(track) ? [sdh] : []], (track) => track.forced !== true);
140
149
  const word = this.word("label-track", "track", "Track");
141
- const items = [[OFF, this.word("label-off", "subtitlesOff", "Off")], ...trackNames(tracks, word, player.locale || void 0)];
150
+ const live = player.getAttribute(LIVE_CAPTIONS);
151
+ const generated = this.word("label-generated", "liveCaptionsGenerated", "Generated automatically from speech");
152
+ const items = [
153
+ [OFF, this.word("label-off", "subtitlesOff", "Off")],
154
+ ...live === null ? [] : [[
155
+ LIVE,
156
+ this.word("label-live", "liveCaptions", "Live captions"),
157
+ void 0,
158
+ void 0,
159
+ [generated]
160
+ ]],
161
+ ...trackNames(tracks, word, player.locale || void 0)
162
+ ];
142
163
  this.menu.fill([{
143
164
  name: "track",
144
165
  label: word,
@@ -146,15 +167,17 @@ var MbxSubtitlesMenu = class extends MenuElement {
146
167
  items,
147
168
  badgeGlyphs: {
148
169
  [cc]: () => icon("closed-captions"),
149
- [sdh]: () => icon("sdh")
170
+ [sdh]: () => icon("sdh"),
171
+ [generated]: () => icon("generated")
150
172
  },
151
- value: active ?? OFF,
173
+ value: live === "on" ? LIVE : active ?? OFF,
152
174
  onSelect: (value) => {
175
+ if (live !== null) player.setAttribute(LIVE_CAPTIONS, value === LIVE ? "on" : "off");
153
176
  if (listed !== void 0) {
154
177
  for (const track of listed) track.mode = "disabled";
155
178
  const chosen = listed[Number(value)];
156
179
  if (chosen !== void 0) chosen.mode = "showing";
157
- } else if (value === OFF) engine?.tracks.deselect("text");
180
+ } else if (value === OFF || value === LIVE) engine?.tracks.deselect("text");
158
181
  else engine?.tracks.select(value);
159
182
  this.render();
160
183
  }
@@ -163,8 +186,8 @@ var MbxSubtitlesMenu = class extends MenuElement {
163
186
  label: this.word("label-settings", "subtitleSettings", "Settings"),
164
187
  entries: [this.looks(player, SUBTITLE_SIZE, "size", "subtitleSize", "Size", SIZES, "medium", "text-size"), this.looks(player, SUBTITLE_BACKGROUND, "background", "subtitleBackground", "Background", BACKGROUNDS, "dark", "text-background")]
165
188
  }]);
166
- show(this.slots, active === null ? "off" : "on");
167
- this.hidden = tracks.length === 0;
189
+ show(this.slots, active === null && live !== "on" ? "off" : "on");
190
+ this.hidden = tracks.length === 0 && live === null;
168
191
  }
169
192
  };
170
193
  export { MbxSubtitlesMenu, SUBTITLE_BACKGROUND, SUBTITLE_SIZE };
@@ -1 +1 @@
1
- {"version":3,"file":"subtitles-menu.js","names":[],"sources":["../../src/elements/subtitles-menu.ts"],"sourcesContent":["/**\n * <mbx-subtitles-menu>: the text track over `engine.tracks`, or over the\n * video's `textTracks` of kind `subtitles` and `captions` for a native\n * session, with \"off\" because a text selection is releasable and an audio\n * one is not, and a Settings page behind it with the size and the\n * background. The glyph says whether a track is on: `icon` or `icon-on`.\n * Hidden without text tracks.\n *\n * The looks are attributes on the player, `subtitle-size` and\n * `subtitle-background`, where the element's stylesheet turns them into\n * the cue rules; a page can set them in markup and persist them however\n * it likes. Every word the menu shows is an attribute: `label`,\n * `label-off`, `label-track`, `label-settings`, `label-size`,\n * `label-background`, one per size and one per background, `label-sdh`\n * for the badge on subtitles for the deaf and hard of hearing, and\n * `label-cc` for the badge on closed captions carried in the video.\n * `label-track` also names a track that has no name and no language.\n *\n * Forced tracks are not listed. The engine's forced-subtitles stage shows\n * one while no subtitle is selected, so the menu reads Off then (guide\n * chapter 06). In a native session Safari shows them itself. A native\n * `captions` track carries the SDH badge: Safari gives that kind to the\n * subtitles that describe music and sound.\n */\nimport type { Mattebox } from 'mattebox';\nimport { isSdh } from 'mattebox';\nimport type { IconName } from '../controls/icons.js';\nimport { icon } from '../controls/icons.js';\nimport type { MenuGroup, MenuPage } from '../controls/menu.js';\nimport { nativeTracks, onNativeTracks } from '../controls/native-tracks.js';\nimport type { TrackEntry } from '../controls/track-names.js';\nimport { trackNames } from '../controls/track-names.js';\nimport type { PlayerHost } from '../host.js';\nimport type { Messages } from '../messages.js';\nimport { onTracks, trackItems } from './audio-menu.js';\nimport { MenuElement } from './menu-element.js';\nimport { show } from './shared.js';\n\nconst OFF = 'off';\nexport const SUBTITLE_SIZE = 'subtitle-size';\nexport const SUBTITLE_BACKGROUND = 'subtitle-background';\n\n/** A look's value, the id of its word, and its English. */\ntype Choice = readonly [string, keyof Messages, string];\n\nconst SIZES: readonly Choice[] = [\n ['small', 'sizeSmall', 'Small'],\n ['medium', 'sizeMedium', 'Medium'],\n ['large', 'sizeLarge', 'Large'],\n ['xlarge', 'sizeExtraLarge', 'Extra large'],\n];\nconst BACKGROUNDS: readonly Choice[] = [\n ['none', 'backgroundNone', 'None'],\n ['dark', 'backgroundDark', 'Dark'],\n ['solid', 'backgroundSolid', 'Solid'],\n];\n\ntype State = 'off' | 'on';\nconst STATES: readonly State[] = ['off', 'on'];\n\nexport class MbxSubtitlesMenu extends MenuElement<State> {\n static get observedAttributes(): readonly string[] {\n return [\n 'label',\n 'label-back',\n 'label-off',\n 'label-track',\n 'label-settings',\n 'label-size',\n 'label-background',\n 'label-sdh',\n 'label-cc',\n ...SIZES.map(([id]) => `label-${id}`),\n ...BACKGROUNDS.map(([id]) => `label-${id}`),\n ];\n }\n\n declare private engine: Mattebox | null;\n\n constructor() {\n super(STATES, (state) => icon(state === 'on' ? 'subtitles-on' : 'subtitles'));\n // It would change the engine of the page, which a device does not play.\n this.leaves = 'remote';\n this.engine = null;\n show(this.slots, 'off');\n }\n\n protected override name(): readonly [keyof Messages, string] {\n return ['subtitles', 'Subtitles'];\n }\n\n /**\n * A look's page: an item with the look's glyph, its name and the value\n * chosen, which opens the choices. They are named from the attributes,\n * and the value is the player's.\n */\n private looks(\n player: PlayerHost,\n attribute: string,\n name: string,\n id: keyof Messages,\n fallback: string,\n choices: readonly Choice[],\n initial: string,\n glyph: IconName,\n ): MenuPage {\n const set = player.getAttribute(attribute);\n const value = set !== null && choices.some(([id]) => id === set) ? set : initial;\n const label = this.word(`label-${name}`, id, fallback);\n const items = choices.map(\n ([value, word, english]) => [value, this.word(`label-${value}`, word, english)] as const,\n );\n return {\n name,\n label,\n glyph: () => icon(glyph),\n detail: items.find(([id]) => id === value)?.[1] ?? '',\n entries: [\n {\n name,\n label,\n hideLabel: true,\n items,\n value,\n onSelect: (chosen) => {\n player.setAttribute(attribute, chosen);\n this.render();\n },\n },\n ],\n };\n }\n\n protected override attach(player: PlayerHost): void {\n this.follow(player, (engine) => {\n this.engine = engine;\n this.render();\n const tick = (): void => {\n this.render();\n };\n return engine === null\n ? onNativeTracks(player.media, 'textTracks', tick)\n : onTracks(engine, tick);\n });\n }\n\n /** The native session's subtitle tracks as entries, and the showing one's. */\n private native(tracks: readonly TextTrack[]): [TrackEntry[], string | null] {\n const sdh = this.word('label-sdh', 'sdh', 'SDH');\n const entries = tracks.map(\n (track, index): TrackEntry => [\n String(index),\n track.label,\n track.language,\n track.kind === 'captions' ? [sdh] : [],\n [],\n ],\n );\n const on = tracks.findIndex((track) => track.mode === 'showing');\n return [entries, on === -1 ? null : String(on)];\n }\n\n protected override render(): void {\n super.render();\n const engine = this.engine;\n const player = this.player;\n // The chapters track the element adds, and any metadata track, are not subtitles.\n const listed =\n engine === null && player !== null\n ? nativeTracks<TextTrack>(player, 'textTracks')?.filter(\n (track) => track.kind === 'subtitles' || track.kind === 'captions',\n )\n : undefined;\n if (player === null || (engine === null && listed === undefined)) {\n this.hidden = true;\n return;\n }\n const cc = this.word('label-cc', 'closedCaptions', 'CC');\n const sdh = this.word('label-sdh', 'sdh', 'SDH');\n const [tracks, active] =\n listed !== undefined\n ? this.native(listed)\n : trackItems(\n engine as Mattebox,\n 'text',\n (track) => [\n // A manifest names in-band captions by their channel (guide chapter 06).\n ...(track.instreamId !== undefined ? [cc] : []),\n ...(isSdh(track) ? [sdh] : []),\n ],\n (track) => track.forced !== true,\n );\n const word = this.word('label-track', 'track', 'Track');\n const items: MenuGroup['items'] = [\n [OFF, this.word('label-off', 'subtitlesOff', 'Off')],\n ...trackNames(tracks, word, player.locale || undefined),\n ];\n this.menu.fill([\n {\n name: 'track',\n label: word,\n // The menu's title says what the list is.\n hideLabel: true,\n items,\n // The badges are glyphs, named by `label-cc` and `label-sdh`.\n badgeGlyphs: {\n [cc]: () => icon('closed-captions'),\n [sdh]: () => icon('sdh'),\n },\n value: active ?? OFF,\n onSelect: (value) => {\n if (listed !== undefined) {\n // Off first, so two tracks never show at once.\n for (const track of listed) track.mode = 'disabled';\n const chosen = listed[Number(value)];\n if (chosen !== undefined) chosen.mode = 'showing';\n } else if (value === OFF) engine?.tracks.deselect('text');\n else engine?.tracks.select(value);\n this.render();\n },\n },\n {\n name: 'settings',\n label: this.word('label-settings', 'subtitleSettings', 'Settings'),\n entries: [\n this.looks(\n player,\n SUBTITLE_SIZE,\n 'size',\n 'subtitleSize',\n 'Size',\n SIZES,\n 'medium',\n 'text-size',\n ),\n this.looks(\n player,\n SUBTITLE_BACKGROUND,\n 'background',\n 'subtitleBackground',\n 'Background',\n BACKGROUNDS,\n 'dark',\n 'text-background',\n ),\n ],\n },\n ]);\n show(this.slots, active === null ? 'off' : 'on');\n this.hidden = tracks.length === 0;\n }\n}\n"],"mappings":";;;;;;;;AAsCA,MAAM,MAAM;AACZ,MAAa,gBAAgB;AAC7B,MAAa,sBAAsB;AAKnC,MAAM,QAA2B;CAC/B;EAAC;EAAS;EAAa;CAAO;CAC9B;EAAC;EAAU;EAAc;CAAQ;CACjC;EAAC;EAAS;EAAa;CAAO;CAC9B;EAAC;EAAU;EAAkB;CAAa;AAC5C;AACA,MAAM,cAAiC;CACrC;EAAC;EAAQ;EAAkB;CAAM;CACjC;EAAC;EAAQ;EAAkB;CAAM;CACjC;EAAC;EAAS;EAAmB;CAAO;AACtC;AAGA,MAAM,SAA2B,CAAC,OAAO,IAAI;AAE7C,IAAa,mBAAb,cAAsC,YAAmB;CACvD,WAAW,qBAAwC;EACjD,OAAO;GACL;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA,GAAG,MAAM,KAAK,CAAC,QAAQ,SAAS,IAAI;GACpC,GAAG,YAAY,KAAK,CAAC,QAAQ,SAAS,IAAI;EAC5C;CACF;CAIA,cAAc;EACZ,MAAM,SAAS,UAAU,KAAK,UAAU,OAAO,iBAAiB,WAAW,CAAC;EAE5E,KAAK,SAAS;EACd,KAAK,SAAS;EACd,KAAK,KAAK,OAAO,KAAK;CACxB;CAEmB,OAA0C;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ACF,GACA;GACE,MAAM;GACN,OAAO,KAAK,KAAK,kBAAkB,oBAAoB,UAAU;GACjE,SAAS,CACP,KAAK,MACH,QACA,eACA,QACA,gBACA,QACA,OACA,UACA,WACF,GACA,KAAK,MACH,QACA,qBACA,cACA,sBACA,cACA,aACA,QACA,iBACF,CACF;EACF,CACF,CAAC;EACD,KAAK,KAAK,OAAO,WAAW,OAAO,QAAQ,IAAI;EAC/C,KAAK,SAAS,OAAO,WAAW;CAClC;AACF"}
1
+ {"version":3,"file":"subtitles-menu.js","names":[],"sources":["../../src/elements/subtitles-menu.ts"],"sourcesContent":["/**\n * <mbx-subtitles-menu>: the text track over `engine.tracks`, or over the\n * video's `textTracks` of kind `subtitles` and `captions` for a native\n * session, with \"off\" because a text selection is releasable and an audio\n * one is not, and a Settings page behind it with the size and the\n * background. The glyph says whether a track is on: `icon` or `icon-on`.\n * Hidden without text tracks.\n *\n * The looks are attributes on the player, `subtitle-size` and\n * `subtitle-background`, where the element's stylesheet turns them into\n * the cue rules; a page can set them in markup and persist them however\n * it likes. Every word the menu shows is an attribute: `label`,\n * `label-off`, `label-track`, `label-settings`, `label-size`,\n * `label-background`, one per size and one per background, `label-sdh`\n * for the badge on subtitles for the deaf and hard of hearing, and\n * `label-cc` for the badge on closed captions carried in the video.\n * `label-live` names live captions, and `label-generated` is their badge, a\n * sparkle glyph that says a machine wrote them.\n * `label-track` also names a track that has no name and no language.\n *\n * Forced tracks are not listed. The engine's forced-subtitles stage shows\n * one while no subtitle is selected, so the menu reads Off then (guide\n * chapter 06). In a native session Safari shows them itself. A native\n * `captions` track carries the SDH badge: Safari gives that kind to the\n * subtitles that describe music and sound.\n *\n * Live captions: where a package such as `@mattebox/player-live-captions`\n * sets `live-captions` on the player, the menu lists them after Off.\n * Choosing them turns the selected track off and writes `on`; choosing a\n * track or Off writes `off`. The player only reads and writes the\n * attribute, and never knows the package.\n */\nimport type { Mattebox } from 'mattebox';\nimport { isSdh } from 'mattebox';\nimport type { IconName } from '../controls/icons.js';\nimport { icon } from '../controls/icons.js';\nimport type { MenuGroup, MenuPage } from '../controls/menu.js';\nimport { nativeTracks, onNativeTracks } from '../controls/native-tracks.js';\nimport type { TrackEntry } from '../controls/track-names.js';\nimport { trackNames } from '../controls/track-names.js';\nimport type { PlayerHost } from '../host.js';\nimport type { Messages } from '../messages.js';\nimport { onTracks, trackItems } from './audio-menu.js';\nimport { MenuElement } from './menu-element.js';\nimport { show } from './shared.js';\n\nconst OFF = 'off';\n/** The live captions' item, a value no track id or native index takes. */\nconst LIVE = 'live-captions';\n/** The player's attribute a live captions package sets: absent, `off` or `on`. */\nconst LIVE_CAPTIONS = 'live-captions';\nexport const SUBTITLE_SIZE = 'subtitle-size';\nexport const SUBTITLE_BACKGROUND = 'subtitle-background';\n\n/** A look's value, the id of its word, and its English. */\ntype Choice = readonly [string, keyof Messages, string];\n\nconst SIZES: readonly Choice[] = [\n ['small', 'sizeSmall', 'Small'],\n ['medium', 'sizeMedium', 'Medium'],\n ['large', 'sizeLarge', 'Large'],\n ['xlarge', 'sizeExtraLarge', 'Extra large'],\n];\nconst BACKGROUNDS: readonly Choice[] = [\n ['none', 'backgroundNone', 'None'],\n ['dark', 'backgroundDark', 'Dark'],\n ['solid', 'backgroundSolid', 'Solid'],\n];\n\ntype State = 'off' | 'on';\nconst STATES: readonly State[] = ['off', 'on'];\n\nexport class MbxSubtitlesMenu extends MenuElement<State> {\n static get observedAttributes(): readonly string[] {\n return [\n 'label',\n 'label-back',\n 'label-off',\n 'label-track',\n 'label-settings',\n 'label-size',\n 'label-background',\n 'label-sdh',\n 'label-cc',\n 'label-live',\n 'label-generated',\n ...SIZES.map(([id]) => `label-${id}`),\n ...BACKGROUNDS.map(([id]) => `label-${id}`),\n ];\n }\n\n declare private engine: Mattebox | null;\n\n constructor() {\n super(STATES, (state) => icon(state === 'on' ? 'subtitles-on' : 'subtitles'));\n // It would change the engine of the page, which a device does not play.\n this.leaves = 'remote';\n this.engine = null;\n show(this.slots, 'off');\n }\n\n protected override name(): readonly [keyof Messages, string] {\n return ['subtitles', 'Subtitles'];\n }\n\n /**\n * A look's page: an item with the look's glyph, its name and the value\n * chosen, which opens the choices. They are named from the attributes,\n * and the value is the player's.\n */\n private looks(\n player: PlayerHost,\n attribute: string,\n name: string,\n id: keyof Messages,\n fallback: string,\n choices: readonly Choice[],\n initial: string,\n glyph: IconName,\n ): MenuPage {\n const set = player.getAttribute(attribute);\n const value = set !== null && choices.some(([id]) => id === set) ? set : initial;\n const label = this.word(`label-${name}`, id, fallback);\n const items = choices.map(\n ([value, word, english]) => [value, this.word(`label-${value}`, word, english)] as const,\n );\n return {\n name,\n label,\n glyph: () => icon(glyph),\n detail: items.find(([id]) => id === value)?.[1] ?? '',\n entries: [\n {\n name,\n label,\n hideLabel: true,\n items,\n value,\n onSelect: (chosen) => {\n player.setAttribute(attribute, chosen);\n this.render();\n },\n },\n ],\n };\n }\n\n protected override attach(player: PlayerHost): void {\n this.observe(player, [LIVE_CAPTIONS], () => {\n this.render();\n });\n this.follow(player, (engine) => {\n this.engine = engine;\n this.render();\n const tick = (): void => {\n this.render();\n };\n return engine === null\n ? onNativeTracks(player.media, 'textTracks', tick)\n : onTracks(engine, tick);\n });\n }\n\n /** The native session's subtitle tracks as entries, and the showing one's. */\n private native(tracks: readonly TextTrack[]): [TrackEntry[], string | null] {\n const sdh = this.word('label-sdh', 'sdh', 'SDH');\n const entries = tracks.map(\n (track, index): TrackEntry => [\n String(index),\n track.label,\n track.language,\n track.kind === 'captions' ? [sdh] : [],\n [],\n ],\n );\n const on = tracks.findIndex((track) => track.mode === 'showing');\n return [entries, on === -1 ? null : String(on)];\n }\n\n protected override render(): void {\n super.render();\n const engine = this.engine;\n const player = this.player;\n // The chapters track the element adds, and any metadata track, are not subtitles.\n const listed =\n engine === null && player !== null\n ? nativeTracks<TextTrack>(player, 'textTracks')?.filter(\n (track) => track.kind === 'subtitles' || track.kind === 'captions',\n )\n : undefined;\n if (player === null || (engine === null && listed === undefined)) {\n this.hidden = true;\n return;\n }\n const cc = this.word('label-cc', 'closedCaptions', 'CC');\n const sdh = this.word('label-sdh', 'sdh', 'SDH');\n const [tracks, active] =\n listed !== undefined\n ? this.native(listed)\n : trackItems(\n engine as Mattebox,\n 'text',\n (track) => [\n // A manifest names in-band captions by their channel (guide chapter 06).\n ...(track.instreamId !== undefined ? [cc] : []),\n ...(isSdh(track) ? [sdh] : []),\n ],\n (track) => track.forced !== true,\n );\n const word = this.word('label-track', 'track', 'Track');\n const live = player.getAttribute(LIVE_CAPTIONS);\n // A badge says the live captions are a machine's, so no one takes them for a person's.\n const generated = this.word(\n 'label-generated',\n 'liveCaptionsGenerated',\n 'Generated automatically from speech',\n );\n const items: MenuGroup['items'] = [\n [OFF, this.word('label-off', 'subtitlesOff', 'Off')],\n ...(live === null\n ? []\n : [\n [\n LIVE,\n this.word('label-live', 'liveCaptions', 'Live captions'),\n undefined,\n undefined,\n [generated],\n ] as const,\n ]),\n ...trackNames(tracks, word, player.locale || undefined),\n ];\n this.menu.fill([\n {\n name: 'track',\n label: word,\n // The menu's title says what the list is.\n hideLabel: true,\n items,\n // The badges are glyphs, named by `label-cc` and `label-sdh`.\n badgeGlyphs: {\n [cc]: () => icon('closed-captions'),\n [sdh]: () => icon('sdh'),\n [generated]: () => icon('generated'),\n },\n value: live === 'on' ? LIVE : (active ?? OFF),\n onSelect: (value) => {\n if (live !== null) player.setAttribute(LIVE_CAPTIONS, value === LIVE ? 'on' : 'off');\n if (listed !== undefined) {\n // Off first, so two tracks never show at once.\n for (const track of listed) track.mode = 'disabled';\n const chosen = listed[Number(value)];\n if (chosen !== undefined) chosen.mode = 'showing';\n } else if (value === OFF || value === LIVE) engine?.tracks.deselect('text');\n else engine?.tracks.select(value);\n this.render();\n },\n },\n {\n name: 'settings',\n label: this.word('label-settings', 'subtitleSettings', 'Settings'),\n entries: [\n this.looks(\n player,\n SUBTITLE_SIZE,\n 'size',\n 'subtitleSize',\n 'Size',\n SIZES,\n 'medium',\n 'text-size',\n ),\n this.looks(\n player,\n SUBTITLE_BACKGROUND,\n 'background',\n 'subtitleBackground',\n 'Background',\n BACKGROUNDS,\n 'dark',\n 'text-background',\n ),\n ],\n },\n ]);\n show(this.slots, active === null && live !== 'on' ? 'off' : 'on');\n this.hidden = tracks.length === 0 && live === null;\n }\n}\n"],"mappings":";;;;;;;;AA8CA,MAAM,MAAM;;AAEZ,MAAM,OAAO;;AAEb,MAAM,gBAAgB;AACtB,MAAa,gBAAgB;AAC7B,MAAa,sBAAsB;AAKnC,MAAM,QAA2B;CAC/B;EAAC;EAAS;EAAa;CAAO;CAC9B;EAAC;EAAU;EAAc;CAAQ;CACjC;EAAC;EAAS;EAAa;CAAO;CAC9B;EAAC;EAAU;EAAkB;CAAa;AAC5C;AACA,MAAM,cAAiC;CACrC;EAAC;EAAQ;EAAkB;CAAM;CACjC;EAAC;EAAQ;EAAkB;CAAM;CACjC;EAAC;EAAS;EAAmB;CAAO;AACtC;AAGA,MAAM,SAA2B,CAAC,OAAO,IAAI;AAE7C,IAAa,mBAAb,cAAsC,YAAmB;CACvD,WAAW,qBAAwC;EACjD,OAAO;GACL;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA,GAAG,MAAM,KAAK,CAAC,QAAQ,SAAS,IAAI;GACpC,GAAG,YAAY,KAAK,CAAC,QAAQ,SAAS,IAAI;EAC5C;CACF;CAIA,cAAc;EACZ,MAAM,SAAS,UAAU,KAAK,UAAU,OAAO,iBAAiB,WAAW,CAAC;EAE5E,KAAK,SAAS;EACd,KAAK,SAAS;EACd,KAAK,KAAK,OAAO,KAAK;CACxB;CAEmB,OAA0C;EAC3D,OAAO,CAAC,aAAa,WAAW;CAClC;;;;;;CAOQ,MACN,QACA,WACA,MACA,IACA,UACA,SACA,SACA,OACU;EACV,MAAM,MAAM,OAAO,aAAa,SAAS;EACzC,MAAM,QAAQ,QAAQ,QAAQ,QAAQ,MAAM,CAAC,QAAQ,OAAO,GAAG,IAAI,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AO;KACzC,MAAM,SAAS,OAAO,OAAO,KAAK;KAClC,IAAI,WAAW,KAAA,GAAW,OAAO,OAAO;IAC1C,OAAO,IAAI,UAAU,OAAO,UAAU,MAAM,QAAQ,OAAO,SAAS,MAAM;SACrE,QAAQ,OAAO,OAAO,KAAK;IAChC,KAAK,OAAO;GACd;EACF,GACA;GACE,MAAM;GACN,OAAO,KAAK,KAAK,kBAAkB,oBAAoB,UAAU;GACjE,SAAS,CACP,KAAK,MACH,QACA,eACA,QACA,gBACA,QACA,OACA,UACA,WACF,GACA,KAAK,MACH,QACA,qBACA,cACA,sBACA,cACA,aACA,QACA,iBACF,CACF;EACF,CACF,CAAC;EACD,KAAK,KAAK,OAAO,WAAW,QAAQ,SAAS,OAAO,QAAQ,IAAI;EAChE,KAAK,SAAS,OAAO,WAAW,KAAK,SAAS;CAChD;AACF"}
@@ -22,7 +22,7 @@
22
22
  * already follows the video's height, in the page and in fullscreen alike.
23
23
  * A page that wants more writes its own `mattebox-player > video::cue`.
24
24
  */
25
- const CUE_RULES = "mattebox-player[subtitle-size=small]>video::cue{font-size:75%}mattebox-player[subtitle-size=large]>video::cue{font-size:150%}mattebox-player[subtitle-size=xlarge]>video::cue{font-size:200%}mattebox-player[subtitle-background=none]>video::cue{background-color:#0000}mattebox-player[subtitle-background=solid]>video::cue{background-color:#000}mattebox-player[subtitle-background=none]>video::-webkit-media-text-track-display-backdrop{background-color:#0000}mattebox-player[subtitle-background=solid]>video::-webkit-media-text-track-display-backdrop{background-color:#000}";
25
+ const CUE_RULES = "mattebox-player>video::cue{background-color:#0009}mattebox-player>video::-webkit-media-text-track-display-backdrop{background-color:#0000}mattebox-player[subtitle-size=small]>video::cue{font-size:75%}mattebox-player[subtitle-size=large]>video::cue{font-size:150%}mattebox-player[subtitle-size=xlarge]>video::cue{font-size:200%}mattebox-player[subtitle-background=none]>video::cue{background-color:#0000}mattebox-player[subtitle-background=solid]>video::cue{background-color:#000}mattebox-player[subtitle-background=none]>video::-webkit-media-text-track-display-backdrop{background-color:#0000}mattebox-player[subtitle-background=solid]>video::-webkit-media-text-track-display-backdrop{background-color:#000}";
26
26
  /** How the sizes scale the browser's own cue size; the lift counts lines by it. */
27
27
  const SCALES = {
28
28
  small: .75,
@@ -52,7 +52,7 @@ function cueStyle() {
52
52
  const style = document.createElement("style");
53
53
  style.setAttribute(MARK, "");
54
54
  style.textContent = CUE_RULES;
55
- document.head.append(style);
55
+ document.head.prepend(style);
56
56
  }
57
57
  function cueLift(video, host, covered) {
58
58
  /** The cues moved, with what they were, so they and only they are put back. */
@@ -34,12 +34,14 @@ const PATHS = {
34
34
  "picture-in-picture-exit": "M4 6h24v20H4zM6.5 8.5v15h19v-15zM9.5 11.5L16 11.5L9.5 18zM13.63 13.87L19.29 19.52L17.52 21.29L11.87 15.63z",
35
35
  airplay: "M4 6H28V23.25H23V20.75H25.5V8.5H6.5V20.75H9V23.25H4zM16 17.5L23.5 27L8.5 27z",
36
36
  "airplay-active": "M4 6H28V23.25H22.1L16 15.5L9.9 23.25H4zM16 17.5L23.5 27L8.5 27z",
37
+ cast: "M4 6H28V26H17.5V23.5H25.5V8.5H6.5V12H4zM4 22.5A3.5 3.5 0 0 1 7.5 26H4zM4 16A10 10 0 0 1 14 26H11.5A7.5 7.5 0 0 0 4 18.5z",
37
38
  chapters: "M5 6.5h4v4h-4zM12 7.25h15v2.5h-15zM5 14h4v4h-4zM12 14.75h15v2.5h-15zM5 21.5h4v4h-4zM12 22.25h15v2.5h-15z",
38
39
  "fast-forward": "M4 7L15 16L4 25zM16 7L27 16L16 25z",
39
40
  "fast-backward": "M28 7L17 16L28 25zM16 7L5 16L16 25z",
40
41
  "audio-description": "M1.5 23L4.8 9h2.6L10.7 23H8.4l-.75-3.2H4.55L3.8 23zM5.1 17.4h2L6.1 12.9zM12.2 9h2.8a7 7 0 0 1 0 14h-2.8zM14.6 11.4v9.2h.4a4.6 4.6 0 0 0 0-9.2zM24.2 9.96A9.4 9.4 0 0 1 24.2 22.04L22.82 20.89A7.6 7.6 0 0 0 22.82 11.11zM27.11 7.52A13.2 13.2 0 0 1 27.11 24.48L25.73 23.33A11.4 11.4 0 0 0 25.73 8.67z",
41
42
  sdh: "M9.7 13.2L10.3 10.4L11.6 8.5L13.6 7.2L16 6.8L18.7 7.3L20.8 8.6L22.2 10.6L22.7 13L22.5 14.9L21.8 16.3L20.8 17.5L19.6 18.7L18.5 19.9L17.9 21.3L17.5 22.5L17.1 23.5L16.7 24.5L16 25.2L15.2 25.6L14.3 25.7L13.3 25.6L12.6 25.1L12 24.4L11.7 23.4L9.3 24.2L9.8 25.7L10.9 27L12.5 27.9L14.3 28.3L16 28L17.6 27.2L18.7 26L19.5 24.5L19.8 23.3L20.2 22.2L20.6 21.3L21.4 20.3L22.6 19.2L23.9 17.7L24.9 15.7L25.3 13L24.6 9.5L22.6 6.7L19.6 4.9L16 4.2L12.7 4.9L9.9 6.6L7.9 9.4L7.3 12.8zM13.7 13.2L13.9 12.1L14.4 11.4L15.1 10.9L16 10.8L16.9 10.9L17.6 11.4L18.1 12.1L18.3 13.2L20.7 12.8L20.4 11.1L19.4 9.6L17.9 8.6L16 8.2L14.1 8.6L12.6 9.6L11.6 11.1L11.3 12.8z",
42
43
  "closed-captions": "M14.24 20.24A6 6 0 1 1 14.24 11.76L12.47 13.53A3.5 3.5 0 1 0 12.47 18.47zM26.24 20.24A6 6 0 1 1 26.24 11.76L24.47 13.53A3.5 3.5 0 1 0 24.47 18.47z",
44
+ generated: "M13 6Q13.8 15.2 23 16Q13.8 16.8 13 26Q12.2 16.8 3 16Q12.2 15.2 13 6zM24 2Q24.4 6.6 29 7Q24.4 7.4 24 12Q23.6 7.4 19 7Q23.6 6.6 24 2z",
43
45
  "text-size": "M2.5 23L5.9 13L8.1 13L11.5 23zM7 16.53L7.64 18.4L6.36 18.4zM5.65 20.5L8.35 20.5L9.2 23L4.8 23zM12.5 23L19.5 6L22.5 6L29.5 23zM21 9.64L23.45 15.6L18.55 15.6zM17.48 18.2L24.52 18.2L26.5 23L15.5 23z",
44
46
  "text-background": "M4 6h24v20h-24zM9 22.5L14.6 9.5L17.4 9.5L23 22.5zM16 12.75L17.66 16.6L14.34 16.6zM13.35 18.9L18.65 18.9L20.2 22.5L11.8 22.5z"
45
47
  };