@mattebox/player 0.12.0 → 0.13.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/dist/cdn/mattebox-player.min.js +3 -3
  2. package/dist/controls/breaks.d.ts +24 -0
  3. package/dist/controls/breaks.d.ts.map +1 -0
  4. package/dist/controls/breaks.js +20 -0
  5. package/dist/controls/breaks.js.map +1 -0
  6. package/dist/element-entry.d.ts +1 -1
  7. package/dist/element-entry.d.ts.map +1 -1
  8. package/dist/element-entry.js.map +1 -1
  9. package/dist/element.d.ts +46 -1
  10. package/dist/element.d.ts.map +1 -1
  11. package/dist/element.js +89 -6
  12. package/dist/element.js.map +1 -1
  13. package/dist/elements/marker-button.d.ts +1 -0
  14. package/dist/elements/marker-button.d.ts.map +1 -1
  15. package/dist/elements/marker-button.js +12 -8
  16. package/dist/elements/marker-button.js.map +1 -1
  17. package/dist/elements/quality-menu.d.ts.map +1 -1
  18. package/dist/elements/quality-menu.js +1 -0
  19. package/dist/elements/quality-menu.js.map +1 -1
  20. package/dist/elements/seek-bar.d.ts +4 -0
  21. package/dist/elements/seek-bar.d.ts.map +1 -1
  22. package/dist/elements/seek-bar.js +19 -3
  23. package/dist/elements/seek-bar.js.map +1 -1
  24. package/dist/elements/spinner.d.ts +11 -9
  25. package/dist/elements/spinner.d.ts.map +1 -1
  26. package/dist/elements/spinner.js +8 -3
  27. package/dist/elements/spinner.js.map +1 -1
  28. package/dist/elements/start-button.d.ts.map +1 -1
  29. package/dist/elements/start-button.js +1 -1
  30. package/dist/elements/start-button.js.map +1 -1
  31. package/dist/elements/title.d.ts.map +1 -1
  32. package/dist/elements/title.js +6 -4
  33. package/dist/elements/title.js.map +1 -1
  34. package/dist/es2015/controls/breaks.js +18 -0
  35. package/dist/es2015/element.js +160 -66
  36. package/dist/es2015/elements/marker-button.js +12 -8
  37. package/dist/es2015/elements/quality-menu.js +1 -0
  38. package/dist/es2015/elements/seek-bar.js +25 -7
  39. package/dist/es2015/elements/spinner.js +8 -3
  40. package/dist/es2015/elements/start-button.js +1 -1
  41. package/dist/es2015/elements/title.js +6 -4
  42. package/dist/host.d.ts +31 -1
  43. package/dist/host.d.ts.map +1 -1
  44. package/dist/host.js.map +1 -1
  45. package/dist/index.d.ts +2 -1
  46. package/dist/index.d.ts.map +1 -1
  47. package/package.json +3 -3
@@ -8,7 +8,7 @@ import { bufferGoal, live, optional, span, wall } from "../controls/session.js";
8
8
  import { chapterAt, chapters, followChapters } from "../controls/chapters.js";
9
9
  import { slider } from "../controls/slider.js";
10
10
  // src/elements/seek-bar.ts
11
- const STYLE_CSS = ":host,[part~=slider]{flex:1}[part~=thumb]{width:1em;height:1em;margin:-.5em 0 0 -.5em;box-shadow:0 1px 3px #0006}[part~=buffered]{position:absolute;top:0;bottom:0;left:0;right:0}[part~=blocked]{pointer-events:none;position:absolute;top:0;bottom:0;left:0;right:0}[part~=blocked-range]{background:var(--mbx-blocked,#000000bf);position:absolute;top:0;bottom:0}[part~=buffered-range]{background:#ffffff4d;position:absolute;top:0;bottom:0}[part~=hover]{background:var(--mbx-text);width:.125em;margin-left:-1px;position:absolute;top:0;bottom:0}[part~=edge]{background:var(--mbx-live);width:.125em;margin-left:-1px;position:absolute;top:0;bottom:0}[part~=preview]{background:var(--mbx-surface);border-radius:var(--mbx-radius);font-variant-numeric:tabular-nums;white-space:nowrap;pointer-events:none;flex-direction:column;align-items:center;margin-bottom:.3077em;padding:.1538em;font-size:.8125em;display:flex;position:absolute;bottom:100%;transform:translate(-50%)}[part~=preview]>:not([hidden])~:not([hidden]){margin-top:.125em}[part~=preview-image]{border-radius:2px;position:relative;overflow:hidden}[part~=preview-frame]{border-radius:2px;display:block}[part~=preview-tile]{transform-origin:0 0;background-repeat:no-repeat;position:absolute;top:0;left:0}[part~=preview-time]{padding:0 .3077em}[part~=preview-title]{text-overflow:ellipsis;max-width:18.4615em;padding:0 .3077em;overflow:hidden}[hidden]{display:none}";
11
+ const STYLE_CSS = ":host,[part~=slider]{flex:1}[part~=thumb]{width:1em;height:1em;margin:-.5em 0 0 -.5em;box-shadow:0 1px 3px #0006}[part~=buffered]{position:absolute;top:0;bottom:0;left:0;right:0}[part~=blocked]{pointer-events:none;position:absolute;top:0;bottom:0;left:0;right:0}[part~=blocked-range]{background:var(--mbx-blocked,#000000bf);position:absolute;top:0;bottom:0}[part~=break]{background:var(--mbx-ad,#f5c518);width:.25em;margin-left:-.125em;position:absolute;top:0;bottom:0}[part~=break][part~=span]{margin-left:0}[part~=break][part~=played]{opacity:.4}[part~=buffered-range]{background:#ffffff4d;position:absolute;top:0;bottom:0}[part~=hover]{background:var(--mbx-text);width:.125em;margin-left:-1px;position:absolute;top:0;bottom:0}[part~=edge]{background:var(--mbx-live);width:.125em;margin-left:-1px;position:absolute;top:0;bottom:0}[part~=preview]{background:var(--mbx-surface);border-radius:var(--mbx-radius);font-variant-numeric:tabular-nums;white-space:nowrap;pointer-events:none;flex-direction:column;align-items:center;margin-bottom:.3077em;padding:.1538em;font-size:.8125em;display:flex;position:absolute;bottom:100%;transform:translate(-50%)}[part~=preview]>:not([hidden])~:not([hidden]){margin-top:.125em}[part~=preview-image]{border-radius:2px;position:relative;overflow:hidden}[part~=preview-frame]{border-radius:2px;display:block}[part~=preview-tile]{transform-origin:0 0;background-repeat:no-repeat;position:absolute;top:0;left:0}[part~=preview-time]{padding:0 .3077em}[part~=preview-title]{text-overflow:ellipsis;max-width:18.4615em;padding:0 .3077em;overflow:hidden}[hidden]{display:none}";
12
12
  const STEP = 5;
