@mattebox/player 0.8.0 → 0.9.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 (86) hide show
  1. package/dist/cdn/mattebox-player.min.js +3 -3
  2. package/dist/controls/icons.d.ts +5 -30
  3. package/dist/controls/icons.d.ts.map +1 -1
  4. package/dist/controls/icons.js +38 -29
  5. package/dist/controls/icons.js.map +1 -1
  6. package/dist/controls/menu.d.ts +11 -0
  7. package/dist/controls/menu.d.ts.map +1 -1
  8. package/dist/controls/menu.js +31 -5
  9. package/dist/controls/menu.js.map +1 -1
  10. package/dist/element.d.ts +36 -2
  11. package/dist/element.d.ts.map +1 -1
  12. package/dist/element.js +140 -24
  13. package/dist/element.js.map +1 -1
  14. package/dist/elements/audio-menu.d.ts.map +1 -1
  15. package/dist/elements/audio-menu.js +3 -1
  16. package/dist/elements/audio-menu.js.map +1 -1
  17. package/dist/elements/component.d.ts.map +1 -1
  18. package/dist/elements/component.js +10 -0
  19. package/dist/elements/component.js.map +1 -1
  20. package/dist/elements/control-bar.d.ts +2 -0
  21. package/dist/elements/control-bar.d.ts.map +1 -1
  22. package/dist/elements/control-bar.js +23 -7
  23. package/dist/elements/control-bar.js.map +1 -1
  24. package/dist/elements/current-time.d.ts.map +1 -1
  25. package/dist/elements/current-time.js +1 -1
  26. package/dist/elements/current-time.js.map +1 -1
  27. package/dist/elements/drm-badge.js +1 -1
  28. package/dist/elements/duration.d.ts.map +1 -1
  29. package/dist/elements/duration.js +6 -2
  30. package/dist/elements/duration.js.map +1 -1
  31. package/dist/elements/error-screen.js +1 -1
  32. package/dist/elements/live-button.js +1 -1
  33. package/dist/elements/marker-button.d.ts +3 -3
  34. package/dist/elements/marker-button.d.ts.map +1 -1
  35. package/dist/elements/marker-button.js +18 -22
  36. package/dist/elements/marker-button.js.map +1 -1
  37. package/dist/elements/quality-menu.js +1 -1
  38. package/dist/elements/quality-menu.js.map +1 -1
  39. package/dist/elements/scan-button.js +1 -1
  40. package/dist/elements/seek-bar.d.ts.map +1 -1
  41. package/dist/elements/seek-bar.js +5 -4
  42. package/dist/elements/seek-bar.js.map +1 -1
  43. package/dist/elements/shared.js +3 -3
  44. package/dist/elements/skip-button.js +2 -2
  45. package/dist/elements/skip-button.js.map +1 -1
  46. package/dist/elements/spinner.js +1 -1
  47. package/dist/elements/start-button.d.ts +5 -0
  48. package/dist/elements/start-button.d.ts.map +1 -1
  49. package/dist/elements/start-button.js +15 -2
  50. package/dist/elements/start-button.js.map +1 -1
  51. package/dist/elements/subtitles-menu.d.ts +5 -1
  52. package/dist/elements/subtitles-menu.d.ts.map +1 -1
  53. package/dist/elements/subtitles-menu.js +29 -11
  54. package/dist/elements/subtitles-menu.js.map +1 -1
  55. package/dist/elements/title.d.ts.map +1 -1
  56. package/dist/elements/title.js +3 -1
  57. package/dist/elements/title.js.map +1 -1
  58. package/dist/elements/volume-slider.js +1 -1
  59. package/dist/elements/volume.js +1 -1
  60. package/dist/es2015/controls/icons.js +38 -29
  61. package/dist/es2015/controls/menu.js +32 -5
  62. package/dist/es2015/element.js +142 -28
  63. package/dist/es2015/elements/audio-menu.js +4 -1
  64. package/dist/es2015/elements/component.js +10 -0
  65. package/dist/es2015/elements/control-bar.js +23 -7
  66. package/dist/es2015/elements/current-time.js +1 -1
  67. package/dist/es2015/elements/drm-badge.js +1 -1
  68. package/dist/es2015/elements/duration.js +6 -2
  69. package/dist/es2015/elements/error-screen.js +1 -1
  70. package/dist/es2015/elements/live-button.js +1 -1
  71. package/dist/es2015/elements/marker-button.js +19 -23
  72. package/dist/es2015/elements/quality-menu.js +1 -1
  73. package/dist/es2015/elements/scan-button.js +1 -1
  74. package/dist/es2015/elements/seek-bar.js +5 -4
  75. package/dist/es2015/elements/shared.js +3 -3
  76. package/dist/es2015/elements/skip-button.js +2 -2
  77. package/dist/es2015/elements/spinner.js +1 -1
  78. package/dist/es2015/elements/start-button.js +15 -2
  79. package/dist/es2015/elements/subtitles-menu.js +35 -17
  80. package/dist/es2015/elements/title.js +3 -1
  81. package/dist/es2015/elements/volume-slider.js +1 -1
  82. package/dist/es2015/elements/volume.js +1 -1
  83. package/dist/es2015/style.js +1 -1
  84. package/dist/style.js +1 -1
  85. package/package.json +4 -5
  86. package/NOTICE +0 -24
@@ -4,7 +4,7 @@ import { number, style } from "./shared.js";
4
4
  import { cueLift, cueStyle } from "../controls/cues.js";
5
5
  import { fullscreen } from "../controls/fullscreen.js";
6
6
  //#region src/elements/control-bar.ts
7
- const STYLE = ":host{box-sizing:border-box;color:var(--mbx-text);font:500 16px / 1.2 var(--mbx-font);background:linear-gradient(#0000,#0009);flex-direction:column;padding:40px 16px 12px;transition:opacity .2s;display:flex;position:absolute;bottom:0;left:0;right:0}:host([idle]){opacity:0;pointer-events:none}[part~=row]{align-items:center;margin:0 -4px;display:flex}[part~=buttons-row]{margin-top:4px}[part~=seek-row]{margin:0 -8px}slot:not([name])::slotted(*){margin:0 4px}slot[name=seek]::slotted(*){margin:0 8px}::slotted([collapsed]){display:none}@media (prefers-reduced-motion:reduce){:host{transition:none}}";
7
+ const STYLE = ":host{box-sizing:border-box;color:var(--mbx-text);font:500 1em / 1.2 var(--mbx-font);background:linear-gradient(#0000,#0009);flex-direction:column;padding:2.5em 1em .75em;transition:opacity .2s;display:flex;position:absolute;bottom:0;left:0;right:0}:host([menu]){z-index:2;--mbx-tooltip:none}:host([idle]){opacity:0;pointer-events:none}[part~=row]{align-items:center;margin:0 -.25em;display:flex}[part~=buttons-row]{margin-top:.25em}[part~=seek-row]{margin:0 -.5em}slot:not([name])::slotted(*){margin:0 .25em}slot[name=seek]::slotted(*){margin:0 .5em}::slotted([collapsed]){display:none}@media (prefers-reduced-motion:reduce){:host{transition:none}}:host([layout=compact]){padding:1.5em .5em .25em}";
8
8
  const IDLE_MS = 3e3;
9
9
  const SEEK_STEP = 5;
10
10
  /**
@@ -33,10 +33,10 @@ const PRIORITY = {
33
33
  [VOLUME]: 1,
34
34
  [MUTE_BUTTON]: 1
35
35
  };
36
- /** The width the volume group unfolds its slider to, from volume.ts: what a folded slider is counted at. */
37
- const SLIDER_WIDTH = 80;
38
- /** Room kept between the last button and the edge, so nothing sits flush against it. */
39
- const SLACK = 8;
36
+ /** The width the volume group unfolds its slider to, in em, from volume.css: what a folded slider is counted at. */
37
+ const SLIDER_WIDTH = 5;
38
+ /** Room kept between the last button and the edge, in em, so nothing sits flush against it. */
39
+ const SLACK = .5;
40
40
  function shown(node) {
41
41
  return node.getClientRects().length > 0;
42
42
  }
