@mattebox/player 0.6.0 → 0.7.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 (241) hide show
  1. package/dist/cdn/mattebox-player.min.js +3 -435
  2. package/dist/controls/airplay.js +28 -44
  3. package/dist/controls/airplay.js.map +1 -1
  4. package/dist/controls/chapters.d.ts +22 -11
  5. package/dist/controls/chapters.d.ts.map +1 -1
  6. package/dist/controls/chapters.js +87 -73
  7. package/dist/controls/chapters.js.map +1 -1
  8. package/dist/controls/cues.d.ts +0 -22
  9. package/dist/controls/cues.d.ts.map +1 -1
  10. package/dist/controls/cues.js +161 -191
  11. package/dist/controls/cues.js.map +1 -1
  12. package/dist/controls/fullscreen.js +52 -70
  13. package/dist/controls/fullscreen.js.map +1 -1
  14. package/dist/controls/icons.d.ts +1 -1
  15. package/dist/controls/icons.d.ts.map +1 -1
  16. package/dist/controls/icons.js +46 -70
  17. package/dist/controls/icons.js.map +1 -1
  18. package/dist/controls/menu.d.ts +7 -4
  19. package/dist/controls/menu.d.ts.map +1 -1
  20. package/dist/controls/menu.js +241 -223
  21. package/dist/controls/menu.js.map +1 -1
  22. package/dist/controls/pip.js +35 -49
  23. package/dist/controls/pip.js.map +1 -1
  24. package/dist/controls/ranges.js +42 -37
  25. package/dist/controls/ranges.js.map +1 -1
  26. package/dist/controls/session.d.ts +6 -1
  27. package/dist/controls/session.d.ts.map +1 -1
  28. package/dist/controls/session.js +41 -26
  29. package/dist/controls/session.js.map +1 -1
  30. package/dist/controls/slider.d.ts +2 -2
  31. package/dist/controls/slider.d.ts.map +1 -1
  32. package/dist/controls/slider.js +151 -159
  33. package/dist/controls/slider.js.map +1 -1
  34. package/dist/controls/time.js +17 -17
  35. package/dist/controls/time.js.map +1 -1
  36. package/dist/dom.d.ts +6 -0
  37. package/dist/dom.d.ts.map +1 -1
  38. package/dist/dom.js +28 -19
  39. package/dist/dom.js.map +1 -1
  40. package/dist/element-entry.js +9 -6
  41. package/dist/element-entry.js.map +1 -1
  42. package/dist/element.d.ts +4 -2
  43. package/dist/element.d.ts.map +1 -1
  44. package/dist/element.js +384 -443
  45. package/dist/element.js.map +1 -1
  46. package/dist/elements/airplay-button.js +51 -53
  47. package/dist/elements/airplay-button.js.map +1 -1
  48. package/dist/elements/audio-menu.js +62 -63
  49. package/dist/elements/audio-menu.js.map +1 -1
  50. package/dist/elements/chapters-menu.d.ts.map +1 -1
  51. package/dist/elements/chapters-menu.js +75 -65
  52. package/dist/elements/chapters-menu.js.map +1 -1
  53. package/dist/elements/component.d.ts +1 -1
  54. package/dist/elements/component.d.ts.map +1 -1
  55. package/dist/elements/component.js +86 -89
  56. package/dist/elements/component.js.map +1 -1
  57. package/dist/elements/control-bar.d.ts +18 -5
  58. package/dist/elements/control-bar.d.ts.map +1 -1
  59. package/dist/elements/control-bar.js +282 -319
  60. package/dist/elements/control-bar.js.map +1 -1
  61. package/dist/elements/current-time.js +26 -25
  62. package/dist/elements/current-time.js.map +1 -1
  63. package/dist/elements/drm-badge.d.ts.map +1 -1
  64. package/dist/elements/drm-badge.js +107 -141
  65. package/dist/elements/drm-badge.js.map +1 -1
  66. package/dist/elements/duration.d.ts.map +1 -1
  67. package/dist/elements/duration.js +24 -21
  68. package/dist/elements/duration.js.map +1 -1
  69. package/dist/elements/error-screen.d.ts.map +1 -1
  70. package/dist/elements/error-screen.js +68 -102
  71. package/dist/elements/error-screen.js.map +1 -1
  72. package/dist/elements/fullscreen-button.js +48 -54
  73. package/dist/elements/fullscreen-button.js.map +1 -1
  74. package/dist/elements/live-button.d.ts.map +1 -1
  75. package/dist/elements/live-button.js +67 -94
  76. package/dist/elements/live-button.js.map +1 -1
  77. package/dist/elements/menu-element.js +31 -28
  78. package/dist/elements/menu-element.js.map +1 -1
  79. package/dist/elements/mute-button.js +58 -59
  80. package/dist/elements/mute-button.js.map +1 -1
  81. package/dist/elements/pip-button.js +54 -54
  82. package/dist/elements/pip-button.js.map +1 -1
  83. package/dist/elements/play-button.d.ts.map +1 -1
  84. package/dist/elements/play-button.js +73 -58
  85. package/dist/elements/play-button.js.map +1 -1
  86. package/dist/elements/quality-menu.js +66 -69
  87. package/dist/elements/quality-menu.js.map +1 -1
  88. package/dist/elements/remaining-time.d.ts.map +1 -1
  89. package/dist/elements/remaining-time.js +27 -24
  90. package/dist/elements/remaining-time.js.map +1 -1
  91. package/dist/elements/scan-button.d.ts +17 -0
  92. package/dist/elements/scan-button.d.ts.map +1 -0
  93. package/dist/elements/scan-button.js +117 -0
  94. package/dist/elements/scan-button.js.map +1 -0
  95. package/dist/elements/seek-bar.d.ts +93 -14
  96. package/dist/elements/seek-bar.d.ts.map +1 -1
  97. package/dist/elements/seek-bar.js +475 -335
  98. package/dist/elements/seek-bar.js.map +1 -1
  99. package/dist/elements/shared.d.ts +3 -11
  100. package/dist/elements/shared.d.ts.map +1 -1
  101. package/dist/elements/shared.js +44 -144
  102. package/dist/elements/shared.js.map +1 -1
  103. package/dist/elements/skip-button.d.ts.map +1 -1
  104. package/dist/elements/skip-button.js +54 -55
  105. package/dist/elements/skip-button.js.map +1 -1
  106. package/dist/elements/spacer.d.ts.map +1 -1
  107. package/dist/elements/spacer.js +12 -7
  108. package/dist/elements/spacer.js.map +1 -1
  109. package/dist/elements/speed-menu.js +60 -55
  110. package/dist/elements/speed-menu.js.map +1 -1
  111. package/dist/elements/spinner.d.ts.map +1 -1
  112. package/dist/elements/spinner.js +52 -78
  113. package/dist/elements/spinner.js.map +1 -1
  114. package/dist/elements/start-button.d.ts.map +1 -1
  115. package/dist/elements/start-button.js +107 -120
  116. package/dist/elements/start-button.js.map +1 -1
  117. package/dist/elements/subtitles-menu.js +95 -103
  118. package/dist/elements/subtitles-menu.js.map +1 -1
  119. package/dist/elements/time-element.d.ts.map +1 -1
  120. package/dist/elements/time-element.js +36 -28
  121. package/dist/elements/time-element.js.map +1 -1
  122. package/dist/elements/title.d.ts.map +1 -1
  123. package/dist/elements/title.js +105 -137
  124. package/dist/elements/title.js.map +1 -1
  125. package/dist/elements/volume-slider.d.ts.map +1 -1
  126. package/dist/elements/volume-slider.js +47 -45
  127. package/dist/elements/volume-slider.js.map +1 -1
  128. package/dist/elements/volume.d.ts.map +1 -1
  129. package/dist/elements/volume.js +42 -50
  130. package/dist/elements/volume.js.map +1 -1
  131. package/dist/entries/airplay-button.js +7 -7
  132. package/dist/entries/airplay-button.js.map +1 -1
  133. package/dist/entries/audio-menu.js +7 -6
  134. package/dist/entries/audio-menu.js.map +1 -1
  135. package/dist/entries/chapters-menu.js +7 -7
  136. package/dist/entries/chapters-menu.js.map +1 -1
  137. package/dist/entries/control-bar.js +7 -6
  138. package/dist/entries/control-bar.js.map +1 -1
  139. package/dist/entries/current-time.js +7 -6
  140. package/dist/entries/current-time.js.map +1 -1
  141. package/dist/entries/drm-badge.js +7 -6
  142. package/dist/entries/drm-badge.js.map +1 -1
  143. package/dist/entries/duration.js +7 -6
  144. package/dist/entries/duration.js.map +1 -1
  145. package/dist/entries/error-screen.js +7 -6
  146. package/dist/entries/error-screen.js.map +1 -1
  147. package/dist/entries/fullscreen-button.js +7 -6
  148. package/dist/entries/fullscreen-button.js.map +1 -1
  149. package/dist/entries/live-button.js +7 -6
  150. package/dist/entries/live-button.js.map +1 -1
  151. package/dist/entries/mute-button.js +7 -6
  152. package/dist/entries/mute-button.js.map +1 -1
  153. package/dist/entries/pip-button.js +7 -6
  154. package/dist/entries/pip-button.js.map +1 -1
  155. package/dist/entries/play-button.js +7 -6
  156. package/dist/entries/play-button.js.map +1 -1
  157. package/dist/entries/quality-menu.js +7 -6
  158. package/dist/entries/quality-menu.js.map +1 -1
  159. package/dist/entries/remaining-time.js +7 -7
  160. package/dist/entries/remaining-time.js.map +1 -1
  161. package/dist/entries/scan-button.d.ts +5 -0
  162. package/dist/entries/scan-button.d.ts.map +1 -0
  163. package/dist/entries/scan-button.js +9 -0
  164. package/dist/entries/scan-button.js.map +1 -0
  165. package/dist/entries/seek-bar.js +7 -6
  166. package/dist/entries/seek-bar.js.map +1 -1
  167. package/dist/entries/skip-button.js +7 -6
  168. package/dist/entries/skip-button.js.map +1 -1
  169. package/dist/entries/spacer.js +7 -6
  170. package/dist/entries/spacer.js.map +1 -1
  171. package/dist/entries/speed-menu.js +7 -6
  172. package/dist/entries/speed-menu.js.map +1 -1
  173. package/dist/entries/spinner.js +7 -7
  174. package/dist/entries/spinner.js.map +1 -1
  175. package/dist/entries/start-button.js +7 -6
  176. package/dist/entries/start-button.js.map +1 -1
  177. package/dist/entries/subtitles-menu.js +7 -6
  178. package/dist/entries/subtitles-menu.js.map +1 -1
  179. package/dist/entries/title.js +7 -7
  180. package/dist/entries/title.js.map +1 -1
  181. package/dist/entries/volume-slider.js +7 -6
  182. package/dist/entries/volume-slider.js.map +1 -1
  183. package/dist/entries/volume.js +9 -8
  184. package/dist/entries/volume.js.map +1 -1
  185. package/dist/es2015/controls/chapters.js +40 -7
  186. package/dist/es2015/controls/cues.js +1 -8
  187. package/dist/es2015/controls/icons.js +3 -1
  188. package/dist/es2015/controls/menu.js +27 -8
  189. package/dist/es2015/controls/session.js +16 -4
  190. package/dist/es2015/controls/slider.js +5 -4
  191. package/dist/es2015/dom.js +10 -1
  192. package/dist/es2015/element.js +23 -7
  193. package/dist/es2015/elements/chapters-menu.js +18 -10
  194. package/dist/es2015/elements/control-bar.js +41 -35
  195. package/dist/es2015/elements/drm-badge.js +1 -25
  196. package/dist/es2015/elements/duration.js +2 -1
  197. package/dist/es2015/elements/error-screen.js +1 -30
  198. package/dist/es2015/elements/live-button.js +1 -29
  199. package/dist/es2015/elements/menu-element.js +2 -2
  200. package/dist/es2015/elements/play-button.js +10 -3
  201. package/dist/es2015/elements/remaining-time.js +2 -1
  202. package/dist/es2015/elements/scan-button.js +118 -0
  203. package/dist/es2015/elements/seek-bar.js +264 -71
  204. package/dist/es2015/elements/shared.js +5 -106
  205. package/dist/es2015/elements/skip-button.js +2 -1
  206. package/dist/es2015/elements/spacer.js +2 -1
  207. package/dist/es2015/elements/spinner.js +1 -32
  208. package/dist/es2015/elements/start-button.js +8 -26
  209. package/dist/es2015/elements/time-element.js +1 -4
  210. package/dist/es2015/elements/title.js +1 -45
  211. package/dist/es2015/elements/volume-slider.js +2 -1
  212. package/dist/es2015/elements/volume.js +1 -11
  213. package/dist/es2015/entries/scan-button.js +7 -0
  214. package/dist/es2015/index.js +3 -1
  215. package/dist/es2015/style.js +1 -101
  216. package/dist/es2015/tags.js +2 -1
  217. package/dist/host.js +19 -17
  218. package/dist/host.js.map +1 -1
  219. package/dist/index.d.ts +3 -0
  220. package/dist/index.d.ts.map +1 -1
  221. package/dist/index.js +55 -27
  222. package/dist/labels.js +13 -9
  223. package/dist/labels.js.map +1 -1
  224. package/dist/namespaces.d.ts +9 -26
  225. package/dist/namespaces.d.ts.map +1 -1
  226. package/dist/namespaces.js +6 -2
  227. package/dist/namespaces.js.map +1 -1
  228. package/dist/presets.js +33 -28
  229. package/dist/presets.js.map +1 -1
  230. package/dist/style.d.ts +1 -20
  231. package/dist/style.d.ts.map +1 -1
  232. package/dist/style.js +4 -100
  233. package/dist/style.js.map +1 -1
  234. package/dist/surface.js +25 -21
  235. package/dist/surface.js.map +1 -1
  236. package/dist/tags.d.ts +1 -0
  237. package/dist/tags.d.ts.map +1 -1
  238. package/dist/tags.js +31 -26
  239. package/dist/tags.js.map +1 -1
  240. package/package.json +4 -4
  241. package/dist/index.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"menu-element.js","sourceRoot":"","sources":["../../src/elements/menu-element.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAE5C,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,aAAa,C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,IAAI,CAAC,CAAC,CAAC;AACzC,CAAC"}
