@mattebox/player 0.7.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 (138) hide show
  1. package/dist/cdn/mattebox-player.min.js +3 -3
  2. package/dist/controls/icons.d.ts +5 -28
  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/markers.d.ts +39 -0
  7. package/dist/controls/markers.d.ts.map +1 -0
  8. package/dist/controls/markers.js +38 -0
  9. package/dist/controls/markers.js.map +1 -0
  10. package/dist/controls/menu.d.ts +14 -2
  11. package/dist/controls/menu.d.ts.map +1 -1
  12. package/dist/controls/menu.js +50 -4
  13. package/dist/controls/menu.js.map +1 -1
  14. package/dist/controls/native-tracks.d.ts +28 -0
  15. package/dist/controls/native-tracks.d.ts.map +1 -0
  16. package/dist/controls/native-tracks.js +30 -0
  17. package/dist/controls/native-tracks.js.map +1 -0
  18. package/dist/controls/quality-names.d.ts +15 -0
  19. package/dist/controls/quality-names.d.ts.map +1 -0
  20. package/dist/controls/quality-names.js +62 -0
  21. package/dist/controls/quality-names.js.map +1 -0
  22. package/dist/controls/track-names.d.ts +40 -0
  23. package/dist/controls/track-names.d.ts.map +1 -0
  24. package/dist/controls/track-names.js +59 -0
  25. package/dist/controls/track-names.js.map +1 -0
  26. package/dist/element.d.ts +60 -2
  27. package/dist/element.d.ts.map +1 -1
  28. package/dist/element.js +182 -23
  29. package/dist/element.js.map +1 -1
  30. package/dist/elements/audio-menu.d.ts +19 -8
  31. package/dist/elements/audio-menu.d.ts.map +1 -1
  32. package/dist/elements/audio-menu.js +60 -19
  33. package/dist/elements/audio-menu.js.map +1 -1
  34. package/dist/elements/component.d.ts.map +1 -1
  35. package/dist/elements/component.js +10 -0
  36. package/dist/elements/component.js.map +1 -1
  37. package/dist/elements/control-bar.d.ts +2 -0
  38. package/dist/elements/control-bar.d.ts.map +1 -1
  39. package/dist/elements/control-bar.js +23 -7
  40. package/dist/elements/control-bar.js.map +1 -1
  41. package/dist/elements/current-time.d.ts.map +1 -1
  42. package/dist/elements/current-time.js +1 -1
  43. package/dist/elements/current-time.js.map +1 -1
  44. package/dist/elements/drm-badge.d.ts +3 -2
  45. package/dist/elements/drm-badge.d.ts.map +1 -1
  46. package/dist/elements/drm-badge.js +11 -9
  47. package/dist/elements/drm-badge.js.map +1 -1
  48. package/dist/elements/duration.d.ts.map +1 -1
  49. package/dist/elements/duration.js +6 -2
  50. package/dist/elements/duration.js.map +1 -1
  51. package/dist/elements/error-screen.js +1 -1
  52. package/dist/elements/live-button.js +1 -1
  53. package/dist/elements/marker-button.d.ts +22 -0
  54. package/dist/elements/marker-button.d.ts.map +1 -0
  55. package/dist/elements/marker-button.js +95 -0
  56. package/dist/elements/marker-button.js.map +1 -0
  57. package/dist/elements/quality-menu.d.ts +4 -0
  58. package/dist/elements/quality-menu.d.ts.map +1 -1
  59. package/dist/elements/quality-menu.js +22 -8
  60. package/dist/elements/quality-menu.js.map +1 -1
  61. package/dist/elements/scan-button.js +1 -1
  62. package/dist/elements/seek-bar.d.ts +6 -1
  63. package/dist/elements/seek-bar.d.ts.map +1 -1
  64. package/dist/elements/seek-bar.js +37 -25
  65. package/dist/elements/seek-bar.js.map +1 -1
  66. package/dist/elements/shared.js +3 -3
  67. package/dist/elements/skip-button.js +2 -2
  68. package/dist/elements/skip-button.js.map +1 -1
  69. package/dist/elements/spinner.js +1 -1
  70. package/dist/elements/start-button.d.ts +5 -0
  71. package/dist/elements/start-button.d.ts.map +1 -1
  72. package/dist/elements/start-button.js +15 -2
  73. package/dist/elements/start-button.js.map +1 -1
  74. package/dist/elements/subtitles-menu.d.ts +7 -1
  75. package/dist/elements/subtitles-menu.d.ts.map +1 -1
  76. package/dist/elements/subtitles-menu.js +62 -20
  77. package/dist/elements/subtitles-menu.js.map +1 -1
  78. package/dist/elements/title.d.ts.map +1 -1
  79. package/dist/elements/title.js +3 -1
  80. package/dist/elements/title.js.map +1 -1
  81. package/dist/elements/volume-slider.js +1 -1
  82. package/dist/elements/volume.js +1 -1
  83. package/dist/entries/marker-button.d.ts +5 -0
  84. package/dist/entries/marker-button.d.ts.map +1 -0
  85. package/dist/entries/marker-button.js +9 -0
  86. package/dist/entries/marker-button.js.map +1 -0
  87. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.150.0 → _@oxc-project_runtime@0.152.0}/helpers/esm/asyncToGenerator.js +1 -1
  88. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.150.0 → _@oxc-project_runtime@0.152.0}/helpers/esm/defineProperty.js +1 -1
  89. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.150.0 → _@oxc-project_runtime@0.152.0}/helpers/esm/objectSpread2.js +1 -1
  90. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.150.0 → _@oxc-project_runtime@0.152.0}/helpers/esm/toPrimitive.js +1 -1
  91. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.150.0 → _@oxc-project_runtime@0.152.0}/helpers/esm/toPropertyKey.js +1 -1
  92. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.150.0 → _@oxc-project_runtime@0.152.0}/helpers/esm/typeof.js +1 -1
  93. package/dist/es2015/controls/chapters.js +1 -1
  94. package/dist/es2015/controls/icons.js +38 -29
  95. package/dist/es2015/controls/markers.js +36 -0
  96. package/dist/es2015/controls/menu.js +52 -5
  97. package/dist/es2015/controls/native-tracks.js +29 -0
  98. package/dist/es2015/controls/quality-names.js +67 -0
  99. package/dist/es2015/controls/track-names.js +57 -0
  100. package/dist/es2015/element.js +185 -29
  101. package/dist/es2015/elements/audio-menu.js +66 -20
  102. package/dist/es2015/elements/component.js +10 -0
  103. package/dist/es2015/elements/control-bar.js +23 -7
  104. package/dist/es2015/elements/current-time.js +1 -1
  105. package/dist/es2015/elements/drm-badge.js +12 -9
  106. package/dist/es2015/elements/duration.js +6 -2
  107. package/dist/es2015/elements/error-screen.js +1 -1
  108. package/dist/es2015/elements/live-button.js +1 -1
  109. package/dist/es2015/elements/marker-button.js +96 -0
  110. package/dist/es2015/elements/quality-menu.js +23 -8
  111. package/dist/es2015/elements/scan-button.js +1 -1
  112. package/dist/es2015/elements/seek-bar.js +42 -29
  113. package/dist/es2015/elements/shared.js +3 -3
  114. package/dist/es2015/elements/skip-button.js +2 -2
  115. package/dist/es2015/elements/spinner.js +1 -1
  116. package/dist/es2015/elements/start-button.js +15 -2
  117. package/dist/es2015/elements/subtitles-menu.js +72 -26
  118. package/dist/es2015/elements/title.js +3 -1
  119. package/dist/es2015/elements/volume-slider.js +1 -1
  120. package/dist/es2015/elements/volume.js +1 -1
  121. package/dist/es2015/entries/marker-button.js +7 -0
  122. package/dist/es2015/index.js +3 -1
  123. package/dist/es2015/presets.js +1 -1
  124. package/dist/es2015/style.js +1 -1
  125. package/dist/es2015/tags.js +2 -1
  126. package/dist/host.d.ts +3 -0
  127. package/dist/host.d.ts.map +1 -1
  128. package/dist/host.js.map +1 -1
  129. package/dist/index.d.ts +4 -0
  130. package/dist/index.d.ts.map +1 -1
  131. package/dist/index.js +3 -1
  132. package/dist/style.js +1 -1
  133. package/dist/tags.d.ts +1 -0
  134. package/dist/tags.d.ts.map +1 -1
  135. package/dist/tags.js +2 -1
  136. package/dist/tags.js.map +1 -1
  137. package/package.json +4 -5
  138. package/NOTICE +0 -24