13
13
  /** Under `key-mode="preview"`, a target seeks this long after the last key. */
14
14
  const KEY_COMMIT_MS = 1e3;
@@ -108,12 +108,13 @@ var MbxSeekBar = class extends Component {
108
108
  });
109
109
  this.buffered = el("div", "buffered");
110
110
  this.blocked = el("div", "blocked");
111
+ this.breaks = el("div", "breaks");
111
112
  this.hover = el("div", "hover");
112
113
  this.edge = el("div", "edge");
113
114
  this.hover.hidden = true;
114
115
  this.edge.hidden = true;
115
116
  this.bar.track.prepend(this.buffered);
116
- this.bar.track.append(this.blocked, this.hover, this.edge);
117
+ this.bar.track.append(this.blocked, this.breaks, this.hover, this.edge);
117
118
  this.preview = el("div", "preview");
118
119
  this.image = el("div", "preview-image");
119
120
  this.tile = el("div", "preview-tile");
@@ -399,6 +400,20 @@ var MbxSeekBar = class extends Component {
399
400
  node.style.width = percent(part[1] - part[0]);
400
401
  }
401
402
  }
403
+ /** The ad breaks inside the bar's range: a tick at each start, a span where one replaces a part. */
404
+ paintBreaks() {
405
+ const { start, end } = this.range;
406
+ const marks = (this.player?.breaks.list ?? []).filter((mark) => mark.start >= start && mark.start <= end);
407
+ while (this.breaks.childElementCount > marks.length) this.breaks.lastElementChild?.remove();
408
+ while (this.breaks.childElementCount < marks.length) this.breaks.append(el("div", "break"));
409
+ marks.forEach((mark, i) => {
410
+ const node = this.breaks.children[i];
411
+ const span = mark.end !== void 0 && mark.end > mark.start;
412
+ node.setAttribute("part", `break${span ? " span" : ""}${mark.played === true ? " played" : ""}`);
413
+ node.style.left = percent(fraction(mark.start, this.range));
414
+ node.style.width = span ? percent(fraction(Math.min(mark.end ?? end, end), this.range) - fraction(mark.start, this.range)) : "";
415
+ });
416
+ }
402
417
  /** Whether a live window is wide enough to be worth a bar. */
