@mattebox/player 0.7.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. package/dist/cdn/mattebox-player.min.js +3 -3
  2. package/dist/controls/icons.d.ts +3 -1
  3. package/dist/controls/icons.d.ts.map +1 -1
  4. package/dist/controls/icons.js +27 -27
  5. package/dist/controls/icons.js.map +1 -1
  6. package/dist/controls/markers.d.ts +39 -0
  7. package/dist/controls/markers.d.ts.map +1 -0
  8. package/dist/controls/markers.js +38 -0
  9. package/dist/controls/markers.js.map +1 -0
  10. package/dist/controls/menu.d.ts +3 -2
  11. package/dist/controls/menu.d.ts.map +1 -1
  12. package/dist/controls/menu.js +23 -3
  13. package/dist/controls/menu.js.map +1 -1
  14. package/dist/controls/native-tracks.d.ts +28 -0
  15. package/dist/controls/native-tracks.d.ts.map +1 -0
  16. package/dist/controls/native-tracks.js +30 -0
  17. package/dist/controls/native-tracks.js.map +1 -0
  18. package/dist/controls/quality-names.d.ts +15 -0
  19. package/dist/controls/quality-names.d.ts.map +1 -0
  20. package/dist/controls/quality-names.js +62 -0
  21. package/dist/controls/quality-names.js.map +1 -0
  22. package/dist/controls/track-names.d.ts +40 -0
  23. package/dist/controls/track-names.d.ts.map +1 -0
  24. package/dist/controls/track-names.js +59 -0
  25. package/dist/controls/track-names.js.map +1 -0
  26. package/dist/element.d.ts +24 -0
  27. package/dist/element.d.ts.map +1 -1
  28. package/dist/element.js +47 -4
  29. package/dist/element.js.map +1 -1
  30. package/dist/elements/audio-menu.d.ts +19 -8
  31. package/dist/elements/audio-menu.d.ts.map +1 -1
  32. package/dist/elements/audio-menu.js +57 -18
  33. package/dist/elements/audio-menu.js.map +1 -1
  34. package/dist/elements/drm-badge.d.ts +3 -2
  35. package/dist/elements/drm-badge.d.ts.map +1 -1
  36. package/dist/elements/drm-badge.js +10 -8
  37. package/dist/elements/drm-badge.js.map +1 -1
  38. package/dist/elements/marker-button.d.ts +22 -0
  39. package/dist/elements/marker-button.d.ts.map +1 -0
  40. package/dist/elements/marker-button.js +99 -0
  41. package/dist/elements/marker-button.js.map +1 -0
  42. package/dist/elements/quality-menu.d.ts +4 -0
  43. package/dist/elements/quality-menu.d.ts.map +1 -1
  44. package/dist/elements/quality-menu.js +21 -7
  45. package/dist/elements/quality-menu.js.map +1 -1
  46. package/dist/elements/seek-bar.d.ts +6 -1
  47. package/dist/elements/seek-bar.d.ts.map +1 -1
  48. package/dist/elements/seek-bar.js +33 -22
  49. package/dist/elements/seek-bar.js.map +1 -1
  50. package/dist/elements/shared.js +1 -1
  51. package/dist/elements/subtitles-menu.d.ts +2 -0
  52. package/dist/elements/subtitles-menu.d.ts.map +1 -1
  53. package/dist/elements/subtitles-menu.js +33 -9
  54. package/dist/elements/subtitles-menu.js.map +1 -1
  55. package/dist/entries/marker-button.d.ts +5 -0
  56. package/dist/entries/marker-button.d.ts.map +1 -0
  57. package/dist/entries/marker-button.js +9 -0
  58. package/dist/entries/marker-button.js.map +1 -0
  59. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.150.0 → _@oxc-project_runtime@0.152.0}/helpers/esm/asyncToGenerator.js +1 -1
  60. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.150.0 → _@oxc-project_runtime@0.152.0}/helpers/esm/defineProperty.js +1 -1
  61. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.150.0 → _@oxc-project_runtime@0.152.0}/helpers/esm/objectSpread2.js +1 -1
  62. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.150.0 → _@oxc-project_runtime@0.152.0}/helpers/esm/toPrimitive.js +1 -1
  63. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.150.0 → _@oxc-project_runtime@0.152.0}/helpers/esm/toPropertyKey.js +1 -1
  64. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.150.0 → _@oxc-project_runtime@0.152.0}/helpers/esm/typeof.js +1 -1
  65. package/dist/es2015/controls/chapters.js +1 -1
  66. package/dist/es2015/controls/icons.js +27 -27
  67. package/dist/es2015/controls/markers.js +36 -0
  68. package/dist/es2015/controls/menu.js +24 -4
  69. package/dist/es2015/controls/native-tracks.js +29 -0
  70. package/dist/es2015/controls/quality-names.js +67 -0
  71. package/dist/es2015/controls/track-names.js +57 -0
  72. package/dist/es2015/element.js +48 -6
  73. package/dist/es2015/elements/audio-menu.js +62 -19
  74. package/dist/es2015/elements/drm-badge.js +11 -8
  75. package/dist/es2015/elements/marker-button.js +100 -0
  76. package/dist/es2015/elements/quality-menu.js +22 -7
  77. package/dist/es2015/elements/seek-bar.js +38 -26
  78. package/dist/es2015/elements/shared.js +1 -1
  79. package/dist/es2015/elements/subtitles-menu.js +39 -11
  80. package/dist/es2015/entries/marker-button.js +7 -0
  81. package/dist/es2015/index.js +3 -1
  82. package/dist/es2015/presets.js +1 -1
  83. package/dist/es2015/style.js +1 -1
  84. package/dist/es2015/tags.js +2 -1
  85. package/dist/host.d.ts +3 -0
  86. package/dist/host.d.ts.map +1 -1
  87. package/dist/host.js.map +1 -1
  88. package/dist/index.d.ts +4 -0
  89. package/dist/index.d.ts.map +1 -1
  90. package/dist/index.js +3 -1
  91. package/dist/style.js +1 -1
  92. package/dist/tags.d.ts +1 -0
  93. package/dist/tags.d.ts.map +1 -1
  94. package/dist/tags.js +2 -1
  95. package/dist/tags.js.map +1 -1
  96. package/package.json +3 -3
@@ -3,9 +3,13 @@ import { MenuElement } from './menu-element.js';
3
3
  export declare class MbxQualityMenu extends MenuElement {
4
4
  static get observedAttributes(): readonly string[];
5
5
  private engine;
6
+ /** The name of what plays, as the Auto row last showed it. */
7
+ private playing;
6
8
  constructor();
7
9
  protected name(): string;
8
10
  protected attach(player: PlayerHost): void;
9
11
  protected render(): void;
12
+ /** The name of the rendition that plays, under Auto only: a pin names itself by its tick. */
13
+ private playingName;
10
14
  }
11
15
  //# sourceMappingURL=quality-menu.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"quality-menu.d.ts","sourceRoot":"","sources":["../../src/elements/quality-menu.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAU,MAAM,mBAAmB,CAAC;AAUxD,qBAAa,cAAe,SAAQ,WAAW;IAC7C,MAAM,KAAK,kBAAkB,IAAI,SAAS,MAAM,EAAE,CAEjD;IAED,QAAgB,MAAM,CAAkB;;cAQrB,IAAI,IAAI,MAAM;cAId,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;cAmBhC,MAAM,IAAI,IAAI;CA4BlC"}