@@ -1 +1 @@
1
- {"version":3,"file":"seek-bar.js","names":[],"sources":["../../src/elements/seek-bar.ts"],"sourcesContent":["/**\n * <mbx-seek-bar>: the bar over the slider primitive, with four layers on\n * its track, every one a part: the buffered ranges from `video.buffered`,\n * the played span, the hover position, and for live the edge from\n * `engine.live`. The span it maps is the availability window for live and\n * the duration for VOD; `controls/session.ts` says which.\n *\n * A live stream is seekable only when the window is worth it: at least\n * `live-window` forward buffer goals long, the goal read from the engine.\n * Below that the bar hides. VOD is always seekable. The element sets\n * `live` and `seekable` on the player, which the time and the live button\n * read, and `scrubbing` while a pointer holds the thumb: `playing` or\n * `paused`, the state before the drag, which the play buttons show\n * instead of the drag's own pause.\n *\n * Reads happen on the events the video already fires; the live window has\n * no event of its own and moves with the clock, so `timeupdate` covers it.\n * While a pointer holds the thumb, the played layer follows the pointer.\n * The element carries `dragging` meanwhile. With an I-frame track\n * (`engine.trick.available`), the drag scrubs: the video pauses and shows\n * the I-frame at every position, and the release seeks there. See the\n * engine guide's trick play chapter. `scrub=\"false\"` turns this off.\n * Otherwise the video pauses, `currentTime` is written at most once per\n * frame, so the bar never fights a slow seek, and the release resumes\n * playback if it was playing. Thumbnail tiles never drive a drag: they are\n * previews, not frames of the video.\n *\n * The preview above the pointer carries the time and a picture of that\n * time from the sources `preview` names, in order of preference: `frames`\n * and `tiles`, \"frames tiles\" by default, `none` for no picture. A frame\n * is the decoded I-frame from `engine.trick.frameAt`, when the track\n * decodes in this browser; the last one stays until the next arrives, so\n * the picture never flickers while the engine decodes. A tile comes from\n * `engine.thumbnails`: a rectangle of a sprite, drawn by background\n * position at the sprite's own size. Both scale to `--mbx-preview-width`,\n * so a page sets the size with one token.\n *\n * Chapters divide the track: one gap per chapter boundary, cut through\n * every layer with a mask, so the played and the buffered spans read per\n * chapter, and the preview names the chapter under the pointer. They come\n * from the session, see `controls/chapters.ts`. `chapters` lists what the\n * bar does with them: `divided` and `titles`, both by default, one of\n * them alone, or `none`.\n *\n * `step` is what an arrow key moves the playhead by and `page` what Page\n * Up and Page Down do, in seconds. `key-mode=\"preview\"`, for a TV, makes\n * the keys aim instead of seek: the thumb and the preview show the target,\n * a held key's step grows, and the seek comes on Enter, on leaving the bar,\n * or a second after the last key. Escape or Back drops the target. The\n * control bar's seeking keys, the arrows and fast forward and rewind\n * anywhere in the player, aim the same way: the bar asks through\n * `seekkey`, and the seek bar takes it. The default, `instant`, seeks on\n * every key. The name comes from `label`; what a\n * screen reader hears at a position from `label-of`, \"{current} of\n * {duration}\", and on live from `label-behind`, \"{time} behind live\". It\n * sits in the bar's seek row unless the page says otherwise.\n */\n\nimport type { Thumbnail } from 'mattebox/stages/thumbnails';\nimport type { Chapter } from '../controls/chapters.js';\nimport { chapterAt, chapters, followChapters } from '../controls/chapters.js';\nimport type { Span } from '../controls/ranges.js';\nimport { at, clip, EMPTY, fraction } from '../controls/ranges.js';\nimport { bufferGoal, live, optional, span, wall } from '../controls/session.js';\nimport type { Slider } from '../controls/slider.js';\nimport { slider } from '../controls/slider.js';\nimport { format } from '../controls/time.js';\nimport { el } from '../dom.js';\nimport type { PlayerHost } from '../host.js';\nimport { fill } from '../labels.js';\nimport { Component } from './component.js';\nimport STYLE_CSS from './seek-bar.css?inline';\nimport { number, SLIDER_STYLE, seekRow, style } from './shared.js';\n\n/** What a drag does, chosen when the pointer takes the thumb. */\ntype Drag = 'none' | 'seek' | 'scrub';\n\n/** Where the preview's picture comes from: decoded I-frames, or thumbnail tiles. */\ntype Preview = 'frames' | 'tiles';\n\nconst STEP = 5;\n\n/** Under `key-mode=\"preview\"`, a target seeks this long after the last key. */\nconst KEY_COMMIT_MS = 1000;\n/** Key moves closer together than this are one hold, whose step grows. */\nconst REPEAT_GAP_MS = 400;\n/** A held key's step grows by one step every this many moves... */\nconst MOVES_PER_STEP = 8;\n/** ...up to this many steps a move. */\nconst MAX_STEPS = 12;\n\n/** The keys that cancel a target: Escape, and Back as a remote sends it. */\nconst CANCEL_KEYS = ['Escape', 'GoBack', 'BrowserBack'];\nconst PAGE = 30;\nconst LIVE_WINDOW = 3;\n\n/** What the tile scales down to when the page sets no `--mbx-preview-width`. */\nconst PREVIEW_WIDTH = 160;\n\n/** The buffer goal assumed for a session that reports none. */\nconst BUFFER_GOAL = 30;\n\n/** The gap cut at a chapter boundary, in pixels. */\nconst GAP = 2;\n\nconst EVENTS = [\n 'timeupdate',\n 'progress',\n 'durationchange',\n 'loadedmetadata',\n 'seeking',\n 'seeked',\n 'emptied',\n];\n\nconst STYLE = SLIDER_STYLE + STYLE_CSS;\n\nfunction percent(part: number): string {\n return `${part * 100}%`;\n}\n\n/**\n * A mask that cuts a gap at each boundary between chapters, as stops along\n * the track: opaque up to a boundary, clear for the gap, opaque after.\n */\nfunction gaps(list: readonly Chapter[], span: Span): string {\n const stops: string[] = ['#000 0'];\n for (const chapter of list.slice(1)) {\n const at = percent(fraction(chapter.start, span));\n const before = `calc(${at} - ${GAP / 2}px)`;\n const after = `calc(${at} + ${GAP / 2}px)`;\n stops.push(`#000 ${before}`, `transparent ${before}`, `transparent ${after}`, `#000 ${after}`);\n }\n stops.push('#000 100%');\n return `linear-gradient(to right, ${stops.join(', ')})`;\n}\n\nexport class MbxSeekBar extends Component {\n static get observedAttributes(): readonly string[] {\n return [\n 'label',\n 'label-of',\n 'label-behind',\n 'live-window',\n 'chapters',\n 'scrub',\n 'preview',\n 'key-mode',\n ];\n }\n\n declare private readonly bar: Slider;\n declare private readonly buffered: HTMLElement;\n declare private readonly hover: HTMLElement;\n declare private readonly edge: HTMLElement;\n declare private readonly preview: HTMLElement;\n declare private readonly image: HTMLElement;\n declare private readonly tile: HTMLElement;\n declare private readonly time: HTMLElement;\n declare private readonly caption: HTMLElement;\n declare private readonly frameCanvas: HTMLCanvasElement;\n declare private drag: Drag;\n /** The last position of the drag, which a cancelled drag settles at. */\n declare private dragged: number | null;\n /** Whether the video played when a seeking drag began, so the release resumes it. */\n declare private resume: boolean;\n /** Frames asked for, and the newest one on screen, so a late frame never replaces a newer one. */\n declare private asked: number;\n /** Under `key-mode=\"preview\"`: where the keys aim, not yet sought to, or null. */\n declare private target: number | null;\n declare private commitTimer: number;\n /** The moves of the current hold, and when the last one came. */\n declare private moves: number;\n declare private lastMove: number;\n declare private shown: number;\n declare private range: Span;\n /** The chapters as last drawn, so the mask is written only when they change. */\n declare private divided: string;\n declare private list: Chapter[];\n declare private pending: number | null;\n declare private frame: number;\n\n constructor() {\n super();\n this.range = EMPTY;\n this.pending = null;\n this.frame = 0;\n this.divided = '';\n this.list = [];\n this.drag = 'none';\n this.dragged = null;\n this.resume = false;\n this.asked = 0;\n this.shown = 0;\n this.target = null;\n this.commitTimer = 0;\n this.moves = 0;\n this.lastMove = 0;\n const root = this.attachShadow({ mode: 'open' });\n this.bar = slider({\n step: () => this.keyStep(),\n page: () => number(this, 'page', PAGE),\n onInput: (value, key) => {\n if (key && this.previewing()) this.aim(value);\n else this.input(value);\n },\n onDrag: (on) => {\n this.toggleAttribute('dragging', on);\n if (on) this.dragStart();\n else this.dragEnd();\n },\n });\n this.buffered = el('div', 'buffered');\n this.hover = el('div', 'hover');\n this.edge = el('div', 'edge');\n this.hover.hidden = true;\n this.edge.hidden = true;\n // Under the fill, so what is played reads over what is buffered.\n this.bar.track.prepend(this.buffered);\n this.bar.track.append(this.hover, this.edge);\n this.preview = el('div', 'preview');\n this.image = el('div', 'preview-image');\n this.tile = el('div', 'preview-tile');\n this.time = el('span', 'preview-time');\n this.caption = el('span', 'preview-title');\n this.caption.hidden = true;\n this.image.append(this.tile);\n this.image.hidden = true;\n this.frameCanvas = el('canvas', 'preview-frame');\n this.frameCanvas.hidden = true;\n this.preview.append(this.frameCanvas, this.image, this.caption, this.time);\n this.preview.hidden = true;\n this.bar.root.append(this.preview);\n this.bar.root.addEventListener('pointermove', (event) => {\n this.point(event);\n });\n this.bar.root.addEventListener('pointerleave', () => {\n if (this.target === null) this.leave();\n });\n // Focus moving on: the target stands, as if the pause ran out.\n this.bar.root.addEventListener('blur', () => {\n if (this.target !== null) this.commit();\n });\n root.append(style(STYLE), this.bar.root);\n }\n\n override connectedCallback(): void {\n seekRow(this);\n super.connectedCallback();\n }\n\n private isLive(): boolean {\n return live(this.player?.engine ?? null) !== undefined;\n }\n\n /** Whether the chapters do `use`: `divided` the track, or name the preview with their `titles`. */\n private chaptered(use: 'divided' | 'titles'): boolean {\n if (this.list.length === 0) return false;\n const value = this.getAttribute('chapters');\n if (value === null) return true;\n const words = value.split(/\\s+/);\n // A value naming neither, as `on` did, keeps both.\n return (\n words.includes(use) ||\n !words.some((word) => word === 'divided' || word === 'titles' || word === 'none')\n );\n }\n\n /** The gaps at the chapter boundaries, on every layer of the track at once. */\n private paintChapters(): void {\n const mask =\n this.chaptered('divided') && this.list.length > 1 ? gaps(this.list, this.range) : '';\n const key = `${mask}|${this.range.start}|${this.range.end}`;\n if (key === this.divided) return;\n this.divided = key;\n const track = this.bar.track.style;\n // Both spellings: WebKit before 15.4 knows only the prefixed one.\n track.setProperty('mask-image', mask === '' ? '' : mask);\n track.setProperty('-webkit-mask-image', mask === '' ? '' : mask);\n }\n\n /** What a screen reader hears at a time. */\n private say(time: number): string {\n const engine = this.player?.engine ?? null;\n if (!this.isLive()) {\n const template = this.getAttribute('label-of') ?? '{current} of {duration}';\n return Number.isFinite(this.range.end) && this.range.end > 0\n ? fill(template, { current: format(time), duration: format(this.range.end) })\n : format(time);\n }\n const behind = fill(this.getAttribute('label-behind') ?? '{time} behind live', {\n time: format(this.range.end - time),\n });\n const clock = wall(engine, time);\n return clock === null ? behind : `${clock}, ${behind}`;\n }\n\n /** What the preview shows at a time. */\n private label(time: number): string {\n if (!this.isLive()) return format(time);\n return wall(this.player?.engine ?? null, time) ?? `-${format(this.range.end - time)}`;\n }\n\n /** Scrubs when the session has an I-frame track and the page allows it; seeks otherwise. */\n private dragStart(): void {\n const trick = optional(this.player?.engine ?? null).trick;\n this.dragged = null;\n // The pause below is the drag's, not the viewer's: the player says so,\n // with the state from before, which the play buttons keep showing.\n const before = this.player?.video.paused === false ? 'playing' : 'paused';\n this.player?.setAttribute('scrubbing', before);\n if (trick?.available === true && this.getAttribute('scrub') !== 'false') {\n trick.scrubStart();\n this.drag = 'scrub';\n } else {\n // Paused for the drag, the way the scrub is: the picture follows the\n // pointer, and playback waits for the release.\n const video = this.player?.video;\n this.resume = video !== undefined && !video.paused;\n video?.pause();\n this.drag = 'seek';\n }\n }\n\n /**\n * The pointer let go. A release writes its own input next, in the same\n * task, and that settles the drag. A cancelled drag writes none, so the\n * drag settles at its last position once the task is over.\n */\n private dragEnd(): void {\n queueMicrotask(() => {\n if (this.drag !== 'none') this.settle(this.dragged);\n });\n }\n\n /** Ends the drag at `value`, or where it stands when there is none. */\n private settle(value: number | null): void {\n const drag = this.drag;\n this.drag = 'none';\n this.dragged = null;\n const player = this.player;\n if (player === null) return;\n if (drag === 'scrub') {\n const trick = optional(player.engine).trick;\n if (value === null) trick?.scrubEnd();\n else trick?.scrubEnd(value);\n } else {\n if (value !== null) player.video.currentTime = value;\n if (this.resume) void player.video.play().catch(() => undefined);\n this.resume = false;\n }\n // After the play, which clears `paused` at once, so the start button\n // never shows between the release and the resume.\n player.removeAttribute('scrubbing');\n }\n\n /** Whether keys aim a target with the preview instead of seeking at once. */\n private previewing(): boolean {\n return this.getAttribute('key-mode') === 'preview';\n }\n\n /** The step for a key on the slider itself. */\n private keyStep(): number {\n const base = number(this, 'step', STEP);\n return this.previewing() ? base * this.growth() : base;\n }\n\n /**\n * How many steps a key moves the target under `key-mode=\"preview\"`. It\n * grows while the viewer holds the key, so a long film takes seconds to\n * cross, not minutes; a pause restarts it.\n */\n private growth(): number {\n const now = performance.now();\n if (now - this.lastMove > REPEAT_GAP_MS) this.moves = 0;\n this.moves += 1;\n this.lastMove = now;\n return Math.min(MAX_STEPS, 1 + Math.floor(this.moves / MOVES_PER_STEP));\n }\n\n /**\n * Aims at `value` without seeking: the thumb and the preview show it, and\n * the seek comes on Enter or once the keys pause. A TV decodes slowly, so\n * a seek per key would stutter where the preview already shows the place.\n */\n private aim(value: number): void {\n const time = Math.min(this.range.end, Math.max(this.range.start, value));\n this.target = time;\n this.bar.set(time, this.say(time));\n const span = this.range.end - this.range.start;\n if (span > 0) this.previewAt((time - this.range.start) / span);\n clearTimeout(this.commitTimer);\n this.commitTimer = window.setTimeout(() => {\n this.commit();\n }, KEY_COMMIT_MS);\n }\n\n /** Seeks to the target, if there is one. */\n private commit(): void {\n const target = this.target;\n this.stopAiming();\n const video = this.player?.video;\n if (target !== null && video !== undefined) video.currentTime = target;\n }\n\n /** Drops the target: the thumb goes back to the playhead. */\n private cancel(): void {\n this.stopAiming();\n this.render();\n }\n\n private stopAiming(): void {\n clearTimeout(this.commitTimer);\n this.commitTimer = 0;\n this.target = null;\n this.moves = 0;\n this.leave();\n }\n\n private input(value: number): void {\n const video = this.player?.video;\n if (video === undefined) return;\n this.bar.set(value, this.say(value));\n if (!this.bar.dragging()) {\n // The release, or a key: written now, and it supersedes whatever a\n // frame queued during the drag was about to write.\n this.pending = null;\n if (this.drag !== 'none') this.settle(value);\n else video.currentTime = value;\n return;\n }\n this.dragged = value;\n if (this.drag === 'scrub') {\n // The engine writes `currentTime` on every move; the browser drops a\n // seek a newer one supersedes, so no throttle is needed here.\n optional(this.player?.engine ?? null).trick?.scrubTo(value);\n return;\n }\n this.pending = value;\n if (this.frame === 0) {\n this.frame = requestAnimationFrame(() => {\n this.flush();\n });\n }\n }\n\n private flush(): void {\n this.frame = 0;\n const video = this.player?.video;\n if (this.pending === null || video === undefined) return;\n video.currentTime = this.pending;\n this.pending = null;\n }\n\n /** The width the page asked for through the token, or the default. */\n private previewWidth(): number {\n const set = Number.parseFloat(\n getComputedStyle(this.preview).getPropertyValue('--mbx-preview-width'),\n );\n return Number.isFinite(set) && set > 0 ? set : PREVIEW_WIDTH;\n }\n\n /** The preview's picture sources from `preview`, in order of preference: frames then tiles by default. */\n private sources(): Preview[] {\n const value = this.getAttribute('preview');\n if (value === 'none') return [];\n const own = (value ?? '')\n .split(/\\s+/)\n .filter((word): word is Preview => word === 'frames' || word === 'tiles');\n return own.length > 0 ? own : ['frames', 'tiles'];\n }\n\n /** `tile`, or none, drawn at its size and scaled to fit. */\n private paintTile(tile: Thumbnail | null): void {\n this.image.hidden = tile === null;\n if (tile === null) return;\n const scale = this.previewWidth() / tile.width;\n this.image.style.width = `${tile.width * scale}px`;\n this.image.style.height = `${tile.height * scale}px`;\n this.tile.style.width = `${tile.width}px`;\n this.tile.style.height = `${tile.height}px`;\n this.tile.style.backgroundImage = `url(\"${tile.url}\")`;\n this.tile.style.backgroundPosition = `-${tile.x}px -${tile.y}px`;\n this.tile.style.transform = `scale(${scale})`;\n }\n\n /**\n * The picture in the preview, from the sources `preview` names, the first\n * that answers winning. A decoded frame arrives later than a tile, so\n * while frames lead, the tile stands in until one is on screen, and the\n * last frame stays until the next one arrives. A scrub already shows the\n * position in the video, so the preview shows none meanwhile.\n */\n private paintPicture(when: number): void {\n const sources = this.drag === 'scrub' ? [] : this.sources();\n const api = optional(this.player?.engine ?? null);\n const trick = api.trick;\n // `previews` turns false once the engine knows no frame will come, such\n // as for TS I-frames; the tile shows then, without asking again.\n const frames = sources.includes('frames') && trick?.previews === true;\n const tile = sources.includes('tiles') ? (api.thumbnails?.at(when) ?? null) : null;\n if (tile !== null && (sources[0] === 'tiles' || !frames)) {\n // A frame still decoding for an earlier position must not replace it.\n this.asked += 1;\n this.shown = this.asked;\n this.frameCanvas.hidden = true;\n this.paintTile(tile);\n return;\n }\n if (!frames || trick === undefined) {\n this.frameCanvas.hidden = true;\n this.paintTile(null);\n return;\n }\n this.asked += 1;\n const request = this.asked;\n const width = this.previewWidth();\n // Null for a call a newer one replaced, and while the track's segments\n // load. What is on screen stays then.\n void trick.frameAt(when, { width: Math.round(width * devicePixelRatio) }).then(\n (bitmap) => {\n if (bitmap === null || request < this.shown || this.preview.hidden) return;\n this.shown = request;\n // The engine keeps the bitmap in its cache: drawn, never closed here.\n const canvas = this.frameCanvas;\n canvas.width = bitmap.width;\n canvas.height = bitmap.height;\n canvas.style.width = `${width}px`;\n canvas.style.height = `${(bitmap.height / bitmap.width) * width}px`;\n canvas.getContext('2d')?.drawImage(bitmap, 0, 0);\n canvas.hidden = false;\n this.image.hidden = true;\n },\n () => undefined,\n );\n if (this.frameCanvas.hidden) this.paintTile(tile);\n }\n\n private paintBuffered(video: HTMLVideoElement): void {\n const parts = clip(\n Array.from({ length: video.buffered.length }, (_, i) => ({\n start: video.buffered.start(i),\n end: video.buffered.end(i),\n })),\n this.range,\n );\n const buffered = this.buffered;\n while (buffered.childElementCount > parts.length) buffered.lastElementChild?.remove();\n while (buffered.childElementCount < parts.length) buffered.append(el('div', 'buffered-range'));\n let i = 0;\n for (const child of buffered.children) {\n const part = parts[i];\n i += 1;\n if (part === undefined) break;\n const node = child as HTMLElement;\n node.style.left = percent(part[0]);\n node.style.width = percent(part[1] - part[0]);\n }\n }\n\n /** Whether a live window is wide enough to be worth a bar. */\n private worthSeeking(): boolean {\n const goals = number(this, 'live-window', LIVE_WINDOW);\n if (goals === 0) return true;\n const goal = bufferGoal(this.player?.engine ?? null) ?? BUFFER_GOAL;\n return this.range.end - this.range.start >= goals * goal;\n }\n\n /** The hover marker and the preview follow the pointer, clamped to the bar. */\n private point(event: PointerEvent): void {\n const rect = this.bar.rail.getBoundingClientRect();\n if (rect.width === 0 || this.range.end <= this.range.start) return;\n const part = Math.min(1, Math.max(0, (event.clientX - rect.left) / rect.width));\n this.hover.hidden = false;\n this.hover.style.left = percent(part);\n this.previewAt(part);\n }\n\n /** The preview over `part` of the bar: the time, the chapter, and the picture. */\n private previewAt(part: number): void {\n const rect = this.bar.rail.getBoundingClientRect();\n if (rect.width === 0 || this.range.end <= this.range.start) return;\n this.preview.hidden = false;\n const when = at(part, this.range);\n this.time.textContent = this.label(when);\n const chapter = this.chaptered('titles') ? this.list[chapterAt(this.list, when)] : undefined;\n this.caption.hidden = chapter === undefined || chapter.title === '';\n this.caption.textContent = chapter?.title ?? '';\n this.paintPicture(when);\n const whole = this.bar.root.getBoundingClientRect();\n const half = this.preview.offsetWidth / 2;\n const x = rect.left - whole.left + part * rect.width;\n this.preview.style.left = `${Math.min(whole.width - half, Math.max(half, x))}px`;\n }\n\n private leave(): void {\n this.hover.hidden = true;\n this.preview.hidden = true;\n // The next hover starts from the tile, not a frame from elsewhere on the bar.\n this.frameCanvas.hidden = true;\n }\n\n protected override attach(player: PlayerHost): void {\n const tick = (): void => {\n this.render();\n };\n this.listen(player.video, EVENTS, tick);\n this.keep(followChapters(player, tick));\n this.listen(player, ['sourcechange'], () => {\n this.drag = 'none';\n this.stopAiming();\n this.render();\n });\n // Under `key-mode=\"preview\"`, the control bar's seeking keys aim: it\n // asks through `seekkey` before it seeks, and a taken event does not.\n this.listen(player, ['seekkey'], (event: Event) => {\n const asked = event as CustomEvent<{ readonly by: number }>;\n if (!this.previewing() || this.hidden || asked.defaultPrevented) return;\n asked.preventDefault();\n this.aim((this.target ?? player.video.currentTime) + asked.detail.by * this.growth());\n });\n // While a target stands, Enter seeks to it and Escape or Back drops it,\n // wherever focus is: on the bar, or anywhere the seeking keys came from.\n // Bubbling, so a focused control has its say first.\n this.listen(player, ['keydown'], (event: Event) => {\n const key = event as KeyboardEvent;\n if (this.target === null || key.defaultPrevented) return;\n // Enter on a button is that button's.\n if (key.key === 'Enter' && !(key.composedPath()[0] instanceof HTMLButtonElement)) {\n this.commit();\n } else if (CANCEL_KEYS.includes(key.key)) {\n this.cancel();\n } else return;\n key.preventDefault();\n });\n this.render();\n }\n\n protected override detach(player: PlayerHost): void {\n cancelAnimationFrame(this.frame);\n this.frame = 0;\n this.pending = null;\n if (this.drag !== 'none') this.settle(null);\n this.stopAiming();\n player.removeAttribute('live');\n player.removeAttribute('seekable');\n player.removeAttribute('scrubbing');\n }\n\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 api = live(engine);\n const on = api !== undefined;\n this.range = span(video, engine);\n this.list = chapters(video, engine);\n this.bar.label(this.getAttribute('label') ?? 'Seek');\n this.bar.range(this.range.start, this.range.end);\n this.paintBuffered(video);\n this.paintChapters();\n this.edge.hidden = !on;\n if (api !== undefined && api.edge !== null) {\n this.edge.style.left = percent(fraction(api.edge, this.range));\n }\n const seekable = !on || this.worthSeeking();\n this.hidden = !seekable;\n player.toggleAttribute('live', on);\n player.toggleAttribute('seekable', seekable);\n if (!this.bar.dragging() && this.target === null) {\n this.bar.set(video.currentTime, this.say(video.currentTime));\n }\n }\n}\n"],"mappings":";;;;;;;;;;AAuEA,MAAA,YAAA;AASA,MAAA,OAAA;;AAGA,MA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A,KAAA,KAAA;EACA,KAAA,QAAA;EACA,KAAA,UAAA;EACA,IAAA,KAAA,SAAA,QAAA,KAAA,OAAA,IAAA;EACA,KAAA,WAAA;EACA,OAAA,gBAAA,MAAA;EACA,OAAA,gBAAA,UAAA;EACA,OAAA,gBAAA,WAAA;CACA;CAEA,SAAA;EACA,MAAA,SAAA,KAAA;EACA,IAAA,WAAA,MAAA;EACA,MAAA,QAAA,OAAA;EACA,MAAA,SAAA,OAAA;EACA,MAAA,MAAA,KAAA,MAAA;EACA,MAAA,KAAA,QAAA,KAAA;EACA,KAAA,QAAA,KAAA,OAAA,MAAA;EACA,KAAA,OAAA,SAAA,OAAA,MAAA;EACA,KAAA,IAAA,MAAA,KAAA,aAAA,OAAA,KAAA,MAAA;EACA,KAAA,IAAA,MAAA,KAAA,MAAA,OAAA,KAAA,MAAA,GAAA;EACA,KAAA,cAAA,KAAA;EACA,KAAA,cAAA;EACA,KAAA,KAAA,SAAA,CAAA;EACA,IAAA,QAAA,KAAA,KAAA,IAAA,SAAA,MACA,KAAA,KAAA,MAAA,OAAA,QAAA,SAAA,IAAA,MAAA,KAAA,KAAA,CAAA;EAEA,MAAA,WAAA,CAAA,MAAA,KAAA,aAAA;EACA,KAAA,SAAA,CAAA;EACA,OAAA,gBAAA,QAAA,EAAA;EACA,OAAA,gBAAA,YAAA,QAAA;EACA,IAAA,CAAA,KAAA,IAAA,SAAA,KAAA,KAAA,WAAA,MACA,KAAA,IAAA,IAAA,MAAA,aAAA,KAAA,IAAA,MAAA,WAAA,CAAA;CAEA;AACA"}
1
+ {"version":3,"file":"seek-bar.js","names":[],"sources":["../../src/elements/seek-bar.ts"],"sourcesContent":["/**\n * <mbx-seek-bar>: the bar over the slider primitive, with four layers on\n * its track, every one a part: the buffered ranges from `video.buffered`,\n * the played span, the hover position, and for live the edge from\n * `engine.live`. The span it maps is the availability window for live and\n * the duration for VOD; `controls/session.ts` says which.\n *\n * A live stream is seekable only when the window is worth it: at least\n * `live-window` forward buffer goals long, the goal read from the engine.\n * Below that the bar hides. VOD is always seekable. The element sets\n * `live` and `seekable` on the player, which the time and the live button\n * read, and `scrubbing` while a pointer holds the thumb: `playing` or\n * `paused`, the state before the drag, which the play buttons show\n * instead of the drag's own pause.\n *\n * Reads happen on the events the video already fires; the live window has\n * no event of its own and moves with the clock, so `timeupdate` covers it.\n * While a pointer holds the thumb, the played layer follows the pointer.\n * The element carries `dragging` meanwhile. With an I-frame track\n * (`engine.trick.available`), the drag scrubs: the video pauses and shows\n * the I-frame at every position, and the release seeks there. See the\n * engine guide's trick play chapter. `scrub=\"false\"` turns this off.\n * Otherwise the video pauses, `currentTime` is written at most once per\n * frame, so the bar never fights a slow seek, and the release resumes\n * playback if it was playing. Thumbnail tiles never drive a drag: they are\n * previews, not frames of the video.\n *\n * The preview above the pointer carries the time and a picture of that\n * time from the sources `preview` names, in order of preference: `frames`\n * and `tiles`, \"frames tiles\" by default, `none` for no picture. A frame\n * is the decoded I-frame from `engine.trick.frameAt`, when the track\n * decodes in this browser; the last one stays until the next arrives, so\n * the picture never flickers while the engine decodes. A tile comes from\n * `engine.thumbnails`: a rectangle of a sprite, drawn by background\n * position at the sprite's own size. Both scale to `--mbx-preview-width`,\n * so a page sets the size with one token.\n *\n * Chapters divide the track: one gap per chapter boundary, cut through\n * every layer with a mask, so the played and the buffered spans read per\n * chapter, and the preview names the chapter under the pointer. They come\n * from the session, see `controls/chapters.ts`. `chapters` lists what the\n * bar does with them: `divided` and `titles`, both by default, one of\n * them alone, or `none`.\n *\n * `step` is what an arrow key moves the playhead by and `page` what Page\n * Up and Page Down do, in seconds. `key-mode=\"preview\"`, for a TV, makes\n * the keys aim instead of seek: the thumb and the preview show the target,\n * a held key's step grows, and the seek comes on Enter, on leaving the bar,\n * or a second after the last key. Escape or Back drops the target. The\n * control bar's seeking keys, the arrows and fast forward and rewind\n * anywhere in the player, aim the same way: the bar asks through\n * `seekkey`, and the seek bar takes it. The default, `instant`, seeks on\n * every key. The name comes from `label`; what a\n * screen reader hears at a position from `label-of`, \"{current} of\n * {duration}\", and on live from `label-behind`, \"{time} behind live\". It\n * sits in the bar's seek row unless the page says otherwise.\n */\n\nimport type { Thumbnail } from 'mattebox/stages/thumbnails';\nimport type { Chapter } from '../controls/chapters.js';\nimport { chapterAt, chapters, followChapters } from '../controls/chapters.js';\nimport type { Span } from '../controls/ranges.js';\nimport { at, clip, EMPTY, fraction, spans } from '../controls/ranges.js';\nimport { bufferGoal, live, optional, span, wall } from '../controls/session.js';\nimport type { Slider } from '../controls/slider.js';\nimport { slider } from '../controls/slider.js';\nimport { format } from '../controls/time.js';\nimport { el } from '../dom.js';\nimport type { PlayerHost } from '../host.js';\nimport { fill } from '../labels.js';\nimport { Component } from './component.js';\nimport STYLE_CSS from './seek-bar.css?inline';\nimport { number, SLIDER_STYLE, seekRow, style } from './shared.js';\n\n/** What a drag does, chosen when the pointer takes the thumb. */\ntype Drag = 'none' | 'seek' | 'scrub';\n\n/** Where the preview's picture comes from: decoded I-frames, or thumbnail tiles. */\ntype Preview = 'frames' | 'tiles';\n\nconst STEP = 5;\n\n/** Under `key-mode=\"preview\"`, a target seeks this long after the last key. */\nconst KEY_COMMIT_MS = 1000;\n/** Key moves closer together than this are one hold, whose step grows. */\nconst REPEAT_GAP_MS = 400;\n/** A held key's step grows by one step every this many moves... */\nconst MOVES_PER_STEP = 8;\n/** ...up to this many steps a move. */\nconst MAX_STEPS = 12;\n\n/** The keys that cancel a target: Escape, and Back as a remote sends it. */\nconst CANCEL_KEYS = ['Escape', 'GoBack', 'BrowserBack'];\nconst PAGE = 30;\nconst LIVE_WINDOW = 3;\n\n/** What the tile scales down to, in em, when the page sets no `--mbx-preview-width`. */\nconst PREVIEW_WIDTH = 10;\n\n/** The buffer goal assumed for a session that reports none. */\nconst BUFFER_GOAL = 30;\n\n/** The gap cut at a chapter boundary, in pixels. */\nconst GAP = 2;\n\nconst EVENTS = [\n 'timeupdate',\n 'progress',\n 'durationchange',\n 'loadedmetadata',\n 'seeking',\n 'seeked',\n 'emptied',\n];\n\nconst STYLE = SLIDER_STYLE + STYLE_CSS;\n\nfunction percent(part: number): string {\n return `${part * 100}%`;\n}\n\n/**\n * A mask that cuts a gap at each chapter boundary, as stops along the\n * track: opaque up to a boundary, clear for the gap, opaque after.\n */\nfunction gaps(boundaries: readonly number[], span: Span): string {\n if (boundaries.length === 0) return '';\n const stops: string[] = ['#000 0'];\n for (const time of boundaries) {\n const at = percent(fraction(time, span));\n const before = `calc(${at} - ${GAP / 2}px)`;\n const after = `calc(${at} + ${GAP / 2}px)`;\n stops.push(`#000 ${before}`, `transparent ${before}`, `transparent ${after}`, `#000 ${after}`);\n }\n stops.push('#000 100%');\n return `linear-gradient(to right, ${stops.join(', ')})`;\n}\n\nexport class MbxSeekBar extends Component {\n static get observedAttributes(): readonly string[] {\n return [\n 'label',\n 'label-of',\n 'label-behind',\n 'label-blocked',\n 'live-window',\n 'chapters',\n 'scrub',\n 'preview',\n 'key-mode',\n ];\n }\n\n declare private readonly bar: Slider;\n declare private readonly buffered: HTMLElement;\n /** The ranges the page marked blocked, drawn as a broken line: they never play. */\n declare private readonly blocked: HTMLElement;\n declare private readonly hover: HTMLElement;\n declare private readonly edge: HTMLElement;\n declare private readonly preview: HTMLElement;\n declare private readonly image: HTMLElement;\n declare private readonly tile: HTMLElement;\n declare private readonly time: HTMLElement;\n declare private readonly caption: HTMLElement;\n declare private readonly frameCanvas: HTMLCanvasElement;\n declare private drag: Drag;\n /** The last position of the drag, which a cancelled drag settles at. */\n declare private dragged: number | null;\n /** Whether the video played when a seeking drag began, so the release resumes it. */\n declare private resume: boolean;\n /** Frames asked for, and the newest one on screen, so a late frame never replaces a newer one. */\n declare private asked: number;\n /** Under `key-mode=\"preview\"`: where the keys aim, not yet sought to, or null. */\n declare private target: number | null;\n declare private commitTimer: number;\n /** The moves of the current hold, and when the last one came. */\n declare private moves: number;\n declare private lastMove: number;\n declare private shown: number;\n declare private range: Span;\n /** The chapters as last drawn, so the mask is written only when they change. */\n declare private divided: string;\n declare private list: Chapter[];\n declare private pending: number | null;\n declare private frame: number;\n\n constructor() {\n super();\n this.range = EMPTY;\n this.pending = null;\n this.frame = 0;\n this.divided = '';\n this.list = [];\n this.drag = 'none';\n this.dragged = null;\n this.resume = false;\n this.asked = 0;\n this.shown = 0;\n this.target = null;\n this.commitTimer = 0;\n this.moves = 0;\n this.lastMove = 0;\n const root = this.attachShadow({ mode: 'open' });\n this.bar = slider({\n step: () => this.keyStep(),\n page: () => number(this, 'page', PAGE),\n onInput: (value, key) => {\n if (key && this.previewing()) this.aim(value);\n else this.input(value);\n },\n onDrag: (on) => {\n this.toggleAttribute('dragging', on);\n if (on) this.dragStart();\n else this.dragEnd();\n },\n });\n this.buffered = el('div', 'buffered');\n this.blocked = el('div', 'blocked');\n this.hover = el('div', 'hover');\n this.edge = el('div', 'edge');\n this.hover.hidden = true;\n this.edge.hidden = true;\n // Under the fill, so what is played reads over what is buffered.\n this.bar.track.prepend(this.buffered);\n // Over the fill, inside the track: the chapter gaps cut through it too.\n this.bar.track.append(this.blocked, this.hover, this.edge);\n this.preview = el('div', 'preview');\n this.image = el('div', 'preview-image');\n this.tile = el('div', 'preview-tile');\n this.time = el('span', 'preview-time');\n this.caption = el('span', 'preview-title');\n this.caption.hidden = true;\n this.image.append(this.tile);\n this.image.hidden = true;\n this.frameCanvas = el('canvas', 'preview-frame');\n this.frameCanvas.hidden = true;\n this.preview.append(this.frameCanvas, this.image, this.caption, this.time);\n this.preview.hidden = true;\n this.bar.root.append(this.preview);\n this.bar.root.addEventListener('pointermove', (event) => {\n this.point(event);\n });\n this.bar.root.addEventListener('pointerleave', () => {\n if (this.target === null) this.leave();\n });\n // Focus moving on: the target stands, as if the pause ran out.\n this.bar.root.addEventListener('blur', () => {\n if (this.target !== null) this.commit();\n });\n root.append(style(STYLE), this.bar.root);\n }\n\n override connectedCallback(): void {\n seekRow(this);\n super.connectedCallback();\n }\n\n private isLive(): boolean {\n return live(this.player?.engine ?? null) !== undefined;\n }\n\n /** Whether the chapters do `use`: `divided` the track, or name the preview with their `titles`. */\n private chaptered(use: 'divided' | 'titles'): boolean {\n if (this.list.length === 0) return false;\n const value = this.getAttribute('chapters');\n if (value === null) return true;\n const words = value.split(/\\s+/);\n // A value naming neither, as `on` did, keeps both.\n return (\n words.includes(use) ||\n !words.some((word) => word === 'divided' || word === 'titles' || word === 'none')\n );\n }\n\n /** The gaps at the chapter boundaries, on every layer of the track at once. */\n private paintChapters(): void {\n const boundaries =\n this.chaptered('divided') && this.list.length > 1\n ? this.list.slice(1).map((chapter) => chapter.start)\n : [];\n const mask = gaps(boundaries, this.range);\n const key = `${mask}|${this.range.start}|${this.range.end}`;\n if (key === this.divided) return;\n this.divided = key;\n const track = this.bar.track.style;\n // Both spellings: WebKit before 15.4 knows only the prefixed one.\n track.setProperty('mask-image', mask === '' ? '' : mask);\n track.setProperty('-webkit-mask-image', mask === '' ? '' : mask);\n }\n\n /** What a screen reader hears at a time. */\n private say(time: number): string {\n const engine = this.player?.engine ?? null;\n if (!this.isLive()) {\n const template = this.getAttribute('label-of') ?? '{current} of {duration}';\n return Number.isFinite(this.range.end) && this.range.end > 0\n ? fill(template, { current: format(time), duration: format(this.range.end) })\n : format(time);\n }\n const behind = fill(this.getAttribute('label-behind') ?? '{time} behind live', {\n time: format(this.range.end - time),\n });\n const clock = wall(engine, time);\n return clock === null ? behind : `${clock}, ${behind}`;\n }\n\n /** What the preview shows at a time. */\n private label(time: number): string {\n if (!this.isLive()) return format(time);\n return wall(this.player?.engine ?? null, time) ?? `-${format(this.range.end - time)}`;\n }\n\n /** Scrubs when the session has an I-frame track and the page allows it; seeks otherwise. */\n private dragStart(): void {\n const trick = optional(this.player?.engine ?? null).trick;\n this.dragged = null;\n // The pause below is the drag's, not the viewer's: the player says so,\n // with the state from before, which the play buttons keep showing.\n const before = this.player?.video.paused === false ? 'playing' : 'paused';\n this.player?.setAttribute('scrubbing', before);\n if (trick?.available === true && this.getAttribute('scrub') !== 'false') {\n trick.scrubStart();\n this.drag = 'scrub';\n } else {\n // Paused for the drag, the way the scrub is: the picture follows the\n // pointer, and playback waits for the release.\n const video = this.player?.video;\n this.resume = video !== undefined && !video.paused;\n video?.pause();\n this.drag = 'seek';\n }\n }\n\n /**\n * The pointer let go. A release writes its own input next, in the same\n * task, and that settles the drag. A cancelled drag writes none, so the\n * drag settles at its last position once the task is over.\n */\n private dragEnd(): void {\n queueMicrotask(() => {\n if (this.drag !== 'none') this.settle(this.dragged);\n });\n }\n\n /** Ends the drag at `value`, or where it stands when there is none. */\n private settle(value: number | null): void {\n const drag = this.drag;\n this.drag = 'none';\n this.dragged = null;\n const player = this.player;\n if (player === null) return;\n if (drag === 'scrub') {\n const trick = optional(player.engine).trick;\n if (value === null) trick?.scrubEnd();\n else trick?.scrubEnd(value);\n } else {\n if (value !== null) player.video.currentTime = value;\n if (this.resume) void player.video.play().catch(() => undefined);\n this.resume = false;\n }\n // After the play, which clears `paused` at once, so the start button\n // never shows between the release and the resume.\n player.removeAttribute('scrubbing');\n }\n\n /** Whether keys aim a target with the preview instead of seeking at once. */\n private previewing(): boolean {\n return this.getAttribute('key-mode') === 'preview';\n }\n\n /** The step for a key on the slider itself. */\n private keyStep(): number {\n const base = number(this, 'step', STEP);\n return this.previewing() ? base * this.growth() : base;\n }\n\n /**\n * How many steps a key moves the target under `key-mode=\"preview\"`. It\n * grows while the viewer holds the key, so a long film takes seconds to\n * cross, not minutes; a pause restarts it.\n */\n private growth(): number {\n const now = performance.now();\n if (now - this.lastMove > REPEAT_GAP_MS) this.moves = 0;\n this.moves += 1;\n this.lastMove = now;\n return Math.min(MAX_STEPS, 1 + Math.floor(this.moves / MOVES_PER_STEP));\n }\n\n /**\n * Aims at `value` without seeking: the thumb and the preview show it, and\n * the seek comes on Enter or once the keys pause. A TV decodes slowly, so\n * a seek per key would stutter where the preview already shows the place.\n */\n private aim(value: number): void {\n const time = Math.min(this.range.end, Math.max(this.range.start, value));\n this.target = time;\n this.bar.set(time, this.say(time));\n const span = this.range.end - this.range.start;\n if (span > 0) this.previewAt((time - this.range.start) / span);\n clearTimeout(this.commitTimer);\n this.commitTimer = window.setTimeout(() => {\n this.commit();\n }, KEY_COMMIT_MS);\n }\n\n /** Seeks to the target, if there is one. */\n private commit(): void {\n const target = this.target;\n this.stopAiming();\n const video = this.player?.video;\n if (target !== null && video !== undefined) video.currentTime = target;\n }\n\n /** Drops the target: the thumb goes back to the playhead. */\n private cancel(): void {\n this.stopAiming();\n this.render();\n }\n\n private stopAiming(): void {\n clearTimeout(this.commitTimer);\n this.commitTimer = 0;\n this.target = null;\n this.moves = 0;\n this.leave();\n }\n\n private input(value: number): void {\n const video = this.player?.video;\n if (video === undefined) return;\n this.bar.set(value, this.say(value));\n if (!this.bar.dragging()) {\n // The release, or a key: written now, and it supersedes whatever a\n // frame queued during the drag was about to write.\n this.pending = null;\n if (this.drag !== 'none') this.settle(value);\n else video.currentTime = value;\n return;\n }\n this.dragged = value;\n if (this.drag === 'scrub') {\n // The engine writes `currentTime` on every move; the browser drops a\n // seek a newer one supersedes, so no throttle is needed here.\n optional(this.player?.engine ?? null).trick?.scrubTo(value);\n return;\n }\n this.pending = value;\n if (this.frame === 0) {\n this.frame = requestAnimationFrame(() => {\n this.flush();\n });\n }\n }\n\n private flush(): void {\n this.frame = 0;\n const video = this.player?.video;\n if (this.pending === null || video === undefined) return;\n video.currentTime = this.pending;\n this.pending = null;\n }\n\n /** The width the page asked for through the token, or the default. */\n private previewWidth(): number {\n const set = Number.parseFloat(\n getComputedStyle(this.preview).getPropertyValue('--mbx-preview-width'),\n );\n if (Number.isFinite(set) && set > 0) return set;\n return PREVIEW_WIDTH * (Number.parseFloat(getComputedStyle(this).fontSize) || 16);\n }\n\n /** The preview's picture sources from `preview`, in order of preference: frames then tiles by default. */\n private sources(): Preview[] {\n const value = this.getAttribute('preview');\n if (value === 'none') return [];\n const own = (value ?? '')\n .split(/\\s+/)\n .filter((word): word is Preview => word === 'frames' || word === 'tiles');\n return own.length > 0 ? own : ['frames', 'tiles'];\n }\n\n /** `tile`, or none, drawn at its size and scaled to fit. */\n private paintTile(tile: Thumbnail | null): void {\n this.image.hidden = tile === null;\n if (tile === null) return;\n const scale = this.previewWidth() / tile.width;\n this.image.style.width = `${tile.width * scale}px`;\n this.image.style.height = `${tile.height * scale}px`;\n this.tile.style.width = `${tile.width}px`;\n this.tile.style.height = `${tile.height}px`;\n this.tile.style.backgroundImage = `url(\"${tile.url}\")`;\n this.tile.style.backgroundPosition = `-${tile.x}px -${tile.y}px`;\n this.tile.style.transform = `scale(${scale})`;\n }\n\n /**\n * The picture in the preview, from the sources `preview` names, the first\n * that answers winning. A decoded frame arrives later than a tile, so\n * while frames lead, the tile stands in until one is on screen, and the\n * last frame stays until the next one arrives. A scrub already shows the\n * position in the video, so the preview shows none meanwhile.\n */\n private paintPicture(when: number): void {\n const sources = this.drag === 'scrub' ? [] : this.sources();\n const api = optional(this.player?.engine ?? null);\n const trick = api.trick;\n // `previews` turns false once the engine knows no frame will come, such\n // as for TS I-frames; the tile shows then, without asking again.\n const frames = sources.includes('frames') && trick?.previews === true;\n const tile = sources.includes('tiles') ? (api.thumbnails?.at(when) ?? null) : null;\n if (tile !== null && (sources[0] === 'tiles' || !frames)) {\n // A frame still decoding for an earlier position must not replace it.\n this.asked += 1;\n this.shown = this.asked;\n this.frameCanvas.hidden = true;\n this.paintTile(tile);\n return;\n }\n if (!frames || trick === undefined) {\n this.frameCanvas.hidden = true;\n this.paintTile(null);\n return;\n }\n this.asked += 1;\n const request = this.asked;\n const width = this.previewWidth();\n // Null for a call a newer one replaced, and while the track's segments\n // load. What is on screen stays then.\n void trick.frameAt(when, { width: Math.round(width * devicePixelRatio) }).then(\n (bitmap) => {\n if (bitmap === null || request < this.shown || this.preview.hidden) return;\n this.shown = request;\n // The engine keeps the bitmap in its cache: drawn, never closed here.\n const canvas = this.frameCanvas;\n canvas.width = bitmap.width;\n canvas.height = bitmap.height;\n canvas.style.width = `${width}px`;\n canvas.style.height = `${(bitmap.height / bitmap.width) * width}px`;\n canvas.getContext('2d')?.drawImage(bitmap, 0, 0);\n canvas.hidden = false;\n this.image.hidden = true;\n },\n () => undefined,\n );\n if (this.frameCanvas.hidden) this.paintTile(tile);\n }\n\n /** The ranges the page marked blocked. */\n private blockedRanges(): Span[] {\n return (this.player?.markers.list ?? []).filter((marker) => marker.kind === 'blocked');\n }\n\n /** One child of `layer` per range, each named `part`, placed along the track. */\n private paintRanges(layer: HTMLElement, ranges: readonly Span[], part: string): void {\n const parts = clip(ranges, this.range);\n while (layer.childElementCount > parts.length) layer.lastElementChild?.remove();\n while (layer.childElementCount < parts.length) layer.append(el('div', part));\n let i = 0;\n for (const child of layer.children) {\n const part = parts[i];\n i += 1;\n if (part === undefined) break;\n const node = child as HTMLElement;\n node.style.left = percent(part[0]);\n node.style.width = percent(part[1] - part[0]);\n }\n }\n\n /** Whether a live window is wide enough to be worth a bar. */\n private worthSeeking(): boolean {\n const goals = number(this, 'live-window', LIVE_WINDOW);\n if (goals === 0) return true;\n const goal = bufferGoal(this.player?.engine ?? null) ?? BUFFER_GOAL;\n return this.range.end - this.range.start >= goals * goal;\n }\n\n /** The hover marker and the preview follow the pointer, clamped to the bar. */\n private point(event: PointerEvent): void {\n const rect = this.bar.rail.getBoundingClientRect();\n if (rect.width === 0 || this.range.end <= this.range.start) return;\n const part = Math.min(1, Math.max(0, (event.clientX - rect.left) / rect.width));\n this.hover.hidden = false;\n this.hover.style.left = percent(part);\n this.previewAt(part);\n }\n\n /** The preview over `part` of the bar: the time, the chapter, and the picture. */\n private previewAt(part: number): void {\n const rect = this.bar.rail.getBoundingClientRect();\n if (rect.width === 0 || this.range.end <= this.range.start) return;\n this.preview.hidden = false;\n const when = at(part, this.range);\n this.time.textContent = this.label(when);\n const chapter = this.chaptered('titles') ? this.list[chapterAt(this.list, when)] : undefined;\n // A blocked range shows no picture: its frames must not play, and a\n // preview would show them.\n const blocked = this.player?.markers.within(when).find((marker) => marker.kind === 'blocked');\n const title = blocked\n ? (blocked.label ?? this.getAttribute('label-blocked') ?? 'Not available')\n : (chapter?.title ?? '');\n this.caption.hidden = title === '';\n this.caption.textContent = title;\n if (blocked) {\n this.image.hidden = true;\n this.frameCanvas.hidden = true;\n } else this.paintPicture(when);\n const whole = this.bar.root.getBoundingClientRect();\n const half = this.preview.offsetWidth / 2;\n const x = rect.left - whole.left + part * rect.width;\n this.preview.style.left = `${Math.min(whole.width - half, Math.max(half, x))}px`;\n }\n\n private leave(): void {\n this.hover.hidden = true;\n this.preview.hidden = true;\n // The next hover starts from the tile, not a frame from elsewhere on the bar.\n this.frameCanvas.hidden = true;\n }\n\n protected override attach(player: PlayerHost): void {\n const tick = (): void => {\n this.render();\n };\n this.listen(player.video, EVENTS, tick);\n this.keep(followChapters(player, tick));\n this.listen(player, ['markerschange'], tick);\n this.listen(player, ['sourcechange'], () => {\n this.drag = 'none';\n this.stopAiming();\n this.render();\n });\n // Under `key-mode=\"preview\"`, the control bar's seeking keys aim: it\n // asks through `seekkey` before it seeks, and a taken event does not.\n this.listen(player, ['seekkey'], (event: Event) => {\n const asked = event as CustomEvent<{ readonly by: number }>;\n if (!this.previewing() || this.hidden || asked.defaultPrevented) return;\n asked.preventDefault();\n this.aim((this.target ?? player.video.currentTime) + asked.detail.by * this.growth());\n });\n // While a target stands, Enter seeks to it and Escape or Back drops it,\n // wherever focus is: on the bar, or anywhere the seeking keys came from.\n // Bubbling, so a focused control has its say first.\n this.listen(player, ['keydown'], (event: Event) => {\n const key = event as KeyboardEvent;\n if (this.target === null || key.defaultPrevented) return;\n // Enter on a button is that button's.\n if (key.key === 'Enter' && !(key.composedPath()[0] instanceof HTMLButtonElement)) {\n this.commit();\n } else if (CANCEL_KEYS.includes(key.key)) {\n this.cancel();\n } else return;\n key.preventDefault();\n });\n this.render();\n }\n\n protected override detach(player: PlayerHost): void {\n cancelAnimationFrame(this.frame);\n this.frame = 0;\n this.pending = null;\n if (this.drag !== 'none') this.settle(null);\n this.stopAiming();\n player.removeAttribute('live');\n player.removeAttribute('seekable');\n player.removeAttribute('scrubbing');\n }\n\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 api = live(engine);\n const on = api !== undefined;\n this.range = span(video, engine);\n this.list = chapters(video, engine);\n this.bar.label(this.getAttribute('label') ?? 'Seek');\n this.bar.range(this.range.start, this.range.end);\n this.paintRanges(this.buffered, spans(video.buffered), 'buffered-range');\n this.paintRanges(this.blocked, this.blockedRanges(), 'blocked-range');\n this.paintChapters();\n this.edge.hidden = !on;\n if (api !== undefined && api.edge !== null) {\n this.edge.style.left = percent(fraction(api.edge, this.range));\n }\n const seekable = !on || this.worthSeeking();\n this.hidden = !seekable;\n player.toggleAttribute('live', on);\n player.toggleAttribute('seekable', seekable);\n if (!this.bar.dragging() && this.target === null) {\n this.bar.set(video.currentTime, this.say(video.currentTime));\n }\n }\n}\n"],"mappings":";;;;;;;;;;AAuEA,MAAA,YAAA;AASA,MAAA,OAAA;;AAGA,MAAA,gBAAA;;AAEA,MAAA,gBAAA;;AAEA,MAAA,iBAAA;;AAEA,MAAA,YAAA;;AAGA,MAAA,cAAA;CAAA;CAAA;CAAA;AAAA;AACA,MAAA,OAAA;AACA,MAAA,cAAA;;AAGA,MAAA,gBAAA;;AAGA,MAAA,cAAA;;AAGA,MAAA,MAAA;AAEA,MAAA,SAAA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACA;AAEA,MAAA,QAAA,eAAA;AAEA,SAAA,QAAA,MAAA;CACA,OAAA,GAAA,OAAA,IAAA;AACA;;;;;AAMA,SAAA,KAAA,YAAA,MAAA;CACA,IAAA,WAAA,WAAA,GAAA,OAAA;CACA,MAAA,QAAA,CAAA,QAAA;CACA,KAAA,MAAA,QAAA,YAAA;EACA,MAAA,KAAA,QAAA,SAAA,MAAA,IAAA,CAAA;EACA,MAAA,SAAA,QAAA,GAAA,KAAA,MAAA,EAAA;EACA,MAAA,QAAA,QAAA,GAAA,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MAAA,SAAA,KAAA;EACA,IAAA,WAAA,MAAA;EACA,MAAA,QAAA,OAAA;EACA,MAAA,SAAA,OAAA;EACA,MAAA,MAAA,KAAA,MAAA;EACA,MAAA,KAAA,QAAA,KAAA;EACA,KAAA,QAAA,KAAA,OAAA,MAAA;EACA,KAAA,OAAA,SAAA,OAAA,MAAA;EACA,KAAA,IAAA,MAAA,KAAA,aAAA,OAAA,KAAA,MAAA;EACA,KAAA,IAAA,MAAA,KAAA,MAAA,OAAA,KAAA,MAAA,GAAA;EACA,KAAA,YAAA,KAAA,UAAA,MAAA,MAAA,QAAA,GAAA,gBAAA;EACA,KAAA,YAAA,KAAA,SAAA,KAAA,cAAA,GAAA,eAAA;EACA,KAAA,cAAA;EACA,KAAA,KAAA,SAAA,CAAA;EACA,IAAA,QAAA,KAAA,KAAA,IAAA,SAAA,MACA,KAAA,KAAA,MAAA,OAAA,QAAA,SAAA,IAAA,MAAA,KAAA,KAAA,CAAA;EAEA,MAAA,WAAA,CAAA,MAAA,KAAA,aAAA;EACA,KAAA,SAAA,CAAA;EACA,OAAA,gBAAA,QAAA,EAAA;EACA,OAAA,gBAAA,YAAA,QAAA;EACA,IAAA,CAAA,KAAA,IAAA,SAAA,KAAA,KAAA,WAAA,MACA,KAAA,IAAA,IAAA,MAAA,aAAA,KAAA,IAAA,MAAA,WAAA,CAAA;CAEA;AACA"}
@@ -7,8 +7,8 @@
7
7
  *