@@ -91,6 +91,10 @@ var MbxControlBar = class extends Component {
91
91
  * folded slider at the width it unfolds to. The row's own width says nothing, because the
92
92
  * spacer fills it whatever the buttons take.
93
93
  */
94
+ /** The bar's em in pixels: its sizes follow the player's font size. */
95
+ em() {
96
+ return Number.parseFloat(getComputedStyle(this).fontSize) || 16;
97
+ }
94
98
  needed(children) {
95
99
  let sum = 0;
96
100
  for (const child of children) {
@@ -99,7 +103,7 @@ var MbxControlBar = class extends Component {
99
103
  sum += child.getBoundingClientRect().width;
100
104
  sum += Number.parseFloat(margins.marginLeft) + Number.parseFloat(margins.marginRight);
101
105
  const folded = slider(child);
102
- if (folded !== null && shown(folded)) sum += Math.max(0, SLIDER_WIDTH - folded.getBoundingClientRect().width);
106
+ if (folded !== null && shown(folded)) sum += Math.max(0, SLIDER_WIDTH * this.em() - folded.getBoundingClientRect().width);
103
107
  }
104
108
  return sum;
105
109
  }
@@ -129,7 +133,7 @@ var MbxControlBar = class extends Component {
129
133
  });
130
134
  }
131
135
  candidates.sort((a, b) => b.priority - a.priority || b.index - a.index);