1
+ {"version":3,"file":"quality-menu.d.ts","sourceRoot":"","sources":["../../src/elements/quality-menu.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAU,MAAM,mBAAmB,CAAC;AAKxD,qBAAa,cAAe,SAAQ,WAAW;IAC7C,MAAM,KAAK,kBAAkB,IAAI,SAAS,MAAM,EAAE,CAEjD;IAED,QAAgB,MAAM,CAAkB;IACxC,8DAA8D;IAC9D,QAAgB,OAAO,CAAqB;;cASzB,IAAI,IAAI,MAAM;cAId,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;cA0BhC,MAAM,IAAI,IAAI;IA4BjC,6FAA6F;IAC7F,OAAO,CAAC,WAAW;CAOpB"}
@@ -1,11 +1,8 @@
1
1
  import { show } from "./shared.js";
2
2
  import { MenuElement, single } from "./menu-element.js";
3
+ import { qualityLabels, qualityNames } from "../controls/quality-names.js";
3
4
  //#region src/elements/quality-menu.ts
4
5
  const AUTO = "auto";
5
- function renditionLabel(rendition) {
6
- if (rendition.height !== void 0) return `${rendition.height}p`;
7
- return `${Math.round(rendition.bitrate / 1e3)} kbps`;
8
- }
9
6
  var MbxQualityMenu = class extends MenuElement {
10
7
  static get observedAttributes() {
11
8
  return [
@@ -17,6 +14,7 @@ var MbxQualityMenu = class extends MenuElement {
17
14
  constructor() {
18
15
  super(...single("settings"));
19
16
  this.engine = null;
17
+ this.playing = void 0;
20
18
  show(this.slots, "default");
21
19
  }
22
20
  name() {
@@ -30,7 +28,12 @@ var MbxQualityMenu = class extends MenuElement {
30
28
  const tick = () => {
31
29
  this.render();
32
30
  };
31
+ const clock = () => {
32
+ if (this.playingName() !== this.playing) this.render();
33
+ };
34
+ player.video.addEventListener("timeupdate", clock);
33
35
  const offs = [
36
+ () => player.video.removeEventListener("timeupdate", clock),
34
37
  engine.on("tracks:changed", tick),
35
38
  engine.on("quality:constraints-unsatisfiable", tick),
36
39
  engine.on("quality:pin-unsatisfiable", tick)
@@ -48,8 +51,12 @@ var MbxQualityMenu = class extends MenuElement {
48
51
  return;
49
52
  }
50
53
  const quality = engine.quality;
51
- const items = [[AUTO, this.getAttribute("label-auto") ?? "Auto"]];
52
- for (const rendition of quality.renditions) items.push([rendition.id, renditionLabel(rendition)]);
54
+ this.playing = this.playingName();
55
+ const items = [[
56
+ AUTO,
57
+ this.getAttribute("label-auto") ?? "Auto",
58
+ this.playing
59
+ ], ...qualityNames(quality.selectable)];
53
60
  this.menu.fill([{
54
61
  name: "rendition",
55
62
  items,
@@ -60,7 +67,14 @@ var MbxQualityMenu = class extends MenuElement {
60
67
  this.render();
61
68
  }
62
69
  }]);
63
- this.hidden = quality.renditions.length === 0;
70
+ this.hidden = items.length === 1;
71
+ }
72
+ /** The name of the rendition that plays, under Auto only: a pin names itself by its tick. */
73
+ playingName() {
74
+ const quality = this.engine?.quality;
75
+ if (quality === void 0 || quality.pinned !== null) return void 0;
76
+ const id = quality.playing?.id;
77
+ return qualityLabels(quality.selectable).find(([candidate]) => candidate === id)?.[1];
64
78
  }
65
79
  };
66
80
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"quality-menu.js","names":[],"sources":["../../src/elements/quality-menu.ts"],"sourcesContent":["/**\n * <mbx-quality-menu>: the pin over `engine.quality`, where \"auto\" means\n * none. Hidden without renditions, and for a native session. The name\n * comes from `label`, the word for no pin from `label-auto`. A rendition\n * reads as its height when the manifest declared one, its bitrate\n * otherwise.\n */\nimport type { Mattebox, Rendition } from 'mattebox';\nimport type { PlayerHost } from '../host.js';\nimport { MenuElement, single } from './menu-element.js';\nimport { show } from './shared.js';\n\nconst AUTO = 'auto';\n\nfunction renditionLabel(rendition: Rendition): string {\n if (rendition.height !== undefined) return `${rendition.height}p`;\n return `${Math.round(rendition.bitrate / 1000)} kbps`;\n}\n\nexport class MbxQualityMenu extends MenuElement {\n static get observedAttributes(): readonly string[] {\n return ['label', 'label-auto', 'label-back'];\n }\n\n declare private engine: Mattebox | null;\n\n constructor() {\n super(...single('settings'));\n this.engine = null;\n show(this.slots, 'default');\n }\n\n protected override name(): string {\n return 'Quality';\n }\n\n protected override attach(player: PlayerHost): void {\n this.follow(player, (engine) => {\n this.engine = engine;\n this.render();\n if (engine === null) return undefined;\n const tick = (): void => {\n this.render();\n };\n const offs = [\n engine.on('tracks:changed', tick),\n engine.on('quality:constraints-unsatisfiable', tick),\n engine.on('quality:pin-unsatisfiable', tick),\n ];\n return () => {\n for (const off of offs) off();\n };\n });\n }\n\n protected override render(): void {\n super.render();\n const engine = this.engine;\n if (engine === null) {\n this.hidden = true;\n return;\n }\n const quality = engine.quality;\n const items: Array<readonly [string, string]> = [\n [AUTO, this.getAttribute('label-auto') ?? 'Auto'],\n ];\n for (const rendition of quality.renditions) {\n items.push([rendition.id, renditionLabel(rendition)]);\n }\n this.menu.fill([\n {\n name: 'rendition',\n items,\n value: quality.pinned ?? AUTO,\n onSelect: (value) => {\n if (value === AUTO) quality.auto();\n else quality.pin(value);\n this.render();\n },\n },\n ]);\n this.hidden = quality.renditions.length === 0;\n }\n}\n"],"mappings":";;;AAYA,MAAM,OAAO;AAEb,SAAS,eAAe,WAA8B;CACpD,IAAI,UAAU,WAAW,KAAA,GAAW,OAAO,GAAG,UAAU,OAAO;CAC/D,OAAO,GAAG,KAAK,MAAM,UAAU,UAAU,GAAI,EAAE;AACjD;AAEA,IAAa,iBAAb,cAAoC,YAAY;CAC9C,WAAW,qBAAwC;EACjD,OAAO;GAAC;GAAS;GAAc;EAAY;CAC7C;CAIA,cAAc;EACZ,MAAM,GAAG,OAAO,UAAU,CAAC;EAC3B,KAAK,SAAS;EACd,KAAK,KAAK,OAAO,SAAS;CAC5B;CAEA,OAAkC;EAChC,OAAO;CACT;CAEA,OAA0B,QAA0B;EAClD,KAAK,OAAO,SAAS,WAAW;GAC9B,KAAK,SAAS;GACd,KAAK,OAAO;GACZ,IAAI,WAAW,MAAM,OAAO,KAAA;GAC5B,MAAM,aAAmB;IACvB,KAAK,OAAO;GACd;GACA,MAAM,OAAO;IACX,OAAO,GAAG,kBAAkB,IAAI;IAChC,OAAO,GAAG,qCAAqC,IAAI;IACnD,OAAO,GAAG,6BAA6B,IAAI;GAC7C;GACA,aAAa;IACX,KAAK,MAAM,OAAO,MAAM,IAAI;GAC9B;EACF,CAAC;CACH;CAEA,SAAkC;EAChC,MAAM,OAAO;EACb,MAAM,SAAS,KAAK;EACpB,IAAI,WAAW,MAAM;GACnB,KAAK,SAAS;GACd;EACF;EACA,MAAM,UAAU,OAAO;EACvB,MAAM,QAA0C,CAC9C,CAAC,MAAM,KAAK,aAAa,YAAY,KAAK,MAAM,CAClD;EACA,KAAK,MAAM,aAAa,QAAQ,YAC9B,MAAM,KAAK,CAAC,UAAU,IAAI,eAAe,SAAS,CAAC,CAAC;EAEtD,KAAK,KAAK,KAAK,CACb;GACE,MAAM;GACN;GACA,OAAO,QAAQ,UAAU;GACzB,WAAW,UAAU;IACnB,IAAI,UAAU,MAAM,QAAQ,KAAK;SAC5B,QAAQ,IAAI,KAAK;IACtB,KAAK,OAAO;GACd;EACF,CACF,CAAC;EACD,KAAK,SAAS,QAAQ,WAAW,WAAW;CAC9C;AACF"}
1
+ {"version":3,"file":"quality-menu.js","names":[],"sources":["../../src/elements/quality-menu.ts"],"sourcesContent":["/**\n * <mbx-quality-menu>: the pin over `engine.quality`, where \"auto\" means\n * none. Hidden without renditions, and for a native session. The name\n * comes from `label`, the word for no pin from `label-auto`. It offers\n * `engine.quality.selectable`, labelled by `qualityNames`. Under Auto, the\n * Auto row names what plays, in its detail.\n */\nimport type { Mattebox } from 'mattebox';\nimport { qualityLabels, qualityNames } from '../controls/quality-names.js';\nimport type { PlayerHost } from '../host.js';\nimport { MenuElement, single } from './menu-element.js';\nimport { show } from './shared.js';\n\nconst AUTO = 'auto';\n\nexport class MbxQualityMenu extends MenuElement {\n static get observedAttributes(): readonly string[] {\n return ['label', 'label-auto', 'label-back'];\n }\n\n declare private engine: Mattebox | null;\n /** The name of what plays, as the Auto row last showed it. */\n declare private playing: string | undefined;\n\n constructor() {\n super(...single('settings'));\n this.engine = null;\n this.playing = undefined;\n show(this.slots, 'default');\n }\n\n protected override name(): string {\n return 'Quality';\n }\n\n protected override attach(player: PlayerHost): void {\n this.follow(player, (engine) => {\n this.engine = engine;\n this.render();\n if (engine === null) return undefined;\n const tick = (): void => {\n this.render();\n };\n // What plays changes as the playhead reaches another rendition's\n // segments, and no event says so: read it on the clock, draw on a change.\n const clock = (): void => {\n if (this.playingName() !== this.playing) this.render();\n };\n player.video.addEventListener('timeupdate', clock);\n const offs = [\n () => player.video.removeEventListener('timeupdate', clock),\n engine.on('tracks:changed', tick),\n engine.on('quality:constraints-unsatisfiable', tick),\n engine.on('quality:pin-unsatisfiable', tick),\n ];\n return () => {\n for (const off of offs) off();\n };\n });\n }\n\n protected override render(): void {\n super.render();\n const engine = this.engine;\n if (engine === null) {\n this.hidden = true;\n return;\n }\n const quality = engine.quality;\n this.playing = this.playingName();\n const items: Array<readonly [string, string, (string | undefined)?]> = [\n [AUTO, this.getAttribute('label-auto') ?? 'Auto', this.playing],\n ...qualityNames(quality.selectable),\n ];\n this.menu.fill([\n {\n name: 'rendition',\n items,\n value: quality.pinned ?? AUTO,\n onSelect: (value) => {\n if (value === AUTO) quality.auto();\n else quality.pin(value);\n this.render();\n },\n },\n ]);\n this.hidden = items.length === 1;\n }\n\n /** The name of the rendition that plays, under Auto only: a pin names itself by its tick. */\n private playingName(): string | undefined {\n const quality = this.engine?.quality;\n if (quality === undefined || quality.pinned !== null) return undefined;\n // Every label, twins too: what plays may be a twin the menu shows once.\n const id = quality.playing?.id;\n return qualityLabels(quality.selectable).find(([candidate]) => candidate === id)?.[1];\n }\n}\n"],"mappings":";;;;AAaA,MAAM,OAAO;AAEb,IAAa,iBAAb,cAAoC,YAAY;CAC9C,WAAW,qBAAwC;EACjD,OAAO;GAAC;GAAS;GAAc;EAAY;CAC7C;CAMA,cAAc;EACZ,MAAM,GAAG,OAAO,UAAU,CAAC;EAC3B,KAAK,SAAS;EACd,KAAK,UAAU,KAAA;EACf,KAAK,KAAK,OAAO,SAAS;CAC5B;CAEA,OAAkC;EAChC,OAAO;CACT;CAEA,OAA0B,QAA0B;EAClD,KAAK,OAAO,SAAS,WAAW;GAC9B,KAAK,SAAS;GACd,KAAK,OAAO;GACZ,IAAI,WAAW,MAAM,OAAO,KAAA;GAC5B,MAAM,aAAmB;IACvB,KAAK,OAAO;GACd;GAGA,MAAM,cAAoB;IACxB,IAAI,KAAK,YAAY,MAAM,KAAK,SAAS,KAAK,OAAO;GACvD;GACA,OAAO,MAAM,iBAAiB,cAAc,KAAK;GACjD,MAAM,OAAO;UACL,OAAO,MAAM,oBAAoB,cAAc,KAAK;IAC1D,OAAO,GAAG,kBAAkB,IAAI;IAChC,OAAO,GAAG,qCAAqC,IAAI;IACnD,OAAO,GAAG,6BAA6B,IAAI;GAC7C;GACA,aAAa;IACX,KAAK,MAAM,OAAO,MAAM,IAAI;GAC9B;EACF,CAAC;CACH;CAEA,SAAkC;EAChC,MAAM,OAAO;EACb,MAAM,SAAS,KAAK;EACpB,IAAI,WAAW,MAAM;GACnB,KAAK,SAAS;GACd;EACF;EACA,MAAM,UAAU,OAAO;EACvB,KAAK,UAAU,KAAK,YAAY;EAChC,MAAM,QAAiE,CACrE;GAAC;GAAM,KAAK,aAAa,YAAY,KAAK;GAAQ,KAAK;EAAO,GAC9D,GAAG,aAAa,QAAQ,UAAU,CACpC;EACA,KAAK,KAAK,KAAK,CACb;GACE,MAAM;GACN;GACA,OAAO,QAAQ,UAAU;GACzB,WAAW,UAAU;IACnB,IAAI,UAAU,MAAM,QAAQ,KAAK;SAC5B,QAAQ,IAAI,KAAK;IACtB,KAAK,OAAO;GACd;EACF,CACF,CAAC;EACD,KAAK,SAAS,MAAM,WAAW;CACjC;;CAGA,cAA0C;EACxC,MAAM,UAAU,KAAK,QAAQ;EAC7B,IAAI,YAAY,KAAA,KAAa,QAAQ,WAAW,MAAM,OAAO,KAAA;EAE7D,MAAM,KAAK,QAAQ,SAAS;EAC5B,OAAO,cAAc,QAAQ,UAAU,CAAC,CAAC,MAAM,CAAC,eAAe,cAAc,EAAE,CAAC,GAAG;CACrF;AACF"}
@@ -61,6 +61,8 @@ export declare class MbxSeekBar extends Component {
61
61
  static get observedAttributes(): readonly string[];
62
62
  private readonly bar;
63
63
  private readonly buffered;
64
+ /** The ranges the page marked blocked, drawn as a broken line: they never play. */
65
+ private readonly blocked;
64
66
  private readonly hover;
65
67
  private readonly edge;
66
68
  private readonly preview;
@@ -147,7 +149,10 @@ export declare class MbxSeekBar extends Component {
147
149
  * position in the video, so the preview shows none meanwhile.
148
150
  */
149
151
  private paintPicture;
150
- private paintBuffered;
152
+ /** The ranges the page marked blocked. */
153
+ private blockedRanges;
154
+ /** One child of `layer` per range, each named `part`, placed along the track. */
155
+ private paintRanges;
151
156
  /** Whether a live window is wide enough to be worth a bar. */
152
157
  private worthSeeking;
153
158
  /** The hover marker and the preview follow the pointer, clamped to the bar. */
@@ -1 +1 @@
1
- {"version":3,"file":"seek-bar.d.ts","sourceRoot":"","sources":["../../src/elements/seek-bar.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AAYH,OAAO,KAAK,EAAE,UAAU,EAAE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AKd,OAAO,CAAC,UAAU;IAQlB,OAAO,CAAC,KAAK;IA2Bb,OAAO,CAAC,KAAK;IAQb,sEAAsE;IACtE,OAAO,CAAC,YAAY;IAOpB,0GAA0G;IAC1G,OAAO,CAAC,OAAO;IASf,4DAA4D;IAC5D,OAAO,CAAC,SAAS;IAajB;;;;;;OAMG;IACH,OAAO,CAAC,YAAY;IA6CpB,0CAA0C;IAC1C,OAAO,CAAC,aAAa;IAIrB,iFAAiF;IACjF,OAAO,CAAC,WAAW;IAenB,8DAA8D;IAC9D,OAAO,CAAC,YAAY;IAOpB,+EAA+E;IAC/E,OAAO,CAAC,KAAK;IASb,kFAAkF;IAClF,OAAO,CAAC,SAAS;IAyBjB,OAAO,CAAC,KAAK;cAOM,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;cAqChC,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;cAWhC,MAAM,IAAI,IAAI;CA0BlC"}
@@ -2,13 +2,13 @@ import { el } from "../dom.js";
2
2
  import { Component } from "./component.js";
3
3
  import { SLIDER_STYLE, number, seekRow, style } from "./shared.js";
4
4
  import { fill } from "../labels.js";
5
- import { EMPTY, at, clip, fraction } from "../controls/ranges.js";
5
+ import { EMPTY, at, clip, fraction, spans } from "../controls/ranges.js";
6
6
  import { format } from "../controls/time.js";
7
7
  import { bufferGoal, live, optional, span, wall } from "../controls/session.js";
8
8
  import { chapterAt, chapters, followChapters } from "../controls/chapters.js";
9
9
  import { slider } from "../controls/slider.js";
10
10
  //#region src/elements/seek-bar.ts
11
- const STYLE_CSS = ":host,[part~=slider]{flex:1}[part~=thumb]{width:16px;height:16px;margin:-8px 0 0 -8px;box-shadow:0 1px 3px #0006}[part~=buffered]{position:absolute;top:0;bottom:0;left:0;right:0}[part~=buffered-range]{background:#ffffff4d;position:absolute;top:0;bottom:0}[part~=hover]{background:var(--mbx-text);width:2px;margin-left:-1px;position:absolute;top:0;bottom:0}[part~=edge]{background:var(--mbx-live);width:2px;margin-left:-1px;position:absolute;top:0;bottom:0}[part~=preview]{background:var(--mbx-surface);border-radius:var(--mbx-radius);font-variant-numeric:tabular-nums;white-space:nowrap;pointer-events:none;flex-direction:column;align-items:center;margin-bottom:4px;padding:2px;font-size:13px;display:flex;position:absolute;bottom:100%;transform:translate(-50%)}[part~=preview]>:not([hidden])~:not([hidden]){margin-top:2px}[part~=preview-image]{border-radius:2px;position:relative;overflow:hidden}[part~=preview-frame]{border-radius:2px;display:block}[part~=preview-tile]{transform-origin:0 0;background-repeat:no-repeat;position:absolute;top:0;left:0}[part~=preview-time]{padding:0 4px}[part~=preview-title]{text-overflow:ellipsis;max-width:240px;padding:0 4px;overflow:hidden}[hidden]{display:none}";
11
+ const STYLE_CSS = ":host,[part~=slider]{flex:1}[part~=thumb]{width:16px;height:16px;margin:-8px 0 0 -8px;box-shadow:0 1px 3px #0006}[part~=buffered]{position:absolute;top:0;bottom:0;left:0;right:0}[part~=blocked]{pointer-events:none;position:absolute;top:0;bottom:0;left:0;right:0}[part~=blocked-range]{background:var(--mbx-blocked,#000000bf);position:absolute;top:0;bottom:0}[part~=buffered-range]{background:#ffffff4d;position:absolute;top:0;bottom:0}[part~=hover]{background:var(--mbx-text);width:2px;margin-left:-1px;position:absolute;top:0;bottom:0}[part~=edge]{background:var(--mbx-live);width:2px;margin-left:-1px;position:absolute;top:0;bottom:0}[part~=preview]{background:var(--mbx-surface);border-radius:var(--mbx-radius);font-variant-numeric:tabular-nums;white-space:nowrap;pointer-events:none;flex-direction:column;align-items:center;margin-bottom:4px;padding:2px;font-size:13px;display:flex;position:absolute;bottom:100%;transform:translate(-50%)}[part~=preview]>:not([hidden])~:not([hidden]){margin-top:2px}[part~=preview-image]{border-radius:2px;position:relative;overflow:hidden}[part~=preview-frame]{border-radius:2px;display:block}[part~=preview-tile]{transform-origin:0 0;background-repeat:no-repeat;position:absolute;top:0;left:0}[part~=preview-time]{padding:0 4px}[part~=preview-title]{text-overflow:ellipsis;max-width:240px;padding:0 4px;overflow:hidden}[hidden]{display:none}";
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;
@@ -46,13 +46,14 @@ function percent(part) {
46
46
  return `${part * 100}%`;
47
47
  }
48
48
  /**
49
- * A mask that cuts a gap at each boundary between chapters, as stops along
50
- * the track: opaque up to a boundary, clear for the gap, opaque after.
49
+ * A mask that cuts a gap at each chapter boundary, as stops along the
50
+ * track: opaque up to a boundary, clear for the gap, opaque after.
51
51
  */
52
- function gaps(list, span) {
52
+ function gaps(boundaries, span) {
53
+ if (boundaries.length === 0) return "";
53
54
  const stops = ["#000 0"];
54
- for (const chapter of list.slice(1)) {
55
- const at = percent(fraction(chapter.start, span));
55
+ for (const time of boundaries) {
56
+ const at = percent(fraction(time, span));
56
57
  const before = `calc(${at} - ${GAP / 2}px)`;
57
58
  const after = `calc(${at} + ${GAP / 2}px)`;
58
59
  stops.push(`#000 ${before}`, `transparent ${before}`, `transparent ${after}`, `#000 ${after}`);
@@ -66,6 +67,7 @@ var MbxSeekBar = class extends Component {
66
67
  "label",
67
68
  "label-of",
68
69
  "label-behind",
70
+ "label-blocked",
69
71
  "live-window",
70
72
  "chapters",
71
73
  "scrub",
@@ -104,12 +106,13 @@ var MbxSeekBar = class extends Component {
104
106
  }
105
107
  });
106
108
  this.buffered = el("div", "buffered");
109
+ this.blocked = el("div", "blocked");
107
110
  this.hover = el("div", "hover");
108
111
  this.edge = el("div", "edge");
109
112
  this.hover.hidden = true;
110
113
  this.edge.hidden = true;
111
114
  this.bar.track.prepend(this.buffered);
112
- this.bar.track.append(this.hover, this.edge);
115
+ this.bar.track.append(this.blocked, this.hover, this.edge);
113
116
  this.preview = el("div", "preview");
114
117
  this.image = el("div", "preview-image");
115
118
  this.tile = el("div", "preview-tile");
@@ -151,7 +154,7 @@ var MbxSeekBar = class extends Component {
151
154
  }
152
155
  /** The gaps at the chapter boundaries, on every layer of the track at once. */
153
156
  paintChapters() {
154
- const mask = this.chaptered("divided") && this.list.length > 1 ? gaps(this.list, this.range) : "";
157
+ const mask = gaps(this.chaptered("divided") && this.list.length > 1 ? this.list.slice(1).map((chapter) => chapter.start) : [], this.range);
155
158
  const key = `${mask}|${this.range.start}|${this.range.end}`;
156
159
  if (key === this.divided) return;
157
160
  this.divided = key;
@@ -372,16 +375,17 @@ var MbxSeekBar = class extends Component {
372
375
  }, () => void 0);
373
376
  if (this.frameCanvas.hidden) this.paintTile(tile);
374
377
  }
375
- paintBuffered(video) {
376
- const parts = clip(Array.from({ length: video.buffered.length }, (_, i) => ({
377
- start: video.buffered.start(i),
378
- end: video.buffered.end(i)
379
- })), this.range);
380
- const buffered = this.buffered;
381
- while (buffered.childElementCount > parts.length) buffered.lastElementChild?.remove();
382
- while (buffered.childElementCount < parts.length) buffered.append(el("div", "buffered-range"));
378
+ /** The ranges the page marked blocked. */
379
+ blockedRanges() {
380
+ return (this.player?.markers.list ?? []).filter((marker) => marker.kind === "blocked");
381
+ }
382
+ /** One child of `layer` per range, each named `part`, placed along the track. */
383
+ paintRanges(layer, ranges, part) {
384
+ const parts = clip(ranges, this.range);
385
+ while (layer.childElementCount > parts.length) layer.lastElementChild?.remove();
386
+ while (layer.childElementCount < parts.length) layer.append(el("div", part));
383
387
  let i = 0;
384
- for (const child of buffered.children) {
388
+ for (const child of layer.children) {
385
389
  const part = parts[i];
386
390
  i += 1;
387
391
  if (part === void 0) break;
@@ -414,9 +418,14 @@ var MbxSeekBar = class extends Component {
414
418
  const when = at(part, this.range);
415
419
  this.time.textContent = this.label(when);
416
420
  const chapter = this.chaptered("titles") ? this.list[chapterAt(this.list, when)] : void 0;
417
- this.caption.hidden = chapter === void 0 || chapter.title === "";
418
- this.caption.textContent = chapter?.title ?? "";
419
- this.paintPicture(when);
421
+ const blocked = this.player?.markers.within(when).find((marker) => marker.kind === "blocked");
422
+ const title = blocked ? blocked.label ?? this.getAttribute("label-blocked") ?? "Not available" : chapter?.title ?? "";
423
+ this.caption.hidden = title === "";
424
+ this.caption.textContent = title;
425
+ if (blocked) {
426
+ this.image.hidden = true;
427
+ this.frameCanvas.hidden = true;
428
+ } else this.paintPicture(when);
420
429
  const whole = this.bar.root.getBoundingClientRect();
421
430
  const half = this.preview.offsetWidth / 2;
422
431
  const x = rect.left - whole.left + part * rect.width;
@@ -433,6 +442,7 @@ var MbxSeekBar = class extends Component {
433
442
  };
434
443
  this.listen(player.video, EVENTS, tick);
435
444
  this.keep(followChapters(player, tick));
445
+ this.listen(player, ["markerschange"], tick);
436
446
  this.listen(player, ["sourcechange"], () => {
437
447
  this.drag = "none";
438
448
  this.stopAiming();
@@ -475,7 +485,8 @@ var MbxSeekBar = class extends Component {
475
485
  this.list = chapters(video, engine);
476
486
  this.bar.label(this.getAttribute("label") ?? "Seek");
477
487
  this.bar.range(this.range.start, this.range.end);
478
- this.paintBuffered(video);
488
+ this.paintRanges(this.buffered, spans(video.buffered), "buffered-range");
489
+ this.paintRanges(this.blocked, this.blockedRanges(), "blocked-range");
479
490
  this.paintChapters();
480
491
  this.edge.hidden = !on;
481
492
  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 } from '../controls/ranges.js';\nimport { bufferGoal, live, optional, span, wall } from '../controls/session.js';\nimport type { Slider } from '../controls/slider.js';\nimport { slider } from '../controls/slider.js';\nimport { format } from '../controls/time.js';\nimport { el } from '../dom.js';\nimport type { PlayerHost } from '../host.js';\nimport { fill } from '../labels.js';\nimport { Component } from './component.js';\nimport STYLE_CSS from './seek-bar.css?inline';\nimport { number, SLIDER_STYLE, seekRow, style } from './shared.js';\n\n/** What a drag does, chosen when the pointer takes the thumb. */\ntype Drag = 'none' | 'seek' | 'scrub';\n\n/** Where the preview's picture comes from: decoded I-frames, or thumbnail tiles. */\ntype Preview = 'frames' | 'tiles';\n\nconst STEP = 5;\n\n/** Under `key-mode=\"preview\"`, a target seeks this long after the last key. */\nconst KEY_COMMIT_MS = 1000;\n/** Key moves closer together than this are one hold, whose step grows. */\nconst REPEAT_GAP_MS = 400;\n/** A held key's step grows by one step every this many moves... */\nconst MOVES_PER_STEP = 8;\n/** ...up to this many steps a move. */\nconst MAX_STEPS = 12;\n\n/** The keys that cancel a target: Escape, and Back as a remote sends it. */\nconst CANCEL_KEYS = ['Escape', 'GoBack', 'BrowserBack'];\nconst PAGE = 30;\nconst LIVE_WINDOW = 3;\n\n/** What the tile scales down to when the page sets no `--mbx-preview-width`. */\nconst PREVIEW_WIDTH = 160;\n\n/** The buffer goal assumed for a session that reports none. */\nconst BUFFER_GOAL = 30;\n\n/** The gap cut at a chapter boundary, in pixels. */\nconst GAP = 2;\n\nconst EVENTS = [\n 'timeupdate',\n 'progress',\n 'durationchange',\n 'loadedmetadata',\n 'seeking',\n 'seeked',\n 'emptied',\n];\n\nconst STYLE = SLIDER_STYLE + STYLE_CSS;\n\nfunction percent(part: number): string {\n return `${part * 100}%`;\n}\n\n/**\n * A mask that cuts a gap at each boundary between chapters, as stops along\n * the track: opaque up to a boundary, clear for the gap, opaque after.\n */\nfunction gaps(list: readonly Chapter[], span: Span): string {\n const stops: string[] = ['#000 0'];\n for (const chapter of list.slice(1)) {\n const at = percent(fraction(chapter.start, span));\n const before = `calc(${at} - ${GAP / 2}px)`;\n const after = `calc(${at} + ${GAP / 2}px)`;\n stops.push(`#000 ${before}`, `transparent ${before}`, `transparent ${after}`, `#000 ${after}`);\n }\n stops.push('#000 100%');\n return `linear-gradient(to right, ${stops.join(', ')})`;\n}\n\nexport class MbxSeekBar extends Component {\n static get observedAttributes(): readonly string[] {\n return [\n 'label',\n 'label-of',\n 'label-behind',\n 'live-window',\n 'chapters',\n 'scrub',\n 'preview',\n 'key-mode',\n ];\n }\n\n declare private readonly bar: Slider;\n declare private readonly buffered: HTMLElement;\n declare private readonly hover: HTMLElement;\n declare private readonly edge: HTMLElement;\n declare private readonly preview: HTMLElement;\n declare private readonly image: HTMLElement;\n declare private readonly tile: HTMLElement;\n declare private readonly time: HTMLElement;\n declare private readonly caption: HTMLElement;\n declare private readonly frameCanvas: HTMLCanvasElement;\n declare private drag: Drag;\n /** The last position of the drag, which a cancelled drag settles at. */\n declare private dragged: number | null;\n /** Whether the video played when a seeking drag began, so the release resumes it. */\n declare private resume: boolean;\n /** Frames asked for, and the newest one on screen, so a late frame never replaces a newer one. */\n declare private asked: number;\n /** Under `key-mode=\"preview\"`: where the keys aim, not yet sought to, or null. */\n declare private target: number | null;\n declare private commitTimer: number;\n /** The moves of the current hold, and when the last one came. */\n declare private moves: number;\n declare private lastMove: number;\n declare private shown: number;\n declare private range: Span;\n /** The chapters as last drawn, so the mask is written only when they change. */\n declare private divided: string;\n declare private list: Chapter[];\n declare private pending: number | null;\n declare private frame: number;\n\n constructor() {\n super();\n this.range = EMPTY;\n this.pending = null;\n this.frame = 0;\n this.divided = '';\n this.list = [];\n this.drag = 'none';\n this.dragged = null;\n this.resume = false;\n this.asked = 0;\n this.shown = 0;\n this.target = null;\n this.commitTimer = 0;\n this.moves = 0;\n this.lastMove = 0;\n const root = this.attachShadow({ mode: 'open' });\n this.bar = slider({\n step: () => this.keyStep(),\n page: () => number(this, 'page', PAGE),\n onInput: (value, key) => {\n if (key && this.previewing()) this.aim(value);\n else this.input(value);\n },\n onDrag: (on) => {\n this.toggleAttribute('dragging', on);\n if (on) this.dragStart();\n else this.dragEnd();\n },\n });\n this.buffered = el('div', 'buffered');\n this.hover = el('div', 'hover');\n this.edge = el('div', 'edge');\n this.hover.hidden = true;\n this.edge.hidden = true;\n // Under the fill, so what is played reads over what is buffered.\n this.bar.track.prepend(this.buffered);\n this.bar.track.append(this.hover, this.edge);\n this.preview = el('div', 'preview');\n this.image = el('div', 'preview-image');\n this.tile = el('div', 'preview-tile');\n this.time = el('span', 'preview-time');\n this.caption = el('span', 'preview-title');\n this.caption.hidden = true;\n this.image.append(this.tile);\n this.image.hidden = true;\n this.frameCanvas = el('canvas', 'preview-frame');\n this.frameCanvas.hidden = true;\n this.preview.append(this.frameCanvas, this.image, this.caption, this.time);\n this.preview.hidden = true;\n this.bar.root.append(this.preview);\n this.bar.root.addEventListener('pointermove', (event) => {\n this.point(event);\n });\n this.bar.root.addEventListener('pointerleave', () => {\n if (this.target === null) this.leave();\n });\n // Focus moving on: the target stands, as if the pause ran out.\n this.bar.root.addEventListener('blur', () => {\n if (this.target !== null) this.commit();\n });\n root.append(style(STYLE), this.bar.root);\n }\n\n override connectedCallback(): void {\n seekRow(this);\n super.connectedCallback();\n }\n\n private isLive(): boolean {\n return live(this.player?.engine ?? null) !== undefined;\n }\n\n /** Whether the chapters do `use`: `divided` the track, or name the preview with their `titles`. */\n private chaptered(use: 'divided' | 'titles'): boolean {\n if (this.list.length === 0) return false;\n const value = this.getAttribute('chapters');\n if (value === null) return true;\n const words = value.split(/\\s+/);\n // A value naming neither, as `on` did, keeps both.\n return (\n words.includes(use) ||\n !words.some((word) => word === 'divided' || word === 'titles' || word === 'none')\n );\n }\n\n /** The gaps at the chapter boundaries, on every layer of the track at once. */\n private paintChapters(): void {\n const mask =\n this.chaptered('divided') && this.list.length > 1 ? gaps(this.list, this.range) : '';\n const key = `${mask}|${this.range.start}|${this.range.end}`;\n if (key === this.divided) return;\n this.divided = key;\n const track = this.bar.track.style;\n // Both spellings: WebKit before 15.4 knows only the prefixed one.\n track.setProperty('mask-image', mask === '' ? '' : mask);\n track.setProperty('-webkit-mask-image', mask === '' ? '' : mask);\n }\n\n /** What a screen reader hears at a time. */\n private say(time: number): string {\n const engine = this.player?.engine ?? null;\n if (!this.isLive()) {\n const template = this.getAttribute('label-of') ?? '{current} of {duration}';\n return Number.isFinite(this.range.end) && this.range.end > 0\n ? fill(template, { current: format(time), duration: format(this.range.end) })\n : format(time);\n }\n const behind = fill(this.getAttribute('label-behind') ?? '{time} behind live', {\n time: format(this.range.end - time),\n });\n const clock = wall(engine, time);\n return clock === null ? behind : `${clock}, ${behind}`;\n }\n\n /** What the preview shows at a time. */\n private label(time: number): string {\n if (!this.isLive()) return format(time);\n return wall(this.player?.engine ?? null, time) ?? `-${format(this.range.end - time)}`;\n }\n\n /** Scrubs when the session has an I-frame track and the page allows it; seeks otherwise. */\n private dragStart(): void {\n const trick = optional(this.player?.engine ?? null).trick;\n this.dragged = null;\n // The pause below is the drag's, not the viewer's: the player says so,\n // with the state from before, which the play buttons keep showing.\n const before = this.player?.video.paused === false ? 'playing' : 'paused';\n this.player?.setAttribute('scrubbing', before);\n if (trick?.available === true && this.getAttribute('scrub') !== 'false') {\n trick.scrubStart();\n this.drag = 'scrub';\n } else {\n // Paused for the drag, the way the scrub is: the picture follows the\n // pointer, and playback waits for the release.\n const video = this.player?.video;\n this.resume = video !== undefined && !video.paused;\n video?.pause();\n this.drag = 'seek';\n }\n }\n\n /**\n * The pointer let go. A release writes its own input next, in the same\n * task, and that settles the drag. A cancelled drag writes none, so the\n * drag settles at its last position once the task is over.\n */\n private dragEnd(): void {\n queueMicrotask(() => {\n if (this.drag !== 'none') this.settle(this.dragged);\n });\n }\n\n /** Ends the drag at `value`, or where it stands when there is none. */\n private settle(value: number | null): void {\n const drag = this.drag;\n this.drag = 'none';\n this.dragged = null;\n const player = this.player;\n if (player === null) return;\n if (drag === 'scrub') {\n const trick = optional(player.engine).trick;\n if (value === null) trick?.scrubEnd();\n else trick?.scrubEnd(value);\n } else {\n if (value !== null) player.video.currentTime = value;\n if (this.resume) void player.video.play().catch(() => undefined);\n this.resume = false;\n }\n // After the play, which clears `paused` at once, so the start button\n // never shows between the release and the resume.\n player.removeAttribute('scrubbing');\n }\n\n /** Whether keys aim a target with the preview instead of seeking at once. */\n private previewing(): boolean {\n return this.getAttribute('key-mode') === 'preview';\n }\n\n /** The step for a key on the slider itself. */\n private keyStep(): number {\n const base = number(this, 'step', STEP);\n return this.previewing() ? base * this.growth() : base;\n }\n\n /**\n * How many steps a key moves the target under `key-mode=\"preview\"`. It\n * grows while the viewer holds the key, so a long film takes seconds to\n * cross, not minutes; a pause restarts it.\n */\n private growth(): number {\n const now = performance.now();\n if (now - this.lastMove > REPEAT_GAP_MS) this.moves = 0;\n this.moves += 1;\n this.lastMove = now;\n return Math.min(MAX_STEPS, 1 + Math.floor(this.moves / MOVES_PER_STEP));\n }\n\n /**\n * Aims at `value` without seeking: the thumb and the preview show it, and\n * the seek comes on Enter or once the keys pause. A TV decodes slowly, so\n * a seek per key would stutter where the preview already shows the place.\n */\n private aim(value: number): void {\n const time = Math.min(this.range.end, Math.max(this.range.start, value));\n this.target = time;\n this.bar.set(time, this.say(time));\n const span = this.range.end - this.range.start;\n if (span > 0) this.previewAt((time - this.range.start) / span);\n clearTimeout(this.commitTimer);\n this.commitTimer = window.setTimeout(() => {\n this.commit();\n }, KEY_COMMIT_MS);\n }\n\n /** Seeks to the target, if there is one. */\n private commit(): void {\n const target = this.target;\n this.stopAiming();\n const video = this.player?.video;\n if (target !== null && video !== undefined) video.currentTime = target;\n }\n\n /** Drops the target: the thumb goes back to the playhead. */\n private cancel(): void {\n this.stopAiming();\n this.render();\n }\n\n private stopAiming(): void {\n clearTimeout(this.commitTimer);\n this.commitTimer = 0;\n this.target = null;\n this.moves = 0;\n this.leave();\n }\n\n private input(value: number): void {\n const video = this.player?.video;\n if (video === undefined) return;\n this.bar.set(value, this.say(value));\n if (!this.bar.dragging()) {\n // The release, or a key: written now, and it supersedes whatever a\n // frame queued during the drag was about to write.\n this.pending = null;\n if (this.drag !== 'none') this.settle(value);\n else video.currentTime = value;\n return;\n }\n this.dragged = value;\n if (this.drag === 'scrub') {\n // The engine writes `currentTime` on every move; the browser drops a\n // seek a newer one supersedes, so no throttle is needed here.\n optional(this.player?.engine ?? null).trick?.scrubTo(value);\n return;\n }\n this.pending = value;\n if (this.frame === 0) {\n this.frame = requestAnimationFrame(() => {\n this.flush();\n });\n }\n }\n\n private flush(): void {\n this.frame = 0;\n const video = this.player?.video;\n if (this.pending === null || video === undefined) return;\n video.currentTime = this.pending;\n this.pending = null;\n }\n\n /** The width the page asked for through the token, or the default. */\n private previewWidth(): number {\n const set = Number.parseFloat(\n getComputedStyle(this.preview).getPropertyValue('--mbx-preview-width'),\n );\n return Number.isFinite(set) && set > 0 ? set : PREVIEW_WIDTH;\n }\n\n /** The preview's picture sources from `preview`, in order of preference: frames then tiles by default. */\n private sources(): Preview[] {\n const value = this.getAttribute('preview');\n if (value === 'none') return [];\n const own = (value ?? '')\n .split(/\\s+/)\n .filter((word): word is Preview => word === 'frames' || word === 'tiles');\n return own.length > 0 ? own : ['frames', 'tiles'];\n }\n\n /** `tile`, or none, drawn at its size and scaled to fit. */\n private paintTile(tile: Thumbnail | null): void {\n this.image.hidden = tile === null;\n if (tile === null) return;\n const scale = this.previewWidth() / tile.width;\n this.image.style.width = `${tile.width * scale}px`;\n this.image.style.height = `${tile.height * scale}px`;\n this.tile.style.width = `${tile.width}px`;\n this.tile.style.height = `${tile.height}px`;\n this.tile.style.backgroundImage = `url(\"${tile.url}\")`;\n this.tile.style.backgroundPosition = `-${tile.x}px -${tile.y}px`;\n this.tile.style.transform = `scale(${scale})`;\n }\n\n /**\n * The picture in the preview, from the sources `preview` names, the first\n * that answers winning. A decoded frame arrives later than a tile, so\n * while frames lead, the tile stands in until one is on screen, and the\n * last frame stays until the next one arrives. A scrub already shows the\n * position in the video, so the preview shows none meanwhile.\n */\n private paintPicture(when: number): void {\n const sources = this.drag === 'scrub' ? [] : this.sources();\n const api = optional(this.player?.engine ?? null);\n const trick = api.trick;\n // `previews` turns false once the engine knows no frame will come, such\n // as for TS I-frames; the tile shows then, without asking again.\n const frames = sources.includes('frames') && trick?.previews === true;\n const tile = sources.includes('tiles') ? (api.thumbnails?.at(when) ?? null) : null;\n if (tile !== null && (sources[0] === 'tiles' || !frames)) {\n // A frame still decoding for an earlier position must not replace it.\n this.asked += 1;\n this.shown = this.asked;\n this.frameCanvas.hidden = true;\n this.paintTile(tile);\n return;\n }\n if (!frames || trick === undefined) {\n this.frameCanvas.hidden = true;\n this.paintTile(null);\n return;\n }\n this.asked += 1;\n const request = this.asked;\n const width = this.previewWidth();\n // Null for a call a newer one replaced, and while the track's segments\n // load. What is on screen stays then.\n void trick.frameAt(when, { width: Math.round(width * devicePixelRatio) }).then(\n (bitmap) => {\n if (bitmap === null || request < this.shown || this.preview.hidden) return;\n this.shown = request;\n // The engine keeps the bitmap in its cache: drawn, never closed here.\n const canvas = this.frameCanvas;\n canvas.width = bitmap.width;\n canvas.height = bitmap.height;\n canvas.style.width = `${width}px`;\n canvas.style.height = `${(bitmap.height / bitmap.width) * width}px`;\n canvas.getContext('2d')?.drawImage(bitmap, 0, 0);\n canvas.hidden = false;\n this.image.hidden = true;\n },\n () => undefined,\n );\n if (this.frameCanvas.hidden) this.paintTile(tile);\n }\n\n private paintBuffered(video: HTMLVideoElement): void {\n const parts = clip(\n Array.from({ length: video.buffered.length }, (_, i) => ({\n start: video.buffered.start(i),\n end: video.buffered.end(i),\n })),\n this.range,\n );\n const buffered = this.buffered;\n while (buffered.childElementCount > parts.length) buffered.lastElementChild?.remove();\n while (buffered.childElementCount < parts.length) buffered.append(el('div', 'buffered-range'));\n let i = 0;\n for (const child of buffered.children) {\n const part = parts[i];\n i += 1;\n if (part === undefined) break;\n const node = child as HTMLElement;\n node.style.left = percent(part[0]);\n node.style.width = percent(part[1] - part[0]);\n }\n }\n\n /** Whether a live window is wide enough to be worth a bar. */\n private worthSeeking(): boolean {\n const goals = number(this, 'live-window', LIVE_WINDOW);\n if (goals === 0) return true;\n const goal = bufferGoal(this.player?.engine ?? null) ?? BUFFER_GOAL;\n return this.range.end - this.range.start >= goals * goal;\n }\n\n /** The hover marker and the preview follow the pointer, clamped to the bar. */\n private point(event: PointerEvent): void {\n const rect = this.bar.rail.getBoundingClientRect();\n if (rect.width === 0 || this.range.end <= this.range.start) return;\n const part = Math.min(1, Math.max(0, (event.clientX - rect.left) / rect.width));\n this.hover.hidden = false;\n this.hover.style.left = percent(part);\n this.previewAt(part);\n }\n\n /** The preview over `part` of the bar: the time, the chapter, and the picture. */\n private previewAt(part: number): void {\n const rect = this.bar.rail.getBoundingClientRect();\n if (rect.width === 0 || this.range.end <= this.range.start) return;\n this.preview.hidden = false;\n const when = at(part, this.range);\n this.time.textContent = this.label(when);\n const chapter = this.chaptered('titles') ? this.list[chapterAt(this.list, when)] : undefined;\n this.caption.hidden = chapter === undefined || chapter.title === '';\n this.caption.textContent = chapter?.title ?? '';\n this.paintPicture(when);\n const whole = this.bar.root.getBoundingClientRect();\n const half = this.preview.offsetWidth / 2;\n const x = rect.left - whole.left + part * rect.width;\n this.preview.style.left = `${Math.min(whole.width - half, Math.max(half, x))}px`;\n }\n\n private leave(): void {\n this.hover.hidden = true;\n this.preview.hidden = true;\n // The next hover starts from the tile, not a frame from elsewhere on the bar.\n this.frameCanvas.hidden = true;\n }\n\n protected override attach(player: PlayerHost): void {\n const tick = (): void => {\n this.render();\n };\n this.listen(player.video, EVENTS, tick);\n this.keep(followChapters(player, tick));\n this.listen(player, ['sourcechange'], () => {\n this.drag = 'none';\n this.stopAiming();\n this.render();\n });\n // Under `key-mode=\"preview\"`, the control bar's seeking keys aim: it\n // asks through `seekkey` before it seeks, and a taken event does not.\n this.listen(player, ['seekkey'], (event: Event) => {\n const asked = event as CustomEvent<{ readonly by: number }>;\n if (!this.previewing() || this.hidden || asked.defaultPrevented) return;\n asked.preventDefault();\n this.aim((this.target ?? player.video.currentTime) + asked.detail.by * this.growth());\n });\n // While a target stands, Enter seeks to it and Escape or Back drops it,\n // wherever focus is: on the bar, or anywhere the seeking keys came from.\n // Bubbling, so a focused control has its say first.\n this.listen(player, ['keydown'], (event: Event) => {\n const key = event as KeyboardEvent;\n if (this.target === null || key.defaultPrevented) return;\n // Enter on a button is that button's.\n if (key.key === 'Enter' && !(key.composedPath()[0] instanceof HTMLButtonElement)) {\n this.commit();\n } else if (CANCEL_KEYS.includes(key.key)) {\n this.cancel();\n } else return;\n key.preventDefault();\n });\n this.render();\n }\n\n protected override detach(player: PlayerHost): void {\n cancelAnimationFrame(this.frame);\n this.frame = 0;\n this.pending = null;\n if (this.drag !== 'none') this.settle(null);\n this.stopAiming();\n player.removeAttribute('live');\n player.removeAttribute('seekable');\n player.removeAttribute('scrubbing');\n }\n\n protected override render(): void {\n const player = this.player;\n if (player === null) return;\n const video = player.video;\n const engine = player.engine;\n const api = live(engine);\n const on = api !== undefined;\n this.range = span(video, engine);\n this.list = chapters(video, engine);\n this.bar.label(this.getAttribute('label') ?? 'Seek');\n this.bar.range(this.range.start, this.range.end);\n this.paintBuffered(video);\n this.paintChapters();\n this.edge.hidden = !on;\n if (api !== undefined && api.edge !== null) {\n this.edge.style.left = percent(fraction(api.edge, this.range));\n }\n const seekable = !on || this.worthSeeking();\n this.hidden = !seekable;\n player.toggleAttribute('live', on);\n player.toggleAttribute('seekable', seekable);\n if (!this.bar.dragging() && this.target === null) {\n this.bar.set(video.currentTime, this.say(video.currentTime));\n }\n }\n}\n"],"mappings":";;;;;;;;;;AAuEA,MAAA,YAAA;AASA,MAAA,OAAA;;AAGA,MAAA,gBAAA;;AAEA,MAAA,gBAAA;;AAEA,MAAA,iBAAA;;AAEA,MAAA,YAAA;;AAGA,MAAA,cAAA;CAAA;CAAA;CAAA;AAAA;AACA,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AA,gBAAA,MAAA;EACA,OAAA,gBAAA,UAAA;EACA,OAAA,gBAAA,WAAA;CACA;CAEA,SAAA;EACA,MAAA,SAAA,KAAA;EACA,IAAA,WAAA,MAAA;EACA,MAAA,QAAA,OAAA;EACA,MAAA,SAAA,OAAA;EACA,MAAA,MAAA,KAAA,MAAA;EACA,MAAA,KAAA,QAAA,KAAA;EACA,KAAA,QAAA,KAAA,OAAA,MAAA;EACA,KAAA,OAAA,SAAA,OAAA,MAAA;EACA,KAAA,IAAA,MAAA,KAAA,aAAA,OAAA,KAAA,MAAA;EACA,KAAA,IAAA,MAAA,KAAA,MAAA,OAAA,KAAA,MAAA,GAAA;EACA,KAAA,cAAA,KAAA;EACA,KAAA,cAAA;EACA,KAAA,KAAA,SAAA,CAAA;EACA,IAAA,QAAA,KAAA,KAAA,IAAA,SAAA,MACA,KAAA,KAAA,MAAA,OAAA,QAAA,SAAA,IAAA,MAAA,KAAA,KAAA,CAAA;EAEA,MAAA,WAAA,CAAA,MAAA,KAAA,aAAA;EACA,KAAA,SAAA,CAAA;EACA,OAAA,gBAAA,QAAA,EAAA;EACA,OAAA,gBAAA,YAAA,QAAA;EACA,IAAA,CAAA,KAAA,IAAA,SAAA,KAAA,KAAA,WAAA,MACA,KAAA,IAAA,IAAA,MAAA,aAAA,KAAA,IAAA,MAAA,WAAA,CAAA;CAEA;AACA"}
1
+ {"version":3,"file":"seek-bar.js","names":[],"sources":["../../src/elements/seek-bar.ts"],"sourcesContent":["/**\n * <mbx-seek-bar>: the bar over the slider primitive, with four layers on\n * its track, every one a part: the buffered ranges from `video.buffered`,\n * the played span, the hover position, and for live the edge from\n * `engine.live`. The span it maps is the availability window for live and\n * the duration for VOD; `controls/session.ts` says which.\n *\n * A live stream is seekable only when the window is worth it: at least\n * `live-window` forward buffer goals long, the goal read from the engine.\n * Below that the bar hides. VOD is always seekable. The element sets\n * `live` and `seekable` on the player, which the time and the live button\n * read, and `scrubbing` while a pointer holds the thumb: `playing` or\n * `paused`, the state before the drag, which the play buttons show\n * instead of the drag's own pause.\n *\n * Reads happen on the events the video already fires; the live window has\n * no event of its own and moves with the clock, so `timeupdate` covers it.\n * While a pointer holds the thumb, the played layer follows the pointer.\n * The element carries `dragging` meanwhile. With an I-frame track\n * (`engine.trick.available`), the drag scrubs: the video pauses and shows\n * the I-frame at every position, and the release seeks there. See the\n * engine guide's trick play chapter. `scrub=\"false\"` turns this off.\n * Otherwise the video pauses, `currentTime` is written at most once per\n * frame, so the bar never fights a slow seek, and the release resumes\n * playback if it was playing. Thumbnail tiles never drive a drag: they are\n * previews, not frames of the video.\n *\n * The preview above the pointer carries the time and a picture of that\n * time from the sources `preview` names, in order of preference: `frames`\n * and `tiles`, \"frames tiles\" by default, `none` for no picture. A frame\n * is the decoded I-frame from `engine.trick.frameAt`, when the track\n * decodes in this browser; the last one stays until the next arrives, so\n * the picture never flickers while the engine decodes. A tile comes from\n * `engine.thumbnails`: a rectangle of a sprite, drawn by background\n * position at the sprite's own size. Both scale to `--mbx-preview-width`,\n * so a page sets the size with one token.\n *\n * Chapters divide the track: one gap per chapter boundary, cut through\n * every layer with a mask, so the played and the buffered spans read per\n * chapter, and the preview names the chapter under the pointer. They come\n * from the session, see `controls/chapters.ts`. `chapters` lists what the\n * bar does with them: `divided` and `titles`, both by default, one of\n * them alone, or `none`.\n *\n * `step` is what an arrow key moves the playhead by and `page` what Page\n * Up and Page Down do, in seconds. `key-mode=\"preview\"`, for a TV, makes\n * the keys aim instead of seek: the thumb and the preview show the target,\n * a held key's step grows, and the seek comes on Enter, on leaving the bar,\n * or a second after the last key. Escape or Back drops the target. The\n * control bar's seeking keys, the arrows and fast forward and rewind\n * anywhere in the player, aim the same way: the bar asks through\n * `seekkey`, and the seek bar takes it. The default, `instant`, seeks on\n * every key. The name comes from `label`; what a\n * screen reader hears at a position from `label-of`, \"{current} of\n * {duration}\", and on live from `label-behind`, \"{time} behind live\". It\n * sits in the bar's seek row unless the page says otherwise.\n */\n\nimport type { Thumbnail } from 'mattebox/stages/thumbnails';\nimport type { Chapter } from '../controls/chapters.js';\nimport { chapterAt, chapters, followChapters } from '../controls/chapters.js';\nimport type { Span } from '../controls/ranges.js';\nimport { at, clip, EMPTY, fraction, spans } from '../controls/ranges.js';\nimport { bufferGoal, live, optional, span, wall } from '../controls/session.js';\nimport type { Slider } from '../controls/slider.js';\nimport { slider } from '../controls/slider.js';\nimport { format } from '../controls/time.js';\nimport { el } from '../dom.js';\nimport type { PlayerHost } from '../host.js';\nimport { fill } from '../labels.js';\nimport { Component } from './component.js';\nimport STYLE_CSS from './seek-bar.css?inline';\nimport { number, SLIDER_STYLE, seekRow, style } from './shared.js';\n\n/** What a drag does, chosen when the pointer takes the thumb. */\ntype Drag = 'none' | 'seek' | 'scrub';\n\n/** Where the preview's picture comes from: decoded I-frames, or thumbnail tiles. */\ntype Preview = 'frames' | 'tiles';\n\nconst STEP = 5;\n\n/** Under `key-mode=\"preview\"`, a target seeks this long after the last key. */\nconst KEY_COMMIT_MS = 1000;\n/** Key moves closer together than this are one hold, whose step grows. */\nconst REPEAT_GAP_MS = 400;\n/** A held key's step grows by one step every this many moves... */\nconst MOVES_PER_STEP = 8;\n/** ...up to this many steps a move. */\nconst MAX_STEPS = 12;\n\n/** The keys that cancel a target: Escape, and Back as a remote sends it. */\nconst CANCEL_KEYS = ['Escape', 'GoBack', 'BrowserBack'];\nconst PAGE = 30;\nconst LIVE_WINDOW = 3;\n\n/** What the tile scales down to when the page sets no `--mbx-preview-width`. */\nconst PREVIEW_WIDTH = 160;\n\n/** The buffer goal assumed for a session that reports none. */\nconst BUFFER_GOAL = 30;\n\n/** The gap cut at a chapter boundary, in pixels. */\nconst GAP = 2;\n\nconst EVENTS = [\n 'timeupdate',\n 'progress',\n 'durationchange',\n 'loadedmetadata',\n 'seeking',\n 'seeked',\n 'emptied',\n];\n\nconst STYLE = SLIDER_STYLE + STYLE_CSS;\n\nfunction percent(part: number): string {\n return `${part * 100}%`;\n}\n\n/**\n * A mask that cuts a gap at each chapter boundary, as stops along the\n * track: opaque up to a boundary, clear for the gap, opaque after.\n */\nfunction gaps(boundaries: readonly number[], span: Span): string {\n if (boundaries.length === 0) return '';\n const stops: string[] = ['#000 0'];\n for (const time of boundaries) {\n const at = percent(fraction(time, span));\n const before = `calc(${at} - ${GAP / 2}px)`;\n const after = `calc(${at} + ${GAP / 2}px)`;\n stops.push(`#000 ${before}`, `transparent ${before}`, `transparent ${after}`, `#000 ${after}`);\n }\n stops.push('#000 100%');\n return `linear-gradient(to right, ${stops.join(', ')})`;\n}\n\nexport class MbxSeekBar extends Component {\n static get observedAttributes(): readonly string[] {\n return [\n 'label',\n 'label-of',\n 'label-behind',\n 'label-blocked',\n 'live-window',\n 'chapters',\n 'scrub',\n 'preview',\n 'key-mode',\n ];\n }\n\n declare private readonly bar: Slider;\n declare private readonly buffered: HTMLElement;\n /** The ranges the page marked blocked, drawn as a broken line: they never play. */\n declare private readonly blocked: HTMLElement;\n declare private readonly hover: HTMLElement;\n declare private readonly edge: HTMLElement;\n declare private readonly preview: HTMLElement;\n declare private readonly image: HTMLElement;\n declare private readonly tile: HTMLElement;\n declare private readonly time: HTMLElement;\n declare private readonly caption: HTMLElement;\n declare private readonly frameCanvas: HTMLCanvasElement;\n declare private drag: Drag;\n /** The last position of the drag, which a cancelled drag settles at. */\n declare private dragged: number | null;\n /** Whether the video played when a seeking drag began, so the release resumes it. */\n declare private resume: boolean;\n /** Frames asked for, and the newest one on screen, so a late frame never replaces a newer one. */\n declare private asked: number;\n /** Under `key-mode=\"preview\"`: where the keys aim, not yet sought to, or null. */\n declare private target: number | null;\n declare private commitTimer: number;\n /** The moves of the current hold, and when the last one came. */\n declare private moves: number;\n declare private lastMove: number;\n declare private shown: number;\n declare private range: Span;\n /** The chapters as last drawn, so the mask is written only when they change. */\n declare private divided: string;\n declare private list: Chapter[];\n declare private pending: number | null;\n declare private frame: number;\n\n constructor() {\n super();\n this.range = EMPTY;\n this.pending = null;\n this.frame = 0;\n this.divided = '';\n this.list = [];\n this.drag = 'none';\n this.dragged = null;\n this.resume = false;\n this.asked = 0;\n this.shown = 0;\n this.target = null;\n this.commitTimer = 0;\n this.moves = 0;\n this.lastMove = 0;\n const root = this.attachShadow({ mode: 'open' });\n this.bar = slider({\n step: () => this.keyStep(),\n page: () => number(this, 'page', PAGE),\n onInput: (value, key) => {\n if (key && this.previewing()) this.aim(value);\n else this.input(value);\n },\n onDrag: (on) => {\n this.toggleAttribute('dragging', on);\n if (on) this.dragStart();\n else this.dragEnd();\n },\n });\n this.buffered = el('div', 'buffered');\n this.blocked = el('div', 'blocked');\n this.hover = el('div', 'hover');\n this.edge = el('div', 'edge');\n this.hover.hidden = true;\n this.edge.hidden = true;\n // Under the fill, so what is played reads over what is buffered.\n this.bar.track.prepend(this.buffered);\n // Over the fill, inside the track: the chapter gaps cut through it too.\n this.bar.track.append(this.blocked, this.hover, this.edge);\n this.preview = el('div', 'preview');\n this.image = el('div', 'preview-image');\n this.tile = el('div', 'preview-tile');\n this.time = el('span', 'preview-time');\n this.caption = el('span', 'preview-title');\n this.caption.hidden = true;\n this.image.append(this.tile);\n this.image.hidden = true;\n this.frameCanvas = el('canvas', 'preview-frame');\n this.frameCanvas.hidden = true;\n this.preview.append(this.frameCanvas, this.image, this.caption, this.time);\n this.preview.hidden = true;\n this.bar.root.append(this.preview);\n this.bar.root.addEventListener('pointermove', (event) => {\n this.point(event);\n });\n this.bar.root.addEventListener('pointerleave', () => {\n if (this.target === null) this.leave();\n });\n // Focus moving on: the target stands, as if the pause ran out.\n this.bar.root.addEventListener('blur', () => {\n if (this.target !== null) this.commit();\n });\n root.append(style(STYLE), this.bar.root);\n }\n\n override connectedCallback(): void {\n seekRow(this);\n super.connectedCallback();\n }\n\n private isLive(): boolean {\n return live(this.player?.engine ?? null) !== undefined;\n }\n\n /** Whether the chapters do `use`: `divided` the track, or name the preview with their `titles`. */\n private chaptered(use: 'divided' | 'titles'): boolean {\n if (this.list.length === 0) return false;\n const value = this.getAttribute('chapters');\n if (value === null) return true;\n const words = value.split(/\\s+/);\n // A value naming neither, as `on` did, keeps both.\n return (\n words.includes(use) ||\n !words.some((word) => word === 'divided' || word === 'titles' || word === 'none')\n );\n }\n\n /** The gaps at the chapter boundaries, on every layer of the track at once. */\n private paintChapters(): void {\n const boundaries =\n this.chaptered('divided') && this.list.length > 1\n ? this.list.slice(1).map((chapter) => chapter.start)\n : [];\n const mask = gaps(boundaries, this.range);\n const key = `${mask}|${this.range.start}|${this.range.end}`;\n if (key === this.divided) return;\n this.divided = key;\n const track = this.bar.track.style;\n // Both spellings: WebKit before 15.4 knows only the prefixed one.\n track.setProperty('mask-image', mask === '' ? '' : mask);\n track.setProperty('-webkit-mask-image', mask === '' ? '' : mask);\n }\n\n /** What a screen reader hears at a time. */\n private say(time: number): string {\n const engine = this.player?.engine ?? null;\n if (!this.isLive()) {\n const template = this.getAttribute('label-of') ?? '{current} of {duration}';\n return Number.isFinite(this.range.end) && this.range.end > 0\n ? fill(template, { current: format(time), duration: format(this.range.end) })\n : format(time);\n }\n const behind = fill(this.getAttribute('label-behind') ?? '{time} behind live', {\n time: format(this.range.end - time),\n });\n const clock = wall(engine, time);\n return clock === null ? behind : `${clock}, ${behind}`;\n }\n\n /** What the preview shows at a time. */\n private label(time: number): string {\n if (!this.isLive()) return format(time);\n return wall(this.player?.engine ?? null, time) ?? `-${format(this.range.end - time)}`;\n }\n\n /** Scrubs when the session has an I-frame track and the page allows it; seeks otherwise. */\n private dragStart(): void {\n const trick = optional(this.player?.engine ?? null).trick;\n this.dragged = null;\n // The pause below is the drag's, not the viewer's: the player says so,\n // with the state from before, which the play buttons keep showing.\n const before = this.player?.video.paused === false ? 'playing' : 'paused';\n this.player?.setAttribute('scrubbing', before);\n if (trick?.available === true && this.getAttribute('scrub') !== 'false') {\n trick.scrubStart();\n this.drag = 'scrub';\n } else {\n // Paused for the drag, the way the scrub is: the picture follows the\n // pointer, and playback waits for the release.\n const video = this.player?.video;\n this.resume = video !== undefined && !video.paused;\n video?.pause();\n this.drag = 'seek';\n }\n }\n\n /**\n * The pointer let go. A release writes its own input next, in the same\n * task, and that settles the drag. A cancelled drag writes none, so the\n * drag settles at its last position once the task is over.\n */\n private dragEnd(): void {\n queueMicrotask(() => {\n if (this.drag !== 'none') this.settle(this.dragged);\n });\n }\n\n /** Ends the drag at `value`, or where it stands when there is none. */\n private settle(value: number | null): void {\n const drag = this.drag;\n this.drag = 'none';\n this.dragged = null;\n const player = this.player;\n if (player === null) return;\n if (drag === 'scrub') {\n const trick = optional(player.engine).trick;\n if (value === null) trick?.scrubEnd();\n else trick?.scrubEnd(value);\n } else {\n if (value !== null) player.video.currentTime = value;\n if (this.resume) void player.video.play().catch(() => undefined);\n this.resume = false;\n }\n // After the play, which clears `paused` at once, so the start button\n // never shows between the release and the resume.\n player.removeAttribute('scrubbing');\n }\n\n /** Whether keys aim a target with the preview instead of seeking at once. */\n private previewing(): boolean {\n return this.getAttribute('key-mode') === 'preview';\n }\n\n /** The step for a key on the slider itself. */\n private keyStep(): number {\n const base = number(this, 'step', STEP);\n return this.previewing() ? base * this.growth() : base;\n }\n\n /**\n * How many steps a key moves the target under `key-mode=\"preview\"`. It\n * grows while the viewer holds the key, so a long film takes seconds to\n * cross, not minutes; a pause restarts it.\n */\n private growth(): number {\n const now = performance.now();\n if (now - this.lastMove > REPEAT_GAP_MS) this.moves = 0;\n this.moves += 1;\n this.lastMove = now;\n return Math.min(MAX_STEPS, 1 + Math.floor(this.moves / MOVES_PER_STEP));\n }\n\n /**\n * Aims at `value` without seeking: the thumb and the preview show it, and\n * the seek comes on Enter or once the keys pause. A TV decodes slowly, so\n * a seek per key would stutter where the preview already shows the place.\n */\n private aim(value: number): void {\n const time = Math.min(this.range.end, Math.max(this.range.start, value));\n this.target = time;\n this.bar.set(time, this.say(time));\n const span = this.range.end - this.range.start;\n if (span > 0) this.previewAt((time - this.range.start) / span);\n clearTimeout(this.commitTimer);\n this.commitTimer = window.setTimeout(() => {\n this.commit();\n }, KEY_COMMIT_MS);\n }\n\n /** Seeks to the target, if there is one. */\n private commit(): void {\n const target = this.target;\n this.stopAiming();\n const video = this.player?.video;\n if (target !== null && video !== undefined) video.currentTime = target;\n }\n\n /** Drops the target: the thumb goes back to the playhead. */\n private cancel(): void {\n this.stopAiming();\n this.render();\n }\n\n private stopAiming(): void {\n clearTimeout(this.commitTimer);\n this.commitTimer = 0;\n this.target = null;\n this.moves = 0;\n this.leave();\n }\n\n private input(value: number): void {\n const video = this.player?.video;\n if (video === undefined) return;\n this.bar.set(value, this.say(value));\n if (!this.bar.dragging()) {\n // The release, or a key: written now, and it supersedes whatever a\n // frame queued during the drag was about to write.\n this.pending = null;\n if (this.drag !== 'none') this.settle(value);\n else video.currentTime = value;\n return;\n }\n this.dragged = value;\n if (this.drag === 'scrub') {\n // The engine writes `currentTime` on every move; the browser drops a\n // seek a newer one supersedes, so no throttle is needed here.\n optional(this.player?.engine ?? null).trick?.scrubTo(value);\n return;\n }\n this.pending = value;\n if (this.frame === 0) {\n this.frame = requestAnimationFrame(() => {\n this.flush();\n });\n }\n }\n\n private flush(): void {\n this.frame = 0;\n const video = this.player?.video;\n if (this.pending === null || video === undefined) return;\n video.currentTime = this.pending;\n this.pending = null;\n }\n\n /** The width the page asked for through the token, or the default. */\n private previewWidth(): number {\n const set = Number.parseFloat(\n getComputedStyle(this.preview).getPropertyValue('--mbx-preview-width'),\n );\n return Number.isFinite(set) && set > 0 ? set : PREVIEW_WIDTH;\n }\n\n /** The preview's picture sources from `preview`, in order of preference: frames then tiles by default. */\n private sources(): Preview[] {\n const value = this.getAttribute('preview');\n if (value === 'none') return [];\n const own = (value ?? '')\n .split(/\\s+/)\n .filter((word): word is Preview => word === 'frames' || word === 'tiles');\n return own.length > 0 ? own : ['frames', 'tiles'];\n }\n\n /** `tile`, or none, drawn at its size and scaled to fit. */\n private paintTile(tile: Thumbnail | null): void {\n this.image.hidden = tile === null;\n if (tile === null) return;\n const scale = this.previewWidth() / tile.width;\n this.image.style.width = `${tile.width * scale}px`;\n this.image.style.height = `${tile.height * scale}px`;\n this.tile.style.width = `${tile.width}px`;\n this.tile.style.height = `${tile.height}px`;\n this.tile.style.backgroundImage = `url(\"${tile.url}\")`;\n this.tile.style.backgroundPosition = `-${tile.x}px -${tile.y}px`;\n this.tile.style.transform = `scale(${scale})`;\n }\n\n /**\n * The picture in the preview, from the sources `preview` names, the first\n * that answers winning. A decoded frame arrives later than a tile, so\n * while frames lead, the tile stands in until one is on screen, and the\n * last frame stays until the next one arrives. A scrub already shows the\n * position in the video, so the preview shows none meanwhile.\n */\n private paintPicture(when: number): void {\n const sources = this.drag === 'scrub' ? [] : this.sources();\n const api = optional(this.player?.engine ?? null);\n const trick = api.trick;\n // `previews` turns false once the engine knows no frame will come, such\n // as for TS I-frames; the tile shows then, without asking again.\n const frames = sources.includes('frames') && trick?.previews === true;\n const tile = sources.includes('tiles') ? (api.thumbnails?.at(when) ?? null) : null;\n if (tile !== null && (sources[0] === 'tiles' || !frames)) {\n // A frame still decoding for an earlier position must not replace it.\n this.asked += 1;\n this.shown = this.asked;\n this.frameCanvas.hidden = true;\n this.paintTile(tile);\n return;\n }\n if (!frames || trick === undefined) {\n this.frameCanvas.hidden = true;\n this.paintTile(null);\n return;\n }\n this.asked += 1;\n const request = this.asked;\n const width = this.previewWidth();\n // Null for a call a newer one replaced, and while the track's segments\n // load. What is on screen stays then.\n void trick.frameAt(when, { width: Math.round(width * devicePixelRatio) }).then(\n (bitmap) => {\n if (bitmap === null || request < this.shown || this.preview.hidden) return;\n this.shown = request;\n // The engine keeps the bitmap in its cache: drawn, never closed here.\n const canvas = this.frameCanvas;\n canvas.width = bitmap.width;\n canvas.height = bitmap.height;\n canvas.style.width = `${width}px`;\n canvas.style.height = `${(bitmap.height / bitmap.width) * width}px`;\n canvas.getContext('2d')?.drawImage(bitmap, 0, 0);\n canvas.hidden = false;\n this.image.hidden = true;\n },\n () => undefined,\n );\n if (this.frameCanvas.hidden) this.paintTile(tile);\n }\n\n /** The ranges the page marked blocked. */\n private blockedRanges(): Span[] {\n return (this.player?.markers.list ?? []).filter((marker) => marker.kind === 'blocked');\n }\n\n /** One child of `layer` per range, each named `part`, placed along the track. */\n private paintRanges(layer: HTMLElement, ranges: readonly Span[], part: string): void {\n const parts = clip(ranges, this.range);\n while (layer.childElementCount > parts.length) layer.lastElementChild?.remove();\n while (layer.childElementCount < parts.length) layer.append(el('div', part));\n let i = 0;\n for (const child of layer.children) {\n const part = parts[i];\n i += 1;\n if (part === undefined) break;\n const node = child as HTMLElement;\n node.style.left = percent(part[0]);\n node.style.width = percent(part[1] - part[0]);\n }\n }\n\n /** Whether a live window is wide enough to be worth a bar. */\n private worthSeeking(): boolean {\n const goals = number(this, 'live-window', LIVE_WINDOW);\n if (goals === 0) return true;\n const goal = bufferGoal(this.player?.engine ?? null) ?? BUFFER_GOAL;\n return this.range.end - this.range.start >= goals * goal;\n }\n\n /** The hover marker and the preview follow the pointer, clamped to the bar. */\n private point(event: PointerEvent): void {\n const rect = this.bar.rail.getBoundingClientRect();\n if (rect.width === 0 || this.range.end <= this.range.start) return;\n const part = Math.min(1, Math.max(0, (event.clientX - rect.left) / rect.width));\n this.hover.hidden = false;\n this.hover.style.left = percent(part);\n this.previewAt(part);\n }\n\n /** The preview over `part` of the bar: the time, the chapter, and the picture. */\n private previewAt(part: number): void {\n const rect = this.bar.rail.getBoundingClientRect();\n if (rect.width === 0 || this.range.end <= this.range.start) return;\n this.preview.hidden = false;\n const when = at(part, this.range);\n this.time.textContent = this.label(when);\n const chapter = this.chaptered('titles') ? this.list[chapterAt(this.list, when)] : undefined;\n // A blocked range shows no picture: its frames must not play, and a\n // preview would show them.\n const blocked = this.player?.markers.within(when).find((marker) => marker.kind === 'blocked');\n const title = blocked\n ? (blocked.label ?? this.getAttribute('label-blocked') ?? 'Not available')\n : (chapter?.title ?? '');\n this.caption.hidden = title === '';\n this.caption.textContent = title;\n if (blocked) {\n this.image.hidden = true;\n this.frameCanvas.hidden = true;\n } else this.paintPicture(when);\n const whole = this.bar.root.getBoundingClientRect();\n const half = this.preview.offsetWidth / 2;\n const x = rect.left - whole.left + part * rect.width;\n this.preview.style.left = `${Math.min(whole.width - half, Math.max(half, x))}px`;\n }\n\n private leave(): void {\n this.hover.hidden = true;\n this.preview.hidden = true;\n // The next hover starts from the tile, not a frame from elsewhere on the bar.\n this.frameCanvas.hidden = true;\n }\n\n protected override attach(player: PlayerHost): void {\n const tick = (): void => {\n this.render();\n };\n this.listen(player.video, EVENTS, tick);\n this.keep(followChapters(player, tick));\n this.listen(player, ['markerschange'], tick);\n this.listen(player, ['sourcechange'], () => {\n this.drag = 'none';\n this.stopAiming();\n this.render();\n });\n // Under `key-mode=\"preview\"`, the control bar's seeking keys aim: it\n // asks through `seekkey` before it seeks, and a taken event does not.\n this.listen(player, ['seekkey'], (event: Event) => {\n const asked = event as CustomEvent<{ readonly by: number }>;\n if (!this.previewing() || this.hidden || asked.defaultPrevented) return;\n asked.preventDefault();\n this.aim((this.target ?? player.video.currentTime) + asked.detail.by * this.growth());\n });\n // While a target stands, Enter seeks to it and Escape or Back drops it,\n // wherever focus is: on the bar, or anywhere the seeking keys came from.\n // Bubbling, so a focused control has its say first.\n this.listen(player, ['keydown'], (event: Event) => {\n const key = event as KeyboardEvent;\n if (this.target === null || key.defaultPrevented) return;\n // Enter on a button is that button's.\n if (key.key === 'Enter' && !(key.composedPath()[0] instanceof HTMLButtonElement)) {\n this.commit();\n } else if (CANCEL_KEYS.includes(key.key)) {\n this.cancel();\n } else return;\n key.preventDefault();\n });\n this.render();\n }\n\n protected override detach(player: PlayerHost): void {\n cancelAnimationFrame(this.frame);\n this.frame = 0;\n this.pending = null;\n if (this.drag !== 'none') this.settle(null);\n this.stopAiming();\n player.removeAttribute('live');\n player.removeAttribute('seekable');\n player.removeAttribute('scrubbing');\n }\n\n protected override render(): void {\n const player = this.player;\n if (player === null) return;\n const video = player.video;\n const engine = player.engine;\n const api = live(engine);\n const on = api !== undefined;\n this.range = span(video, engine);\n this.list = chapters(video, engine);\n this.bar.label(this.getAttribute('label') ?? 'Seek');\n this.bar.range(this.range.start, this.range.end);\n this.paintRanges(this.buffered, spans(video.buffered), 'buffered-range');\n this.paintRanges(this.blocked, this.blockedRanges(), 'blocked-range');\n this.paintChapters();\n this.edge.hidden = !on;\n if (api !== undefined && api.edge !== null) {\n this.edge.style.left = percent(fraction(api.edge, this.range));\n }\n const seekable = !on || this.worthSeeking();\n this.hidden = !seekable;\n player.toggleAttribute('live', on);\n player.toggleAttribute('seekable', seekable);\n if (!this.bar.dragging() && this.target === null) {\n this.bar.set(video.currentTime, this.say(video.currentTime));\n }\n }\n}\n"],"mappings":";;;;;;;;;;AAuEA,MAAA,YAAA;AASA,MAAA,OAAA;;AAGA,MAAA,gBAAA;;AAEA,MAAA,gBAAA;;AAEA,MAAA,iBAAA;;AAEA,MAAA,YAAA;;AAGA,MAAA,cAAA;CAAA;CAAA;CAAA;AAAA;AACA,MAAA,OAAA;AACA,MAAA,cAAA;;AAGA,MAAA,gBAAA;;AAGA,MAAA,cAAA;;AAGA,MAAA,MAAA;AAEA,MAAA,SAAA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACA;AAEA,MAAA,QAAA,eAAA;AAEA,SAAA,QAAA,MAAA;CACA,OAAA,GAAA,OAAA,IAAA;AACA;;;;;AAMA,SAAA,KAAA,YAAA,MAAA;CACA,IAAA,WAAA,WAAA,GAAA,OAAA;CACA,MAAA,QAAA,CAAA,QAAA;CACA,KAAA,MAAA,QAAA,YAAA;EACA,MAAA,KAAA,QAAA,SAAA,MAAA,IAAA,CAAA;EACA,MAAA,SAAA,QAAA,GAAA,KAAA,MAAA,EAAA;EACA,MAAA,QAAA,QAAA,GAAA,KAAA,MAAA,EAAA;EACA,MAAA,KAAA,QAAA,UAAA,eAAA,UAAA,eAAA,SAAA,QAAA,OAAA;CACA;CACA,MAAA,KAAA,WAAA;CACA,OAAA,6BAAA,MAAA,KAAA,IAAA,EAAA;AACA;AAEA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,MAAA,KAAA,aAAA,OAAA,KAAA,MAAA;EACA,KAAA,IAAA,MAAA,KAAA,MAAA,OAAA,KAAA,MAAA,GAAA;EACA,KAAA,YAAA,KAAA,UAAA,MAAA,MAAA,QAAA,GAAA,gBAAA;EACA,KAAA,YAAA,KAAA,SAAA,KAAA,cAAA,GAAA,eAAA;EACA,KAAA,cAAA;EACA,KAAA,KAAA,SAAA,CAAA;EACA,IAAA,QAAA,KAAA,KAAA,IAAA,SAAA,MACA,KAAA,KAAA,MAAA,OAAA,QAAA,SAAA,IAAA,MAAA,KAAA,KAAA,CAAA;EAEA,MAAA,WAAA,CAAA,MAAA,KAAA,aAAA;EACA,KAAA,SAAA,CAAA;EACA,OAAA,gBAAA,QAAA,EAAA;EACA,OAAA,gBAAA,YAAA,QAAA;EACA,IAAA,CAAA,KAAA,IAAA,SAAA,KAAA,KAAA,WAAA,MACA,KAAA,IAAA,IAAA,MAAA,aAAA,KAAA,IAAA,MAAA,WAAA,CAAA;CAEA;AACA"}
@@ -19,7 +19,7 @@ function number(node, name, fallback) {
19
19
  return Number.isFinite(value) && value >= 0 ? value : fallback;
20
20
  }
21
21
  /** The style of a menu: the button from BUTTON_STYLE, and the popup above it with its items. */
22
- const MENU_STYLE = ":host{display:inline-flex}:host([hidden]){display:none}[part~=button]{width:40px;height:40px;font:inherit;color:inherit;border-radius:var(--mbx-radius);cursor:pointer;opacity:.9;background:0 0;border:0;flex:none;justify-content:center;align-items:center;padding:0;display:inline-flex}[part~=button]:hover{opacity:1}[part~=button]:focus{outline:2px solid var(--mbx-accent);outline-offset:-2px}[part~=button]:focus:not(:focus-visible){outline:none}[part~=icon],::slotted(*){fill:currentColor;width:1.75em;height:1.75em}slot[hidden]{display:none}:host{position:relative}[part~=popup]{overscroll-behavior:contain;border-radius:var(--mbx-radius);background:#101114f2;flex-direction:column;min-width:160px;margin-bottom:8px;padding:6px;font-size:14px;display:flex;position:absolute;bottom:100%;right:0;overflow-y:auto;box-shadow:0 4px 16px #00000080}[part~=popup][hidden]{display:none}[part~=section]{flex-direction:column;display:flex}[part~=section]+[part~=section]{border-top:1px solid #ffffff1f;margin-top:6px;padding-top:6px}[part~=section-label]{letter-spacing:.06em;text-transform:uppercase;color:var(--mbx-muted);padding:4px 12px 2px;font-size:11px;font-weight:600}[part~=item]{width:100%;font:inherit;color:inherit;text-align:left;white-space:nowrap;border-radius:var(--mbx-radius);cursor:pointer;background:0 0;border:0;align-items:center;padding:8px 12px 8px 28px;display:flex}[part~=item]:hover{background:#ffffff1f}[part~=item-text]{text-overflow:ellipsis;min-width:0;overflow:hidden}[part~=item-image]{object-fit:cover;background:#ffffff14;border-radius:2px;flex:none;width:64px;height:36px;margin-right:12px}[part~=item-detail]{color:var(--mbx-muted);font-variant-numeric:tabular-nums;margin-left:auto;padding-left:12px}[part~=item]:focus{outline:2px solid var(--mbx-accent);outline-offset:-2px}[part~=item]:focus:not(:focus-visible){outline:none}[part~=page-item]{padding-right:28px;position:relative}[part~=page-item]:after{content:\"\";opacity:.7;border:1.5px solid;border-width:1.5px 1.5px 0 0;width:7px;height:7px;margin-top:-4px;position:absolute;top:50%;right:12px;transform:rotate(45deg)}[part~=back-item]{border-bottom:1px solid #ffffff1f;border-radius:0;margin-bottom:6px;font-weight:600;position:relative}[part~=back-item]:before{content:\"\";opacity:.7;border:0 solid;border-width:1.5px 0 0 1.5px;width:7px;height:7px;margin-top:-4px;position:absolute;top:50%;left:12px;transform:rotate(-45deg)}[part~=checked]{position:relative}[part~=checked]:before{content:\"\";background:var(--mbx-accent);border-radius:50%;width:6px;height:6px;margin-top:-3px;position:absolute;top:50%;left:12px}";
22
+ const MENU_STYLE = ":host{display:inline-flex}:host([hidden]){display:none}[part~=button]{width:40px;height:40px;font:inherit;color:inherit;border-radius:var(--mbx-radius);cursor:pointer;opacity:.9;background:0 0;border:0;flex:none;justify-content:center;align-items:center;padding:0;display:inline-flex}[part~=button]:hover{opacity:1}[part~=button]:focus{outline:2px solid var(--mbx-accent);outline-offset:-2px}[part~=button]:focus:not(:focus-visible){outline:none}[part~=icon],::slotted(*){fill:currentColor;width:1.75em;height:1.75em}slot[hidden]{display:none}:host{position:relative}[part~=popup]{box-sizing:border-box;overscroll-behavior:contain;border-radius:var(--mbx-radius);background:#101114f2;flex-direction:column;min-width:160px;margin-bottom:8px;padding:6px;font-size:14px;display:flex;position:absolute;bottom:100%;right:0;overflow-y:auto;box-shadow:0 4px 16px #00000080}[part~=popup][hidden]{display:none}[part~=popup][more]{-webkit-mask-image:linear-gradient(#000 calc(100% - 24px),#0000);mask-image:linear-gradient(#000 calc(100% - 24px),#0000)}[part~=section]{flex-direction:column;display:flex}[part~=section]+[part~=section]{border-top:1px solid #ffffff1f;margin-top:6px;padding-top:6px}[part~=section-label]{letter-spacing:.06em;text-transform:uppercase;color:var(--mbx-muted);padding:4px 12px 2px;font-size:11px;font-weight:600}[part~=item]{width:100%;font:inherit;color:inherit;text-align:left;white-space:nowrap;border-radius:var(--mbx-radius);cursor:pointer;background:0 0;border:0;align-items:center;padding:8px 12px 8px 28px;display:flex}[part~=item]:hover{background:#ffffff1f}[part~=item-text]{text-overflow:ellipsis;min-width:0;overflow:hidden}[part~=item-image]{object-fit:cover;background:#ffffff14;border-radius:2px;flex:none;width:64px;height:36px;margin-right:12px}[part~=item-badge]{border:1px solid;border-radius:2px;flex:none;margin-left:8px;padding:0 4px;font-size:.75em;font-weight:600;line-height:1.5}[part~=item-detail]{color:var(--mbx-muted);font-variant-numeric:tabular-nums;margin-left:auto;padding-left:12px}[part~=item]:focus{outline:2px solid var(--mbx-accent);outline-offset:-2px}[part~=item]:focus:not(:focus-visible){outline:none}[part~=page-item]{padding-right:28px;position:relative}[part~=page-item]:after{content:\"\";opacity:.7;border:1.5px solid;border-width:1.5px 1.5px 0 0;width:7px;height:7px;margin-top:-4px;position:absolute;top:50%;right:12px;transform:rotate(45deg)}[part~=back-item]{border-bottom:1px solid #ffffff1f;border-radius:0;margin-bottom:6px;font-weight:600;position:relative}[part~=back-item]:before{content:\"\";opacity:.7;border:0 solid;border-width:1.5px 0 0 1.5px;width:7px;height:7px;margin-top:-4px;position:absolute;top:50%;left:12px;transform:rotate(-45deg)}[part~=checked]{position:relative}[part~=checked]:before{content:\"\";background:var(--mbx-accent);border-radius:50%;width:6px;height:6px;margin-top:-3px;position:absolute;top:50%;left:12px}";
23
23
  /** Puts a control in the bar's seek row when it is in a bar, unless the page wrote a `slot` of its own. */
24
24
  function seekRow(node) {
25
25
  if (node.parentElement?.localName === "mbx-control-bar" && !node.hasAttribute("slot")) node.slot = "seek";
@@ -11,6 +11,8 @@ export declare class MbxSubtitlesMenu extends MenuElement<State> {
11
11
  /** A look's group: the choices named from the attributes, the value from the player's. */
12
12
  private looks;
13
13
  protected attach(player: PlayerHost): void;
14
+ /** The native session's subtitle tracks as entries, and the showing one's. */
15
+ private native;
14
16
  protected render(): void;
15
17
  }
16
18
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"subtitles-menu.d.ts","sourceRoot":"","sources":["../../src/elements/subtitles-menu.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAIhD,eAAO,MAAM,aAAa,kBAAkB,CAAC;AAC7C,eAAO,MAAM,mBAAmB,wBAAwB,CAAC;AAczD,KAAK,KAAK,GAAG,KAAK,GAAG,IAAI,CAAC;AAG1B,qBAAa,gBAAiB,SAAQ,WAAW,CAAC,KAAK,CAAC;IACtD,MAAM,KAAK,kBAAkB,IAAI,SAAS,MAAM,EAAE,CAYjD;IAED,QAAgB,MAAM,CAAkB;;cAQrB,IAAI,IAAI,MAAM;IAIjC,0FAA0F;IAC1F,OAAO,CAAC,KAAK;cAsBM,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;cAWhC,MAAM,IAAI,IAAI;CAqClC"}
1
+ {"version":3,"file":"subtitles-menu.d.ts","sourceRoot":"","sources":["../../src/elements/subtitles-menu.ts"],"names":[],"mappings":"AA+BA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAIhD,eAAO,MAAM,aAAa,kBAAkB,CAAC;AAC7C,eAAO,MAAM,mBAAmB,wBAAwB,CAAC;AAczD,KAAK,KAAK,GAAG,KAAK,GAAG,IAAI,CAAC;AAG1B,qBAAa,gBAAiB,SAAQ,WAAW,CAAC,KAAK,CAAC;IACtD,MAAM,KAAK,kBAAkB,IAAI,SAAS,MAAM,EAAE,CAcjD;IAED,QAAgB,MAAM,CAAkB;;cAQrB,IAAI,IAAI,MAAM;IAIjC,0FAA0F;IAC1F,OAAO,CAAC,KAAK;cAsBM,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;IAanD,8EAA8E;IAC9E,OAAO,CAAC,MAAM;cAeK,MAAM,IAAI,IAAI;CA8DlC"}
@@ -1,7 +1,10 @@
1
1
  import { icon } from "../controls/icons.js";
2
2
  import { show } from "./shared.js";
3
+ import { nativeTracks, onNativeTracks } from "../controls/native-tracks.js";
4
+ import { trackNames } from "../controls/track-names.js";
3
5
  import { MenuElement } from "./menu-element.js";
4
6
  import { onTracks, trackItems } from "./audio-menu.js";
7
+ import { isSdh } from "mattebox";
5
8
  //#region src/elements/subtitles-menu.ts
6
9
  const OFF = "off";
7
10
  const SUBTITLE_SIZE = "subtitle-size";
@@ -28,6 +31,8 @@ var MbxSubtitlesMenu = class extends MenuElement {
28
31
  "label-settings",
29
32
  "label-size",
30
33
  "label-background",
34
+ "label-sdh",
35
+ "label-cc",
31
36
  ...SIZES.map(([id]) => `label-${id}`),
32
37
  ...BACKGROUNDS.map(([id]) => `label-${id}`)
33
38
  ];
@@ -59,30 +64,49 @@ var MbxSubtitlesMenu = class extends MenuElement {
59
64
  this.follow(player, (engine) => {
60
65
  this.engine = engine;
61
66
  this.render();
62
- if (engine === null) return void 0;
63
- return onTracks(engine, () => {
67
+ const tick = () => {
64
68
  this.render();
65
- });
69
+ };
70
+ return engine === null ? onNativeTracks(player.video, "textTracks", tick) : onTracks(engine, tick);
66
71
  });
67
72
  }
73
+ /** The native session's subtitle tracks as entries, and the showing one's. */
74
+ native(tracks) {
75
+ const sdh = this.getAttribute("label-sdh") ?? "SDH";
76
+ const entries = tracks.map((track, index) => [
77
+ String(index),
78
+ track.label,
79
+ track.language,
80
+ track.kind === "captions" ? [sdh] : [],
81
+ []
82
+ ]);
83
+ const on = tracks.findIndex((track) => track.mode === "showing");
84
+ return [entries, on === -1 ? null : String(on)];
85
+ }
68
86
  render() {
69
87
  super.render();
70
88
  const engine = this.engine;
71
89
  const player = this.player;
72
- if (engine === null || player === null) {
90
+ const listed = engine === null && player !== null ? nativeTracks(player, "textTracks")?.filter((track) => track.kind === "subtitles" || track.kind === "captions") : void 0;
91
+ if (player === null || engine === null && listed === void 0) {
73
92
  this.hidden = true;
74
93
  return;
75
94
  }
76
- const [tracks, active] = trackItems(engine, "text");
77
- const items = [[OFF, this.getAttribute("label-off") ?? "Off"], ...tracks];
95
+ const [tracks, active] = listed !== void 0 ? this.native(listed) : trackItems(engine, "text", (track) => [...track.instreamId !== void 0 ? [this.getAttribute("label-cc") ?? "CC"] : [], ...isSdh(track) ? [this.getAttribute("label-sdh") ?? "SDH"] : []], (track) => track.forced !== true);
96
+ const word = this.getAttribute("label-track");
97
+ const items = [[OFF, this.getAttribute("label-off") ?? "Off"], ...trackNames(tracks, word)];
78
98
  this.menu.fill([{
79
99
  name: "track",
80
- label: this.getAttribute("label-track") ?? "Track",
100
+ label: word ?? "Track",
81
101
  items,
82
102
  value: active ?? OFF,
83
103
  onSelect: (value) => {
84
- if (value === OFF) engine.tracks.deselect("text");
85
- else engine.tracks.select(value);
104
+ if (listed !== void 0) {
105
+ for (const track of listed) track.mode = "disabled";
106
+ const chosen = listed[Number(value)];
107
+ if (chosen !== void 0) chosen.mode = "showing";
108
+ } else if (value === OFF) engine?.tracks.deselect("text");
109
+ else engine?.tracks.select(value);
86
110
  this.render();
87
111
  }
88
112
  }, {