1
+ {"version":3,"file":"menu-element.js","names":[],"sources":["../../src/elements/menu-element.ts"],"sourcesContent":["/**\n * What the menus share: the primitive in the shadow root, the glyph slots\n * on its button, the name from `label`, the Back item's name from\n * `label-back`, and the popup fitted under the top of the picture. A\n * subclass fills the entries in `render()`, which runs on attach, on every\n * observed attribute, and whenever it asks.\n */\nimport type { IconName } from '../controls/icons.js';\nimport { icon } from '../controls/icons.js';\nimport type { Menu } from '../controls/menu.js';\nimport { menu } from '../controls/menu.js';\nimport { fill } from '../labels.js';\nimport { Component } from './component.js';\nimport { iconSlots, MENU_STYLE, style } from './shared.js';\n\nexport abstract class MenuElement<S extends string = 'default'> extends Component {\n declare protected readonly menu: Menu;\n declare protected readonly slots: Record<S, HTMLSlotElement>;\n\n constructor(states: readonly S[], glyphs: (state: S) => SVGSVGElement) {\n super();\n const root = this.attachShadow({ mode: 'open' });\n this.menu = menu({\n host: this,\n picture: () => this.player?.video.getBoundingClientRect() ?? null,\n back: (page) => fill(this.getAttribute('label-back') ?? 'Back from {page}', { page }),\n });\n this.slots = iconSlots(states, glyphs);\n for (const state of states) this.menu.button.append(this.slots[state]);\n root.append(style(MENU_STYLE), this.menu.button, this.menu.popup);\n }\n\n /** The default name of the button. */\n protected abstract name(): string;\n\n protected override detach(): void {\n this.menu.close();\n }\n\n protected override render(): void {\n this.menu.label(this.getAttribute('label') ?? this.name());\n }\n}\n\n/** A glyph that never changes, for a menu of one state. */\nexport function single(name: IconName): [readonly ['default'], () => SVGSVGElement] {\n return [['default'], () => icon(name)];\n}\n"],"mappings":";;;;;;AAeA,IAAsB,cAAtB,cAAwE,UAAU;CAIhF,YAAY,QAAsB,QAAqC;EACrE,MAAM;EACN,MAAM,OAAO,KAAK,aAAa,EAAE,MAAM,OAAO,CAAC;EAC/C,KAAK,OAAO,KAAK;GACf,MAAM;GACN,eAAe,KAAK,QAAQ,MAAM,sBAAsB,KAAK;GAC7D,OAAO,SAAS,KAAK,KAAK,aAAa,YAAY,KAAK,oBAAoB,EAAE,KAAK,CAAC;EACtF,CAAC;EACD,KAAK,QAAQ,UAAU,QAAQ,MAAM;EACrC,KAAK,MAAM,SAAS,QAAQ,KAAK,KAAK,OAAO,OAAO,KAAK,MAAM,MAAM;EACrE,KAAK,OAAO,MAAM,UAAU,GAAG,KAAK,KAAK,QAAQ,KAAK,KAAK,KAAK;CAClE;CAKA,SAAkC;EAChC,KAAK,KAAK,MAAM;CAClB;CAEA,SAAkC;EAChC,KAAK,KAAK,MAAM,KAAK,aAAa,OAAO,KAAK,KAAK,KAAK,CAAC;CAC3D;AACF;;AAGA,SAAgB,OAAO,MAA6D;CAClF,OAAO,CAAC,CAAC,SAAS,SAAS,KAAK,IAAI,CAAC;AACvC"}
@@ -1,61 +1,60 @@
1
+ import { icon } from "../controls/icons.js";
2
+ import { Component } from "./component.js";
3
+ import { BUTTON_STYLE, iconSlots, show, style } from "./shared.js";
4
+ //#region src/elements/mute-button.ts
1
5
  /**
2
- * <mbx-mute-button>: mute and unmute, with the level drawn in the glyph:
3
- * `icon-mute` while muted or at zero, `icon-low` up to half, `icon-high`
4
- * above. Unmuting at zero volume would change nothing the viewer can
5
- * hear, so it brings the volume up too. The name comes from `label-mute`
6
- * and `label-unmute`, and `aria-pressed` says which state it is in.
7
- */
8
- import { icon } from '../controls/icons.js';
9
- import { Component } from './component.js';
10
- import { BUTTON_STYLE, iconSlots, show, style } from './shared.js';
11
- const LEVELS = ['mute', 'low', 'high'];
12
- export class MbxMuteButton extends Component {
13
- static get observedAttributes() {
14
- return ['label-mute', 'label-unmute'];
15
- }
16
- constructor() {
17
- super();
18
- const root = this.attachShadow({ mode: 'open' });
19
- this.button = document.createElement('button');
20
- this.button.type = 'button';
21
- this.button.setAttribute('part', 'button');
22
- this.slots = iconSlots(LEVELS, (level) => icon(level === 'mute' ? 'mute' : level === 'low' ? 'volume-low' : 'volume-high'));
23
- for (const level of LEVELS)
24
- this.button.append(this.slots[level]);
25
- this.button.addEventListener('click', () => {
26
- this.toggle();
27
- });
28
- root.append(style(BUTTON_STYLE), this.button);
29
- }
30
- toggle() {
31
- const video = this.player?.video;
32
- if (video === undefined)
33
- return;
34
- if (video.muted) {
35
- video.muted = false;
36
- if (video.volume === 0)
37
- video.volume = 1;
38
- }
39
- else {
40
- video.muted = true;
41
- }
42
- }
43
- attach(player) {
44
- this.listen(player.video, ['volumechange', 'emptied'], () => {
45
- this.render();
46
- });
47
- this.render();
48
- }
49
- render() {
50
- const video = this.player?.video;
51
- if (video === undefined)
52
- return;
53
- const silent = video.muted || video.volume === 0;
54
- show(this.slots, silent ? 'mute' : video.volume <= 0.5 ? 'low' : 'high');
55
- this.button.setAttribute('aria-label', silent
56
- ? (this.getAttribute('label-unmute') ?? 'Unmute')
57
- : (this.getAttribute('label-mute') ?? 'Mute'));
58
- this.button.setAttribute('aria-pressed', String(video.muted));
59
- }
60
- }
6
+ * <mbx-mute-button>: mute and unmute, with the level drawn in the glyph:
7
+ * `icon-mute` while muted or at zero, `icon-low` up to half, `icon-high`
8
+ * above. Unmuting at zero volume would change nothing the viewer can
9
+ * hear, so it brings the volume up too. The name comes from `label-mute`
10
+ * and `label-unmute`, and `aria-pressed` says which state it is in.
11
+ */
12
+ const LEVELS = [
13
+ "mute",
14
+ "low",
15
+ "high"
16
+ ];
17
+ var MbxMuteButton = class extends Component {
18
+ static get observedAttributes() {
19
+ return ["label-mute", "label-unmute"];
20
+ }
21
+ constructor() {
22
+ super();
23
+ const root = this.attachShadow({ mode: "open" });
24
+ this.button = document.createElement("button");
25
+ this.button.type = "button";
26
+ this.button.setAttribute("part", "button");
27
+ this.slots = iconSlots(LEVELS, (level) => icon(level === "mute" ? "mute" : level === "low" ? "volume-low" : "volume-high"));
28
+ for (const level of LEVELS) this.button.append(this.slots[level]);
29
+ this.button.addEventListener("click", () => {
30
+ this.toggle();
31
+ });
32
+ root.append(style(BUTTON_STYLE), this.button);
33
+ }
34
+ toggle() {
35
+ const video = this.player?.video;
36
+ if (video === void 0) return;
37
+ if (video.muted) {
38
+ video.muted = false;
39
+ if (video.volume === 0) video.volume = 1;
40
+ } else video.muted = true;
41
+ }
42
+ attach(player) {
43
+ this.listen(player.video, ["volumechange", "emptied"], () => {
44
+ this.render();
45
+ });
46
+ this.render();
47
+ }
48
+ render() {
49
+ const video = this.player?.video;
50
+ if (video === void 0) return;
51
+ const silent = video.muted || video.volume === 0;
52
+ show(this.slots, silent ? "mute" : video.volume <= .5 ? "low" : "high");
53
+ this.button.setAttribute("aria-label", silent ? this.getAttribute("label-unmute") ?? "Unmute" : this.getAttribute("label-mute") ?? "Mute");
54
+ this.button.setAttribute("aria-pressed", String(video.muted));
55
+ }
56
+ };
57
+ //#endregion
58
+ export { MbxMuteButton };
59
+
61
60
  //# sourceMappingURL=mute-button.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"mute-button.js","sourceRoot":"","sources":["../../src/elements/mute-button.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAE5C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAGnE,MAAM,MAAM,GAAqB,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;AAEzD,MAAM,OAAO,aAAc,SAAQ,SAAS;IAC1C,MAAM,KAAK,kBAAkB;QAC3B,OAAO,CAAC,YAAY,EAAE,cAAc,CAAC,CAAC;IACxC,CAAC;IAKD;QACE,KAAK,EAAE,CAAC;QACR,MAAM,IAAI,GAAG,IAAI,CAAC,YAAY,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;QACjD,IAAI,CAAC,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;QAC/C,IAAI,CAAC,MAAM,CAAC,I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AC;QAChB,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,MAAM,EAAE,CAAC;IAChB,CAAC;IAEkB,MAAM;QACvB,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC;QACjC,IAAI,KAAK,KAAK,SAAS;YAAE,OAAO;QAChC,MAAM,MAAM,GAAG,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC;QACjD,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,IAAI,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;QACzE,IAAI,CAAC,MAAM,CAAC,YAAY,CACtB,YAAY,EACZ,MAAM;YACJ,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,cAAc,CAAC,IAAI,QAAQ,CAAC;YACjD,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,YAAY,CAAC,IAAI,MAAM,CAAC,CAChD,CAAC;QACF,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,cAAc,EAAE,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;IAChE,CAAC;CACF"}