132
- const room = this.buttonsRow.clientWidth - SLACK;
136
+ const room = this.buttonsRow.clientWidth - SLACK * this.em();
133
137
  for (const { node, priority: level } of candidates) {
134
138
  if (level === 0) return;
135
139
  if (this.needed(children) <= room) return;
@@ -239,6 +243,18 @@ var MbxControlBar = class extends Component {
239
243
  };
240
244
  this.keep(screen.watch(reflect));
241
245
  reflect();
246
+ const menus = new MutationObserver(() => {
247
+ this.toggleAttribute("menu", this.querySelector("[open]") !== null);
248
+ });
249
+ menus.observe(this, {
250
+ subtree: true,
251
+ attributes: true,
252
+ attributeFilter: ["open"]
253
+ });
254
+ this.keep(() => {
255
+ menus.disconnect();
256
+ this.removeAttribute("menu");
257
+ });
242
258
  const pointer = () => {
243
259
  this.keyboard = false;
244
260
  this.wake(player);
@@ -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 {\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 VOLUME,\n VOLUME_SLIDER,\n} from '../tags.js';\nimport { Component } from './component.js';\nimport STYLE from './control-bar.css?inline';\nimport { number, 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 and the subtitles. The subtitles\n * menu goes last of the menus because it is the one a viewer may need.\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 [VOLUME]: 1,\n [MUTE_BUTTON]: 1,\n};\n\n/** The width the volume group unfolds its slider to, from volume.ts: what a folded slider is counted at. */\nconst SLIDER_WIDTH = 80;\n\n/** Room kept between the last button and the edge, so nothing sits flush against it. */\nconst SLACK = 8;\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 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 - 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;\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 (player.video.paused) 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.video;\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.video;\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.video;\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\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] === video) 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 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":";;;;;;AAgEA,MAAA,QAAA;AAGA,MAAA,UAAA;AACA,MAAA,YAAA;;;;;;;;;;;AAYA,MAAA,WAAA;EACA,cAAA;EACA,gBAAA;CACA,mBAAA;EACA,YAAA;EACA,aAAA;EACA,gBAAA;EACA,aAAA;EACA,eAAA;EACA,aAAA;EACA,iBAAA;EACA,cAAA;EACA,iBAAA;EACA,SAAA;EACA,cAAA;AACA;;AAGA,MAAA,eAAA;;AAGA,MAAA,QAAA;AASA,SAAA,MAAA,MAAA;CACA,OAAA,KAAA,eAAA,CAAA,CAAA,SAAA;AACA;;AAGA,SAAA,OAAA,OAAA;CACA,OAAA,MAAA,cAAA,eAAA,MAAA,cAAA,aAAA,IAAA;AACA;;AAGA,SAAA,SAAA,OAAA;CACA,MAAA,MAAA,MAAA,aAAA,UAAA;CACA,IAAA,QAAA,MAAA;EACA,MAAA,QAAA,OAAA,GAAA;EACA,OAAA,OAAA,SAAA,KAAA,KAAA,QAAA,IAAA,QAAA;CACA;CACA,OAAA,SAAA,MAAA,cAAA;AACA;AAEA,SAAA,IAAA,OAAA;CACA,IAAA,OAAA,SAAA,MAAA,QAAA,GAAA,OAAA,MAAA;CACA,MAAA,SAAA,MAAA;CACA,OAAA,OAAA,SAAA,IAAA,OAAA,IAAA,OAAA,SAAA,CAAA,IAAA,MAAA;AACA;AAEA,SAAA,OAAA,OAAA;CACA,IAAA,MAAA,QAAA,MAAA,KAAA,CAAA,CAAA,YAAA,KAAA,CAAA;MACA,MAAA,MAAA;AACA;AAEA,IAAA,gBAAA,cAAA,UAAA;CACA,WAAA,qBAAA;EACA,OAAA,CAAA,WAAA,WAAA;CACA;CAaA,cAAA;EACA,MAAA;EACA,KAAA,QAAA,KAAA;EACA,KAAA,WAAA;EACA,KAAA,OAAA;EACA,KAAA,SAAA;EACA,KAAA,UAAA;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AAA,KAAA,MAAA;EACA;EACA,MAAA,OAAA,UAAA;GACA,KAAA,IAAA,QAAA,KAAA;EACA;EACA,MAAA,SAAA,UAAA;GAEA,IAAA,MAAA,aAAA,CAAA,CAAA,OAAA,OAAA,OAAA,KAAA;EACA;EACA,KAAA,OAAA,QAAA,CAAA,eAAA,aAAA,GAAA,OAAA;EACA,OAAA,iBAAA,WAAA,GAAA;EACA,OAAA,iBAAA,SAAA,KAAA;EACA,KAAA,WAAA;GACA,OAAA,oBAAA,WAAA,GAAA;GACA,OAAA,oBAAA,SAAA,KAAA;EACA,CAAA;EACA,KAAA,OAAA,OAAA;GAAA;GAAA;GAAA;EAAA,SAAA;GACA,KAAA,KAAA,MAAA;EACA,CAAA;EACA,KAAA,KAAA,MAAA;EACA,KAAA,KAAA,OAAA,IAAA;EAKA,MAAA,iBAAA;GACA,KAAA,SAAA;EACA;EACA,KAAA,OAAA,KAAA,SAAA,CAAA,YAAA,GAAA,QAAA;EACA,KAAA,QAAA,MAAA;GAAA;GAAA;GAAA;EAAA,GAAA,UAAA,IAAA;EACA,IAAA,OAAA,mBAAA,aAAA;GACA,KAAA,UAAA,IAAA,eAAA,QAAA;GACA,KAAA,QAAA,QAAA,KAAA,UAAA;EACA;EACA,SAAA;CACA;CAEA,OAAA,QAAA;EACA,aAAA,KAAA,KAAA;EACA,KAAA,QAAA,KAAA;EACA,KAAA,SAAA,WAAA;EACA,KAAA,UAAA;EACA,KAAA,MAAA,SAAA,KAAA,QAAA,iBAAA,GAAA;GACA,MAAA,gBAAA,WAAA;GACA,OAAA,KAAA,CAAA,EAAA,gBAAA,WAAA;EACA;EACA,KAAA,MAAA,QAAA;EACA,KAAA,OAAA;EACA,KAAA,SAAA;EACA,KAAA,gBAAA,MAAA;EACA,OAAA,gBAAA,MAAA;EACA,OAAA,gBAAA,YAAA;CACA;AACA"}
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 {\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 VOLUME,\n VOLUME_SLIDER,\n} from '../tags.js';\nimport { Component } from './component.js';\nimport STYLE from './control-bar.css?inline';\nimport { number, 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 and the subtitles. The subtitles\n * menu goes last of the menus because it is the one a viewer may need.\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 [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 (player.video.paused) 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.video;\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.video;\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.video;\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] === video) 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 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":";;;;;;AAgEA,MAAA,QAAA;AAGA,MAAA,UAAA;AACA,MAAA,YAAA;;;;;;;;;;;AAYA,MAAA,WAAA;EACA,cAAA;EACA,gBAAA;CACA,mBAAA;EACA,YAAA;EACA,aAAA;EACA,gBAAA;EACA,aAAA;EACA,eAAA;EACA,aAAA;EACA,iBAAA;EACA,cAAA;EACA,iBAAA;EACA,SAAA;EACA,cAAA;AACA;;AAGA,MAAA,eAAA;;AAGA,MAAA,QAAA;AASA,SAAA,MAAA,MAAA;CACA,OAAA,KAAA,eAAA,CAAA,CAAA,SAAA;AACA;;AAGA,SAAA,OAAA,OAAA;CACA,OAAA,MAAA,cAAA,eAAA,MAAA,cAAA,aAAA,IAAA;AACA;;AAGA,SAAA,SAAA,OAAA;CACA,MAAA,MAAA,MAAA,aAAA,UAAA;CACA,IAAA,QAAA,MAAA;EACA,MAAA,QAAA,OAAA,GAAA;EACA,OAAA,OAAA,SAAA,KAAA,KAAA,QAAA,IAAA,QAAA;CACA;CACA,OAAA,SAAA,MAAA,cAAA;AACA;AAEA,SAAA,IAAA,OAAA;CACA,IAAA,OAAA,SAAA,MAAA,QAAA,GAAA,OAAA,MAAA;CACA,MAAA,SAAA,MAAA;CACA,OAAA,OAAA,SAAA,IAAA,OAAA,IAAA,OAAA,SAAA,CAAA,IAAA,MAAA;AACA;AAEA,SAAA,OAAA,OAAA;CACA,IAAA,MAAA,QAAA,MAAA,KAAA,CAAA,CAAA,YAAA,KAAA,CAAA;MACA,MAAA,MAAA;AACA;AAEA,IAAA,gBAAA,cAAA,UAAA;CACA,WAAA,qBAAA;EACA,OAAA,CAAA,WAAA,WAAA;CACA;CAaA,cAAA;EACA,MAAA;EACA,KAAA,QAAA,KAAA;EACA,KAAA,WAAA;EACA,KAAA,OAAA;EACA,KAAA,SAAA;EACA,KAAA,UAAA;EACA,MAAA,OAAA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A;EACA,KAAA,MAAA,SAAA,KAAA,QAAA,iBAAA,GAAA;GACA,MAAA,gBAAA,WAAA;GACA,OAAA,KAAA,CAAA,EAAA,gBAAA,WAAA;EACA;EACA,KAAA,MAAA,QAAA;EACA,KAAA,OAAA;EACA,KAAA,SAAA;EACA,KAAA,gBAAA,MAAA;EACA,OAAA,gBAAA,MAAA;EACA,OAAA,gBAAA,YAAA;CACA;AACA"}
@@ -1 +1 @@
1
- {"version":3,"file":"current-time.d.ts","sourceRoot":"","sources":["../../src/elements/current-time.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,qBAAa,cAAe,SAAQ,WAAW;cAC1B,MAAM,IAAI,IAAI;CAYlC"}
1
+ {"version":3,"file":"current-time.d.ts","sourceRoot":"","sources":["../../src/elements/current-time.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,qBAAa,cAAe,SAAQ,WAAW;cAC1B,MAAM,IAAI,IAAI;CAelC"}
@@ -19,7 +19,7 @@ var MbxCurrentTime = class extends TimeElement {
19
19
  const on = live(engine) !== void 0;
20
20
  const time = video.currentTime;
21
21
  this.text.data = on ? wall(engine, time) ?? `-${format(span(video, engine).end - time)}` : format(time);
22
- this.hidden = on && player.hasAttribute("live") && !player.hasAttribute("seekable");
22
+ this.hidden = on && player.hasAttribute("live") && !player.hasAttribute("seekable") || !on && this.getAttribute("layout") === "compact";
23
23
  }
24
24
  };
25
25
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"current-time.js","names":[],"sources":["../../src/elements/current-time.ts"],"sourcesContent":["/**\n * <mbx-current-time>: the position, \"1:23\". On a live stream it reads the\n * wall clock when `engine.pdt` can say it, \"14:23:05\", which is what a\n * viewer of a broadcast wants to know, and the distance behind the edge\n * otherwise, \"-0:10\". While the player says the stream is live but not\n * seekable, which the seek bar decides, there is no position to show and\n * the element hides.\n */\nimport { live, span, wall } from '../controls/session.js';\nimport { format } from '../controls/time.js';\nimport { TimeElement } from './time-element.js';\n\nexport class MbxCurrentTime extends TimeElement {\n protected override render(): void {\n const player = this.player;\n if (player === null) return;\n const video = player.video;\n const engine = player.engine;\n const on = live(engine) !== undefined;\n const time = video.currentTime;\n this.text.data = on\n ? (wall(engine, time) ?? `-${format(span(video, engine).end - time)}`)\n : format(time);\n this.hidden = on && player.hasAttribute('live') && !player.hasAttribute('seekable');\n }\n}\n"],"mappings":";;;;;;;;;;;;AAYA,IAAa,iBAAb,cAAoC,YAAY;CAC9C,SAAkC;EAChC,MAAM,SAAS,KAAK;EACpB,IAAI,WAAW,MAAM;EACrB,MAAM,QAAQ,OAAO;EACrB,MAAM,SAAS,OAAO;EACtB,MAAM,KAAK,KAAK,MAAM,MAAM,KAAA;EAC5B,MAAM,OAAO,MAAM;EACnB,KAAK,KAAK,OAAO,KACZ,KAAK,QAAQ,IAAI,KAAK,IAAI,OAAO,KAAK,OAAO,MAAM,CAAC,CAAC,MAAM,IAAI,MAChE,OAAO,IAAI;EACf,KAAK,SAAS,MAAM,OAAO,aAAa,MAAM,KAAK,CAAC,OAAO,aAAa,UAAU;CACpF;AACF"}
1
+ {"version":3,"file":"current-time.js","names":[],"sources":["../../src/elements/current-time.ts"],"sourcesContent":["/**\n * <mbx-current-time>: the position, \"1:23\". On a live stream it reads the\n * wall clock when `engine.pdt` can say it, \"14:23:05\", which is what a\n * viewer of a broadcast wants to know, and the distance behind the edge\n * otherwise, \"-0:10\". While the player says the stream is live but not\n * seekable, which the seek bar decides, there is no position to show and\n * the element hides.\n */\nimport { live, span, wall } from '../controls/session.js';\nimport { format } from '../controls/time.js';\nimport { TimeElement } from './time-element.js';\n\nexport class MbxCurrentTime extends TimeElement {\n protected override render(): void {\n const player = this.player;\n if (player === null) return;\n const video = player.video;\n const engine = player.engine;\n const on = live(engine) !== undefined;\n const time = video.currentTime;\n this.text.data = on\n ? (wall(engine, time) ?? `-${format(span(video, engine).end - time)}`)\n : format(time);\n // A compact player keeps one readout, the time left, which the duration shows.\n this.hidden =\n (on && player.hasAttribute('live') && !player.hasAttribute('seekable')) ||\n (!on && this.getAttribute('layout') === 'compact');\n }\n}\n"],"mappings":";;;;;;;;;;;;AAYA,IAAa,iBAAb,cAAoC,YAAY;CAC9C,SAAkC;EAChC,MAAM,SAAS,KAAK;EACpB,IAAI,WAAW,MAAM;EACrB,MAAM,QAAQ,OAAO;EACrB,MAAM,SAAS,OAAO;EACtB,MAAM,KAAK,KAAK,MAAM,MAAM,KAAA;EAC5B,MAAM,OAAO,MAAM;EACnB,KAAK,KAAK,OAAO,KACZ,KAAK,QAAQ,IAAI,KAAK,IAAI,OAAO,KAAK,OAAO,MAAM,CAAC,CAAC,MAAM,IAAI,MAChE,OAAO,IAAI;EAEf,KAAK,SACF,MAAM,OAAO,aAAa,MAAM,KAAK,CAAC,OAAO,aAAa,UAAU,KACpE,CAAC,MAAM,KAAK,aAAa,QAAQ,MAAM;CAC5C;AACF"}
@@ -5,7 +5,7 @@ import { Component } from "./component.js";
5
5
  import { style } from "./shared.js";
6
6
  import { fill } from "../labels.js";
7
7
  //#region src/elements/drm-badge.ts