403
418
  worthSeeking() {
404
419
  const goals = number(this, "live-window", LIVE_WINDOW);
@@ -447,7 +462,7 @@ var MbxSeekBar = class extends Component {
447
462
  };
448
463
  this.listen(player.video, EVENTS, tick);
449
464
  this.keep(followChapters(player, tick));
450
- this.listen(player, ["markerschange"], tick);
465
+ this.listen(player, ["markerschange", "breakschange"], tick);
451
466
  this.listen(player, ["sourcechange"], () => {
452
467
  this.drag = "none";
453
468
  this.stopAiming();
@@ -492,6 +507,7 @@ var MbxSeekBar = class extends Component {
492
507
  this.bar.range(this.range.start, this.range.end);
493
508
  this.paintRanges(this.buffered, spans(video.buffered), "buffered-range");
494
509
  this.paintRanges(this.blocked, this.blockedRanges(), "blocked-range");
510
+ this.paintBreaks();
495
511
  this.paintChapters();
496
512
  this.edge.hidden = !on;
497
513
  if (api !== void 0 && api.edge !== null) this.edge.style.left = percent(fraction(api.edge, this.range));
@@ -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, 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 /** The last time a frame wrote during the drag, so the release does not seek there again. */\n declare private written: number | null;\n declare private frame: number;\n\n constructor() {\n super();\n this.range = EMPTY;\n this.pending = null;\n this.written = 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.word('label-of', 'seekOf', '{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.word('label-behind', 'behindLive', '{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 written = this.written;\n this.written = 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 // A click writes on the press and again on the release, at the same\n // time: one seek is enough, and a tracker counts each one.\n if (value !== null && value !== written) 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 if (this.drag === 'seek') this.written = 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 === undefined\n ? this.word('label-blocked', 'blocked', 'Not available')\n : this.pageText(blocked.label)\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.word('label', 'seek', '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;;AA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AAA,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 /** The ad breaks, as ticks, and as spans where a break replaces a part. */\n declare private readonly breaks: 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 /** The last time a frame wrote during the drag, so the release does not seek there again. */\n declare private written: number | null;\n declare private frame: number;\n\n constructor() {\n super();\n this.range = EMPTY;\n this.pending = null;\n this.written = 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.breaks = el('div', 'breaks');\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.breaks, 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.word('label-of', 'seekOf', '{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.word('label-behind', 'behindLive', '{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 written = this.written;\n this.written = 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 // A click writes on the press and again on the release, at the same\n // time: one seek is enough, and a tracker counts each one.\n if (value !== null && value !== written) 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 if (this.drag === 'seek') this.written = 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 /** The ad breaks inside the bar's range: a tick at each start, a span where one replaces a part. */\n private paintBreaks(): void {\n const { start, end } = this.range;\n const marks = (this.player?.breaks.list ?? []).filter(\n (mark) => mark.start >= start && mark.start <= end,\n );\n while (this.breaks.childElementCount > marks.length) this.breaks.lastElementChild?.remove();\n while (this.breaks.childElementCount < marks.length) this.breaks.append(el('div', 'break'));\n marks.forEach((mark, i) => {\n const node = this.breaks.children[i] as HTMLElement;\n const span = mark.end !== undefined && mark.end > mark.start;\n node.setAttribute(\n 'part',\n `break${span ? ' span' : ''}${mark.played === true ? ' played' : ''}`,\n );\n node.style.left = percent(fraction(mark.start, this.range));\n node.style.width = span\n ? percent(\n fraction(Math.min(mark.end ?? end, end), this.range) - fraction(mark.start, this.range),\n )\n : '';\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 === undefined\n ? this.word('label-blocked', 'blocked', 'Not available')\n : this.pageText(blocked.label)\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', 'breakschange'], 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.word('label', 'seek', '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.paintBreaks();\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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ACA,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,KAAA,SAAA,QAAA,MAAA,CAAA;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,YAAA;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,13 +1,15 @@
1
1
  /**
2
- * <mbx-spinner>: shows while the video waits for data, and nothing else. It
3
- * sits in the player beside the video, centred over the picture, so it is
4
- * over the poster and inside fullscreen. It reads the video's `waiting`,
5
- * `playing`, `canplay` and `emptied`, the same events the
6
- * player's `waiting` attribute comes from, and carries `waiting` on itself
7
- * so its stylesheet shows it. It takes the start button's place: a thin
8
- * ring turns there, a white head on a faint track, in the same monochrome
9
- * as the controls. The glyph is the `icon` slot, for a page's own; the
10
- * name comes from `label`.
2
+ * <mbx-spinner>: shows while the video plays and waits for data. A wait
3
+ * while paused, such as a seek, leaves the start button in place. A drag on
4
+ * the seek bar and a switch to another source count as the state from
5
+ * before, as they do for the play buttons. It sits in the player beside the
6
+ * video, centred over the picture, so it is over the poster and inside
7
+ * fullscreen. It reads the video's `waiting`, `playing`, `canplay`,
8
+ * `emptied`, `play` and `pause`, and carries `waiting` on itself so its
9
+ * stylesheet shows it. It takes the start button's place: a thin ring
10
+ * turns there, a white head on a faint track, in the same monochrome as the
11
+ * controls. The glyph is the `icon` slot, for a page's own; the name comes
12
+ * from `label`.
11
13
  */
12
14
  import type { PlayerHost } from '../host.js';
13
15
  import { Component } from './component.js';
@@ -1 +1 @@
1
- {"version":3,"file":"spinner.d.ts","sourceRoot":"","sources":["../../src/elements/spinner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAO3C,qBAAa,UAAW,SAAQ,SAAS;IACvC,MAAM,KAAK,kBAAkB,IAAI,SAAS,MAAM,EAAE,CAEjD;IAED,iBAAyB,IAAI,CAAc;IAC3C,iBAAyB,KAAK,CAAkB;;IAgBhD,qEAAqE;IAC5D,iBAAiB,IAAI,IAAI;cAKf,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;cAQhC,MAAM,IAAI,IAAI;cAId,MAAM,IAAI,IAAI;CAQlC"}
1
+ {"version":3,"file":"spinner.d.ts","sourceRoot":"","sources":["../../src/elements/spinner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAO3C,qBAAa,UAAW,SAAQ,SAAS;IACvC,MAAM,KAAK,kBAAkB,IAAI,SAAS,MAAM,EAAE,CAEjD;IAED,iBAAyB,IAAI,CAAc;IAC3C,iBAAyB,KAAK,CAAkB;;IAgBhD,qEAAqE;IAC5D,iBAAiB,IAAI,IAAI;cAKf,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;cAWhC,MAAM,IAAI,IAAI;cAId,MAAM,IAAI,IAAI;CAQlC"}
@@ -1,5 +1,5 @@
1
1
  import { Component } from "./component.js";
2
- import { style } from "./shared.js";
2
+ import { HELD, shownPaused, style } from "./shared.js";
3
3
  // src/elements/spinner.ts
4
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. */
@@ -7,7 +7,9 @@ const EVENTS = [
7
7
  "waiting",
8
8
  "playing",
9
9
  "canplay",
10
- "emptied"
10
+ "emptied",
11
+ "play",
12
+ "pause"
11
13
  ];
12
14
  var MbxSpinner = class extends Component {
13
15
  static get observedAttributes() {
@@ -35,6 +37,9 @@ var MbxSpinner = class extends Component {
35
37
  this.listen(video, EVENTS, () => {
36
38
  this.render();
37
39
  });
40
+ this.observe(player, HELD, () => {
41
+ this.render();
42
+ });
38
43
  this.render();
39
44
  }
40
45
  detach() {
@@ -44,7 +49,7 @@ var MbxSpinner = class extends Component {
44
49
  const player = this.player;
45
50
  if (player === null) return;
46
51
  this.setAttribute("aria-label", this.word("label", "loading", "Loading"));
47
- this.toggleAttribute("waiting", player.hasAttribute("waiting"));
52
+ this.toggleAttribute("waiting", player.hasAttribute("waiting") && !shownPaused(player));
48
53
  }
49
54
  };
50
55
  export { MbxSpinner };
@@ -1 +1 @@
1
- {"version":3,"file":"spinner.js","names":[],"sources":["../../src/elements/spinner.ts"],"sourcesContent":["/**\n * <mbx-spinner>: shows while the video waits for data, and nothing else. It\n * sits in the player beside the video, centred over the picture, so it is\n * over the poster and inside fullscreen. It reads the video's `waiting`,\n * `playing`, `canplay` and `emptied`, the same events the\n * player's `waiting` attribute comes from, and carries `waiting` on itself\n * so its stylesheet shows it. It takes the start button's place: a thin\n * ring turns there, a white head on a faint track, in the same monochrome\n * as the controls. The glyph is the `icon` slot, for a page's own; the\n * name comes from `label`.\n */\nimport type { PlayerHost } from '../host.js';\nimport { Component } from './component.js';\nimport { style } from './shared.js';\nimport STYLE from './spinner.css?inline';\n\n/** What the video fires as it waits and as it goes on. */\nconst EVENTS = ['waiting', 'playing', 'canplay', 'emptied'];\n\nexport class MbxSpinner extends Component {\n static get observedAttributes(): readonly string[] {\n return ['label'];\n }\n\n declare private readonly ring: HTMLElement;\n declare private readonly slot_: HTMLSlotElement;\n\n constructor() {\n super();\n const root = this.attachShadow({ mode: 'open' });\n this.ring = document.createElement('div');\n this.ring.setAttribute('part', 'ring');\n this.slot_ = document.createElement('slot');\n this.slot_.name = 'icon';\n // A page's own glyph replaces the ring: the slot is watched for it.\n this.slot_.addEventListener('slotchange', () => {\n this.ring.hidden = this.slot_.assignedNodes().length > 0;\n });\n root.append(style(STYLE), this.ring, this.slot_);\n }\n\n /** Named before attaching: a constructor must not add attributes. */\n override connectedCallback(): void {\n if (!this.hasAttribute('role')) this.setAttribute('role', 'status');\n super.connectedCallback();\n }\n\n protected override attach(player: PlayerHost): void {\n const video = player.video;\n this.listen(video, EVENTS, () => {\n this.render();\n });\n this.render();\n }\n\n protected override detach(): void {\n this.removeAttribute('waiting');\n }\n\n protected override render(): void {\n const player = this.player;\n if (player === null) return;\n this.setAttribute('aria-label', this.word('label', 'loading', 'Loading'));\n // The player reflects the same events, and reads them first: it listens\n // from its constructor, before any control attaches.\n this.toggleAttribute('waiting', player.hasAttribute('waiting'));\n }\n}\n"],"mappings":";;;AAcA,MAAA,QAAA;;AAGA,MAAA,SAAA;CAAA;CAAA;CAAA;CAAA;AAAA;AAEA,IAAA,aAAA,cAAA,UAAA;CACA,WAAA,qBAAA;EACA,OAAA,CAAA,OAAA;CACA;CAKA,cAAA;EACA,MAAA;EACA,MAAA,OAAA,KAAA,aAAA,EAAA,MAAA,OAAA,CAAA;EACA,KAAA,OAAA,SAAA,cAAA,KAAA;EACA,KAAA,KAAA,aAAA,QAAA,MAAA;EACA,KAAA,QAAA,SAAA,cAAA,MAAA;EACA,KAAA,MAAA,OAAA;EAEA,KAAA,MAAA,iBAAA,oBAAA;GACA,KAAA,KAAA,SAAA,KAAA,MAAA,cAAA,CAAA,CAAA,SAAA;EACA,CAAA;EACA,KAAA,OAAA,MAAA,KAAA,GAAA,KAAA,MAAA,KAAA,KAAA;CACA;;CAGA,oBAAA;EACA,IAAA,CAAA,KAAA,aAAA,MAAA,GAAA,KAAA,aAAA,QAAA,QAAA;EACA,MAAA,kBAAA;CACA;CAEA,OAAA,QAAA;EACA,MAAA,QAAA,OAAA;EACA,KAAA,OAAA,OAAA,cAAA;GACA,KAAA,OAAA;EACA,CAAA;EACA,KAAA,OAAA;CACA;CAEA,SAAA;EACA,KAAA,gBAAA,SAAA;CACA;CAEA,SAAA;EACA,MAAA,SAAA,KAAA;EACA,IAAA,WAAA,MAAA;EACA,KAAA,aAAA,cAAA,KAAA,KAAA,SAAA,WAAA,SAAA,CAAA;EAGA,KAAA,gBAAA,WAAA,OAAA,aAAA,SAAA,CAAA;CACA;AACA"}
1
+ {"version":3,"file":"spinner.js","names":[],"sources":["../../src/elements/spinner.ts"],"sourcesContent":["/**\n * <mbx-spinner>: shows while the video plays and waits for data. A wait\n * while paused, such as a seek, leaves the start button in place. A drag on\n * the seek bar and a switch to another source count as the state from\n * before, as they do for the play buttons. It sits in the player beside the\n * video, centred over the picture, so it is over the poster and inside\n * fullscreen. It reads the video's `waiting`, `playing`, `canplay`,\n * `emptied`, `play` and `pause`, and carries `waiting` on itself so its\n * stylesheet shows it. It takes the start button's place: a thin ring\n * turns there, a white head on a faint track, in the same monochrome as the\n * controls. The glyph is the `icon` slot, for a page's own; the name comes\n * from `label`.\n */\nimport type { PlayerHost } from '../host.js';\nimport { Component } from './component.js';\nimport { HELD, shownPaused, style } from './shared.js';\nimport STYLE from './spinner.css?inline';\n\n/** What the video fires as it waits and as it goes on. */\nconst EVENTS = ['waiting', 'playing', 'canplay', 'emptied', 'play', 'pause'];\n\nexport class MbxSpinner extends Component {\n static get observedAttributes(): readonly string[] {\n return ['label'];\n }\n\n declare private readonly ring: HTMLElement;\n declare private readonly slot_: HTMLSlotElement;\n\n constructor() {\n super();\n const root = this.attachShadow({ mode: 'open' });\n this.ring = document.createElement('div');\n this.ring.setAttribute('part', 'ring');\n this.slot_ = document.createElement('slot');\n this.slot_.name = 'icon';\n // A page's own glyph replaces the ring: the slot is watched for it.\n this.slot_.addEventListener('slotchange', () => {\n this.ring.hidden = this.slot_.assignedNodes().length > 0;\n });\n root.append(style(STYLE), this.ring, this.slot_);\n }\n\n /** Named before attaching: a constructor must not add attributes. */\n override connectedCallback(): void {\n if (!this.hasAttribute('role')) this.setAttribute('role', 'status');\n super.connectedCallback();\n }\n\n protected override attach(player: PlayerHost): void {\n const video = player.video;\n this.listen(video, EVENTS, () => {\n this.render();\n });\n this.observe(player, HELD, () => {\n this.render();\n });\n this.render();\n }\n\n protected override detach(): void {\n this.removeAttribute('waiting');\n }\n\n protected override render(): void {\n const player = this.player;\n if (player === null) return;\n this.setAttribute('aria-label', this.word('label', 'loading', 'Loading'));\n // The player reflects the same events, and reads them first: it listens\n // from its constructor, before any control attaches.\n this.toggleAttribute('waiting', player.hasAttribute('waiting') && !shownPaused(player));\n }\n}\n"],"mappings":";;;AAgBA,MAAA,QAAA;;AAGA,MAAA,SAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;AAAA;AAEA,IAAA,aAAA,cAAA,UAAA;CACA,WAAA,qBAAA;EACA,OAAA,CAAA,OAAA;CACA;CAKA,cAAA;EACA,MAAA;EACA,M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MAAM,CAAU;IAChC,kFAAkF;IAClF,QAAgB,OAAO,CAAwB;;cAkB5B,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;cAwChC,MAAM,IAAI,IAAI;IAOjC;;;;;;;;;;;;;OAaG;IACH,OAAO,CAAC,GAAG;cAqBQ,MAAM,IAAI,IAAI;CAmBlC"}
1
+ {"version":3,"file":"start-button.d.ts","sourceRoot":"","sources":["../../src/elements/start-button.ts"],"names":[],"mappings":"AAaA,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;;;;;;;;;;;;;OAaG;IACH,OAAO,CAAC,GAAG;cAqBQ,MAAM,IAAI,IAAI;CAgBlC"}
@@ -114,7 +114,7 @@ var MbxStartButton = class extends Component {
114
114
  show(this.slots, state);
115
115
  this.button.setAttribute("aria-label", state === "play" ? this.word("label-play", "play", "Play") : this.word("label-replay", "replay", "Replay"));
116
116
  const player = this.player;
117
- this.hidden = this.failed || player !== null && !shownPaused(player, ["switching"]) || player?.hasAttribute("waiting") === true || player?.hasAttribute("scrubbing") === true;
117
+ this.hidden = this.failed || player !== null && !shownPaused(player);
118
118
  }
119
119
  };
120
120
  export { MbxStartButton };
@@ -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`). Through a\n * switch to another source it keeps the state from before. 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, HELD, iconSlots, show, shownPaused, 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', '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, HELD, () => {\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 between two middles: the player's own, and the middle\n * of the picture left over the bar's controls. With the bar at the foot,\n * the player's middle reads as too low. The bar is light, a line and a\n * few glyphs over a gradient, so the middle of what it leaves reads as\n * too high, most of all in a short player. Halfway between them is where\n * the eye puts the centre. The bar's top padding is the lead-in of its\n * 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', `${(box.height + controls - box.top) / 4}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 state === 'play'\n ? this.word('label-play', 'play', 'Play')\n : this.word('label-replay', 'replay', '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 (player !== null && !shownPaused(player, ['switching'])) ||\n player?.hasAttribute('waiting') === true ||\n player?.hasAttribute('scrubbing') === true;\n }\n}\n"],"mappings":";;;;AAgBA,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,MAAA;EACA,KAAA,OAAA,iBAAA,eAAA;GACA,KAAA,QAAA,MAAA,KAAA,CAAA,CAAA,YAAA,KAAA,CAAA;EACA,CAAA;EACA,KAAA,OAAA,MAAA,KAAA,GAAA,KAAA,MAAA;CACA;CAEA,OAAA,QAAA;EACA,MAAA,QAAA,OAAA;EACA,KAAA,OAAA,OAAA;GAAA;GAAA;GAAA;GAAA;GAAA;EAAA,SAAA;GACA,KAAA,OAAA;EACA,CAAA;EACA,KAAA,OAAA,OAAA,CAAA,WAAA,WAAA,SAAA;GACA,KAAA,SAAA;GACA,KAAA,OAAA;EACA,CAAA;EACA,KAAA,OAAA,QAAA,CAAA,cAAA,SAAA;GACA,KAAA,SAAA;GACA,KAAA,OAAA;EACA,CAAA;EACA,KAAA,QAAA,QAAA,YAAA;GACA,KAAA,OAAA;EACA,CAAA;EACA,MAAA,WAA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AAA,UAAA,KAAA,GAAA;EACA,MAAA,QAAA,MAAA,QAAA,WAAA;EACA,KAAA,KAAA,OAAA,KAAA;EACA,KAAA,OAAA,aACA,cACA,UAAA,SACA,KAAA,KAAA,cAAA,QAAA,MAAA,IACA,KAAA,KAAA,gBAAA,UAAA,QAAA,CACA;EAEA,MAAA,SAAA,KAAA;EACA,KAAA,SACA,KAAA,UACA,WAAA,QAAA,CAAA,YAAA,QAAA,CAAA,WAAA,CAAA,KACA,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 and while a fatal error is on screen. A drag on the seek bar (the\n * player carries `scrubbing`) and a switch to another source keep the\n * state from before, so a seek while paused keeps it in place, and a seek\n * while playing never shows it. It sits in the player beside the video,\n * not in the bar, so it is over the poster and inside fullscreen. While the\n * video plays and waits for data, the spinner takes the centre. The glyph\n * is `icon-play` or `icon-replay`, the name `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, HELD, iconSlots, show, shownPaused, 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', '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, HELD, () => {\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 between two middles: the player's own, and the middle\n * of the picture left over the bar's controls. With the bar at the foot,\n * the player's middle reads as too low. The bar is light, a line and a\n * few glyphs over a gradient, so the middle of what it leaves reads as\n * too high, most of all in a short player. Halfway between them is where\n * the eye puts the centre. The bar's top padding is the lead-in of its\n * 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', `${(box.height + controls - box.top) / 4}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 state === 'play'\n ? this.word('label-play', 'play', 'Play')\n : this.word('label-replay', 'replay', 'Replay'),\n );\n // A wait while paused, such as a seek, keeps the button: the spinner\n // shows only while the video plays.\n const player = this.player;\n this.hidden = this.failed || (player !== null && !shownPaused(player));\n }\n}\n"],"mappings":";;;;AAgBA,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,MAAA;EACA,KAAA,OAAA,iBAAA,eAAA;GACA,KAAA,QAAA,MAAA,KAAA,CAAA,CAAA,YAAA,KAAA,C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AuE;IACvE,OAAO,CAAC,KAAK;IAKb,gHAAgH;IAChH,OAAO,CAAC,GAAG;cAUQ,MAAM,IAAI,IAAI;CAgBlC"}
1
+ {"version":3,"file":"title.d.ts","sourceRoot":"","sources":["../../src/elements/title.ts"],"names":[],"mappings":"AA4BA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAI3C,qBAAa,QAAS,SAAQ,SAAS;IACrC,MAAM,KAAK,kBAAkB,IAAI,SAAS,MAAM,EAAE,CAEjD;IAED,iBAAyB,OAAO,CAAmB;IACnD,iBAAyB,OAAO,CAAc;IAC9C,iBAAyB,UAAU,CAAc;IACjD,0FAA0F;IAC1F,QAAgB,OAAO,CAAwB;;cAgB5B,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;cAyBhC,MAAM,IAAI,IAAI;IAOjC,uEAAuE;IACvE,OAAO,CAAC,KAAK;IAKb,gHAAgH;IAChH,OAAO,CAAC,GAAG;cAUQ,MAAM,IAAI,IAAI;CAgBlC"}
@@ -1,6 +1,6 @@
1
1
  import { el } from "../dom.js";
2
2
  import { Component } from "./component.js";
3
- import { shownPaused, style } from "./shared.js";
3
+ import { HELD, shownPaused, style } from "./shared.js";
4
4
  // src/elements/title.ts
5
5
  /**
6
6
  * <mbx-title>: the heading, the subheading and the artwork of what plays,
@@ -16,7 +16,9 @@ import { shownPaused, style } from "./shared.js";
16
16
  * the element draws nothing.
17
17
  *
18
18
  * Shown while the video is paused, which includes before the first play,
19
- * and hidden while it plays. The element carries `playing` for that rule,
19
+ * and hidden while it plays. A drag on the seek bar and a switch to another
20
+ * source keep the state from before, so a seek while playing never shows
21
+ * it. The element carries `playing` for that rule,
20
22
  * so a page changes it in CSS: `mattebox-player[started] mbx-title
21
23
  * { display: none }` keeps it to the time before the first play, like the
22
24
  * poster, and `mattebox-player:hover mbx-title { display: flex }` brings it
@@ -58,7 +60,7 @@ var MbxTitle = class extends Component {
58
60
  ], () => {
59
61
  this.state(player);
60
62
  });
61
- this.observe(player, ["switching"], () => {
63
+ this.observe(player, HELD, () => {
62
64
  this.state(player);
63
65
  });
64
66
  this.listen(player, ["programmechange"], () => {
@@ -84,7 +86,7 @@ var MbxTitle = class extends Component {
84
86
  }
85
87
  /** `playing` on the element, for its own stylesheet and the page's. */
86
88
  state(player) {
87
- this.toggleAttribute("playing", !shownPaused(player, ["switching"]));
89
+ this.toggleAttribute("playing", !shownPaused(player));
88
90
  }
89
91
  /** The height of the bar's rows: its box less the padding above them, which is its fade. Zero without a bar. */
90
92
  fit(player) {
@@ -1 +1 @@
1
- {"version":3,"file":"title.js","names":[],"sources":["../../src/elements/title.ts"],"sourcesContent":["/**\n * <mbx-title>: the heading, the subheading and the artwork of what plays,\n * as a lower third across the picture above the bar: a scrim that fades\n * upward, the artwork in the first column, the two lines in the second,\n * so a heading alone sits on a band and never floats. The content comes\n * from attributes, `heading`,\n * `subheading` and `artwork`, because the stream carries none of it: a page\n * writes what it knows, and a Cast receiver writes what the sender said.\n * A heading or subheading the page leaves out takes the programme's title\n * or subtitle, from what a connector resolved. The artwork comes from the\n * attribute only: the programme's image is the poster already. With none,\n * the element draws nothing.\n *\n * Shown while the video is paused, which includes before the first play,\n * and hidden while it plays. The element carries `playing` for that rule,\n * so a page changes it in CSS: `mattebox-player[started] mbx-title\n * { display: none }` keeps it to the time before the first play, like the\n * poster, and `mattebox-player:hover mbx-title { display: flex }` brings it\n * back on hover. The height of the bar's rows, its box less the fade it\n * pads itself with, goes on the host as `--mbx-bar-rows`, so the text sits\n * just above the seek row while the band runs under the bar to the bottom\n * edge, one ramp with the bar's own fade. The scrim is the page's to\n * override. Placed first among the screens, so the start button, the\n * error screen and the spinner paint over its band.\n */\nimport { el } from '../dom.js';\nimport type { PlayerHost } from '../host.js';\nimport { Component } from './component.js';\nimport { shownPaused, style } from './shared.js';\nimport STYLE from './title.css?inline';\n\nexport class MbxTitle extends Component {\n static get observedAttributes(): readonly string[] {\n return ['heading', 'subheading', 'artwork'];\n }\n\n declare private readonly artwork: HTMLImageElement;\n declare private readonly heading: HTMLElement;\n declare private readonly subheading: HTMLElement;\n /** Watches the player's box: the height of the bar's rows decides where the text sits. */\n declare private resizer: ResizeObserver | null;\n\n constructor() {\n super();\n this.resizer = null;\n const root = this.attachShadow({ mode: 'open' });\n this.artwork = el('img', 'artwork');\n this.artwork.alt = '';\n this.artwork.hidden = true;\n const text = el('div', 'text');\n this.heading = el('div', 'heading');\n this.subheading = el('div', 'subheading');\n text.append(this.heading, this.subheading);\n root.append(style(STYLE), this.artwork, text);\n }\n\n protected override attach(player: PlayerHost): void {\n this.listen(player.video, ['play', 'pause', 'ended', 'emptied'], () => {\n this.state(player);\n });\n this.observe(player, ['switching'], () => {\n this.state(player);\n });\n this.listen(player, ['programmechange'], () => {\n this.render();\n });\n if (typeof ResizeObserver !== 'undefined') {\n this.resizer = new ResizeObserver(() => {\n this.fit(player);\n });\n this.resizer.observe(player);\n // The bar's rows change height with the player's size tier, without\n // the player's box changing.\n const bar = player.querySelector('mbx-control-bar');\n if (bar !== null) this.resizer.observe(bar);\n }\n this.fit(player);\n this.state(player);\n this.render();\n }\n\n protected override detach(): void {\n this.resizer?.disconnect();\n this.resizer = null;\n this.removeAttribute('playing');\n this.style.removeProperty('--mbx-bar-rows');\n }\n\n /** `playing` on the element, for its own stylesheet and the page's. */\n private state(player: PlayerHost): void {\n // A switch to another source of the same programme is no pause.\n this.toggleAttribute('playing', !shownPaused(player, ['switching']));\n }\n\n /** The height of the bar's rows: its box less the padding above them, which is its fade. Zero without a bar. */\n private fit(player: PlayerHost): void {\n const bar = player.querySelector('mbx-control-bar');\n let rows = 0;\n if (bar !== null) {\n const top = Number.parseFloat(getComputedStyle(bar).paddingTop) || 0;\n rows = Math.max(0, bar.getBoundingClientRect().height - top);\n }\n this.style.setProperty('--mbx-bar-rows', `${rows}px`);\n }\n\n protected override render(): void {\n const metadata = this.player?.programme?.metadata;\n const heading = this.getAttribute('heading') ?? metadata?.title ?? '';\n const subheading = this.getAttribute('subheading') ?? metadata?.subtitle ?? '';\n const artwork = this.getAttribute('artwork');\n this.heading.textContent = heading;\n this.subheading.textContent = subheading;\n if (artwork === null) {\n this.artwork.removeAttribute('src');\n this.artwork.hidden = true;\n } else {\n this.artwork.src = artwork;\n this.artwork.hidden = false;\n }\n this.toggleAttribute('empty', heading === '' && subheading === '' && artwork === null);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,MAAA,QAAA;AAEA,IAAA,WAAA,cAAA,UAAA;CACA,WAAA,qBAAA;EACA,OAAA;GAAA;GAAA;GAAA;EAAA;CACA;CAQA,cAAA;EACA,MAAA;EACA,KAAA,UAAA;EACA,MAAA,OAAA,KAAA,aAAA,EAAA,MAAA,OAAA,CAAA;EACA,KAAA,UAAA,GAAA,OAAA,SAAA;EACA,KAAA,QAAA,MAAA;EACA,KAAA,QAAA,SAAA;EACA,MAAA,OAAA,GAAA,OAAA,MAAA;EACA,KAAA,UAAA,GAAA,OAAA,SAAA;EACA,KAAA,aAAA,GAAA,OAAA,YAAA;EACA,KAAA,OAAA,KAAA,SAAA,KAAA,UAAA;EACA,KAAA,OAAA,MAAA,KAAA,GAAA,KAAA,SAAA,IAAA;CACA;CAEA,OAAA,QAAA;EACA,KAAA,OAAA,OAAA,OAAA;GAAA;GAAA;GAAA;GAAA;EAAA,SAAA;GACA,KAAA,MAAA,MAAA;EACA,CAAA;EACA,KAAA,QAAA,QAAA,CAAA,WAAA,SAAA;GACA,KAAA,MAAA,MAAA;EACA,CAAA;EACA,KAAA,OAAA,QAAA,CAAA,iBAAA,SAAA;GACA,KAAA,OAAA;EACA,CAAA;EACA,IAAA,OAAA,mBAAA,aAAA;GACA,KAAA,UAAA,IAAA,qBAAA;IACA,KAAA,IAAA,MAAA;GACA,CAAA;GACA,KAAA,QAAA,QAAA,MAAA;GAGA,MAAA,MAAA,OAAA,cAAA,iBAAA;GACA,IAAA,QAAA,MAAA,KAAA,QAAA,QAAA,GAAA;EACA;EACA,KAAA,IAAA,MAAA;EACA,KAAA,MAAA,MAAA;EACA,KAAA,OAAA;CACA;CAEA,SAAA;EACA,KAAA,SAAA,WAAA;EACA,KAAA,UAAA;EACA,KAAA,gBAAA,SAAA;EACA,KAAA,MAAA,eAAA,gBAAA;CACA;;CAGA,MAAA,QAAA;EAEA,KAAA,gBAAA,WAAA,CAAA,YAAA,QAAA,CAAA,WAAA,CAAA,CAAA;CACA;;CAGA,IAAA,QAAA;EACA,MAAA,MAAA,OAAA,cAAA,iBAAA;EACA,IAAA,OAAA;EACA,IAAA,QAAA,MAAA;GACA,MAAA,MAAA,OAAA,WAAA,iBAAA,GAAA,CAAA,CAAA,UAAA,KAAA;GACA,OAAA,KAAA,IAAA,GAAA,IAAA,sBAAA,CAAA,CAAA,SAAA,GAAA;EACA;EACA,KAAA,MAAA,YAAA,kBAAA,GAAA,KAAA,GAAA;CACA;CAEA,SAAA;EACA,MAAA,WAAA,KAAA,QAAA,WAAA;EACA,MAAA,UAAA,KAAA,aAAA,SAAA,KAAA,UAAA,SAAA;EACA,MAAA,aAAA,KAAA,aAAA,YAAA,KAAA,UAAA,YAAA;EACA,MAAA,UAAA,KAAA,aAAA,SAAA;EACA,KAAA,QAAA,cAAA;EACA,KAAA,WAAA,cAAA;EACA,IAAA,YAAA,MAAA;GACA,KAAA,QAAA,gBAAA,KAAA;GACA,KAAA,QAAA,SAAA;EACA,OAAA;GACA,KAAA,QAAA,MAAA;GACA,KAAA,QAAA,SAAA;EACA;EACA,KAAA,gBAAA,SAAA,YAAA,MAAA,eAAA,MAAA,YAAA,IAAA;CACA;AACA"}
1
+ {"version":3,"file":"title.js","names":[],"sources":["../../src/elements/title.ts"],"sourcesContent":["/**\n * <mbx-title>: the heading, the subheading and the artwork of what plays,\n * as a lower third across the picture above the bar: a scrim that fades\n * upward, the artwork in the first column, the two lines in the second,\n * so a heading alone sits on a band and never floats. The content comes\n * from attributes, `heading`,\n * `subheading` and `artwork`, because the stream carries none of it: a page\n * writes what it knows, and a Cast receiver writes what the sender said.\n * A heading or subheading the page leaves out takes the programme's title\n * or subtitle, from what a connector resolved. The artwork comes from the\n * attribute only: the programme's image is the poster already. With none,\n * the element draws nothing.\n *\n * Shown while the video is paused, which includes before the first play,\n * and hidden while it plays. A drag on the seek bar and a switch to another\n * source keep the state from before, so a seek while playing never shows\n * it. The element carries `playing` for that rule,\n * so a page changes it in CSS: `mattebox-player[started] mbx-title\n * { display: none }` keeps it to the time before the first play, like the\n * poster, and `mattebox-player:hover mbx-title { display: flex }` brings it\n * back on hover. The height of the bar's rows, its box less the fade it\n * pads itself with, goes on the host as `--mbx-bar-rows`, so the text sits\n * just above the seek row while the band runs under the bar to the bottom\n * edge, one ramp with the bar's own fade. The scrim is the page's to\n * override. Placed first among the screens, so the start button, the\n * error screen and the spinner paint over its band.\n */\nimport { el } from '../dom.js';\nimport type { PlayerHost } from '../host.js';\nimport { Component } from './component.js';\nimport { HELD, shownPaused, style } from './shared.js';\nimport STYLE from './title.css?inline';\n\nexport class MbxTitle extends Component {\n static get observedAttributes(): readonly string[] {\n return ['heading', 'subheading', 'artwork'];\n }\n\n declare private readonly artwork: HTMLImageElement;\n declare private readonly heading: HTMLElement;\n declare private readonly subheading: HTMLElement;\n /** Watches the player's box: the height of the bar's rows decides where the text sits. */\n declare private resizer: ResizeObserver | null;\n\n constructor() {\n super();\n this.resizer = null;\n const root = this.attachShadow({ mode: 'open' });\n this.artwork = el('img', 'artwork');\n this.artwork.alt = '';\n this.artwork.hidden = true;\n const text = el('div', 'text');\n this.heading = el('div', 'heading');\n this.subheading = el('div', 'subheading');\n text.append(this.heading, this.subheading);\n root.append(style(STYLE), this.artwork, text);\n }\n\n protected override attach(player: PlayerHost): void {\n this.listen(player.video, ['play', 'pause', 'ended', 'emptied'], () => {\n this.state(player);\n });\n this.observe(player, HELD, () => {\n this.state(player);\n });\n this.listen(player, ['programmechange'], () => {\n this.render();\n });\n if (typeof ResizeObserver !== 'undefined') {\n this.resizer = new ResizeObserver(() => {\n this.fit(player);\n });\n this.resizer.observe(player);\n // The bar's rows change height with the player's size tier, without\n // the player's box changing.\n const bar = player.querySelector('mbx-control-bar');\n if (bar !== null) this.resizer.observe(bar);\n }\n this.fit(player);\n this.state(player);\n this.render();\n }\n\n protected override detach(): void {\n this.resizer?.disconnect();\n this.resizer = null;\n this.removeAttribute('playing');\n this.style.removeProperty('--mbx-bar-rows');\n }\n\n /** `playing` on the element, for its own stylesheet and the page's. */\n private state(player: PlayerHost): void {\n // The pause of a drag or of a switch to another source is no pause.\n this.toggleAttribute('playing', !shownPaused(player));\n }\n\n /** The height of the bar's rows: its box less the padding above them, which is its fade. Zero without a bar. */\n private fit(player: PlayerHost): void {\n const bar = player.querySelector('mbx-control-bar');\n let rows = 0;\n if (bar !== null) {\n const top = Number.parseFloat(getComputedStyle(bar).paddingTop) || 0;\n rows = Math.max(0, bar.getBoundingClientRect().height - top);\n }\n this.style.setProperty('--mbx-bar-rows', `${rows}px`);\n }\n\n protected override render(): void {\n const metadata = this.player?.programme?.metadata;\n const heading = this.getAttribute('heading') ?? metadata?.title ?? '';\n const subheading = this.getAttribute('subheading') ?? metadata?.subtitle ?? '';\n const artwork = this.getAttribute('artwork');\n this.heading.textContent = heading;\n this.subheading.textContent = subheading;\n if (artwork === null) {\n this.artwork.removeAttribute('src');\n this.artwork.hidden = true;\n } else {\n this.artwork.src = artwork;\n this.artwork.hidden = false;\n }\n this.toggleAttribute('empty', heading === '' && subheading === '' && artwork === null);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,MAAA,QAAA;AAEA,IAAA,WAAA,cAAA,UAAA;CACA,WAAA,qBAAA;EACA,OAAA;GAAA;GAAA;GAAA;EAAA;CACA;CAQA,cAAA;EACA,MAAA;EACA,KAAA,UAAA;EACA,MAAA,OAAA,KAAA,aAAA,EAAA,MAAA,OAAA,CAAA;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,KAAA,MAAA,YAAA,kBAAA,GAAA,KAAA,GAAA;CACA;CAEA,SAAA;EACA,MAAA,WAAA,KAAA,QAAA,WAAA;EACA,MAAA,UAAA,KAAA,aAAA,SAAA,KAAA,UAAA,SAAA;EACA,MAAA,aAAA,KAAA,aAAA,YAAA,KAAA,UAAA,YAAA;EACA,MAAA,UAAA,KAAA,aAAA,SAAA;EACA,KAAA,QAAA,cAAA;EACA,KAAA,WAAA,cAAA;EACA,IAAA,YAAA,MAAA;GACA,KAAA,QAAA,gBAAA,KAAA;GACA,KAAA,QAAA,SAAA;EACA,OAAA;GACA,KAAA,QAAA,MAAA;GACA,KAAA,QAAA,SAAA;EACA;EACA,KAAA,gBAAA,SAAA,YAAA,MAAA,eAAA,MAAA,YAAA,IAAA;CACA;AACA"}
@@ -0,0 +1,18 @@
1
+ // src/controls/breaks.ts
2
+ /** Break marks; `emit` reports each change as `breakschange`, with the list. */
3
+ function createBreakMarks(emit) {
4
+ const owners = /* @__PURE__ */ new Map();
5
+ let list = [];
6
+ return {
7
+ get list() {
8
+ return list;
9
+ },
10
+ set(owner, marks) {
11
+ if (marks.length === 0) owners.delete(owner);
12
+ else owners.set(owner, marks);
13
+ list = [...owners.values()].flat().sort((a, b) => a.start - b.start);
14
+ emit(list);
15
+ }
16
+ };
17
+ }
18
+ export { createBreakMarks };