1
+ {"version":3,"file":"mute-button.js","names":[],"sources":["../../src/elements/mute-button.ts"],"sourcesContent":["/**\n * <mbx-mute-button>: mute and unmute, with the level drawn in the glyph:\n * `icon-mute` while muted or at zero, `icon-low` up to half, `icon-high`\n * above. Unmuting at zero volume would change nothing the viewer can\n * hear, so it brings the volume up too. The name comes from `label-mute`\n * and `label-unmute`, and `aria-pressed` says which state it is in.\n */\nimport { icon } from '../controls/icons.js';\nimport type { PlayerHost } from '../host.js';\nimport { Component } from './component.js';\nimport { BUTTON_STYLE, iconSlots, show, style } from './shared.js';\n\ntype Level = 'mute' | 'low' | 'high';\nconst LEVELS: readonly Level[] = ['mute', 'low', 'high'];\n\nexport class MbxMuteButton extends Component {\n static get observedAttributes(): readonly string[] {\n return ['label-mute', 'label-unmute'];\n }\n\n declare private readonly button: HTMLButtonElement;\n declare private readonly slots: Record<Level, HTMLSlotElement>;\n\n constructor() {\n super();\n const root = this.attachShadow({ mode: 'open' });\n this.button = document.createElement('button');\n this.button.type = 'button';\n this.button.setAttribute('part', 'button');\n this.slots = iconSlots(LEVELS, (level) =>\n icon(level === 'mute' ? 'mute' : level === 'low' ? 'volume-low' : 'volume-high'),\n );\n for (const level of LEVELS) this.button.append(this.slots[level]);\n this.button.addEventListener('click', () => {\n this.toggle();\n });\n root.append(style(BUTTON_STYLE), this.button);\n }\n\n private toggle(): void {\n const video = this.player?.video;\n if (video === undefined) return;\n if (video.muted) {\n video.muted = false;\n if (video.volume === 0) video.volume = 1;\n } else {\n video.muted = true;\n }\n }\n\n protected override attach(player: PlayerHost): void {\n this.listen(player.video, ['volumechange', 'emptied'], () => {\n this.render();\n });\n this.render();\n }\n\n protected override render(): void {\n const video = this.player?.video;\n if (video === undefined) return;\n const silent = video.muted || video.volume === 0;\n show(this.slots, silent ? 'mute' : video.volume <= 0.5 ? 'low' : 'high');\n this.button.setAttribute(\n 'aria-label',\n silent\n ? (this.getAttribute('label-unmute') ?? 'Unmute')\n : (this.getAttribute('label-mute') ?? 'Mute'),\n );\n this.button.setAttribute('aria-pressed', String(video.muted));\n }\n}\n"],"mappings":";;;;;;;;;;;AAaA,MAAM,SAA2B;CAAC;CAAQ;CAAO;AAAM;AAEvD,IAAa,gBAAb,cAAmC,UAAU;CAC3C,WAAW,qBAAwC;EACjD,OAAO,CAAC,cAAc,cAAc;CACtC;CAKA,cAAc;EACZ,MAAM;EACN,MAAM,OAAO,KAAK,aAAa,EAAE,MAAM,OAAO,CAAC;EAC/C,KAAK,SAAS,SAAS,cAAc,QAAQ;EAC7C,KAAK,OAAO,OAAO;EACnB,KAAK,OAAO,aAAa,QAAQ,QAAQ;EACzC,KAAK,QAAQ,UAAU,SAAS,UAC9B,KAAK,UAAU,SAAS,SAAS,UAAU,QAAQ,eAAe,aAAa,CACjF;EACA,KAAK,MAAM,SAAS,QAAQ,KAAK,OAAO,OAAO,KAAK,MAAM,MAAM;EAChE,KAAK,OAAO,iBAAiB,eAAe;GAC1C,KAAK,OAAO;EACd,CAAC;EACD,KAAK,OAAO,MAAM,YAAY,GAAG,KAAK,MAAM;CAC9C;CAEA,SAAuB;EACrB,MAAM,QAAQ,KAAK,QAAQ;EAC3B,IAAI,UAAU,KAAA,GAAW;EACzB,IAAI,MAAM,OAAO;GACf,MAAM,QAAQ;GACd,IAAI,MAAM,WAAW,GAAG,MAAM,SAAS;EACzC,OACE,MAAM,QAAQ;CAElB;CAEA,OAA0B,QAA0B;EAClD,KAAK,OAAO,OAAO,OAAO,CAAC,gBAAgB,SAAS,SAAS;GAC3D,KAAK,OAAO;EACd,CAAC;EACD,KAAK,OAAO;CACd;CAEA,SAAkC;EAChC,MAAM,QAAQ,KAAK,QAAQ;EAC3B,IAAI,UAAU,KAAA,GAAW;EACzB,MAAM,SAAS,MAAM,SAAS,MAAM,WAAW;EAC/C,KAAK,KAAK,OAAO,SAAS,SAAS,MAAM,UAAU,KAAM,QAAQ,MAAM;EACvE,KAAK,OAAO,aACV,cACA,SACK,KAAK,aAAa,cAAc,KAAK,WACrC,KAAK,aAAa,YAAY,KAAK,MAC1C;EACA,KAAK,OAAO,aAAa,gBAAgB,OAAO,MAAM,KAAK,CAAC;CAC9D;AACF"}
@@ -1,56 +1,56 @@
1
+ import { icon } from "../controls/icons.js";
2
+ import { Component } from "./component.js";
3
+ import { BUTTON_STYLE, iconSlots, show, style } from "./shared.js";
4
+ import { pictureInPicture } from "../controls/pip.js";
5
+ //#region src/elements/pip-button.ts
1
6
  /**
2
- * <mbx-pip-button>: picture in picture, through whichever API the browser
3
- * has, and hidden where there is none. The glyph is `icon-enter` or
4
- * `icon-exit`, the name `label-enter` or `label-exit`, and the element
5
- * sets `pip` on the player while the video is in the floating window.
6
- */
7
- import { icon } from '../controls/icons.js';
8
- import { pictureInPicture } from '../controls/pip.js';
9
- import { Component } from './component.js';
10
- import { BUTTON_STYLE, iconSlots, show, style } from './shared.js';
11
- const STATES = ['enter', 'exit'];
12
- export class MbxPipButton extends Component {
13
- static get observedAttributes() {
14
- return ['label-enter', 'label-exit'];
15
- }
16
- constructor() {
17
- super();
18
- this.api = null;
19
- const root = this.attachShadow({ mode: 'open' });
20
- this.button = document.createElement('button');
21
- this.button.type = 'button';
22
- this.button.setAttribute('part', 'button');
23
- this.slots = iconSlots(STATES, (state) => icon(state === 'enter' ? 'picture-in-picture' : 'picture-in-picture-exit'));
24
- for (const state of STATES)
25
- this.button.append(this.slots[state]);
26
- this.button.addEventListener('click', () => {
27
- this.api?.toggle();
28
- });
29
- root.append(style(BUTTON_STYLE), this.button);
30
- }
31
- attach(player) {
32
- const api = pictureInPicture(player.video);
33
- this.api = api;
34
- this.hidden = !api.supported;
35
- this.keep(api.watch(() => {
36
- this.render();
37
- }));
38
- this.render();
39
- }
40
- detach(player) {
41
- this.api = null;
42
- player.removeAttribute('pip');
43
- }
44
- render() {
45
- const player = this.player;
46
- if (player === null || this.api === null)
47
- return;
48
- const active = this.api.active();
49
- show(this.slots, active ? 'exit' : 'enter');
50
- this.button.setAttribute('aria-label', active
51
- ? (this.getAttribute('label-exit') ?? 'Leave picture in picture')
52
- : (this.getAttribute('label-enter') ?? 'Picture in picture'));
53
- player.toggleAttribute('pip', active);
54
- }
55
- }
7
+ * <mbx-pip-button>: picture in picture, through whichever API the browser
8
+ * has, and hidden where there is none. The glyph is `icon-enter` or
9
+ * `icon-exit`, the name `label-enter` or `label-exit`, and the element
10
+ * sets `pip` on the player while the video is in the floating window.
11
+ */
12
+ const STATES = ["enter", "exit"];
13
+ var MbxPipButton = class extends Component {
14
+ static get observedAttributes() {
15
+ return ["label-enter", "label-exit"];
16
+ }
17
+ constructor() {
18
+ super();
19
+ this.api = null;
20
+ const root = this.attachShadow({ mode: "open" });
21
+ this.button = document.createElement("button");
22
+ this.button.type = "button";
23
+ this.button.setAttribute("part", "button");
24
+ this.slots = iconSlots(STATES, (state) => icon(state === "enter" ? "picture-in-picture" : "picture-in-picture-exit"));
25
+ for (const state of STATES) this.button.append(this.slots[state]);
26
+ this.button.addEventListener("click", () => {
27
+ this.api?.toggle();
28
+ });
29
+ root.append(style(BUTTON_STYLE), this.button);
30
+ }
31
+ attach(player) {
32
+ const api = pictureInPicture(player.video);
33
+ this.api = api;
34
+ this.hidden = !api.supported;
35
+ this.keep(api.watch(() => {
36
+ this.render();
37
+ }));
38
+ this.render();
39
+ }
40
+ detach(player) {
41
+ this.api = null;
42
+ player.removeAttribute("pip");
43
+ }
44
+ render() {
45
+ const player = this.player;
46
+ if (player === null || this.api === null) return;
47
+ const active = this.api.active();
48
+ show(this.slots, active ? "exit" : "enter");
49
+ this.button.setAttribute("aria-label", active ? this.getAttribute("label-exit") ?? "Leave picture in picture" : this.getAttribute("label-enter") ?? "Picture in picture");
50
+ player.toggleAttribute("pip", active);
51
+ }
52
+ };
53
+ //#endregion
54
+ export { MbxPipButton };
55
+
56
56
  //# sourceMappingURL=pip-button.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"pip-button.js","sourceRoot":"","sources":["../../src/elements/pip-button.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAE5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAGnE,MAAM,MAAM,GAAqB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;AAEnD,MAAM,OAAO,YAAa,SAAQ,SAAS;IACzC,MAAM,KAAK,kBAAkB;QAC3B,OAAO,CAAC,aAAa,EAAE,YAAY,CAAC,CAAC;IAC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ChB,CAAC,CAAC,CACH,CAAC;QACF,IAAI,CAAC,MAAM,EAAE,CAAC;IAChB,CAAC;IAEkB,MAAM,CAAC,MAAkB;QAC1C,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC;QAChB,MAAM,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;IAChC,CAAC;IAEkB,MAAM;QACvB,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAC3B,IAAI,MAAM,KAAK,IAAI,IAAI,IAAI,CAAC,GAAG,KAAK,IAAI;YAAE,OAAO;QACjD,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC;QACjC,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;QAC5C,IAAI,CAAC,MAAM,CAAC,YAAY,CACtB,YAAY,EACZ,MAAM;YACJ,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,YAAY,CAAC,IAAI,0BAA0B,CAAC;YACjE,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,aAAa,CAAC,IAAI,oBAAoB,CAAC,CAC/D,CAAC;QACF,MAAM,CAAC,eAAe,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IACxC,CAAC;CACF"}