8
- const STYLE = ":host{width:40px;height:40px;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:#101114f2;margin-bottom:8px;padding:8px 10px;font-size:13px;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: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";
@@ -1 +1 @@
1
- {"version":3,"file":"duration.d.ts","sourceRoot":"","sources":["../../src/elements/duration.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGhD,qBAAa,WAAY,SAAQ,WAAW;;cAKvB,MAAM,IAAI,IAAI;CAQlC"}
1
+ {"version":3,"file":"duration.d.ts","sourceRoot":"","sources":["../../src/elements/duration.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGhD,qBAAa,WAAY,SAAQ,WAAW;;cAKvB,MAAM,IAAI,IAAI;CAclC"}
@@ -4,7 +4,9 @@ import { TimeElement } from "./time-element.js";
4
4
  //#region src/elements/duration.ts
5
5
  /**
6
6
  * <mbx-duration>: the duration, "4:56", once the metadata is in. A live
7
- * stream has none, so the element hides while the stream is live.
7
+ * stream has none, so the element hides while the stream is live. On a
8
+ * compact player it shows the time left, "-3:12", in place of the current
9
+ * time, which hides there.
8
10
  */
9
11
  const TRAILING = ":host{text-align:right}";
10
12
  var MbxDuration = class extends TimeElement {
@@ -17,7 +19,9 @@ var MbxDuration = class extends TimeElement {
17
19
  const engine = player.engine;
18
20
  const on = live(engine) !== void 0;
19
21
  this.hidden = on;
20
- if (!on) this.text.data = format(span(player.video, engine).end);
22
+ if (on) return;
23
+ const end = span(player.video, engine).end;
24
+ this.text.data = this.getAttribute("layout") === "compact" ? `-${format(Math.max(0, end - player.video.currentTime))}` : format(end);
21
25
  }
22
26
  };
23
27
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"duration.js","names":[],"sources":["../../src/elements/duration.ts"],"sourcesContent":["/**\n * <mbx-duration>: the duration, \"4:56\", once the metadata is in. A live\n * stream has none, so the element hides while the stream is live.\n */\nimport { live, span } from '../controls/session.js';\nimport { format } from '../controls/time.js';\nimport { TimeElement } from './time-element.js';\nimport TRAILING from './trailing-time.css?inline';\n\nexport class MbxDuration extends TimeElement {\n constructor() {\n super(TRAILING);\n }\n\n protected override render(): void {\n const player = this.player;\n if (player === null) return;\n const engine = player.engine;\n const on = live(engine) !== undefined;\n this.hidden = on;\n if (!on) this.text.data = format(span(player.video, engine).end);\n }\n}\n"],"mappings":";;;;;;;;AAOA,MAAA,WAAA;AAEA,IAAA,cAAA,cAAA,YAAA;CACA,cAAA;EACA,MAAA,QAAA;CACA;CAEA,SAAA;EACA,MAAA,SAAA,KAAA;EACA,IAAA,WAAA,MAAA;EACA,MAAA,SAAA,OAAA;EACA,MAAA,KAAA,KAAA,MAAA,MAAA,KAAA;EACA,KAAA,SAAA;EACA,IAAA,CAAA,IAAA,KAAA,KAAA,OAAA,OAAA,KAAA,OAAA,OAAA,MAAA,CAAA,CAAA,GAAA;CACA;AACA"}
1
+ {"version":3,"file":"duration.js","names":[],"sources":["../../src/elements/duration.ts"],"sourcesContent":["/**\n * <mbx-duration>: the duration, \"4:56\", once the metadata is in. A live\n * stream has none, so the element hides while the stream is live. On a\n * compact player it shows the time left, \"-3:12\", in place of the current\n * time, which hides there.\n */\nimport { live, span } from '../controls/session.js';\nimport { format } from '../controls/time.js';\nimport { TimeElement } from './time-element.js';\nimport TRAILING from './trailing-time.css?inline';\n\nexport class MbxDuration extends TimeElement {\n constructor() {\n super(TRAILING);\n }\n\n protected override render(): void {\n const player = this.player;\n if (player === null) return;\n const engine = player.engine;\n const on = live(engine) !== undefined;\n this.hidden = on;\n if (on) return;\n const end = span(player.video, engine).end;\n // A compact player has one readout, so this one counts down.\n this.text.data =\n this.getAttribute('layout') === 'compact'\n ? `-${format(Math.max(0, end - player.video.currentTime))}`\n : format(end);\n }\n}\n"],"mappings":";;;;;;;;;;AASA,MAAA,WAAA;AAEA,IAAA,cAAA,cAAA,YAAA;CACA,cAAA;EACA,MAAA,QAAA;CACA;CAEA,SAAA;EACA,MAAA,SAAA,KAAA;EACA,IAAA,WAAA,MAAA;EACA,MAAA,SAAA,OAAA;EACA,MAAA,KAAA,KAAA,MAAA,MAAA,KAAA;EACA,KAAA,SAAA;EACA,IAAA,IAAA;EACA,MAAA,MAAA,KAAA,OAAA,OAAA,MAAA,CAAA,CAAA;EAEA,KAAA,KAAA,OACA,KAAA,aAAA,QAAA,MAAA,YACA,IAAA,OAAA,KAAA,IAAA,GAAA,MAAA,OAAA,MAAA,WAAA,CAAA,MACA,OAAA,GAAA;CACA;AACA"}
@@ -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
  //#region src/elements/error-screen.ts
5
- const STYLE = ":host{color:var(--mbx-text);font:400 15px / 1.4 var(--mbx-font);text-align:center;background:#000000bf;justify-content:center;align-items:center;padding:16px;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:8px}[part~=title]{font-size:18px;font-weight:600}[part~=detail]{color:var(--mbx-error);font-family:monospace;font-size:13px}[part~=retry]{height:36px;font:inherit;color:inherit;border-radius:var(--mbx-radius);cursor:pointer;background:0 0;border:1px solid;padding:0 16px;font-weight:600}[part~=retry]:focus{outline:2px solid var(--mbx-accent);outline-offset:-2px}[part~=retry]: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~=retry]{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~=retry]:focus{outline:2px solid var(--mbx-accent);outline-offset:-2px}[part~=retry]:focus:not(:focus-visible){outline:none}";
6
6
  var MbxErrorScreen = class extends Component {
7
7
  static get observedAttributes() {
8
8
  return ["label-title", "label-retry"];
@@ -16,7 +16,7 @@ import { live } from "../controls/session.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:40px;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 8px;font-size:12px;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:10px;height:10px;margin-right:6px;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: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 [
@@ -12,9 +12,9 @@ export declare class MbxMarkerButton extends Component {
12
12
  protected attach(player: PlayerHost): void;
13
13
  protected detach(): void;
14
14
  /**
15
- * Lifts the button above the bar's rows, or above the title's text while
16
- * it shows: each one's box less the padding over its content, which is
17
- * its fade. A hidden title has no box.
15
+ * Lifts the button above the bar's rows: the bar's box less the padding
16
+ * over them, its fade. The title sits on the other side, so the button
17
+ * stays where it is while the title shows.
18
18
  */
19
19
  private fit;
20
20
  protected render(): void;
@@ -1 +1 @@
1
- {"version":3,"file":"marker-button.d.ts","sourceRoot":"","sources":["../../src/elements/marker-button.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAS3C,qBAAa,eAAgB,SAAQ,SAAS;IAC5C,MAAM,KAAK,kBAAkB,IAAI,SAAS,MAAM,EAAE,CAEjD;IAED,iBAAyB,MAAM,CAAoB;IACnD,qEAAqE;IACrE,QAAgB,MAAM,CAAgB;IACtC,gFAAgF;IAChF,QAAgB,OAAO,CAAwB;;IAkBtC,iBAAiB,IAAI,IAAI;cAMf,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;cAyBhC,MAAM,IAAI,IAAI;IAKjC;;;;OAIG;IACH,OAAO,CAAC,GAAG;cAWQ,MAAM,IAAI,IAAI;CAelC"}
1
+ {"version":3,"file":"marker-button.d.ts","sourceRoot":"","sources":["../../src/elements/marker-button.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAS3C,qBAAa,eAAgB,SAAQ,SAAS;IAC5C,MAAM,KAAK,kBAAkB,IAAI,SAAS,MAAM,EAAE,CAEjD;IAED,iBAAyB,MAAM,CAAoB;IACnD,qEAAqE;IACrE,QAAgB,MAAM,CAAgB;IACtC,gFAAgF;IAChF,QAAgB,OAAO,CAAwB;;IAkBtC,iBAAiB,IAAI,IAAI;cAMf,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;cA6BhC,MAAM,IAAI,IAAI;IAKjC;;;;OAIG;IACH,OAAO,CAAC,GAAG;cAOQ,MAAM,IAAI,IAAI;CAoBlC"}
@@ -1,7 +1,7 @@
1
1
  import { Component } from "./component.js";
2
2
  import { BUTTON_STYLE, style } from "./shared.js";
3
3
  //#region src/elements/marker-button.ts
4
- const STYLE_CSS = ":host{right:calc(var(--mbx-pad,8px) + 8px);bottom:calc(var(--mbx-marker-lift,56px) + 12px);z-index:1;position:absolute}:host([hidden]){display:none}[part~=button]{width:auto;height:40px;color:var(--mbx-text);font:inherit;white-space:nowrap;background:#0009;border:1px solid #ffffff80;padding:0 18px;font-weight:600}[part~=button]:hover{background:#000c}";
4
+ const STYLE_CSS = ":host{right:calc(var(--mbx-pad,.5em) + .5em);bottom:calc(var(--mbx-marker-lift,3.5em) + .75em);z-index:1;transition:transform .3s;position:absolute}:host([idle]){transform:translateY(var(--mbx-marker-lift,3.5em))}:host([hidden]){display:none}[part~=button]{width:auto;height:2.5em;color:var(--mbx-text);font:inherit;white-space:nowrap;background:#0009;border:1px solid #ffffff80;padding:0 1.125em;font-weight:600}[part~=button]:hover{background:#000c}@media (prefers-reduced-motion:reduce){:host{transition:none}}";
5
5
  const WORDS = {
6
6
  "opening-credits": "Skip intro",
7
7
  "closing-credits": "Skip credits"
@@ -44,22 +44,21 @@ var MbxMarkerButton = class extends Component {
44
44
  this.listen(player, ["markerschange"], () => {
45
45
  this.render();
46
46
  });
47
- this.listen(player.video, [
48
- "play",
49
- "pause",
50
- "ended"
51
- ], () => {
52
- this.fit(player);
47
+ this.observe(player, ["upnext"], () => {
48
+ this.render();
53
49
  });
50
+ const idle = () => {
51
+ this.toggleAttribute("idle", player.hasAttribute("idle"));
52
+ };
53
+ this.observe(player, ["idle"], idle);
54
+ idle();
54
55
  if (typeof ResizeObserver !== "undefined") {
55
56
  this.resizer = new ResizeObserver(() => {
56
57
  this.fit(player);
57
58
  });
58
59
  this.resizer.observe(player);
59
- for (const tag of ["mbx-control-bar", "mbx-title"]) {
60
- const node = player.querySelector(tag);
61
- if (node !== null) this.resizer.observe(node);
62
- }
60
+ const bar = player.querySelector("mbx-control-bar");
61
+ if (bar !== null) this.resizer.observe(bar);
63
62
  }
64
63
  this.fit(player);
65
64
  this.render();
@@ -69,23 +68,20 @@ var MbxMarkerButton = class extends Component {
69
68
  this.resizer = null;
70
69
  }
71
70
  /**
72
- * Lifts the button above the bar's rows, or above the title's text while
73
- * it shows: each one's box less the padding over its content, which is
74
- * its fade. A hidden title has no box.
71
+ * Lifts the button above the bar's rows: the bar's box less the padding
72
+ * over them, its fade. The title sits on the other side, so the button
73
+ * stays where it is while the title shows.
75
74
  */
76
75
  fit(player) {
77
- let lift = 0;
78
- for (const tag of ["mbx-control-bar", "mbx-title"]) {
79
- const node = player.querySelector(tag);
80
- if (node === null) continue;
81
- const fade = Number.parseFloat(getComputedStyle(node).paddingTop) || 0;
82
- lift = Math.max(lift, node.getBoundingClientRect().height - fade);
83
- }
84
- this.style.setProperty("--mbx-marker-lift", `${lift}px`);
76
+ const bar = player.querySelector("mbx-control-bar");
77
+ const fade = bar === null ? 0 : Number.parseFloat(getComputedStyle(bar).paddingTop) || 0;
78
+ const lift = bar === null ? 0 : bar.getBoundingClientRect().height - fade;
79
+ this.style.setProperty("--mbx-marker-lift", `${Math.max(0, lift)}px`);
85
80
  }
86
81
  render() {
87
82
  const player = this.player;
88
83
  this.marker = player?.markers.within(player.video.currentTime).find((marker) => marker.kind !== "blocked") ?? null;
84
+ if (this.marker?.kind === "closing-credits" && player?.hasAttribute("upnext") === true) this.marker = null;
89
85
  this.hidden = this.marker === null;
90
86
  if (this.marker === null) return;
91
87
  const kind = this.marker.kind;
@@ -1 +1 @@
1
- {"version":3,"file":"marker-button.js","names":[],"sources":["../../src/elements/marker-button.ts"],"sourcesContent":["/**\n * <mbx-marker-button>: \"Skip intro\" over the picture while playback is in\n * the opening credits, \"Skip credits\" in the closing ones, and \"Skip\" with\n * the marker's own label in any other range the page named. A press moves\n * the playhead to the range's end. Blocked ranges never show it: the\n * player moves past those itself. The words come from\n * `label-opening-credits`, `label-closing-credits` and `label-skip`.\n */\nimport type { Marker } from '../controls/markers.js';\nimport type { PlayerHost } from '../host.js';\nimport { Component } from './component.js';\nimport STYLE_CSS from './marker-button.css?inline';\nimport { BUTTON_STYLE, style } from './shared.js';\n\nconst WORDS: Readonly<Record<string, string>> = {\n 'opening-credits': 'Skip intro',\n 'closing-credits': 'Skip credits',\n};\n\nexport class MbxMarkerButton extends Component {\n static get observedAttributes(): readonly string[] {\n return ['label-opening-credits', 'label-closing-credits', 'label-skip'];\n }\n\n declare private readonly button: HTMLButtonElement;\n /** The range the button skips, or null while playback is in none. */\n declare private marker: Marker | null;\n /** Watches the bar and the title: the button sits above whichever is taller. */\n declare private resizer: ResizeObserver | null;\n\n constructor() {\n super();\n this.marker = null;\n this.resizer = null;\n const root = this.attachShadow({ mode: 'open' });\n this.button = document.createElement('button');\n this.button.type = 'button';\n this.button.setAttribute('part', 'button');\n this.button.textContent = 'Skip';\n this.button.addEventListener('click', () => {\n const video = this.player?.video;\n if (video !== undefined && this.marker !== null) video.currentTime = this.marker.end;\n });\n root.append(style(BUTTON_STYLE + STYLE_CSS), this.button);\n }\n\n override connectedCallback(): void {\n // Hidden until playback is in a marker; a constructor may not set attributes.\n this.hidden = true;\n super.connectedCallback();\n }\n\n protected override attach(player: PlayerHost): void {\n this.listen(player.video, ['timeupdate', 'seeking', 'emptied'], () => {\n this.render();\n });\n this.listen(player, ['markerschange'], () => {\n this.render();\n });\n // The title shows while paused, and its text sits above the bar.\n this.listen(player.video, ['play', 'pause', 'ended'], () => {\n this.fit(player);\n });\n if (typeof ResizeObserver !== 'undefined') {\n this.resizer = new ResizeObserver(() => {\n this.fit(player);\n });\n this.resizer.observe(player);\n for (const tag of ['mbx-control-bar', 'mbx-title']) {\n const node = player.querySelector(tag);\n if (node !== null) this.resizer.observe(node);\n }\n }\n this.fit(player);\n this.render();\n }\n\n protected override detach(): void {\n this.resizer?.disconnect();\n this.resizer = null;\n }\n\n /**\n * Lifts the button above the bar's rows, or above the title's text while\n * it shows: each one's box less the padding over its content, which is\n * its fade. A hidden title has no box.\n */\n private fit(player: PlayerHost): void {\n let lift = 0;\n for (const tag of ['mbx-control-bar', 'mbx-title']) {\n const node = player.querySelector(tag);\n if (node === null) continue;\n const fade = Number.parseFloat(getComputedStyle(node).paddingTop) || 0;\n lift = Math.max(lift, node.getBoundingClientRect().height - fade);\n }\n this.style.setProperty('--mbx-marker-lift', `${lift}px`);\n }\n\n protected override render(): void {\n const player = this.player;\n this.marker =\n player?.markers\n .within(player.video.currentTime)\n .find((marker) => marker.kind !== 'blocked') ?? null;\n this.hidden = this.marker === null;\n if (this.marker === null) return;\n const kind = this.marker.kind;\n const skip = this.getAttribute('label-skip') ?? 'Skip';\n this.button.textContent =\n this.getAttribute(`label-${kind}`) ??\n WORDS[kind] ??\n (this.marker.label === undefined ? skip : `${skip} ${this.marker.label}`);\n }\n}\n"],"mappings":";;;AAWA,MAAA,YAAA;AAGA,MAAA,QAAA;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CAOA,IAAA,QAAA;EACA,IAAA,OAAA;EACA,KAAA,MAAA,OAAA,CAAA,mBAAA,WAAA,GAAA;GACA,MAAA,OAAA,OAAA,cAAA,GAAA;GACA,IAAA,SAAA,MAAA;GACA,MAAA,OAAA,OAAA,WAAA,iBAAA,IAAA,CAAA,CAAA,UAAA,KAAA;GACA,OAAA,KAAA,IAAA,MAAA,KAAA,sBAAA,CAAA,CAAA,SAAA,IAAA;EACA;EACA,KAAA,MAAA,YAAA,qBAAA,GAAA,KAAA,GAAA;CACA;CAEA,SAAA;EACA,MAAA,SAAA,KAAA;EACA,KAAA,SACA,QAAA,QACA,OAAA,OAAA,MAAA,WAAA,CAAA,CACA,MAAA,WAAA,OAAA,SAAA,SAAA,KAAA;EACA,KAAA,SAAA,KAAA,WAAA;EACA,IAAA,KAAA,WAAA,MAAA;EACA,MAAA,OAAA,KAAA,OAAA;EACA,MAAA,OAAA,KAAA,aAAA,YAAA,KAAA;EACA,KAAA,OAAA,cACA,KAAA,aAAA,SAAA,MAAA,KACA,MAAA,UACA,KAAA,OAAA,UAAA,KAAA,IAAA,OAAA,GAAA,KAAA,GAAA,KAAA,OAAA;CACA;AACA"}
1
+ {"version":3,"file":"marker-button.js","names":[],"sources":["../../src/elements/marker-button.ts"],"sourcesContent":["/**\n * <mbx-marker-button>: \"Skip intro\" over the picture while playback is in\n * the opening credits, \"Skip credits\" in the closing ones, and \"Skip\" with\n * the marker's own label in any other range the page named. A press moves\n * the playhead to the range's end. Blocked ranges never show it: the\n * player moves past those itself. The words come from\n * `label-opening-credits`, `label-closing-credits` and `label-skip`.\n *\n * While the player carries `upnext`, set by a card that offers the next\n * item, the button leaves the closing credits to it.\n */\nimport type { Marker } from '../controls/markers.js';\nimport type { PlayerHost } from '../host.js';\nimport { Component } from './component.js';\nimport STYLE_CSS from './marker-button.css?inline';\nimport { BUTTON_STYLE, style } from './shared.js';\n\nconst WORDS: Readonly<Record<string, string>> = {\n 'opening-credits': 'Skip intro',\n 'closing-credits': 'Skip credits',\n};\n\nexport class MbxMarkerButton extends Component {\n static get observedAttributes(): readonly string[] {\n return ['label-opening-credits', 'label-closing-credits', 'label-skip'];\n }\n\n declare private readonly button: HTMLButtonElement;\n /** The range the button skips, or null while playback is in none. */\n declare private marker: Marker | null;\n /** Watches the bar and the title: the button sits above whichever is taller. */\n declare private resizer: ResizeObserver | null;\n\n constructor() {\n super();\n this.marker = null;\n this.resizer = null;\n const root = this.attachShadow({ mode: 'open' });\n this.button = document.createElement('button');\n this.button.type = 'button';\n this.button.setAttribute('part', 'button');\n this.button.textContent = 'Skip';\n this.button.addEventListener('click', () => {\n const video = this.player?.video;\n if (video !== undefined && this.marker !== null) video.currentTime = this.marker.end;\n });\n root.append(style(BUTTON_STYLE + STYLE_CSS), this.button);\n }\n\n override connectedCallback(): void {\n // Hidden until playback is in a marker; a constructor may not set attributes.\n this.hidden = true;\n super.connectedCallback();\n }\n\n protected override attach(player: PlayerHost): void {\n this.listen(player.video, ['timeupdate', 'seeking', 'emptied'], () => {\n this.render();\n });\n this.listen(player, ['markerschange'], () => {\n this.render();\n });\n // An up next card, from a playlist, takes over the closing credits.\n this.observe(player, ['upnext'], () => {\n this.render();\n });\n // With the bar hidden, the button slides down to where the bar was.\n const idle = (): void => {\n this.toggleAttribute('idle', player.hasAttribute('idle'));\n };\n this.observe(player, ['idle'], idle);\n idle();\n if (typeof ResizeObserver !== 'undefined') {\n this.resizer = new ResizeObserver(() => {\n this.fit(player);\n });\n this.resizer.observe(player);\n const bar = player.querySelector('mbx-control-bar');\n if (bar !== null) this.resizer.observe(bar);\n }\n this.fit(player);\n this.render();\n }\n\n protected override detach(): void {\n this.resizer?.disconnect();\n this.resizer = null;\n }\n\n /**\n * Lifts the button above the bar's rows: the bar's box less the padding\n * over them, its fade. The title sits on the other side, so the button\n * stays where it is while the title shows.\n */\n private fit(player: PlayerHost): void {\n const bar = player.querySelector('mbx-control-bar');\n const fade = bar === null ? 0 : Number.parseFloat(getComputedStyle(bar).paddingTop) || 0;\n const lift = bar === null ? 0 : bar.getBoundingClientRect().height - fade;\n this.style.setProperty('--mbx-marker-lift', `${Math.max(0, lift)}px`);\n }\n\n protected override render(): void {\n const player = this.player;\n this.marker =\n player?.markers\n .within(player.video.currentTime)\n .find((marker) => marker.kind !== 'blocked') ?? null;\n // A playlist's up next card offers the next item over the closing\n // credits, so this button steps aside while the player carries `upnext`.\n if (this.marker?.kind === 'closing-credits' && player?.hasAttribute('upnext') === true) {\n this.marker = null;\n }\n this.hidden = this.marker === null;\n if (this.marker === null) return;\n const kind = this.marker.kind;\n const skip = this.getAttribute('label-skip') ?? 'Skip';\n this.button.textContent =\n this.getAttribute(`label-${kind}`) ??\n WORDS[kind] ??\n (this.marker.label === undefined ? skip : `${skip} ${this.marker.label}`);\n }\n}\n"],"mappings":";;;AAcA,MAAA,YAAA;AAGA,MAAA,QAAA;CACA,mBAAA;CACA,mBAAA;AACA;AAEA,IAAA,kBAAA,cAAA,UAAA;CACA,WAAA,qBAAA;EACA,OAAA;GAAA;GAAA;GAAA;EAAA;CACA;CAQA,cAAA;EACA,MAAA;EACA,KAAA,SAAA;EACA,KAAA,UAAA;EACA,MAAA,OAAA,KAAA,aAAA,EAAA,MAAA,OAAA,CAAA;EACA,KAAA,SAAA,SAAA,cAAA,QAAA;EACA,KAAA,OAAA,OAAA;EACA,KAAA,OAAA,aAAA,QAAA,QAAA;EACA,KAAA,OAAA,cAAA;EACA,KAAA,OAAA,iBAAA,eAAA;GACA,MAAA,QAAA,KAAA,QAAA;GACA,IAAA,UAAA,KAAA,KAAA,KAAA,WAAA,MAAA,MAAA,cAAA,KAAA,OAAA;EACA,CAAA;EACA,KAAA,OAAA,MAAA,eAAA,SAAA,GAAA,KAAA,MAAA;CACA;CAEA,oBAAA;EAEA,KAAA,SAAA;EACA,MAAA,kBAAA;CACA;CAEA,OAAA,QAAA;EACA,KAAA,OAAA,OAAA,OAAA;GAAA;GAAA;GAAA;EAAA,SAAA;GACA,KAAA,OAAA;E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cACA,KAAA,aAAA,SAAA,MAAA,KACA,MAAA,UACA,KAAA,OAAA,UAAA,KAAA,IAAA,OAAA,GAAA,KAAA,GAAA,KAAA,OAAA;CACA;AACA"}
@@ -12,7 +12,7 @@ var MbxQualityMenu = class extends MenuElement {
12
12
  ];
13
13
  }
14
14
  constructor() {
15
- super(...single("settings"));
15
+ super(...single("quality"));
16
16
  this.engine = null;
17
17
  this.playing = void 0;
18
18
  show(this.slots, "default");
@@ -1 +1 @@
1
- {"version":3,"file":"quality-menu.js","names":[],"sources":["../../src/elements/quality-menu.ts"],"sourcesContent":["/**\n * <mbx-quality-menu>: the pin over `engine.quality`, where \"auto\" means\n * none. Hidden without renditions, and for a native session. The name\n * comes from `label`, the word for no pin from `label-auto`. It offers\n * `engine.quality.selectable`, labelled by `qualityNames`. Under Auto, the\n * Auto row names what plays, in its detail.\n */\nimport type { Mattebox } from 'mattebox';\nimport { qualityLabels, qualityNames } from '../controls/quality-names.js';\nimport type { PlayerHost } from '../host.js';\nimport { MenuElement, single } from './menu-element.js';\nimport { show } from './shared.js';\n\nconst AUTO = 'auto';\n\nexport class MbxQualityMenu extends MenuElement {\n static get observedAttributes(): readonly string[] {\n return ['label', 'label-auto', 'label-back'];\n }\n\n declare private engine: Mattebox | null;\n /** The name of what plays, as the Auto row last showed it. */\n declare private playing: string | undefined;\n\n constructor() {\n super(...single('settings'));\n this.engine = null;\n this.playing = undefined;\n show(this.slots, 'default');\n }\n\n protected override name(): string {\n return 'Quality';\n }\n\n protected override attach(player: PlayerHost): void {\n this.follow(player, (engine) => {\n this.engine = engine;\n this.render();\n if (engine === null) return undefined;\n const tick = (): void => {\n this.render();\n };\n // What plays changes as the playhead reaches another rendition's\n // segments, and no event says so: read it on the clock, draw on a change.\n const clock = (): void => {\n if (this.playingName() !== this.playing) this.render();\n };\n player.video.addEventListener('timeupdate', clock);\n const offs = [\n () => player.video.removeEventListener('timeupdate', clock),\n engine.on('tracks:changed', tick),\n engine.on('quality:constraints-unsatisfiable', tick),\n engine.on('quality:pin-unsatisfiable', tick),\n ];\n return () => {\n for (const off of offs) off();\n };\n });\n }\n\n protected override render(): void {\n super.render();\n const engine = this.engine;\n if (engine === null) {\n this.hidden = true;\n return;\n }\n const quality = engine.quality;\n this.playing = this.playingName();\n const items: Array<readonly [string, string, (string | undefined)?]> = [\n [AUTO, this.getAttribute('label-auto') ?? 'Auto', this.playing],\n ...qualityNames(quality.selectable),\n ];\n this.menu.fill([\n {\n name: 'rendition',\n items,\n value: quality.pinned ?? AUTO,\n onSelect: (value) => {\n if (value === AUTO) quality.auto();\n else quality.pin(value);\n this.render();\n },\n },\n ]);\n this.hidden = items.length === 1;\n }\n\n /** The name of the rendition that plays, under Auto only: a pin names itself by its tick. */\n private playingName(): string | undefined {\n const quality = this.engine?.quality;\n if (quality === undefined || quality.pinned !== null) return undefined;\n // Every label, twins too: what plays may be a twin the menu shows once.\n const id = quality.playing?.id;\n return qualityLabels(quality.selectable).find(([candidate]) => candidate === id)?.[1];\n }\n}\n"],"mappings":";;;;AAaA,MAAM,OAAO;AAEb,IAAa,iBAAb,cAAoC,YAAY;CAC9C,WAAW,qBAAwC;EACjD,OAAO;GAAC;GAAS;GAAc;EAAY;CAC7C;CAMA,cAAc;EACZ,MAAM,GAAG,OAAO,UAAU,CAAC;EAC3B,KAAK,SAAS;EACd,KAAK,UAAU,KAAA;EACf,KAAK,KAAK,OAAO,SAAS;CAC5B;CAEA,OAAkC;EAChC,OAAO;CACT;CAEA,OAA0B,QAA0B;EAClD,KAAK,OAAO,SAAS,WAAW;GAC9B,KAAK,SAAS;GACd,KAAK,OAAO;GACZ,IAAI,WAAW,MAAM,OAAO,KAAA;GAC5B,MAAM,aAAmB;IACvB,KAAK,OAAO;GACd;GAGA,MAAM,cAAoB;IACxB,IAAI,KAAK,YAAY,MAAM,KAAK,SAAS,KAAK,OAAO;GACvD;GACA,OAAO,MAAM,iBAAiB,cAAc,KAAK;GACjD,MAAM,OAAO;UACL,OAAO,MAAM,oBAAoB,cAAc,KAAK;IAC1D,OAAO,GAAG,kBAAkB,IAAI;IAChC,OAAO,GAAG,qCAAqC,IAAI;IACnD,OAAO,GAAG,6BAA6B,IAAI;GAC7C;GACA,aAAa;IACX,KAAK,MAAM,OAAO,MAAM,IAAI;GAC9B;EACF,CAAC;CACH;CAEA,SAAkC;EAChC,MAAM,OAAO;EACb,MAAM,SAAS,KAAK;EACpB,IAAI,WAAW,MAAM;GACnB,KAAK,SAAS;GACd;EACF;EACA,MAAM,UAAU,OAAO;EACvB,KAAK,UAAU,KAAK,YAAY;EAChC,MAAM,QAAiE,CACrE;GAAC;GAAM,KAAK,aAAa,YAAY,KAAK;GAAQ,KAAK;EAAO,GAC9D,GAAG,aAAa,QAAQ,UAAU,CACpC;EACA,KAAK,KAAK,KAAK,CACb;GACE,MAAM;GACN;GACA,OAAO,QAAQ,UAAU;GACzB,WAAW,UAAU;IACnB,IAAI,UAAU,MAAM,QAAQ,KAAK;SAC5B,QAAQ,IAAI,KAAK;IACtB,KAAK,OAAO;GACd;EACF,CACF,CAAC;EACD,KAAK,SAAS,MAAM,WAAW;CACjC;;CAGA,cAA0C;EACxC,MAAM,UAAU,KAAK,QAAQ;EAC7B,IAAI,YAAY,KAAA,KAAa,QAAQ,WAAW,MAAM,OAAO,KAAA;EAE7D,MAAM,KAAK,QAAQ,SAAS;EAC5B,OAAO,cAAc,QAAQ,UAAU,CAAC,CAAC,MAAM,CAAC,eAAe,cAAc,EAAE,CAAC,GAAG;CACrF;AACF"}
1
+ {"version":3,"file":"quality-menu.js","names":[],"sources":["../../src/elements/quality-menu.ts"],"sourcesContent":["/**\n * <mbx-quality-menu>: the pin over `engine.quality`, where \"auto\" means\n * none. Hidden without renditions, and for a native session. The name\n * comes from `label`, the word for no pin from `label-auto`. It offers\n * `engine.quality.selectable`, labelled by `qualityNames`. Under Auto, the\n * Auto row names what plays, in its detail.\n */\nimport type { Mattebox } from 'mattebox';\nimport { qualityLabels, qualityNames } from '../controls/quality-names.js';\nimport type { PlayerHost } from '../host.js';\nimport { MenuElement, single } from './menu-element.js';\nimport { show } from './shared.js';\n\nconst AUTO = 'auto';\n\nexport class MbxQualityMenu extends MenuElement {\n static get observedAttributes(): readonly string[] {\n return ['label', 'label-auto', 'label-back'];\n }\n\n declare private engine: Mattebox | null;\n /** The name of what plays, as the Auto row last showed it. */\n declare private playing: string | undefined;\n\n constructor() {\n super(...single('quality'));\n this.engine = null;\n this.playing = undefined;\n show(this.slots, 'default');\n }\n\n protected override name(): string {\n return 'Quality';\n }\n\n protected override attach(player: PlayerHost): void {\n this.follow(player, (engine) => {\n this.engine = engine;\n this.render();\n if (engine === null) return undefined;\n const tick = (): void => {\n this.render();\n };\n // What plays changes as the playhead reaches another rendition's\n // segments, and no event says so: read it on the clock, draw on a change.\n const clock = (): void => {\n if (this.playingName() !== this.playing) this.render();\n };\n player.video.addEventListener('timeupdate', clock);\n const offs = [\n () => player.video.removeEventListener('timeupdate', clock),\n engine.on('tracks:changed', tick),\n engine.on('quality:constraints-unsatisfiable', tick),\n engine.on('quality:pin-unsatisfiable', tick),\n ];\n return () => {\n for (const off of offs) off();\n };\n });\n }\n\n protected override render(): void {\n super.render();\n const engine = this.engine;\n if (engine === null) {\n this.hidden = true;\n return;\n }\n const quality = engine.quality;\n this.playing = this.playingName();\n const items: Array<readonly [string, string, (string | undefined)?]> = [\n [AUTO, this.getAttribute('label-auto') ?? 'Auto', this.playing],\n ...qualityNames(quality.selectable),\n ];\n this.menu.fill([\n {\n name: 'rendition',\n items,\n value: quality.pinned ?? AUTO,\n onSelect: (value) => {\n if (value === AUTO) quality.auto();\n else quality.pin(value);\n this.render();\n },\n },\n ]);\n this.hidden = items.length === 1;\n }\n\n /** The name of the rendition that plays, under Auto only: a pin names itself by its tick. */\n private playingName(): string | undefined {\n const quality = this.engine?.quality;\n if (quality === undefined || quality.pinned !== null) return undefined;\n // Every label, twins too: what plays may be a twin the menu shows once.\n const id = quality.playing?.id;\n return qualityLabels(quality.selectable).find(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C5B,QAAQ,IAAI,KAAK;IACtB,KAAK,OAAO;GACd;EACF,CACF,CAAC;EACD,KAAK,SAAS,MAAM,WAAW;CACjC;;CAGA,cAA0C;EACxC,MAAM,UAAU,KAAK,QAAQ;EAC7B,IAAI,YAAY,KAAA,KAAa,QAAQ,WAAW,MAAM,OAAO,KAAA;EAE7D,MAAM,KAAK,QAAQ,SAAS;EAC5B,OAAO,cAAc,QAAQ,UAAU,CAAC,CAAC,MAAM,CAAC,eAAe,cAAc,EAAE,CAAC,GAAG;CACrF;AACF"}
@@ -19,7 +19,7 @@ import { optional } from "../controls/session.js";
19
19
  * `rate` part shows the rate, "8×". The name comes from `label`,
20
20
  * "Fast forward" or "Rewind".
21
21
  */
22
- const STYLE_CSS = "[part~=button]{position:relative}[part~=rate]{font-variant-numeric:tabular-nums;font-size:10px;font-weight:700;line-height:1;position:absolute;bottom:2px;right:0}[part~=rate][hidden]{display:none}";
22
+ const STYLE_CSS = "[part~=button]{position:relative}[part~=rate]{font-variant-numeric:tabular-nums;font-size:.625em;font-weight:700;line-height:1;position:absolute;bottom:.2em;right:0}[part~=rate][hidden]{display:none}";
23
23
  const RATES = [
24
24
  4,
25
25
  8,
@@ -1 +1 @@
1
- {"version":3,"file":"seek-bar.d.ts","sourceRoot":"","sources":["../../src/elements/seek-bar.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AAYH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAoE3C,qBAAa,UAAW,SAAQ,SAAS;IACvC,MAAM,KAAK,kBAAkB,IAAI,SAAS,MAAM,EAAE,CAYjD;IAED,iBAAyB,GAAG,CAAS;IACrC,iBAAyB,QAAQ,CAAc;IAC/C,mFAAmF;IACnF,iBAAyB,OAAO,CAAc;IAC9C,iBAAyB,KAAK,CAAc;I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AajB;;;;;;OAMG;IACH,OAAO,CAAC,YAAY;IA6CpB,0CAA0C;IAC1C,OAAO,CAAC,aAAa;IAIrB,iFAAiF;IACjF,OAAO,CAAC,WAAW;IAenB,8DAA8D;IAC9D,OAAO,CAAC,YAAY;IAOpB,+EAA+E;IAC/E,OAAO,CAAC,KAAK;IASb,kFAAkF;IAClF,OAAO,CAAC,SAAS;IAyBjB,OAAO,CAAC,KAAK;cAOM,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;cAqChC,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;cAWhC,MAAM,IAAI,IAAI;CA0BlC"}
@@ -8,7 +8,7 @@ import { bufferGoal, live, optional, span, wall } from "../controls/session.js";
8
8
  import { chapterAt, chapters, followChapters } from "../controls/chapters.js";
9
9
  import { slider } from "../controls/slider.js";
10
10
  //#region src/elements/seek-bar.ts
11
- const STYLE_CSS = ":host,[part~=slider]{flex:1}[part~=thumb]{width:16px;height:16px;margin:-8px 0 0 -8px;box-shadow:0 1px 3px #0006}[part~=buffered]{position:absolute;top:0;bottom:0;left:0;right:0}[part~=blocked]{pointer-events:none;position:absolute;top:0;bottom:0;left:0;right:0}[part~=blocked-range]{background:var(--mbx-blocked,#000000bf);position:absolute;top:0;bottom:0}[part~=buffered-range]{background:#ffffff4d;position:absolute;top:0;bottom:0}[part~=hover]{background:var(--mbx-text);width:2px;margin-left:-1px;position:absolute;top:0;bottom:0}[part~=edge]{background:var(--mbx-live);width:2px;margin-left:-1px;position:absolute;top:0;bottom:0}[part~=preview]{background:var(--mbx-surface);border-radius:var(--mbx-radius);font-variant-numeric:tabular-nums;white-space:nowrap;pointer-events:none;flex-direction:column;align-items:center;margin-bottom:4px;padding:2px;font-size:13px;display:flex;position:absolute;bottom:100%;transform:translate(-50%)}[part~=preview]>:not([hidden])~:not([hidden]){margin-top:2px}[part~=preview-image]{border-radius:2px;position:relative;overflow:hidden}[part~=preview-frame]{border-radius:2px;display:block}[part~=preview-tile]{transform-origin:0 0;background-repeat:no-repeat;position:absolute;top:0;left:0}[part~=preview-time]{padding:0 4px}[part~=preview-title]{text-overflow:ellipsis;max-width:240px;padding:0 4px;overflow:hidden}[hidden]{display:none}";
11
+ const STYLE_CSS = ":host,[part~=slider]{flex:1}[part~=thumb]{width:1em;height:1em;margin:-.5em 0 0 -.5em;box-shadow:0 1px 3px #0006}[part~=buffered]{position:absolute;top:0;bottom:0;left:0;right:0}[part~=blocked]{pointer-events:none;position:absolute;top:0;bottom:0;left:0;right:0}[part~=blocked-range]{background:var(--mbx-blocked,#000000bf);position:absolute;top:0;bottom:0}[part~=buffered-range]{background:#ffffff4d;position:absolute;top:0;bottom:0}[part~=hover]{background:var(--mbx-text);width:.125em;margin-left:-1px;position:absolute;top:0;bottom:0}[part~=edge]{background:var(--mbx-live);width:.125em;margin-left:-1px;position:absolute;top:0;bottom:0}[part~=preview]{background:var(--mbx-surface);border-radius:var(--mbx-radius);font-variant-numeric:tabular-nums;white-space:nowrap;pointer-events:none;flex-direction:column;align-items:center;margin-bottom:.3077em;padding:.1538em;font-size:.8125em;display:flex;position:absolute;bottom:100%;transform:translate(-50%)}[part~=preview]>:not([hidden])~:not([hidden]){margin-top:.125em}[part~=preview-image]{border-radius:2px;position:relative;overflow:hidden}[part~=preview-frame]{border-radius:2px;display:block}[part~=preview-tile]{transform-origin:0 0;background-repeat:no-repeat;position:absolute;top:0;left:0}[part~=preview-time]{padding:0 .3077em}[part~=preview-title]{text-overflow:ellipsis;max-width:18.4615em;padding:0 .3077em;overflow:hidden}[hidden]{display:none}";
12
12
  const STEP = 5;
13
13
  /** Under `key-mode="preview"`, a target seeks this long after the last key. */
14
14
  const KEY_COMMIT_MS = 1e3;
@@ -26,8 +26,8 @@ const CANCEL_KEYS = [
26
26
  ];
27
27
  const PAGE = 30;
28
28
  const LIVE_WINDOW = 3;
29
- /** What the tile scales down to when the page sets no `--mbx-preview-width`. */
30
- const PREVIEW_WIDTH = 160;
29
+ /** What the tile scales down to, in em, when the page sets no `--mbx-preview-width`. */
30
+ const PREVIEW_WIDTH = 10;
31
31
  /** The buffer goal assumed for a session that reports none. */
32
32
  const BUFFER_GOAL = 30;
33
33
  /** The gap cut at a chapter boundary, in pixels. */
@@ -311,7 +311,8 @@ var MbxSeekBar = class extends Component {
311
311
  /** The width the page asked for through the token, or the default. */
312
312
  previewWidth() {
313
313
  const set = Number.parseFloat(getComputedStyle(this.preview).getPropertyValue("--mbx-preview-width"));
314
- return Number.isFinite(set) && set > 0 ? set : PREVIEW_WIDTH;
314
+ if (Number.isFinite(set) && set > 0) return set;
315
+ return PREVIEW_WIDTH * (Number.parseFloat(getComputedStyle(this).fontSize) || 16);
315
316
  }
316
317
  /** The preview's picture sources from `preview`, in order of preference: frames then tiles by default. */
317
318
  sources() {