8
8
  * Nothing carries `!important`: a page's `::part()` rule must win.
9
9
  */
10
- const BUTTON_STYLE_CSS = ":host{display:inline-flex}:host([hidden]){display:none}[part~=button]{width:40px;height:40px;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}[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}";
11
- const SLIDER_STYLE_CSS = ":host{display:block}:host([hidden]){display:none}[part~=slider]{border-radius:var(--mbx-radius);cursor:pointer;touch-action:none;height:40px;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:8px;right:8px}[part~=track]{background:#ffffff59;border-radius:2px;height:4px;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:12px;height:12px;margin:-6px 0 0 -6px;position:absolute;top:50%}";
10
+ const BUTTON_STYLE_CSS = ":host{display:inline-flex}:host([hidden]){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}";
11
+ 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%}";
12
12
  const BUTTON_STYLE = BUTTON_STYLE_CSS;
13
13
  /** The style of a slider: the rail, the track with its fill, and the thumb. */
14
14
  const SLIDER_STYLE = SLIDER_STYLE_CSS;
@@ -19,7 +19,7 @@ function number(node, name, fallback) {
19
19
  return Number.isFinite(value) && value >= 0 ? value : fallback;
20
20
  }
21
21
  /** The style of a menu: the button from BUTTON_STYLE, and the popup above it with its items. */