1
+ {"version":3,"file":"pip-button.js","names":[],"sources":["../../src/elements/pip-button.ts"],"sourcesContent":["/**\n * <mbx-pip-button>: picture in picture, through whichever API the browser\n * has, and hidden where there is none. The glyph is `icon-enter` or\n * `icon-exit`, the name `label-enter` or `label-exit`, and the element\n * sets `pip` on the player while the video is in the floating window.\n */\nimport { icon } from '../controls/icons.js';\nimport type { PictureInPicture } from '../controls/pip.js';\nimport { pictureInPicture } from '../controls/pip.js';\nimport type { PlayerHost } from '../host.js';\nimport { Component } from './component.js';\nimport { BUTTON_STYLE, iconSlots, show, style } from './shared.js';\n\ntype State = 'enter' | 'exit';\nconst STATES: readonly State[] = ['enter', 'exit'];\n\nexport class MbxPipButton extends Component {\n static get observedAttributes(): readonly string[] {\n return ['label-enter', 'label-exit'];\n }\n\n declare private readonly button: HTMLButtonElement;\n declare private readonly slots: Record<State, HTMLSlotElement>;\n declare private api: PictureInPicture | null;\n\n constructor() {\n super();\n this.api = null;\n const root = this.attachShadow({ mode: 'open' });\n this.button = document.createElement('button');\n this.button.type = 'button';\n this.button.setAttribute('part', 'button');\n this.slots = iconSlots(STATES, (state) =>\n icon(state === 'enter' ? 'picture-in-picture' : 'picture-in-picture-exit'),\n );\n for (const state of STATES) this.button.append(this.slots[state]);\n this.button.addEventListener('click', () => {\n this.api?.toggle();\n });\n root.append(style(BUTTON_STYLE), this.button);\n }\n\n protected override attach(player: PlayerHost): void {\n const api = pictureInPicture(player.video);\n this.api = api;\n this.hidden = !api.supported;\n this.keep(\n api.watch(() => {\n this.render();\n }),\n );\n this.render();\n }\n\n protected override detach(player: PlayerHost): void {\n this.api = null;\n player.removeAttribute('pip');\n }\n\n protected override render(): void {\n const player = this.player;\n if (player === null || this.api === null) return;\n const active = this.api.active();\n show(this.slots, active ? 'exit' : 'enter');\n this.button.setAttribute(\n 'aria-label',\n active\n ? (this.getAttribute('label-exit') ?? 'Leave picture in picture')\n : (this.getAttribute('label-enter') ?? 'Picture in picture'),\n );\n player.toggleAttribute('pip', active);\n }\n}\n"],"mappings":";;;;;;;;;;;AAcA,MAAM,SAA2B,CAAC,SAAS,MAAM;AAEjD,IAAa,eAAb,cAAkC,UAAU;CAC1C,WAAW,qBAAwC;EACjD,OAAO,CAAC,eAAe,YAAY;CACrC;CAMA,cAAc;EACZ,MAAM;EACN,KAAK,MAAM;EACX,MAAM,OAAO,KAAK,aAAa,EAAE,MAAM,OAAO,CAAC;EAC/C,KAAK,SAAS,SAAS,cAAc,QAAQ;EAC7C,KAAK,OAAO,OAAO;EACnB,KAAK,OAAO,aAAa,QAAQ,QAAQ;EACzC,KAAK,QAAQ,UAAU,SAAS,UAC9B,KA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I;CAOlC"}
1
+ {"version":3,"file":"play-button.d.ts","sourceRoot":"","sources":["../../src/elements/play-button.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAO3C,qBAAa,aAAc,SAAQ,SAAS;IAC1C,MAAM,KAAK,kBAAkB,IAAI,SAAS,MAAM,EAAE,CAEjD;IAED,iBAAyB,MAAM,CAAoB;IACnD,iBAAyB,KAAK,CAAiC;;IAgB/D,OAAO,CAAC,MAAM;cAYK,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;cAUhC,MAAM,IAAI,IAAI;CASlC"}
@@ -1,60 +1,75 @@
1
+ import { icon } from "../controls/icons.js";
2
+ import { Component } from "./component.js";
3
+ import { BUTTON_STYLE, iconSlots, show, style } from "./shared.js";
4
+ //#region src/elements/play-button.ts
1
5
  /**
2
- * <mbx-play-button>: play, pause, or replay once the media has ended. It
3
- * reads the video on the events the video already fires and writes one
4
- * thing back on click. The glyph is a slot per state, so a page drops its
5
- * own SVG into `icon-play`, `icon-pause` or `icon-replay`; the name is on
6
- * the button, from `label-play`, `label-pause` and `label-replay`, where a
7
- * screen reader reads it.
8
- */
9
- import { icon } from '../controls/icons.js';
10
- import { Component } from './component.js';
11
- import { BUTTON_STYLE, iconSlots, show, style } from './shared.js';
12
- const STATES = ['play', 'pause', 'replay'];
13
- const LABELS = { play: 'Play', pause: 'Pause', replay: 'Replay' };
14
- export class MbxPlayButton extends Component {
15
- static get observedAttributes() {
16
- return STATES.map((state) => `label-${state}`);
17
- }
18
- constructor() {
19
- super();
20
- const root = this.attachShadow({ mode: 'open' });
21
- this.button = document.createElement('button');
22
- this.button.type = 'button';
23
- this.button.setAttribute('part', 'button');
24
- this.slots = iconSlots(STATES, icon);
25
- for (const state of STATES)
26
- this.button.append(this.slots[state]);
27
- this.button.addEventListener('click', () => {
28
- this.toggle();
29
- });
30
- root.append(style(BUTTON_STYLE), this.button);
31
- }
32
- toggle() {
33
- const video = this.player?.video;
34
- if (video === undefined)
35
- return;
36
- if (video.paused) {
37
- // Rejected outside a user gesture on an unmuted video, which the
38
- // browser reports on the video's own error path; nothing to add.
39
- video.play().catch(() => undefined);
40
- }
41
- else {
42
- video.pause();
43
- }
44
- }
45
- attach(player) {
46
- this.listen(player.video, ['play', 'pause', 'ended', 'emptied'], () => {
47
- this.render();
48
- });
49
- this.render();
50
- }
51
- render() {
52
- const video = this.player?.video;
53
- if (video === undefined)
54
- return;
55
- const state = video.ended ? 'replay' : video.paused ? 'play' : 'pause';
56
- show(this.slots, state);
57
- this.button.setAttribute('aria-label', this.getAttribute(`label-${state}`) ?? LABELS[state]);
58
- }
59
- }
6
+ * <mbx-play-button>: play, pause, or replay once the media has ended. It
7
+ * reads the video on the events the video already fires and writes one
8
+ * thing back on click. The glyph is a slot per state, so a page drops its
9
+ * own SVG into `icon-play`, `icon-pause` or `icon-replay`; the name is on
10
+ * the button, from `label-play`, `label-pause` and `label-replay`, where a
11
+ * screen reader reads it. While the seek bar holds the video paused for a
12
+ * drag, the button shows the state from before the drag, which the player
13
+ * carries as `scrubbing`.
14
+ */
15
+ const STATES = [
16
+ "play",
17
+ "pause",
18
+ "replay"
19
+ ];
20
+ const LABELS = {
21
+ play: "Play",
22
+ pause: "Pause",
23
+ replay: "Replay"
24
+ };
25
+ var MbxPlayButton = class extends Component {
26
+ static get observedAttributes() {
27
+ return STATES.map((state) => `label-${state}`);
28
+ }
29
+ constructor() {
30
+ super();
31
+ const root = this.attachShadow({ mode: "open" });
32
+ this.button = document.createElement("button");
33
+ this.button.type = "button";
34
+ this.button.setAttribute("part", "button");
35
+ this.slots = iconSlots(STATES, icon);
36
+ for (const state of STATES) this.button.append(this.slots[state]);
37
+ this.button.addEventListener("click", () => {
38
+ this.toggle();
39
+ });
40
+ root.append(style(BUTTON_STYLE), this.button);
41
+ }
42
+ toggle() {
43
+ const video = this.player?.video;
44
+ if (video === void 0) return;
45
+ if (video.paused) video.play().catch(() => void 0);
46
+ else video.pause();
47
+ }
48
+ attach(player) {
49
+ this.listen(player.video, [
50
+ "play",
51
+ "pause",
52
+ "ended",
53
+ "emptied"
54
+ ], () => {
55
+ this.render();
56
+ });
57
+ this.observe(player, ["scrubbing"], () => {
58
+ this.render();
59
+ });
60
+ this.render();
61
+ }
62
+ render() {
63
+ const video = this.player?.video;
64
+ if (video === void 0) return;
65
+ const held = this.player?.getAttribute("scrubbing") ?? null;
66
+ const paused = held === null ? video.paused : held === "paused";
67
+ const state = video.ended ? "replay" : paused ? "play" : "pause";
68
+ show(this.slots, state);
69
+ this.button.setAttribute("aria-label", this.getAttribute(`label-${state}`) ?? LABELS[state]);
70
+ }
71
+ };
72
+ //#endregion
73
+ export { MbxPlayButton };
74
+
60
75
  //# sourceMappingURL=play-button.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"play-button.js","sourceRoot":"","sources":["../../src/elements/play-button.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAE5C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAGnE,MAAM,MAAM,GAAqB,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;AAC7D,MAAM,MAAM,GAAoC,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;AAEnG,MAAM,OAAO,aAAc,SAAQ,SAAS;IAC1C,MAAM,KAAK,kBAAkB;QAC3B,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,SAAS,KAAK,EAAE,CAAC,CAAC;IACjD,CAAC;IAKD;QACE,KAAK,EAAE,CAAC;QACR,MAAM,I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AC,MAAM,EAAE,CAAC;QAChB,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,MAAM,EAAE,CAAC;IAChB,CAAC;IAEkB,MAAM;QACvB,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC;QACjC,IAAI,KAAK,KAAK,SAAS;YAAE,OAAO;QAChC,MAAM,KAAK,GAAU,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC;QAC9E,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QACxB,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,YAAY,EAAE,IAAI,CAAC,YAAY,CAAC,SAAS,KAAK,EAAE,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IAC/F,CAAC;CACF"}
1
+ {"version":3,"file":"play-button.js","names":[],"sources":["../../src/elements/play-button.ts"],"sourcesContent":["/**\n * <mbx-play-button>: play, pause, or replay once the media has ended. It\n * reads the video on the events the video already fires and writes one\n * thing back on click. The glyph is a slot per state, so a page drops its\n * own SVG into `icon-play`, `icon-pause` or `icon-replay`; the name is on\n * the button, from `label-play`, `label-pause` and `label-replay`, where a\n * screen reader reads it. While the seek bar holds the video paused for a\n * drag, the button shows the state from before the drag, which the player\n * carries as `scrubbing`.\n */\nimport { icon } from '../controls/icons.js';\nimport type { PlayerHost } from '../host.js';\nimport { Component } from './component.js';\nimport { BUTTON_STYLE, iconSlots, show, style } from './shared.js';\n\ntype State = 'play' | 'pause' | 'replay';\nconst STATES: readonly State[] = ['play', 'pause', 'replay'];\nconst LABELS: Readonly<Record<State, string>> = { play: 'Play', pause: 'Pause', replay: 'Replay' };\n\nexport class MbxPlayButton extends Component {\n static get observedAttributes(): readonly string[] {\n return STATES.map((state) => `label-${state}`);\n }\n\n declare private readonly button: HTMLButtonElement;\n declare private readonly slots: Record<State, HTMLSlotElement>;\n\n constructor() {\n super();\n const root = this.attachShadow({ mode: 'open' });\n this.button = document.createElement('button');\n this.button.type = 'button';\n this.button.setAttribute('part', 'button');\n this.slots = iconSlots(STATES, icon);\n for (const state of STATES) this.button.append(this.slots[state]);\n this.button.addEventListener('click', () => {\n this.toggle();\n });\n root.append(style(BUTTON_STYLE), this.button);\n }\n\n private toggle(): void {\n const video = this.player?.video;\n if (video === undefined) return;\n if (video.paused) {\n // Rejected outside a user gesture on an unmuted video, which the\n // browser reports on the video's own error path; nothing to add.\n video.play().catch(() => undefined);\n } else {\n video.pause();\n }\n }\n\n protected override attach(player: PlayerHost): void {\n this.listen(player.video, ['play', 'pause', 'ended', 'emptied'], () => {\n this.render();\n });\n this.observe(player, ['scrubbing'], () => {\n this.render();\n });\n this.render();\n }\n\n protected override render(): void {\n const video = this.player?.video;\n if (video === undefined) return;\n const held = this.player?.getAttribute('scrubbing') ?? null;\n const paused = held === null ? video.paused : held === 'paused';\n const state: State = video.ended ? 'replay' : paused ? 'play' : 'pause';\n show(this.slots, state);\n this.button.setAttribute('aria-label', this.getAttribute(`label-${state}`) ?? LABELS[state]);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAgBA,MAAM,SAA2B;CAAC;CAAQ;CAAS;AAAQ;AAC3D,MAAM,SAA0C;CAAE,MAAM;CAAQ,OAAO;CAAS,QAAQ;AAAS;AAEjG,IAAa,gBAAb,cAAmC,UAAU;CAC3C,WAAW,qBAAwC;EACjD,OAAO,OAAO,KAAK,UAAU,SAAS,OAAO;CAC/C;CAKA,cAAc;EACZ,MAAM;EACN,MAAM,OAAO,KAAK,aAAa,EAAE,MAAM,OAAO,CAAC;EAC/C,KAAK,SAAS,SAAS,cAAc,QAAQ;EAC7C,KAAK,OAAO,OAAO;EACnB,KAAK,OAAO,aAAa,QAAQ,QAAQ;EACzC,KAAK,QAAQ,UAAU,QAAQ,IAAI;EACnC,KAAK,MAAM,SAAS,QAAQ,KAAK,OAAO,OAAO,KAAK,MAAM,MAAM;EAChE,KAAK,OAAO,iBAAiB,eAAe;GAC1C,KAAK,OAAO;EACd,CAAC;EACD,KAAK,OAAO,MAAM,YAAY,GAAG,KAAK,MAAM;CAC9C;CAEA,SAAuB;EACrB,MAAM,QAAQ,KAAK,QAAQ;EAC3B,IAAI,UAAU,KAAA,GAAW;EACzB,IAAI,MAAM,QAGR,MAAM,KAAK,CAAC,CAAC,YAAY,KAAA,CAAS;OAElC,MAAM,MAAM;CAEhB;CAEA,OAA0B,QAA0B;EAClD,KAAK,OAAO,OAAO,OAAO;GAAC;GAAQ;GAAS;GAAS;EAAS,SAAS;GACrE,KAAK,OAAO;EACd,CAAC;EACD,KAAK,QAAQ,QAAQ,CAAC,WAAW,SAAS;GACxC,KAAK,OAAO;EACd,CAAC;EACD,KAAK,OAAO;CACd;CAEA,SAAkC;EAChC,MAAM,QAAQ,KAAK,QAAQ;EAC3B,IAAI,UAAU,KAAA,GAAW;EACzB,MAAM,OAAO,KAAK,QAAQ,aAAa,WAAW,KAAK;EACvD,MAAM,SAAS,SAAS,OAAO,MAAM,SAAS,SAAS;EACvD,MAAM,QAAe,MAAM,QAAQ,WAAW,SAAS,SAAS;EAChE,KAAK,KAAK,OAAO,KAAK;EACtB,KAAK,OAAO,aAAa,cAAc,KAAK,aAAa,SAAS,OAAO,KAAK,OAAO,MAAM;CAC7F;AACF"}
@@ -1,72 +1,69 @@
1
- import { MenuElement, single } from './menu-element.js';
2
- import { show } from './shared.js';
3
- const AUTO = 'auto';
1
+ import { show } from "./shared.js";
2
+ import { MenuElement, single } from "./menu-element.js";
3
+ //#region src/elements/quality-menu.ts
4
+ const AUTO = "auto";
4
5
  function renditionLabel(rendition) {
5
- if (rendition.height !== undefined)
6
- return `${rendition.height}p`;
7
- return `${Math.round(rendition.bitrate / 1000)} kbps`;
8
- }
9
- export class MbxQualityMenu extends MenuElement {
10
- static get observedAttributes() {
11
- return ['label', 'label-auto', 'label-back'];
12
- }
13
- constructor() {
14
- super(...single('settings'));
15
- this.engine = null;
16
- show(this.slots, 'default');
17
- }
18
- name() {
19
- return 'Quality';
20
- }
21
- attach(player) {
22
- this.follow(player, (engine) => {
23
- this.engine = engine;
24
- this.render();
25
- if (engine === null)
26
- return undefined;
27
- const tick = () => {
28
- this.render();
29
- };
30
- const offs = [
31
- engine.on('tracks:changed', tick),
32
- engine.on('quality:constraints-unsatisfiable', tick),
33
- engine.on('quality:pin-unsatisfiable', tick),
34
- ];
35
- return () => {
36
- for (const off of offs)
37
- off();
38
- };
39
- });
40
- }
41
- render() {
42
- super.render();
43
- const engine = this.engine;
44
- if (engine === null) {
45
- this.hidden = true;
46
- return;
47
- }
48
- const quality = engine.quality;
49
- const items = [
50
- [AUTO, this.getAttribute('label-auto') ?? 'Auto'],
51
- ];
52
- for (const rendition of quality.renditions) {
53
- items.push([rendition.id, renditionLabel(rendition)]);
54
- }
55
- this.menu.fill([
56
- {
57
- name: 'rendition',
58
- items,
59
- value: quality.pinned ?? AUTO,
60
- onSelect: (value) => {
61
- if (value === AUTO)
62
- quality.auto();
63
- else
64
- quality.pin(value);
65
- this.render();
66
- },
67
- },
68
- ]);
69
- this.hidden = quality.renditions.length === 0;
70
- }
6
+ if (rendition.height !== void 0) return `${rendition.height}p`;
7
+ return `${Math.round(rendition.bitrate / 1e3)} kbps`;
71
8
  }
9
+ var MbxQualityMenu = class extends MenuElement {
10
+ static get observedAttributes() {
11
+ return [
12
+ "label",
13
+ "label-auto",
14
+ "label-back"
15
+ ];
16
+ }
17
+ constructor() {
18
+ super(...single("settings"));
19
+ this.engine = null;
20
+ show(this.slots, "default");
21
+ }
22
+ name() {
23
+ return "Quality";
24
+ }
25
+ attach(player) {
26
+ this.follow(player, (engine) => {
27
+ this.engine = engine;
28
+ this.render();
29
+ if (engine === null) return void 0;
30
+ const tick = () => {
31
+ this.render();
32
+ };
33
+ const offs = [
34
+ engine.on("tracks:changed", tick),
35
+ engine.on("quality:constraints-unsatisfiable", tick),
36
+ engine.on("quality:pin-unsatisfiable", tick)
37
+ ];
38
+ return () => {
39
+ for (const off of offs) off();
40
+ };
41
+ });
42
+ }
43
+ render() {
44
+ super.render();
45
+ const engine = this.engine;
46
+ if (engine === null) {
47
+ this.hidden = true;
48
+ return;
49
+ }
50
+ 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)]);
53
+ this.menu.fill([{
54
+ name: "rendition",
55
+ items,
56
+ value: quality.pinned ?? AUTO,
57
+ onSelect: (value) => {
58
+ if (value === AUTO) quality.auto();
59
+ else quality.pin(value);
60
+ this.render();
61
+ }
62
+ }]);
63
+ this.hidden = quality.renditions.length === 0;
64
+ }
65
+ };
66
+ //#endregion
67
+ export { MbxQualityMenu };
68
+
72
69
  //# sourceMappingURL=quality-menu.js.map