22
- const MENU_STYLE = ":host{display:inline-flex}:host([hidden]){display:none}[part~=button]{width:40px;height:40px;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}[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]{overscroll-behavior:contain;border-radius:var(--mbx-radius);background:#101114f2;flex-direction:column;min-width:160px;margin-bottom:8px;padding:6px;font-size:14px;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:6px;padding-top:6px}[part~=section-label]{letter-spacing:.06em;text-transform:uppercase;color:var(--mbx-muted);padding:4px 12px 2px;font-size:11px;font-weight:600}[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:8px 12px 8px 28px;display:flex}[part~=item]:hover{background:#ffffff1f}[part~=item-text]{text-overflow:ellipsis;min-width:0;overflow:hidden}[part~=item-image]{object-fit:cover;background:#ffffff14;border-radius:2px;flex:none;width:64px;height:36px;margin-right:12px}[part~=item-detail]{color:var(--mbx-muted);font-variant-numeric:tabular-nums;margin-left:auto;padding-left:12px}[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:28px;position:relative}[part~=page-item]:after{content:\"\";opacity:.7;border:1.5px solid;border-width:1.5px 1.5px 0 0;width:7px;height:7px;margin-top:-4px;position:absolute;top:50%;right:12px;transform:rotate(45deg)}[part~=back-item]{border-bottom:1px solid #ffffff1f;border-radius:0;margin-bottom:6px;font-weight:600;position:relative}[part~=back-item]:before{content:\"\";opacity:.7;border:0 solid;border-width:1.5px 0 0 1.5px;width:7px;height:7px;margin-top:-4px;position:absolute;top:50%;left:12px;transform:rotate(-45deg)}[part~=checked]{position:relative}[part~=checked]:before{content:\"\";background:var(--mbx-accent);border-radius:50%;width:6px;height:6px;margin-top:-3px;position:absolute;top:50%;left:12px}";
22
+ const MENU_STYLE = ":host{display:inline-flex}:host([hidden]){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~=popup][more]{-webkit-mask-image:linear-gradient(#000 calc(100% - 1.5em),#0000);mask-image:linear-gradient(#000 calc(100% - 1.5em),#0000)}[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~=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~=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;max-height:70vh;padding-bottom:calc(.4286em + env(safe-area-inset-bottom,0px));background:#1c1c20;border-radius:.75em .75em 0 0;margin:0;font-size:1em;position:fixed;bottom:0;left:0;right:0;box-shadow:0 0 0 100vmax #00000080}";
23
23
  /** Puts a control in the bar's seek row when it is in a bar, unless the page wrote a `slot` of its own. */
24
24
  function seekRow(node) {
25
25
  if (node.parentElement?.localName === "mbx-control-bar" && !node.hasAttribute("slot")) node.slot = "seek";
@@ -5,10 +5,10 @@ import { BUTTON_STYLE, style } from "./shared.js";
5
5
  import { fill } from "../labels.js";
6
6
  //#region src/elements/skip-button.ts
7
7
  const SECONDS = 10;
8
- /** The glyph for a skip amount: the set draws 10 and 30, and a plain arrow says the rest. */
8
+ /** The glyph for a skip amount: the set draws 5, 10, 15 and 30, and a plain arrow says the rest. */
9
9
  function glyphFor(back, amount) {
10
10
  const side = back ? "seek-backward" : "seek-forward";
11
- if (amount === 10 || amount === 30) return `${side}-${amount}`;
11
+ if (amount === 5 || amount === 10 || amount === 15 || amount === 30) return `${side}-${amount}`;
12
12
  return side;
13
13
  }
14
14
  var MbxSkipButton = class extends Component {
@@ -1 +1 @@
1
- {"version":3,"file":"skip-button.js","names":[],"sources":["../../src/elements/skip-button.ts"],"sourcesContent":["/**\n * <mbx-skip-button>: moves the playhead by `seconds`, negative for back,\n * within what the video can reach. The glyph says the amount where the\n * set has one, 10 and 30, and a plain arrow otherwise; `icon` takes a\n * page's own. The name comes from `label`, where `{seconds}` is the\n * amount without its sign: \"Back {seconds} seconds\".\n */\nimport type { IconName } from '../controls/icons.js';\nimport { icon } from '../controls/icons.js';\nimport { setChildren } from '../dom.js';\nimport type { PlayerHost } from '../host.js';\nimport { fill } from '../labels.js';\nimport { Component } from './component.js';\nimport { BUTTON_STYLE, style } from './shared.js';\n\nconst SECONDS = 10;\n\n/** The glyph for a skip amount: the set draws 10 and 30, and a plain arrow says the rest. */\nfunction glyphFor(back: boolean, amount: number): IconName {\n const side = back ? 'seek-backward' : 'seek-forward';\n if (amount === 10 || amount === 30) return `${side}-${amount}`;\n return side;\n}\n\nexport class MbxSkipButton extends Component {\n static get observedAttributes(): readonly string[] {\n return ['seconds', 'label'];\n }\n\n declare private readonly button: HTMLButtonElement;\n declare private readonly glyph: HTMLSlotElement;\n\n constructor() {\n super();\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.glyph = document.createElement('slot');\n this.glyph.name = 'icon';\n this.button.append(this.glyph);\n this.button.addEventListener('click', () => {\n this.skip();\n });\n root.append(style(BUTTON_STYLE), this.button);\n }\n\n /** The amount, signed. A value that is not a number is the default. */\n private seconds(): number {\n const value = Number(this.getAttribute('seconds') ?? SECONDS);\n return Number.isFinite(value) ? value : SECONDS;\n }\n\n private skip(): void {\n const video = this.player?.video;\n if (video === undefined) return;\n const ranges = video.seekable;\n const end = Number.isFinite(video.duration)\n ? video.duration\n : ranges.length > 0\n ? ranges.end(ranges.length - 1)\n : video.currentTime;\n video.currentTime = Math.min(end, Math.max(0, video.currentTime + this.seconds()));\n }\n\n protected override attach(_player: PlayerHost): void {\n this.render();\n }\n\n protected override render(): void {\n const seconds = this.seconds();\n const back = seconds < 0;\n const amount = Math.abs(seconds);\n setChildren(this.glyph, icon(glyphFor(back, amount)));\n const template =\n this.getAttribute('label') ?? (back ? 'Back {seconds} seconds' : 'Forward {seconds} seconds');\n this.button.setAttribute('aria-label', fill(template, { seconds: amount }));\n }\n}\n"],"mappings":";;;;;;AAeA,MAAM,UAAU;;AAGhB,SAAS,SAAS,MAAe,QAA0B;CACzD,MAAM,OAAO,OAAO,kBAAkB;CACtC,IAAI,WAAW,MAAM,WAAW,IAAI,OAAO,GAAG,KAAK,GAAG;CACtD,OAAO;AACT;AAEA,IAAa,gBAAb,cAAmC,UAAU;CAC3C,WAAW,qBAAwC;EACjD,OAAO,CAAC,WAAW,OAAO;CAC5B;CAKA,cAAc;EACZ,MAAM;EACN,MAAM,OAAO,KAAK,aAAa,EAAE,MAAM,OAAO,CAAC;EAC/C,KAAK,SAAS,SAAS,cAAc,QAAQ;EAC7C,KAAK,OAAO,OAAO;EACnB,KAAK,OAAO,aAAa,QAAQ,QAAQ;EACzC,KAAK,QAAQ,SAAS,cAAc,MAAM;EAC1C,KAAK,MAAM,OAAO;EAClB,KAAK,OAAO,OAAO,KAAK,KAAK;EAC7B,KAAK,OAAO,iBAAiB,eAAe;GAC1C,KAAK,KAAK;EACZ,CAAC;EACD,KAAK,OAAO,MAAM,YAAY,GAAG,KAAK,MAAM;CAC9C;;CAGA,UAA0B;EACxB,MAAM,QAAQ,OAAO,KAAK,aAAa,SAAS,KAAK,OAAO;EAC5D,OAAO,OAAO,SAAS,KAAK,IAAI,QAAQ;CAC1C;CAEA,OAAqB;EACnB,MAAM,QAAQ,KAAK,QAAQ;EAC3B,IAAI,UAAU,KAAA,GAAW;EACzB,MAAM,SAAS,MAAM;EACrB,MAAM,MAAM,OAAO,SAAS,MAAM,QAAQ,IACtC,MAAM,WACN,OAAO,SAAS,IACd,OAAO,IAAI,OAAO,SAAS,CAAC,IAC5B,MAAM;EACZ,MAAM,cAAc,KAAK,IAAI,KAAK,KAAK,IAAI,GAAG,MAAM,cAAc,KAAK,QAAQ,CAAC,CAAC;CACnF;CAEA,OAA0B,SAA2B;EACnD,KAAK,OAAO;CACd;CAEA,SAAkC;EAChC,MAAM,UAAU,KAAK,QAAQ;EAC7B,MAAM,OAAO,UAAU;EACvB,MAAM,SAAS,KAAK,IAAI,OAAO;EAC/B,YAAY,KAAK,OAAO,KAAK,SAAS,MAAM,MAAM,CAAC,CAAC;EACpD,MAAM,WACJ,KAAK,aAAa,OAAO,MAAM,OAAO,2BAA2B;EACnE,KAAK,OAAO,aAAa,cAAc,KAAK,UAAU,EAAE,SAAS,OAAO,CAAC,CAAC;CAC5E;AACF"}
1
+ {"version":3,"file":"skip-button.js","names":[],"sources":["../../src/elements/skip-button.ts"],"sourcesContent":["/**\n * <mbx-skip-button>: moves the playhead by `seconds`, negative for back,\n * within what the video can reach. The glyph says the amount where the\n * set has one, 5, 10, 15 and 30, and a plain arrow otherwise; `icon` takes a\n * page's own. The name comes from `label`, where `{seconds}` is the\n * amount without its sign: \"Back {seconds} seconds\".\n */\nimport type { IconName } from '../controls/icons.js';\nimport { icon } from '../controls/icons.js';\nimport { setChildren } from '../dom.js';\nimport type { PlayerHost } from '../host.js';\nimport { fill } from '../labels.js';\nimport { Component } from './component.js';\nimport { BUTTON_STYLE, style } from './shared.js';\n\nconst SECONDS = 10;\n\n/** The glyph for a skip amount: the set draws 5, 10, 15 and 30, and a plain arrow says the rest. */\nfunction glyphFor(back: boolean, amount: number): IconName {\n const side = back ? 'seek-backward' : 'seek-forward';\n if (amount === 5 || amount === 10 || amount === 15 || amount === 30) return `${side}-${amount}`;\n return side;\n}\n\nexport class MbxSkipButton extends Component {\n static get observedAttributes(): readonly string[] {\n return ['seconds', 'label'];\n }\n\n declare private readonly button: HTMLButtonElement;\n declare private readonly glyph: HTMLSlotElement;\n\n constructor() {\n super();\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.glyph = document.createElement('slot');\n this.glyph.name = 'icon';\n this.button.append(this.glyph);\n this.button.addEventListener('click', () => {\n this.skip();\n });\n root.append(style(BUTTON_STYLE), this.button);\n }\n\n /** The amount, signed. A value that is not a number is the default. */\n private seconds(): number {\n const value = Number(this.getAttribute('seconds') ?? SECONDS);\n return Number.isFinite(value) ? value : SECONDS;\n }\n\n private skip(): void {\n const video = this.player?.video;\n if (video === undefined) return;\n const ranges = video.seekable;\n const end = Number.isFinite(video.duration)\n ? video.duration\n : ranges.length > 0\n ? ranges.end(ranges.length - 1)\n : video.currentTime;\n video.currentTime = Math.min(end, Math.max(0, video.currentTime + this.seconds()));\n }\n\n protected override attach(_player: PlayerHost): void {\n this.render();\n }\n\n protected override render(): void {\n const seconds = this.seconds();\n const back = seconds < 0;\n const amount = Math.abs(seconds);\n setChildren(this.glyph, icon(glyphFor(back, amount)));\n const template =\n this.getAttribute('label') ?? (back ? 'Back {seconds} seconds' : 'Forward {seconds} seconds');\n this.button.setAttribute('aria-label', fill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K,QAAQ;EAC7B,MAAM,OAAO,UAAU;EACvB,MAAM,SAAS,KAAK,IAAI,OAAO;EAC/B,YAAY,KAAK,OAAO,KAAK,SAAS,MAAM,MAAM,CAAC,CAAC;EACpD,MAAM,WACJ,KAAK,aAAa,OAAO,MAAM,OAAO,2BAA2B;EACnE,KAAK,OAAO,aAAa,cAAc,KAAK,UAAU,EAAE,SAAS,OAAO,CAAC,CAAC;CAC5E;AACF"}
@@ -1,7 +1,7 @@
1
1
  import { Component } from "./component.js";
2
2
  import { style } from "./shared.js";
3
3
  //#region src/elements/spinner.ts
4
- const STYLE = ":host{pointer-events:none;width:44px;height:44px;color:var(--mbx-text);filter:drop-shadow(0 1px 3px #00000080);margin:-22px 0 0 -22px;display:none;position:absolute;top:50%;left:50%}:host([waiting]){display:block}:host([hidden]){display:none}[part~=ring]{box-sizing:border-box;border:3px solid #ffffff38;border-top-color:currentColor;border-radius:50%;width:100%;height:100%;animation:.8s linear infinite mbx-turn}[part~=ring][hidden],slot[hidden]{display:none}::slotted(*){width:100%;height:100%}@keyframes mbx-turn{to{transform:rotate(360deg)}}@media (prefers-reduced-motion:reduce){[part~=ring]{animation:none}}";
4
+ const STYLE = ":host{pointer-events:none;width:2.75em;height:2.75em;color:var(--mbx-text);filter:drop-shadow(0 1px 3px #00000080);margin:-1.375em 0 0 -1.375em;display:none;position:absolute;top:50%;left:50%}:host([waiting]){display:block}:host([hidden]){display:none}[part~=ring]{box-sizing:border-box;border:3px solid #ffffff38;border-top-color:currentColor;border-radius:50%;width:100%;height:100%;animation:.8s linear infinite mbx-turn}[part~=ring][hidden],slot[hidden]{display:none}::slotted(*){width:100%;height:100%}@keyframes mbx-turn{to{transform:rotate(360deg)}}@media (prefers-reduced-motion:reduce){[part~=ring]{animation:none}}";
5
5
  /** What the video fires as it waits and as it goes on. */
6
6
  const EVENTS = [
7
7
  "waiting",
@@ -12,6 +12,11 @@ export declare class MbxStartButton extends Component {
12
12
  protected attach(player: PlayerHost): void;
13
13
  protected detach(): void;
14
14
  /**
15
+ * The button sits in the middle of the picture left over the bar's
16
+ * controls, not of the whole player: with the bar at the foot, the
17
+ * player's own middle reads as too low. The bar's top padding is the
18
+ * lead-in of its gradient, so the controls start under it.
19
+ *
15
20
  * Cramped when the button's foot would be inside the bar's box, which
16
21
  * starts at the top of its gradient: then the bar's own play button is
17
22
  * the one to press. Measured with the button shown, since a hidden one
@@ -1 +1 @@
1
- {"version":3,"file":"start-button.d.ts","sourceRoot":"","sources":["../../src/elements/start-button.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAS3C,qBAAa,cAAe,SAAQ,SAAS;IAC3C,MAAM,KAAK,kBAAkB,IAAI,SAAS,MAAM,EAAE,CAEjD;IAED,iBAAyB,MAAM,CAAoB;IACnD,iBAAyB,KAAK,CAAiC;IAC/D,8FAA8F;IAC9F,QAAgB,MAAM,CAAU;IAChC,kFAAkF;IAClF,QAAgB,OAAO,CAAwB;;cAkB5B,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;cAqChC,MAAM,IAAI,IAAI;IAMjC;;;;;OAKG;IACH,OAAO,CAAC,GAAG;cAgBQ,MAAM,IAAI,IAAI;CAiBlC"}
1
+ {"version":3,"file":"start-button.d.ts","sourceRoot":"","sources":["../../src/elements/start-button.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAS3C,qBAAa,cAAe,SAAQ,SAAS;IAC3C,MAAM,KAAK,kBAAkB,IAAI,SAAS,MAAM,EAAE,CAEjD;IAED,iBAAyB,MAAM,CAAoB;IACnD,iBAAyB,KAAK,CAAiC;IAC/D,8FAA8F;IAC9F,QAAgB,MAAM,CAAU;IAChC,kFAAkF;IAClF,QAAgB,OAAO,CAAwB;;cAkB5B,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;cAwChC,MAAM,IAAI,IAAI;IAOjC;;;;;;;;;;OAUG;IACH,OAAO,CAAC,GAAG;cAqBQ,MAAM,IAAI,IAAI;CAiBlC"}
@@ -2,7 +2,7 @@ import { icon } from "../controls/icons.js";
2
2
  import { Component } from "./component.js";
3
3
  import { BUTTON_STYLE, iconSlots, show, style } from "./shared.js";
4
4
  //#region src/elements/start-button.ts
5
- const STYLE_CSS = ":host{margin:-32px 0 0 -52px;position:absolute;top:50%;left:50%}[part~=button]{width:104px;height:64px;color:var(--mbx-text);opacity:.9;background:#00000073;border:1px solid #ffffff2e;transition:opacity .15s,background .15s}[part~=button]:hover{opacity:1;background:#0009}:host([cramped]){display:none}[part~=icon],::slotted(*){width:40px;height:40px;margin-left:2px}@media (prefers-reduced-motion:reduce){[part~=button]{transition:none}}";
5
+ const STYLE_CSS = ":host{--mbx-tooltip:none;top:var(--mbx-start-top,50%);margin:-2.5em 0 0 -2.5em;position:absolute;left:50%}[part~=button]{z-index:0;width:5em;height:5em;color:var(--mbx-text);background:0 0;border:0;transition:color .15s;position:relative}[part~=button]:before{content:\"\";z-index:-1;background:var(--mbx-surface);opacity:.88;clip-path:polygon(0 0,79% 0,100% 21%,100% 100%,21% 100%,0 79%);transition:opacity .15s,background .15s;position:absolute;top:0;bottom:0;left:0;right:0}[part~=button]:hover{color:var(--mbx-surface)}[part~=button]:hover:before{background:var(--mbx-accent);opacity:1}:host([cramped]){display:none}[part~=icon],::slotted(*){width:3em;height:3em}@media (prefers-reduced-motion:reduce){[part~=button],[part~=button]:before{transition:none}}";
6
6
  const STATES = ["play", "replay"];
7
7
  const STYLE = BUTTON_STYLE + STYLE_CSS;
8
8
  var MbxStartButton = class extends Component {
@@ -62,6 +62,8 @@ var MbxStartButton = class extends Component {
62
62
  this.fit(player);
63
63
  });
64
64
  this.resizer.observe(player);
65
+ const bar = player.querySelector("mbx-control-bar");
66
+ if (bar !== null) this.resizer.observe(bar);
65
67
  }
66
68
  this.fit(player);
67
69
  this.render();
@@ -70,8 +72,14 @@ var MbxStartButton = class extends Component {
70
72
  this.resizer?.disconnect();
71
73
  this.resizer = null;
72
74
  this.removeAttribute("cramped");
75
+ this.style.removeProperty("--mbx-start-top");
73
76
  }
74
77
  /**
78
+ * The button sits in the middle of the picture left over the bar's
79
+ * controls, not of the whole player: with the bar at the foot, the
80
+ * player's own middle reads as too low. The bar's top padding is the
81
+ * lead-in of its gradient, so the controls start under it.
82
+ *
75
83
  * Cramped when the button's foot would be inside the bar's box, which
76
84
  * starts at the top of its gradient: then the bar's own play button is
77
85
  * the one to press. Measured with the button shown, since a hidden one
@@ -81,13 +89,18 @@ var MbxStartButton = class extends Component {
81
89
  const bar = player.querySelector("mbx-control-bar");
82
90
  if (bar === null) {
83
91
  this.removeAttribute("cramped");
92
+ this.style.removeProperty("--mbx-start-top");
84
93
  return;
85
94
  }
95
+ const box = player.getBoundingClientRect();
96
+ const barBox = bar.getBoundingClientRect();
97
+ const controls = barBox.top + (Number.parseFloat(getComputedStyle(bar).paddingTop) || 0);
98
+ this.style.setProperty("--mbx-start-top", `${(controls - box.top) / 2}px`);
86
99
  const wasHidden = this.hidden;
87
100
  const wasCramped = this.hasAttribute("cramped");
88
101
  this.hidden = false;
89
102
  this.removeAttribute("cramped");
90
- const cramped = this.button.getBoundingClientRect().bottom > bar.getBoundingClientRect().top;
103
+ const cramped = this.button.getBoundingClientRect().bottom > barBox.top;
91
104
  this.hidden = wasHidden;
92
105
  this.toggleAttribute("cramped", cramped);
93
106
  if (cramped !== wasCramped) this.render();
@@ -1 +1 @@
1
- {"version":3,"file":"start-button.js","names":[],"sources":["../../src/elements/start-button.ts"],"sourcesContent":["/**\n * <mbx-start-button>: the large play in the middle of the picture, shown\n * while the video is paused, a replay once it has ended, gone while it\n * plays, while a fatal error is on screen, and while the seek bar holds\n * the video paused for a drag (the player carries `scrubbing`). It sits in the player\n * beside the video, not in the bar, so it is over the poster and inside\n * fullscreen, and gone while the player waits for data, where the spinner\n * takes the centre. The glyph is `icon-play` or `icon-replay`, the name\n * `label-play` or `label-replay`.\n */\nimport type { PlayerError } from '@mattebox/player-core';\nimport { icon } from '../controls/icons.js';\nimport type { PlayerHost } from '../host.js';\nimport { Component } from './component.js';\nimport { BUTTON_STYLE, iconSlots, show, style } from './shared.js';\nimport STYLE_CSS from './start-button.css?inline';\n\ntype State = 'play' | 'replay';\nconst STATES: readonly State[] = ['play', 'replay'];\n\nconst STYLE = BUTTON_STYLE + STYLE_CSS;\n\nexport class MbxStartButton extends Component {\n static get observedAttributes(): readonly string[] {\n return ['label-play', 'label-replay'];\n }\n\n declare private readonly button: HTMLButtonElement;\n declare private readonly slots: Record<State, HTMLSlotElement>;\n /** A fatal error is on screen, and the play stays out of its way until playback or a load. */\n declare private failed: boolean;\n /** Watches the player's box: in a short one the button would sit over the bar. */\n declare private resizer: ResizeObserver | null;\n\n constructor() {\n super();\n this.failed = false;\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.slots = iconSlots(STATES, icon);\n for (const state of STATES) this.button.append(this.slots[state]);\n this.button.addEventListener('click', () => {\n this.player?.video.play().catch(() => undefined);\n });\n root.append(style(STYLE), this.button);\n }\n\n protected override attach(player: PlayerHost): void {\n const video = player.video;\n this.listen(video, ['play', 'pause', 'ended', 'waiting', 'stalled', 'canplay'], () => {\n this.render();\n });\n this.listen(video, ['playing', 'loadstart'], () => {\n this.failed = false;\n this.render();\n });\n this.listen(player, ['sourcechange'], () => {\n this.failed = false;\n this.render();\n });\n this.observe(player, ['scrubbing'], () => {\n this.render();\n });\n const failure = (event: Event): void => {\n const error = (event as CustomEvent<PlayerError>).detail;\n if (!error.fatal) return;\n this.failed = true;\n this.render();\n };\n player.addEventListener('error', failure);\n this.keep(() => {\n player.removeEventListener('error', failure);\n });\n this.failed = player.error !== null;\n if (typeof ResizeObserver !== 'undefined') {\n this.resizer = new ResizeObserver(() => {\n this.fit(player);\n });\n this.resizer.observe(player);\n }\n this.fit(player);\n this.render();\n }\n\n protected override detach(): void {\n this.resizer?.disconnect();\n this.resizer = null;\n this.removeAttribute('cramped');\n }\n\n /**\n * Cramped when the button's foot would be inside the bar's box, which\n * starts at the top of its gradient: then the bar's own play button is\n * the one to press. Measured with the button shown, since a hidden one\n * has no box.\n */\n private fit(player: PlayerHost): void {\n const bar = player.querySelector('mbx-control-bar');\n if (bar === null) {\n this.removeAttribute('cramped');\n return;\n }\n const wasHidden = this.hidden;\n const wasCramped = this.hasAttribute('cramped');\n this.hidden = false;\n this.removeAttribute('cramped');\n const cramped = this.button.getBoundingClientRect().bottom > bar.getBoundingClientRect().top;\n this.hidden = wasHidden;\n this.toggleAttribute('cramped', cramped);\n if (cramped !== wasCramped) this.render();\n }\n\n protected override render(): void {\n const video = this.player?.video;\n if (video === undefined) return;\n const state: State = video.ended ? 'replay' : 'play';\n show(this.slots, state);\n this.button.setAttribute(\n 'aria-label',\n this.getAttribute(`label-${state}`) ?? (state === 'play' ? 'Play' : 'Replay'),\n );\n // The player reflects `waiting` first: it listens from its constructor.\n const player = this.player;\n this.hidden =\n this.failed ||\n !video.paused ||\n player?.hasAttribute('waiting') === true ||\n player?.hasAttribute('scrubbing') === true;\n }\n}\n"],"mappings":";;;;AAeA,MAAA,YAAA;AAGA,MAAA,SAAA,CAAA,QAAA,QAAA;AAEA,MAAA,QAAA,eAAA;AAEA,IAAA,iBAAA,cAAA,UAAA;CACA,WAAA,qBAAA;EACA,OAAA,CAAA,cAAA,cAAA;CACA;CASA,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,QAAA,UAAA,QAA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KAAA,aAAA,SAAA;EACA,KAAA,SAAA;EACA,KAAA,gBAAA,SAAA;EACA,MAAA,UAAA,KAAA,OAAA,sBAAA,CAAA,CAAA,SAAA,IAAA,sBAAA,CAAA,CAAA;EACA,KAAA,SAAA;EACA,KAAA,gBAAA,WAAA,OAAA;EACA,IAAA,YAAA,YAAA,KAAA,OAAA;CACA;CAEA,SAAA;EACA,MAAA,QAAA,KAAA,QAAA;EACA,IAAA,UAAA,KAAA,GAAA;EACA,MAAA,QAAA,MAAA,QAAA,WAAA;EACA,KAAA,KAAA,OAAA,KAAA;EACA,KAAA,OAAA,aACA,cACA,KAAA,aAAA,SAAA,OAAA,MAAA,UAAA,SAAA,SAAA,SACA;EAEA,MAAA,SAAA,KAAA;EACA,KAAA,SACA,KAAA,UACA,CAAA,MAAA,UACA,QAAA,aAAA,SAAA,MAAA,QACA,QAAA,aAAA,WAAA,MAAA;CACA;AACA"}
1
+ {"version":3,"file":"start-button.js","names":[],"sources":["../../src/elements/start-button.ts"],"sourcesContent":["/**\n * <mbx-start-button>: the large play in the middle of the picture, shown\n * while the video is paused, a replay once it has ended, gone while it\n * plays, while a fatal error is on screen, and while the seek bar holds\n * the video paused for a drag (the player carries `scrubbing`). It sits in the player\n * beside the video, not in the bar, so it is over the poster and inside\n * fullscreen, and gone while the player waits for data, where the spinner\n * takes the centre. The glyph is `icon-play` or `icon-replay`, the name\n * `label-play` or `label-replay`.\n */\nimport type { PlayerError } from '@mattebox/player-core';\nimport { icon } from '../controls/icons.js';\nimport type { PlayerHost } from '../host.js';\nimport { Component } from './component.js';\nimport { BUTTON_STYLE, iconSlots, show, style } from './shared.js';\nimport STYLE_CSS from './start-button.css?inline';\n\ntype State = 'play' | 'replay';\nconst STATES: readonly State[] = ['play', 'replay'];\n\nconst STYLE = BUTTON_STYLE + STYLE_CSS;\n\nexport class MbxStartButton extends Component {\n static get observedAttributes(): readonly string[] {\n return ['label-play', 'label-replay'];\n }\n\n declare private readonly button: HTMLButtonElement;\n declare private readonly slots: Record<State, HTMLSlotElement>;\n /** A fatal error is on screen, and the play stays out of its way until playback or a load. */\n declare private failed: boolean;\n /** Watches the player's box: in a short one the button would sit over the bar. */\n declare private resizer: ResizeObserver | null;\n\n constructor() {\n super();\n this.failed = false;\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.slots = iconSlots(STATES, icon);\n for (const state of STATES) this.button.append(this.slots[state]);\n this.button.addEventListener('click', () => {\n this.player?.video.play().catch(() => undefined);\n });\n root.append(style(STYLE), this.button);\n }\n\n protected override attach(player: PlayerHost): void {\n const video = player.video;\n this.listen(video, ['play', 'pause', 'ended', 'waiting', 'stalled', 'canplay'], () => {\n this.render();\n });\n this.listen(video, ['playing', 'loadstart'], () => {\n this.failed = false;\n this.render();\n });\n this.listen(player, ['sourcechange'], () => {\n this.failed = false;\n this.render();\n });\n this.observe(player, ['scrubbing'], () => {\n this.render();\n });\n const failure = (event: Event): void => {\n const error = (event as CustomEvent<PlayerError>).detail;\n if (!error.fatal) return;\n this.failed = true;\n this.render();\n };\n player.addEventListener('error', failure);\n this.keep(() => {\n player.removeEventListener('error', failure);\n });\n this.failed = player.error !== null;\n if (typeof ResizeObserver !== 'undefined') {\n this.resizer = new ResizeObserver(() => {\n this.fit(player);\n });\n this.resizer.observe(player);\n // The bar's height moves the middle too, when its rows wrap or a tier changes.\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 this.removeAttribute('cramped');\n this.style.removeProperty('--mbx-start-top');\n }\n\n /**\n * The button sits in the middle of the picture left over the bar's\n * controls, not of the whole player: with the bar at the foot, the\n * player's own middle reads as too low. The bar's top padding is the\n * lead-in of its gradient, so the controls start under it.\n *\n * Cramped when the button's foot would be inside the bar's box, which\n * starts at the top of its gradient: then the bar's own play button is\n * the one to press. Measured with the button shown, since a hidden one\n * has no box.\n */\n private fit(player: PlayerHost): void {\n const bar = player.querySelector('mbx-control-bar');\n if (bar === null) {\n this.removeAttribute('cramped');\n this.style.removeProperty('--mbx-start-top');\n return;\n }\n const box = player.getBoundingClientRect();\n const barBox = bar.getBoundingClientRect();\n const controls = barBox.top + (Number.parseFloat(getComputedStyle(bar).paddingTop) || 0);\n this.style.setProperty('--mbx-start-top', `${(controls - box.top) / 2}px`);\n const wasHidden = this.hidden;\n const wasCramped = this.hasAttribute('cramped');\n this.hidden = false;\n this.removeAttribute('cramped');\n const cramped = this.button.getBoundingClientRect().bottom > barBox.top;\n this.hidden = wasHidden;\n this.toggleAttribute('cramped', cramped);\n if (cramped !== wasCramped) this.render();\n }\n\n protected override render(): void {\n const video = this.player?.video;\n if (video === undefined) return;\n const state: State = video.ended ? 'replay' : 'play';\n show(this.slots, state);\n this.button.setAttribute(\n 'aria-label',\n this.getAttribute(`label-${state}`) ?? (state === 'play' ? 'Play' : 'Replay'),\n );\n // The player reflects `waiting` first: it listens from its constructor.\n const player = this.player;\n this.hidden =\n this.failed ||\n !video.paused ||\n player?.hasAttribute('waiting') === true ||\n player?.hasAttribute('scrubbing') === true;\n }\n}\n"],"mappings":";;;;AAeA,MAAA,YAAA;AAGA,MAAA,SAAA,CAAA,QAAA,QAAA;AAEA,MAAA,QAAA,eAAA;AAEA,IAAA,iBAAA,cAAA,UAAA;CACA,WAAA,qBAAA;EACA,OAAA,CAAA,cAAA,cAAA;CACA;CASA,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,QAAA,UAAA,QAAA,IAAA;EACA,KAAA,MAAA,SAAA,QAAA,KAAA,OAAA,OAAA,KAAA,MAAA,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AA;GACA,KAAA,MAAA,eAAA,iBAAA;GACA;EACA;EACA,MAAA,MAAA,OAAA,sBAAA;EACA,MAAA,SAAA,IAAA,sBAAA;EACA,MAAA,WAAA,OAAA,OAAA,OAAA,WAAA,iBAAA,GAAA,CAAA,CAAA,UAAA,KAAA;EACA,KAAA,MAAA,YAAA,mBAAA,IAAA,WAAA,IAAA,OAAA,EAAA,GAAA;EACA,MAAA,YAAA,KAAA;EACA,MAAA,aAAA,KAAA,aAAA,SAAA;EACA,KAAA,SAAA;EACA,KAAA,gBAAA,SAAA;EACA,MAAA,UAAA,KAAA,OAAA,sBAAA,CAAA,CAAA,SAAA,OAAA;EACA,KAAA,SAAA;EACA,KAAA,gBAAA,WAAA,OAAA;EACA,IAAA,YAAA,YAAA,KAAA,OAAA;CACA;CAEA,SAAA;EACA,MAAA,QAAA,KAAA,QAAA;EACA,IAAA,UAAA,KAAA,GAAA;EACA,MAAA,QAAA,MAAA,QAAA,WAAA;EACA,KAAA,KAAA,OAAA,KAAA;EACA,KAAA,OAAA,aACA,cACA,KAAA,aAAA,SAAA,OAAA,MAAA,UAAA,SAAA,SAAA,SACA;EAEA,MAAA,SAAA,KAAA;EACA,KAAA,SACA,KAAA,UACA,CAAA,MAAA,UACA,QAAA,aAAA,SAAA,MAAA,QACA,QAAA,aAAA,WAAA,MAAA;CACA;AACA"}
@@ -8,9 +8,15 @@ export declare class MbxSubtitlesMenu extends MenuElement<State> {
8
8
  private engine;
9
9
  constructor();
10
10
  protected name(): string;
11
- /** A look's group: the choices named from the attributes, the value from the player's. */
11
+ /**
12
+ * A look's page: an item with the look's glyph, its name and the value
13
+ * chosen, which opens the choices. They are named from the attributes,
14
+ * and the value is the player's.
15
+ */
12
16
  private looks;
13
17
  protected attach(player: PlayerHost): void;
18
+ /** The native session's subtitle tracks as entries, and the showing one's. */
19
+ private native;
14
20
  protected render(): void;
15
21
  }
16
22
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"subtitles-menu.d.ts","sourceRoot":"","sources":["../../src/elements/subtitles-menu.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAIhD,eAAO,MAAM,aAAa,kBAAkB,CAAC;AAC7C,eAAO,MAAM,mBAAmB,wBAAwB,CAAC;AAczD,KAAK,KAAK,GAAG,KAAK,GAAG,IAAI,CAAC;AAG1B,qBAAa,gBAAiB,SAAQ,WAAW,CAAC,KAAK,CAAC;IACtD,MAAM,KAAK,kBAAkB,IAAI,SAAS,MAAM,EAAE,CAYjD;IAED,QAAgB,MAAM,CAAkB;;cAQrB,IAAI,IAAI,MAAM;IAIjC,0FAA0F;IAC1F,OAAO,CAAC,KAAK;cAsBM,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;cAWhC,MAAM,IAAI,IAAI;CAqClC"}
1
+ {"version":3,"file":"subtitles-menu.d.ts","sourceRoot":"","sources":["../../src/elements/subtitles-menu.ts"],"names":[],"mappings":"AAgCA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAIhD,eAAO,MAAM,aAAa,kBAAkB,CAAC;AAC7C,eAAO,MAAM,mBAAmB,wBAAwB,CAAC;AAczD,KAAK,KAAK,GAAG,KAAK,GAAG,IAAI,CAAC;AAG1B,qBAAa,gBAAiB,SAAQ,WAAW,CAAC,KAAK,CAAC;IACtD,MAAM,KAAK,kBAAkB,IAAI,SAAS,MAAM,EAAE,CAcjD;IAED,QAAgB,MAAM,CAAkB;;cAQrB,IAAI,IAAI,MAAM;IAIjC;;;;OAIG;IACH,OAAO,CAAC,KAAK;cAoCM,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;IAanD,8EAA8E;IAC9E,OAAO,CAAC,MAAM;cAeK,MAAM,IAAI,IAAI;CA6ElC"}
@@ -1,7 +1,10 @@
1
1
  import { icon } from "../controls/icons.js";
2
2
  import { show } from "./shared.js";
3
+ import { nativeTracks, onNativeTracks } from "../controls/native-tracks.js";
4
+ import { trackNames } from "../controls/track-names.js";
3
5
  import { MenuElement } from "./menu-element.js";
4
6
  import { onTracks, trackItems } from "./audio-menu.js";
7
+ import { isSdh } from "mattebox";
5
8
  //#region src/elements/subtitles-menu.ts
6
9
  const OFF = "off";
7
10
  const SUBTITLE_SIZE = "subtitle-size";
@@ -28,67 +31,106 @@ var MbxSubtitlesMenu = class extends MenuElement {
28
31
  "label-settings",
29
32
  "label-size",
30
33
  "label-background",
34
+ "label-sdh",
35
+ "label-cc",
31
36
  ...SIZES.map(([id]) => `label-${id}`),
32
37
  ...BACKGROUNDS.map(([id]) => `label-${id}`)
33
38
  ];
34
39
  }
35
40
  constructor() {
36
- super(STATES, (state) => icon(state === "on" ? "closed-captions-on" : "closed-captions"));
41
+ super(STATES, (state) => icon(state === "on" ? "subtitles-on" : "subtitles"));
37
42
  this.engine = null;
38
43
  show(this.slots, "off");
39
44
  }
40
45
  name() {
41
46
  return "Subtitles";
42
47
  }
43
- /** A look's group: the choices named from the attributes, the value from the player's. */
44
- looks(player, attribute, name, fallback, choices, initial) {
48
+ /**
49
+ * A look's page: an item with the look's glyph, its name and the value
50
+ * chosen, which opens the choices. They are named from the attributes,
51
+ * and the value is the player's.
52
+ */
53
+ looks(player, attribute, name, fallback, choices, initial, glyph) {
45
54
  const set = player.getAttribute(attribute);
46
55
  const value = set !== null && choices.some(([id]) => id === set) ? set : initial;
56
+ const label = this.getAttribute(`label-${name}`) ?? fallback;
57
+ const items = choices.map(([id, text]) => [id, this.getAttribute(`label-${id}`) ?? text]);
47
58
  return {
48
59
  name,
49
- label: this.getAttribute(`label-${name}`) ?? fallback,
50
- items: choices.map(([id, text]) => [id, this.getAttribute(`label-${id}`) ?? text]),
51
- value,
52
- onSelect: (chosen) => {
53
- player.setAttribute(attribute, chosen);
54
- this.render();
55
- }
60
+ label,
61
+ glyph: () => icon(glyph),
62
+ detail: items.find(([id]) => id === value)?.[1] ?? "",
63
+ entries: [{
64
+ name,
65
+ label,
66
+ hideLabel: true,
67
+ items,
68
+ value,
69
+ onSelect: (chosen) => {
70
+ player.setAttribute(attribute, chosen);
71
+ this.render();
72
+ }
73
+ }]
56
74
  };
57
75
  }
58
76
  attach(player) {
59
77
  this.follow(player, (engine) => {
60
78
  this.engine = engine;
61
79
  this.render();
62
- if (engine === null) return void 0;
63
- return onTracks(engine, () => {
80
+ const tick = () => {
64
81
  this.render();
65
- });
82
+ };
83
+ return engine === null ? onNativeTracks(player.video, "textTracks", tick) : onTracks(engine, tick);
66
84
  });
67
85
  }
86
+ /** The native session's subtitle tracks as entries, and the showing one's. */
87
+ native(tracks) {
88
+ const sdh = this.getAttribute("label-sdh") ?? "SDH";
89
+ const entries = tracks.map((track, index) => [
90
+ String(index),
91
+ track.label,
92
+ track.language,
93
+ track.kind === "captions" ? [sdh] : [],
94
+ []
95
+ ]);
96
+ const on = tracks.findIndex((track) => track.mode === "showing");
97
+ return [entries, on === -1 ? null : String(on)];
98
+ }
68
99
  render() {
69
100
  super.render();
70
101
  const engine = this.engine;
71
102
  const player = this.player;
72
- if (engine === null || player === null) {
103
+ const listed = engine === null && player !== null ? nativeTracks(player, "textTracks")?.filter((track) => track.kind === "subtitles" || track.kind === "captions") : void 0;
104
+ if (player === null || engine === null && listed === void 0) {
73
105
  this.hidden = true;
74
106
  return;
75
107
  }
76
- const [tracks, active] = trackItems(engine, "text");
77
- const items = [[OFF, this.getAttribute("label-off") ?? "Off"], ...tracks];
108
+ const [tracks, active] = listed !== void 0 ? this.native(listed) : trackItems(engine, "text", (track) => [...track.instreamId !== void 0 ? [this.getAttribute("label-cc") ?? "CC"] : [], ...isSdh(track) ? [this.getAttribute("label-sdh") ?? "SDH"] : []], (track) => track.forced !== true);
109
+ const word = this.getAttribute("label-track");
110
+ const items = [[OFF, this.getAttribute("label-off") ?? "Off"], ...trackNames(tracks, word)];
78
111
  this.menu.fill([{
79
112
  name: "track",
80
- label: this.getAttribute("label-track") ?? "Track",
113
+ label: word ?? "Track",
114
+ hideLabel: true,
81
115
  items,
116
+ badgeGlyphs: {
117
+ [this.getAttribute("label-cc") ?? "CC"]: () => icon("closed-captions"),
118
+ [this.getAttribute("label-sdh") ?? "SDH"]: () => icon("sdh")
119
+ },
82
120
  value: active ?? OFF,
83
121
  onSelect: (value) => {
84
- if (value === OFF) engine.tracks.deselect("text");
85
- else engine.tracks.select(value);
122
+ if (listed !== void 0) {
123
+ for (const track of listed) track.mode = "disabled";
124
+ const chosen = listed[Number(value)];
125
+ if (chosen !== void 0) chosen.mode = "showing";
126
+ } else if (value === OFF) engine?.tracks.deselect("text");
127
+ else engine?.tracks.select(value);
86
128
  this.render();
87
129
  }
88
130
  }, {
89
131
  name: "settings",
90
132
  label: this.getAttribute("label-settings") ?? "Settings",
91
- entries: [this.looks(player, SUBTITLE_SIZE, "size", "Size", SIZES, "medium"), this.looks(player, SUBTITLE_BACKGROUND, "background", "Background", BACKGROUNDS, "dark")]
133
+ entries: [this.looks(player, SUBTITLE_SIZE, "size", "Size", SIZES, "medium", "text-size"), this.looks(player, SUBTITLE_BACKGROUND, "background", "Background", BACKGROUNDS, "dark", "text-background")]
92
134
  }]);
93
135
  show(this.slots, active === null ? "off" : "on");
94
136
  this.hidden = tracks.length === 0;