@mattebox/player 0.13.1 → 0.15.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.
- package/dist/cdn/mattebox-player.min.js +3 -3
- package/dist/controls/chapters.js +1 -1
- package/dist/controls/chapters.js.map +1 -1
- package/dist/controls/cues.js.map +1 -1
- package/dist/controls/native-tracks.js +1 -1
- package/dist/controls/native-tracks.js.map +1 -1
- package/dist/controls/pip.d.ts +6 -0
- package/dist/controls/pip.d.ts.map +1 -1
- package/dist/controls/pip.js +16 -3
- package/dist/controls/pip.js.map +1 -1
- package/dist/element-entry.d.ts +1 -0
- package/dist/element-entry.d.ts.map +1 -1
- package/dist/element-entry.js.map +1 -1
- package/dist/element.d.ts +49 -3
- package/dist/element.d.ts.map +1 -1
- package/dist/element.js +203 -38
- package/dist/element.js.map +1 -1
- package/dist/elements/airplay-button.js +1 -1
- package/dist/elements/airplay-button.js.map +1 -1
- package/dist/elements/audio-menu.d.ts.map +1 -1
- package/dist/elements/audio-menu.js +4 -3
- package/dist/elements/audio-menu.js.map +1 -1
- package/dist/elements/casting.d.ts +12 -0
- package/dist/elements/casting.d.ts.map +1 -0
- package/dist/elements/casting.js +58 -0
- package/dist/elements/casting.js.map +1 -0
- package/dist/elements/chapters-menu.js +5 -5
- package/dist/elements/chapters-menu.js.map +1 -1
- package/dist/elements/component.d.ts +13 -0
- package/dist/elements/component.d.ts.map +1 -1
- package/dist/elements/component.js +21 -3
- package/dist/elements/component.js.map +1 -1
- package/dist/elements/control-bar.d.ts.map +1 -1
- package/dist/elements/control-bar.js +7 -6
- package/dist/elements/control-bar.js.map +1 -1
- package/dist/elements/current-time.js +2 -2
- package/dist/elements/current-time.js.map +1 -1
- package/dist/elements/drm-badge.js +1 -1
- package/dist/elements/drm-badge.js.map +1 -1
- package/dist/elements/duration.js +3 -3
- package/dist/elements/duration.js.map +1 -1
- package/dist/elements/error-screen.js +1 -1
- package/dist/elements/error-screen.js.map +1 -1
- package/dist/elements/fullscreen-button.d.ts.map +1 -1
- package/dist/elements/fullscreen-button.js +3 -2
- package/dist/elements/fullscreen-button.js.map +1 -1
- package/dist/elements/live-button.js +2 -2
- package/dist/elements/live-button.js.map +1 -1
- package/dist/elements/marker-button.js +3 -3
- package/dist/elements/marker-button.js.map +1 -1
- package/dist/elements/menu-element.js +3 -3
- package/dist/elements/menu-element.js.map +1 -1
- package/dist/elements/mute-button.js +3 -3
- package/dist/elements/mute-button.js.map +1 -1
- package/dist/elements/pip-button.d.ts.map +1 -1
- package/dist/elements/pip-button.js +9 -4
- package/dist/elements/pip-button.js.map +1 -1
- package/dist/elements/play-button.js +3 -3
- package/dist/elements/play-button.js.map +1 -1
- package/dist/elements/quality-menu.d.ts.map +1 -1
- package/dist/elements/quality-menu.js +5 -4
- package/dist/elements/quality-menu.js.map +1 -1
- package/dist/elements/remaining-time.js +2 -2
- package/dist/elements/remaining-time.js.map +1 -1
- package/dist/elements/scan-button.d.ts.map +1 -1
- package/dist/elements/scan-button.js +4 -3
- package/dist/elements/scan-button.js.map +1 -1
- package/dist/elements/seek-bar.d.ts.map +1 -1
- package/dist/elements/seek-bar.js +20 -16
- package/dist/elements/seek-bar.js.map +1 -1
- package/dist/elements/shared.js +3 -3
- package/dist/elements/shared.js.map +1 -1
- package/dist/elements/skip-button.js +2 -2
- package/dist/elements/skip-button.js.map +1 -1
- package/dist/elements/spacer.js.map +1 -1
- package/dist/elements/speed-menu.d.ts.map +1 -1
- package/dist/elements/speed-menu.js +4 -3
- package/dist/elements/speed-menu.js.map +1 -1
- package/dist/elements/spinner.js +1 -1
- package/dist/elements/spinner.js.map +1 -1
- package/dist/elements/start-button.js +3 -3
- package/dist/elements/start-button.js.map +1 -1
- package/dist/elements/subtitles-menu.d.ts.map +1 -1
- package/dist/elements/subtitles-menu.js +5 -4
- package/dist/elements/subtitles-menu.js.map +1 -1
- package/dist/elements/time-element.js +1 -1
- package/dist/elements/time-element.js.map +1 -1
- package/dist/elements/title.js +1 -1
- package/dist/elements/title.js.map +1 -1
- package/dist/elements/video-menu.d.ts.map +1 -1
- package/dist/elements/video-menu.js +5 -4
- package/dist/elements/video-menu.js.map +1 -1
- package/dist/elements/volume-slider.js +4 -4
- package/dist/elements/volume-slider.js.map +1 -1
- package/dist/elements/volume.js.map +1 -1
- package/dist/entries/airplay-button.js +1 -1
- package/dist/entries/audio-menu.js +1 -1
- package/dist/entries/casting.d.ts +5 -0
- package/dist/entries/casting.d.ts.map +1 -0
- package/dist/entries/casting.js +8 -0
- package/dist/entries/casting.js.map +1 -0
- package/dist/entries/chapters-menu.js +1 -1
- package/dist/entries/control-bar.js +1 -1
- package/dist/entries/current-time.js +1 -1
- package/dist/entries/drm-badge.js +1 -1
- package/dist/entries/duration.js +1 -1
- package/dist/entries/error-screen.js +1 -1
- package/dist/entries/fullscreen-button.js +1 -1
- package/dist/entries/live-button.js +1 -1
- package/dist/entries/marker-button.js +1 -1
- package/dist/entries/mute-button.js +1 -1
- package/dist/entries/pip-button.js +1 -1
- package/dist/entries/play-button.js +1 -1
- package/dist/entries/quality-menu.js +1 -1
- package/dist/entries/remaining-time.js +1 -1
- package/dist/entries/scan-button.js +1 -1
- package/dist/entries/seek-bar.js +1 -1
- package/dist/entries/skip-button.js +1 -1
- package/dist/entries/spacer.js +1 -1
- package/dist/entries/speed-menu.js +1 -1
- package/dist/entries/spinner.js +1 -1
- package/dist/entries/start-button.js +1 -1
- package/dist/entries/subtitles-menu.js +1 -1
- package/dist/entries/title.js +1 -1
- package/dist/entries/video-menu.js +1 -1
- package/dist/entries/volume-slider.js +1 -1
- package/dist/entries/volume.js +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.155.0 → _@oxc-project_runtime@0.158.0}/helpers/esm/asyncToGenerator.js +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.155.0 → _@oxc-project_runtime@0.158.0}/helpers/esm/defineProperty.js +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.155.0 → _@oxc-project_runtime@0.158.0}/helpers/esm/objectSpread2.js +1 -1
- package/dist/es2015/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/toPrimitive.js +13 -0
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.155.0 → _@oxc-project_runtime@0.158.0}/helpers/esm/toPropertyKey.js +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.155.0 → _@oxc-project_runtime@0.158.0}/helpers/esm/typeof.js +1 -1
- package/dist/es2015/controls/chapters.js +2 -2
- package/dist/es2015/controls/menu.js +1 -1
- package/dist/es2015/controls/native-tracks.js +1 -1
- package/dist/es2015/controls/pip.js +16 -3
- package/dist/es2015/element.js +220 -46
- package/dist/es2015/elements/airplay-button.js +1 -1
- package/dist/es2015/elements/audio-menu.js +4 -3
- package/dist/es2015/elements/casting.js +57 -0
- package/dist/es2015/elements/chapters-menu.js +5 -5
- package/dist/es2015/elements/component.js +26 -7
- package/dist/es2015/elements/control-bar.js +7 -6
- package/dist/es2015/elements/current-time.js +2 -2
- package/dist/es2015/elements/drm-badge.js +1 -1
- package/dist/es2015/elements/duration.js +3 -3
- package/dist/es2015/elements/error-screen.js +1 -1
- package/dist/es2015/elements/fullscreen-button.js +3 -2
- package/dist/es2015/elements/live-button.js +2 -2
- package/dist/es2015/elements/marker-button.js +3 -3
- package/dist/es2015/elements/menu-element.js +4 -4
- package/dist/es2015/elements/mute-button.js +3 -3
- package/dist/es2015/elements/pip-button.js +9 -4
- package/dist/es2015/elements/play-button.js +3 -3
- package/dist/es2015/elements/quality-menu.js +5 -4
- package/dist/es2015/elements/remaining-time.js +2 -2
- package/dist/es2015/elements/scan-button.js +4 -3
- package/dist/es2015/elements/seek-bar.js +20 -16
- package/dist/es2015/elements/shared.js +3 -3
- package/dist/es2015/elements/skip-button.js +2 -2
- package/dist/es2015/elements/speed-menu.js +4 -3
- package/dist/es2015/elements/spinner.js +1 -1
- package/dist/es2015/elements/start-button.js +3 -3
- package/dist/es2015/elements/subtitles-menu.js +5 -4
- package/dist/es2015/elements/time-element.js +1 -1
- package/dist/es2015/elements/title.js +1 -1
- package/dist/es2015/elements/video-menu.js +5 -4
- package/dist/es2015/elements/volume-slider.js +4 -4
- package/dist/es2015/entries/airplay-button.js +1 -1
- package/dist/es2015/entries/audio-menu.js +1 -1
- package/dist/es2015/entries/casting.js +6 -0
- package/dist/es2015/entries/chapters-menu.js +1 -1
- package/dist/es2015/entries/control-bar.js +1 -1
- package/dist/es2015/entries/current-time.js +1 -1
- package/dist/es2015/entries/drm-badge.js +1 -1
- package/dist/es2015/entries/duration.js +1 -1
- package/dist/es2015/entries/error-screen.js +1 -1
- package/dist/es2015/entries/fullscreen-button.js +1 -1
- package/dist/es2015/entries/live-button.js +1 -1
- package/dist/es2015/entries/marker-button.js +1 -1
- package/dist/es2015/entries/mute-button.js +1 -1
- package/dist/es2015/entries/pip-button.js +1 -1
- package/dist/es2015/entries/play-button.js +1 -1
- package/dist/es2015/entries/quality-menu.js +1 -1
- package/dist/es2015/entries/remaining-time.js +1 -1
- package/dist/es2015/entries/scan-button.js +1 -1
- package/dist/es2015/entries/seek-bar.js +1 -1
- package/dist/es2015/entries/skip-button.js +1 -1
- package/dist/es2015/entries/spacer.js +1 -1
- package/dist/es2015/entries/speed-menu.js +1 -1
- package/dist/es2015/entries/spinner.js +1 -1
- package/dist/es2015/entries/start-button.js +1 -1
- package/dist/es2015/entries/subtitles-menu.js +1 -1
- package/dist/es2015/entries/title.js +1 -1
- package/dist/es2015/entries/video-menu.js +1 -1
- package/dist/es2015/entries/volume-slider.js +1 -1
- package/dist/es2015/entries/volume.js +1 -1
- package/dist/es2015/host.js +9 -1
- package/dist/es2015/index.js +5 -3
- package/dist/es2015/locales/ar.js +2 -1
- package/dist/es2015/locales/ca.js +2 -1
- package/dist/es2015/locales/de.js +2 -1
- package/dist/es2015/locales/es.js +2 -1
- package/dist/es2015/locales/fr.js +2 -1
- package/dist/es2015/locales/hi.js +2 -1
- package/dist/es2015/locales/it.js +2 -1
- package/dist/es2015/locales/ja.js +2 -1
- package/dist/es2015/locales/ko.js +2 -1
- package/dist/es2015/locales/pt.js +2 -1
- package/dist/es2015/locales/zh.js +2 -1
- package/dist/es2015/locales.js +1 -1
- package/dist/es2015/media.js +136 -0
- package/dist/es2015/presets.js +1 -1
- package/dist/es2015/style.js +1 -1
- package/dist/es2015/tags.js +2 -1
- package/dist/es2015/video-sources.js +1 -1
- package/dist/host.d.ts +19 -1
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +9 -1
- package/dist/host.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -3
- package/dist/locales/ar.d.ts +1 -0
- package/dist/locales/ar.d.ts.map +1 -1
- package/dist/locales/ar.js +2 -1
- package/dist/locales/ar.js.map +1 -1
- package/dist/locales/ca.d.ts +1 -0
- package/dist/locales/ca.d.ts.map +1 -1
- package/dist/locales/ca.js +2 -1
- package/dist/locales/ca.js.map +1 -1
- package/dist/locales/de.d.ts +1 -0
- package/dist/locales/de.d.ts.map +1 -1
- package/dist/locales/de.js +2 -1
- package/dist/locales/de.js.map +1 -1
- package/dist/locales/es.d.ts +1 -0
- package/dist/locales/es.d.ts.map +1 -1
- package/dist/locales/es.js +2 -1
- package/dist/locales/es.js.map +1 -1
- package/dist/locales/fr.d.ts +1 -0
- package/dist/locales/fr.d.ts.map +1 -1
- package/dist/locales/fr.js +2 -1
- package/dist/locales/fr.js.map +1 -1
- package/dist/locales/hi.d.ts +1 -0
- package/dist/locales/hi.d.ts.map +1 -1
- package/dist/locales/hi.js +2 -1
- package/dist/locales/hi.js.map +1 -1
- package/dist/locales/it.d.ts +1 -0
- package/dist/locales/it.d.ts.map +1 -1
- package/dist/locales/it.js +2 -1
- package/dist/locales/it.js.map +1 -1
- package/dist/locales/ja.d.ts +1 -0
- package/dist/locales/ja.d.ts.map +1 -1
- package/dist/locales/ja.js +2 -1
- package/dist/locales/ja.js.map +1 -1
- package/dist/locales/ko.d.ts +1 -0
- package/dist/locales/ko.d.ts.map +1 -1
- package/dist/locales/ko.js +2 -1
- package/dist/locales/ko.js.map +1 -1
- package/dist/locales/pt.d.ts +1 -0
- package/dist/locales/pt.d.ts.map +1 -1
- package/dist/locales/pt.js +2 -1
- package/dist/locales/pt.js.map +1 -1
- package/dist/locales/zh.d.ts +1 -0
- package/dist/locales/zh.d.ts.map +1 -1
- package/dist/locales/zh.js +2 -1
- package/dist/locales/zh.js.map +1 -1
- package/dist/media.d.ts +22 -0
- package/dist/media.d.ts.map +1 -0
- package/dist/media.js +136 -0
- package/dist/media.js.map +1 -0
- package/dist/messages.d.ts +2 -0
- package/dist/messages.d.ts.map +1 -1
- package/dist/remote.d.ts +80 -0
- package/dist/remote.d.ts.map +1 -0
- package/dist/style.js +1 -1
- package/dist/style.js.map +1 -1
- package/dist/tags.d.ts +1 -0
- package/dist/tags.d.ts.map +1 -1
- package/dist/tags.js +2 -1
- package/dist/tags.js.map +1 -1
- package/dist/trackers.d.ts +2 -3
- package/dist/trackers.d.ts.map +1 -1
- package/dist/trackers.js.map +1 -1
- package/package.json +2 -2
- package/dist/es2015/_virtual/_@oxc-project_runtime@0.155.0/helpers/esm/toPrimitive.js +0 -13
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { fullscreen } from "../controls/fullscreen.js";
|
|
1
2
|
import { icon } from "../controls/icons.js";
|
|
2
3
|
import { Component } from "./component.js";
|
|
3
4
|
import { BUTTON_STYLE, iconSlots, show, style } from "./shared.js";
|
|
4
|
-
import { fullscreen } from "../controls/fullscreen.js";
|
|
5
5
|
// src/elements/fullscreen-button.ts
|
|
6
6
|
const STATES = ["enter", "exit"];
|
|
7
7
|
var MbxFullscreenButton = class extends Component {
|
|
@@ -10,6 +10,7 @@ var MbxFullscreenButton = class extends Component {
|
|
|
10
10
|
}
|
|
11
11
|
constructor() {
|
|
12
12
|
super();
|
|
13
|
+
this.leaves = "device";
|
|
13
14
|
this.api = null;
|
|
14
15
|
const root = this.attachShadow({ mode: "open" });
|
|
15
16
|
this.button = document.createElement("button");
|
|
@@ -23,7 +24,7 @@ var MbxFullscreenButton = class extends Component {
|
|
|
23
24
|
root.append(style(BUTTON_STYLE), this.button);
|
|
24
25
|
}
|
|
25
26
|
attach(player) {
|
|
26
|
-
const api = fullscreen(player, player.
|
|
27
|
+
const api = fullscreen(player, player.media);
|
|
27
28
|
this.api = api;
|
|
28
29
|
this.hidden = !api.supported;
|
|
29
30
|
this.keep(api.watch(() => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fullscreen-button.js","names":[],"sources":["../../src/elements/fullscreen-button.ts"],"sourcesContent":["/**\n * <mbx-fullscreen-button>: fullscreen on the player, through whichever\n * API the browser has, and hidden where there is none. The glyph is\n * `icon-enter` or `icon-exit`, the name `label-enter` or `label-exit`,\n * and the element sets `fullscreen` on the player while it is in.\n */\n\nimport type { Fullscreen } from '../controls/fullscreen.js';\nimport { fullscreen } from '../controls/fullscreen.js';\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 = 'enter' | 'exit';\nconst STATES: readonly State[] = ['enter', 'exit'];\n\nexport class MbxFullscreenButton 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: Fullscreen | 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' ? 'fullscreen' : 'fullscreen-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 = fullscreen(player, player.
|
|
1
|
+
{"version":3,"file":"fullscreen-button.js","names":[],"sources":["../../src/elements/fullscreen-button.ts"],"sourcesContent":["/**\n * <mbx-fullscreen-button>: fullscreen on the player, through whichever\n * API the browser has, and hidden where there is none. The glyph is\n * `icon-enter` or `icon-exit`, the name `label-enter` or `label-exit`,\n * and the element sets `fullscreen` on the player while it is in.\n */\n\nimport type { Fullscreen } from '../controls/fullscreen.js';\nimport { fullscreen } from '../controls/fullscreen.js';\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 = 'enter' | 'exit';\nconst STATES: readonly State[] = ['enter', 'exit'];\n\nexport class MbxFullscreenButton 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: Fullscreen | null;\n\n constructor() {\n super();\n // The device picks its own: nothing here reaches it.\n this.leaves = 'device';\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' ? 'fullscreen' : 'fullscreen-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 = fullscreen(player, player.media);\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(): void {\n this.api = null;\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.word('label-exit', 'exitFullscreen', 'Exit fullscreen')\n : this.word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AAM;CAC7C;AACF"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { live } from "../controls/session.js";
|
|
1
2
|
import { el } from "../dom.js";
|
|
2
3
|
import { Component } from "./component.js";
|
|
3
4
|
import { seekRow, style } from "./shared.js";
|
|
4
|
-
import { live } from "../controls/session.js";
|
|
5
5
|
// src/elements/live-button.ts
|
|
6
6
|
/**
|
|
7
7
|
* <mbx-live-button>: a dot and the word, the dot red at the edge and grey
|
|
@@ -45,7 +45,7 @@ var MbxLiveButton = class extends Component {
|
|
|
45
45
|
const tick = () => {
|
|
46
46
|
this.render();
|
|
47
47
|
};
|
|
48
|
-
this.listen(player.
|
|
48
|
+
this.listen(player.media, ["timeupdate", "emptied"], tick);
|
|
49
49
|
this.listen(player, ["sourcechange"], tick);
|
|
50
50
|
this.observe(player, ["live", "seekable"], tick);
|
|
51
51
|
this.render();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"live-button.js","names":[],"sources":["../../src/elements/live-button.ts"],"sourcesContent":["/**\n * <mbx-live-button>: a dot and the word, the dot red at the edge and grey\n * behind it, the way viewers read it everywhere. Shown once the stream has\n * an availability window, which is what makes it live; disabled at the\n * edge, where there is nowhere to go; a click seeks to the edge, the one\n * engine write the row makes. The element carries `at-edge` meanwhile.\n *\n * Without a seek bar, when the player says the stream is not seekable,\n * there is nowhere to come back from either: the dot stays red and the\n * button stays inert, whatever the playhead does. The word comes from\n * `text`, the name from `label-live` and `label-at-edge`. It sits in the\n * bar's seek row unless the page says otherwise.\n */\nimport { live } from '../controls/session.js';\nimport { el } from '../dom.js';\nimport type { PlayerHost } from '../host.js';\nimport { Component } from './component.js';\nimport STYLE from './live-button.css?inline';\nimport { seekRow, style } from './shared.js';\n\nexport class MbxLiveButton extends Component {\n static get observedAttributes(): readonly string[] {\n return ['text', 'label-live', 'label-at-edge'];\n }\n\n declare private readonly button: HTMLButtonElement;\n declare private readonly text: HTMLElement;\n\n constructor() {\n super();\n const root = this.attachShadow({ mode: 'open' });\n this.button = el('button', 'button');\n this.button.type = 'button';\n this.text = el('span', 'text');\n this.button.append(el('span', 'dot'), this.text);\n this.button.addEventListener('click', () => {\n live(this.player?.engine ?? null)?.seekToEdge();\n });\n root.append(style(STYLE), this.button);\n }\n\n override connectedCallback(): void {\n seekRow(this);\n super.connectedCallback();\n }\n\n protected override attach(player: PlayerHost): void {\n const tick = (): void => {\n this.render();\n };\n this.listen(player.
|
|
1
|
+
{"version":3,"file":"live-button.js","names":[],"sources":["../../src/elements/live-button.ts"],"sourcesContent":["/**\n * <mbx-live-button>: a dot and the word, the dot red at the edge and grey\n * behind it, the way viewers read it everywhere. Shown once the stream has\n * an availability window, which is what makes it live; disabled at the\n * edge, where there is nowhere to go; a click seeks to the edge, the one\n * engine write the row makes. The element carries `at-edge` meanwhile.\n *\n * Without a seek bar, when the player says the stream is not seekable,\n * there is nowhere to come back from either: the dot stays red and the\n * button stays inert, whatever the playhead does. The word comes from\n * `text`, the name from `label-live` and `label-at-edge`. It sits in the\n * bar's seek row unless the page says otherwise.\n */\nimport { live } from '../controls/session.js';\nimport { el } from '../dom.js';\nimport type { PlayerHost } from '../host.js';\nimport { Component } from './component.js';\nimport STYLE from './live-button.css?inline';\nimport { seekRow, style } from './shared.js';\n\nexport class MbxLiveButton extends Component {\n static get observedAttributes(): readonly string[] {\n return ['text', 'label-live', 'label-at-edge'];\n }\n\n declare private readonly button: HTMLButtonElement;\n declare private readonly text: HTMLElement;\n\n constructor() {\n super();\n const root = this.attachShadow({ mode: 'open' });\n this.button = el('button', 'button');\n this.button.type = 'button';\n this.text = el('span', 'text');\n this.button.append(el('span', 'dot'), this.text);\n this.button.addEventListener('click', () => {\n live(this.player?.engine ?? null)?.seekToEdge();\n });\n root.append(style(STYLE), this.button);\n }\n\n override connectedCallback(): void {\n seekRow(this);\n super.connectedCallback();\n }\n\n protected override attach(player: PlayerHost): void {\n const tick = (): void => {\n this.render();\n };\n this.listen(player.media, ['timeupdate', 'emptied'], tick);\n this.listen(player, ['sourcechange'], tick);\n this.observe(player, ['live', 'seekable'], tick);\n this.render();\n }\n\n protected override render(): void {\n const player = this.player;\n if (player === null) return;\n const api = live(player.engine);\n this.hidden = api === undefined;\n this.text.textContent = this.word('text', 'live', 'LIVE');\n if (api === undefined) return;\n // The seek bar decides seekability; while the player says live and not\n // seekable there is no bar to come back from.\n const stuck = player.hasAttribute('live') && !player.hasAttribute('seekable');\n const atEdge = stuck || api.atEdge;\n this.button.disabled = atEdge;\n this.toggleAttribute('at-edge', atEdge);\n this.button.setAttribute(\n 'aria-label',\n atEdge\n ? this.word('label-at-edge', 'atLiveEdge', 'At the live edge')\n : this.word('label-live', 'goLive', 'Go to the live edge'),\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAiBA,MAAA,QAAA;AAGA,IAAa,gBAAb,cAAmC,UAAU;CAC3C,WAAW,qBAAwC;EACjD,OAAO;GAAC;GAAQ;GAAc;EAAe;CAC/C;CAKA,cAAc;EACZ,MAAM;EACN,MAAM,OAAO,KAAK,aAAa,EAAE,MAAM,OAAO,CAAC;EAC/C,KAAK,SAAS,GAAG,UAAU,QAAQ;EACnC,KAAK,OAAO,OAAO;EACnB,KAAK,OAAO,GAAG,QAAQ,MAAM;EAC7B,KAAK,OAAO,OAAO,GAAG,QAAQ,KAAK,GAAG,KAAK,IAAI;EAC/C,KAAK,OAAO,iBAAiB,eAAe;GAC1C,KAAK,KAAK,QAAQ,UAAU,IAAI,CAAC,EAAE,WAAW;EAChD,CAAC;EACD,KAAK,OAAO,MAAM,KAAK,GAAG,KAAK,MAAM;CACvC;CAES,oBAA0B;EACjC,QAAQ,IAAI;EACZ,MAAM,kBAAkB;CAC1B;CAEmB,OAAO,QAA0B;EAClD,MAAM,aAAmB;GACvB,KAAK,OAAO;EACd;EACA,KAAK,OAAO,OAAO,OAAO,CAAC,cAAc,SAAS,GAAG,IAAI;EACzD,KAAK,OAAO,QAAQ,CAAC,cAAc,GAAG,IAAI;EAC1C,KAAK,QAAQ,QAAQ,CAAC,QAAQ,UAAU,GAAG,IAAI;EAC/C,KAAK,OAAO;CACd;CAEmB,SAAe;EAChC,MAAM,SAAS,KAAK;EACpB,IAAI,WAAW,MAAM;EACrB,MAAM,MAAM,KAAK,OAAO,MAAM;EAC9B,KAAK,SAAS,QAAQ,KAAA;EACtB,KAAK,KAAK,cAAc,KAAK,KAAK,QAAQ,QAAQ,MAAM;EACxD,IAAI,QAAQ,KAAA,GAAW;EAIvB,MAAM,SADQ,OAAO,aAAa,MAAM,KAAK,CAAC,OAAO,aAAa,UAAU,KACpD,IAAI;EAC5B,KAAK,OAAO,WAAW;EACvB,KAAK,gBAAgB,WAAW,MAAM;EACtC,KAAK,OAAO,aACV,cACA,SACI,KAAK,KAAK,iBAAiB,cAAc,kBAAkB,IAC3D,KAAK,KAAK,cAAc,UAAU,qBAAqB,CAC7D;CACF;AACF"}
|
|
@@ -34,7 +34,7 @@ var MbxMarkerButton = class extends Component {
|
|
|
34
34
|
chevron.append(path);
|
|
35
35
|
this.button.append(this.text, chevron);
|
|
36
36
|
this.button.addEventListener("click", () => {
|
|
37
|
-
const video = this.player?.
|
|
37
|
+
const video = this.player?.media;
|
|
38
38
|
if (video !== void 0 && this.marker !== null) video.currentTime = this.marker.end;
|
|
39
39
|
});
|
|
40
40
|
root.append(style(BUTTON_STYLE + STYLE_CSS), this.button);
|
|
@@ -44,7 +44,7 @@ var MbxMarkerButton = class extends Component {
|
|
|
44
44
|
super.connectedCallback();
|
|
45
45
|
}
|
|
46
46
|
attach(player) {
|
|
47
|
-
this.listen(player.
|
|
47
|
+
this.listen(player.media, [
|
|
48
48
|
"timeupdate",
|
|
49
49
|
"seeking",
|
|
50
50
|
"emptied"
|
|
@@ -85,7 +85,7 @@ var MbxMarkerButton = class extends Component {
|
|
|
85
85
|
}
|
|
86
86
|
render() {
|
|
87
87
|
const player = this.player;
|
|
88
|
-
this.marker = player?.markers.within(player.
|
|
88
|
+
this.marker = player?.markers.within(player.media.currentTime).find((marker) => marker.kind !== "blocked") ?? null;
|
|
89
89
|
if (this.marker?.kind === "closing-credits" && player?.hasAttribute("upnext") === true) this.marker = null;
|
|
90
90
|
this.hidden = this.marker === null;
|
|
91
91
|
if (this.marker === null) return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"marker-button.js","names":[],"sources":["../../src/elements/marker-button.ts"],"sourcesContent":["/**\n * <mbx-marker-button>: \"Skip intro\" over the picture while playback is in\n * the opening credits, \"Skip credits\" in the closing ones, and \"Skip\" with\n * the marker's own label in any other range the page named. A press moves\n * the playhead to the range's end. Blocked ranges never show it: the\n * player moves past those itself. The words come from\n * `label-opening-credits`, `label-closing-credits` and `label-skip`.\n *\n * While the player carries `upnext`, set by a card that offers the next\n * item, the button leaves the closing credits to it.\n */\nimport type { Marker } from '../controls/markers.js';\nimport type { PlayerHost } from '../host.js';\nimport type { Messages } from '../messages.js';\nimport { Component } from './component.js';\nimport STYLE_CSS from './marker-button.css?inline';\nimport { BUTTON_STYLE, style } from './shared.js';\n\n/** The id and the English of the button over each kind of range. */\nconst WORDS: Readonly<Record<string, readonly [keyof Messages, string]>> = {\n 'opening-credits': ['skipIntro', 'Skip intro'],\n 'closing-credits': ['skipCredits', 'Skip credits'],\n};\n\nexport class MbxMarkerButton extends Component {\n static get observedAttributes(): readonly string[] {\n return ['label-opening-credits', 'label-closing-credits', 'label-skip'];\n }\n\n declare private readonly button: HTMLButtonElement;\n declare private readonly text: HTMLSpanElement;\n /** The range the button skips, or null while playback is in none. */\n declare private marker: Marker | null;\n /** Watches the bar and the title: the button sits above whichever is taller. */\n declare private resizer: ResizeObserver | null;\n\n constructor() {\n super();\n this.marker = null;\n this.resizer = null;\n const root = this.attachShadow({ mode: 'open' });\n this.button = document.createElement('button');\n this.button.type = 'button';\n this.button.setAttribute('part', 'button');\n this.text = document.createElement('span');\n this.text.textContent = 'Skip';\n const chevron = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n chevron.setAttribute('viewBox', '0 0 32 32');\n chevron.setAttribute('aria-hidden', 'true');\n chevron.setAttribute('part', 'icon');\n const path = document.createElementNS('http://www.w3.org/2000/svg', 'path');\n path.setAttribute('d', 'M12 8l8 8l-8 8');\n chevron.append(path);\n this.button.append(this.text, chevron);\n this.button.addEventListener('click', () => {\n const video = this.player?.
|
|
1
|
+
{"version":3,"file":"marker-button.js","names":[],"sources":["../../src/elements/marker-button.ts"],"sourcesContent":["/**\n * <mbx-marker-button>: \"Skip intro\" over the picture while playback is in\n * the opening credits, \"Skip credits\" in the closing ones, and \"Skip\" with\n * the marker's own label in any other range the page named. A press moves\n * the playhead to the range's end. Blocked ranges never show it: the\n * player moves past those itself. The words come from\n * `label-opening-credits`, `label-closing-credits` and `label-skip`.\n *\n * While the player carries `upnext`, set by a card that offers the next\n * item, the button leaves the closing credits to it.\n */\nimport type { Marker } from '../controls/markers.js';\nimport type { PlayerHost } from '../host.js';\nimport type { Messages } from '../messages.js';\nimport { Component } from './component.js';\nimport STYLE_CSS from './marker-button.css?inline';\nimport { BUTTON_STYLE, style } from './shared.js';\n\n/** The id and the English of the button over each kind of range. */\nconst WORDS: Readonly<Record<string, readonly [keyof Messages, string]>> = {\n 'opening-credits': ['skipIntro', 'Skip intro'],\n 'closing-credits': ['skipCredits', 'Skip credits'],\n};\n\nexport class MbxMarkerButton extends Component {\n static get observedAttributes(): readonly string[] {\n return ['label-opening-credits', 'label-closing-credits', 'label-skip'];\n }\n\n declare private readonly button: HTMLButtonElement;\n declare private readonly text: HTMLSpanElement;\n /** The range the button skips, or null while playback is in none. */\n declare private marker: Marker | null;\n /** Watches the bar and the title: the button sits above whichever is taller. */\n declare private resizer: ResizeObserver | null;\n\n constructor() {\n super();\n this.marker = null;\n this.resizer = null;\n const root = this.attachShadow({ mode: 'open' });\n this.button = document.createElement('button');\n this.button.type = 'button';\n this.button.setAttribute('part', 'button');\n this.text = document.createElement('span');\n this.text.textContent = 'Skip';\n const chevron = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n chevron.setAttribute('viewBox', '0 0 32 32');\n chevron.setAttribute('aria-hidden', 'true');\n chevron.setAttribute('part', 'icon');\n const path = document.createElementNS('http://www.w3.org/2000/svg', 'path');\n path.setAttribute('d', 'M12 8l8 8l-8 8');\n chevron.append(path);\n this.button.append(this.text, chevron);\n this.button.addEventListener('click', () => {\n const video = this.player?.media;\n if (video !== undefined && this.marker !== null) video.currentTime = this.marker.end;\n });\n root.append(style(BUTTON_STYLE + STYLE_CSS), this.button);\n }\n\n override connectedCallback(): void {\n // Hidden until playback is in a marker; a constructor may not set attributes.\n this.hidden = true;\n super.connectedCallback();\n }\n\n protected override attach(player: PlayerHost): void {\n this.listen(player.media, ['timeupdate', 'seeking', 'emptied'], () => {\n this.render();\n });\n this.listen(player, ['markerschange'], () => {\n this.render();\n });\n // An up next card, from a playlist, takes over the closing credits.\n this.observe(player, ['upnext'], () => {\n this.render();\n });\n if (typeof ResizeObserver !== 'undefined') {\n this.resizer = new ResizeObserver(() => {\n this.fit(player);\n });\n this.resizer.observe(player);\n const bar = player.querySelector('mbx-control-bar');\n if (bar !== null) this.resizer.observe(bar);\n }\n this.fit(player);\n this.render();\n }\n\n protected override detach(): void {\n this.resizer?.disconnect();\n this.resizer = null;\n }\n\n /**\n * Lifts the button above the bar's rows: the bar's box less the padding\n * over them, its fade. The title sits on the other side, so the button\n * stays where it is while the title shows.\n */\n private fit(player: PlayerHost): void {\n const bar = player.querySelector('mbx-control-bar');\n const fade = bar === null ? 0 : Number.parseFloat(getComputedStyle(bar).paddingTop) || 0;\n const lift = bar === null ? 0 : bar.getBoundingClientRect().height - fade;\n this.style.setProperty('--mbx-marker-lift', `${Math.max(0, lift)}px`);\n }\n\n protected override render(): void {\n const player = this.player;\n this.marker =\n player?.markers\n .within(player.media.currentTime)\n .find((marker) => marker.kind !== 'blocked') ?? null;\n // A playlist's up next card offers the next item over the closing\n // credits, so this button steps aside while the player carries `upnext`.\n if (this.marker?.kind === 'closing-credits' && player?.hasAttribute('upnext') === true) {\n this.marker = null;\n }\n this.hidden = this.marker === null;\n if (this.marker === null) return;\n const kind = this.marker.kind;\n const skip = this.word('label-skip', 'skip', 'Skip');\n const known = WORDS[kind];\n this.text.textContent =\n known !== undefined\n ? this.word(`label-${kind}`, ...known)\n : (this.getAttribute(`label-${kind}`) ??\n (this.marker.label === undefined ? skip : `${skip} ${this.pageText(this.marker.label)}`));\n }\n}\n"],"mappings":";;;AAeA,MAAA,YAAA;;AAIA,MAAM,QAAqE;CACzE,mBAAmB,CAAC,aAAa,YAAY;CAC7C,mBAAmB,CAAC,eAAe,cAAc;AACnD;AAEA,IAAa,kBAAb,cAAqC,UAAU;CAC7C,WAAW,qBAAwC;EACjD,OAAO;GAAC;GAAyB;GAAyB;EAAY;CACxE;CASA,cAAc;EACZ,MAAM;EACN,KAAK,SAAS;EACd,KAAK,UAAU;EACf,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,OAAO,SAAS,cAAc,MAAM;EACzC,KAAK,KAAK,cAAc;EACxB,MAAM,UAAU,SAAS,gBAAgB,8BAA8B,KAAK;EAC5E,QAAQ,aAAa,WAAW,WAAW;EAC3C,QAAQ,aAAa,eAAe,MAAM;EAC1C,QAAQ,aAAa,QAAQ,MAAM;EACnC,MAAM,OAAO,SAAS,gBAAgB,8BAA8B,MAAM;EAC1E,KAAK,aAAa,KAAK,gBAAgB;EACvC,QAAQ,OAAO,IAAI;EACnB,KAAK,OAAO,OAAO,KAAK,MAAM,OAAO;EACrC,KAAK,OAAO,iBAAiB,eAAe;GAC1C,MAAM,QAAQ,KAAK,QAAQ;GAC3B,IAAI,UAAU,KAAA,KAAa,KAAK,WAAW,MAAM,MAAM,cAAc,KAAK,OAAO;EACnF,CAAC;EACD,KAAK,OAAO,MAAM,eAAe,SAA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AAW;EAC9B,IAAI,KAAK,WAAW,MAAM;EAC1B,MAAM,OAAO,KAAK,OAAO;EACzB,MAAM,OAAO,KAAK,KAAK,cAAc,QAAQ,MAAM;EACnD,MAAM,QAAQ,MAAM;EACpB,KAAK,KAAK,cACR,UAAU,KAAA,IACN,KAAK,KAAK,SAAS,QAAQ,GAAG,KAAK,IAClC,KAAK,aAAa,SAAS,MAAM,MACjC,KAAK,OAAO,UAAU,KAAA,IAAY,OAAO,GAAG,KAAK,GAAG,KAAK,SAAS,KAAK,OAAO,KAAK;CAC5F;AACF"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { fill } from "../labels.js";
|
|
2
1
|
import { icon } from "../controls/icons.js";
|
|
2
|
+
import { menu } from "../controls/menu.js";
|
|
3
|
+
import { fill } from "../labels.js";
|
|
3
4
|
import { Component } from "./component.js";
|
|
4
5
|
import { MENU_STYLE, iconSlots, style } from "./shared.js";
|
|
5
|
-
import { menu } from "../controls/menu.js";
|
|
6
6
|
// src/elements/menu-element.ts
|
|
7
7
|
var MenuElement = class extends Component {
|
|
8
8
|
constructor(states, glyphs) {
|
|
@@ -10,7 +10,7 @@ var MenuElement = class extends Component {
|
|
|
10
10
|
const root = this.attachShadow({ mode: "open" });
|
|
11
11
|
this.menu = menu({
|
|
12
12
|
host: this,
|
|
13
|
-
picture: () => this.player?.
|
|
13
|
+
picture: () => this.player?.media.getBoundingClientRect() ?? null,
|
|
14
14
|
frame: () => this.player,
|
|
15
15
|
back: (page) => fill(this.word("label-back", "menuBack", "Back from {page}"), { page })
|
|
16
16
|
});
|
|
@@ -1 +1 @@
|
|
|
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 type { Messages } from '../messages.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?.
|
|
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 type { Messages } from '../messages.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?.media.getBoundingClientRect() ?? null,\n frame: () => this.player,\n back: (page) => fill(this.word('label-back', 'menuBack', '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.backdrop, this.menu.popup);\n }\n\n /** The id and the English of the button's default name. */\n protected abstract name(): readonly [keyof Messages, string];\n\n protected override detach(): void {\n this.menu.close();\n }\n\n protected override render(): void {\n this.menu.label(this.word('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":";;;;;;AAgBA,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,aAAa,KAAK;GAClB,OAAO,SAAS,KAAK,KAAK,KAAK,cAAc,YAAY,kBAAkB,GAAG,EAAE,KAAK,CAAC;EACxF,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,UAAU,KAAK,KAAK,KAAK;CACtF;CAKmB,SAAe;EAChC,KAAK,KAAK,MAAM;CAClB;CAEmB,SAAe;EAChC,KAAK,KAAK,MAAM,KAAK,KAAK,SAAS,GAAG,KAAK,KAAK,CAAC,CAAC;CACpD;AACF;;AAGA,SAAgB,OAAO,MAA6D;CAClF,OAAO,CAAC,CAAC,SAAS,SAAS,KAAK,IAAI,CAAC;AACvC"}
|
|
@@ -32,7 +32,7 @@ var MbxMuteButton = class extends Component {
|
|
|
32
32
|
root.append(style(BUTTON_STYLE), this.button);
|
|
33
33
|
}
|
|
34
34
|
toggle() {
|
|
35
|
-
const video = this.player?.
|
|
35
|
+
const video = this.player?.media;
|
|
36
36
|
if (video === void 0) return;
|
|
37
37
|
if (video.muted) {
|
|
38
38
|
video.muted = false;
|
|
@@ -40,13 +40,13 @@ var MbxMuteButton = class extends Component {
|
|
|
40
40
|
} else video.muted = true;
|
|
41
41
|
}
|
|
42
42
|
attach(player) {
|
|
43
|
-
this.listen(player.
|
|
43
|
+
this.listen(player.media, ["volumechange", "emptied"], () => {
|
|
44
44
|
this.render();
|
|
45
45
|
});
|
|
46
46
|
this.render();
|
|
47
47
|
}
|
|
48
48
|
render() {
|
|
49
|
-
const video = this.player?.
|
|
49
|
+
const video = this.player?.media;
|
|
50
50
|
if (video === void 0) return;
|
|
51
51
|
const silent = video.muted || video.volume === 0;
|
|
52
52
|
show(this.slots, silent ? "mute" : video.volume <= .5 ? "low" : "high");
|
|
@@ -1 +1 @@
|
|
|
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?.
|
|
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?.media;\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.media, ['volumechange', 'emptied'], () => {\n this.render();\n });\n this.render();\n }\n\n protected override render(): void {\n const video = this.player?.media;\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.word('label-unmute', 'unmute', 'Unmute')\n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AK,gBAAgB,UAAU,QAAQ,IAC5C,KAAK,KAAK,cAAc,QAAQ,MAAM,CAC5C;EACA,KAAK,OAAO,aAAa,gBAAgB,OAAO,MAAM,KAAK,CAAC;CAC9D;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pip-button.d.ts","sourceRoot":"","sources":["../../src/elements/pip-button.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pip-button.d.ts","sourceRoot":"","sources":["../../src/elements/pip-button.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAM3C,qBAAa,YAAa,SAAQ,SAAS;IACzC,MAAM,KAAK,kBAAkB,IAAI,SAAS,MAAM,EAAE,CAEjD;IAED,iBAAyB,MAAM,CAAoB;IACnD,iBAAyB,KAAK,CAAiC;IAC/D,QAAgB,GAAG,CAA0B;;cAqB1B,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;cAehC,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;cAKhC,MAAM,IAAI,IAAI;CAelC"}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { icon } from "../controls/icons.js";
|
|
2
|
+
import { pictureInPicture } from "../controls/pip.js";
|
|
3
|
+
import { videoOf } from "../host.js";
|
|
2
4
|
import { Component } from "./component.js";
|
|
3
5
|
import { BUTTON_STYLE, iconSlots, show, style } from "./shared.js";
|
|
4
|
-
import { pictureInPicture } from "../controls/pip.js";
|
|
5
6
|
// src/elements/pip-button.ts
|
|
6
7
|
/**
|
|
7
8
|
* <mbx-pip-button>: picture in picture, through whichever API the browser
|
|
8
|
-
* has, and hidden where there is none
|
|
9
|
+
* has, and hidden where there is none or the player has
|
|
10
|
+
* `disablepictureinpicture`. The glyph is `icon-enter` or
|
|
9
11
|
* `icon-exit`, the name `label-enter` or `label-exit`, and the element
|
|
10
12
|
* sets `pip` on the player while the video is in the floating window.
|
|
11
13
|
*/
|
|
@@ -16,6 +18,7 @@ var MbxPipButton = class extends Component {
|
|
|
16
18
|
}
|
|
17
19
|
constructor() {
|
|
18
20
|
super();
|
|
21
|
+
this.leaves = "device";
|
|
19
22
|
this.api = null;
|
|
20
23
|
const root = this.attachShadow({ mode: "open" });
|
|
21
24
|
this.button = document.createElement("button");
|
|
@@ -29,9 +32,10 @@ var MbxPipButton = class extends Component {
|
|
|
29
32
|
root.append(style(BUTTON_STYLE), this.button);
|
|
30
33
|
}
|
|
31
34
|
attach(player) {
|
|
32
|
-
const
|
|
35
|
+
const video = videoOf(player);
|
|
36
|
+
if (video === null) return;
|
|
37
|
+
const api = pictureInPicture(video);
|
|
33
38
|
this.api = api;
|
|
34
|
-
this.hidden = !api.supported;
|
|
35
39
|
this.keep(api.watch(() => {
|
|
36
40
|
this.render();
|
|
37
41
|
}));
|
|
@@ -45,6 +49,7 @@ var MbxPipButton = class extends Component {
|
|
|
45
49
|
const player = this.player;
|
|
46
50
|
if (player === null || this.api === null) return;
|
|
47
51
|
const active = this.api.active();
|
|
52
|
+
this.hidden = !this.api.supported || !this.api.allowed() && !active;
|
|
48
53
|
show(this.slots, active ? "exit" : "enter");
|
|
49
54
|
this.button.setAttribute("aria-label", active ? this.word("label-exit", "exitPip", "Leave picture in picture") : this.word("label-enter", "enterPip", "Picture in picture"));
|
|
50
55
|
player.toggleAttribute("pip", active);
|
|
@@ -1 +1 @@
|
|
|
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
|
|
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 or the player has\n * `disablepictureinpicture`. 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 { videoOf } 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 // The device picks its own: nothing here reaches it.\n this.leaves = 'device';\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 // The node, since the document names the picture-in-picture element by\n // it and an observer takes nothing else. `player.media` is not a node.\n const video = videoOf(player);\n if (video === null) return;\n const api = pictureInPicture(video);\n this.api = api;\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 // While the video floats the button stays, so the viewer can bring it back.\n this.hidden = !this.api.supported || (!this.api.allowed() && !active);\n show(this.slots, active ? 'exit' : 'enter');\n this.button.setAttribute(\n 'aria-label',\n active\n ? this.word('label-exit', 'exitPip', 'Leave picture in picture')\n : this.word('label-enter', 'enterPip', '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A,SACI,KAAK,KAAK,cAAc,WAAW,0BAA0B,IAC7D,KAAK,KAAK,eAAe,YAAY,oBAAoB,CAC/D;EACA,OAAO,gBAAgB,OAAO,MAAM;CACtC;AACF"}
|
|
@@ -40,13 +40,13 @@ var MbxPlayButton = class extends Component {
|
|
|
40
40
|
root.append(style(BUTTON_STYLE), this.button);
|
|
41
41
|
}
|
|
42
42
|
toggle() {
|
|
43
|
-
const video = this.player?.
|
|
43
|
+
const video = this.player?.media;
|
|
44
44
|
if (video === void 0) return;
|
|
45
45
|
if (video.paused) video.play().catch(() => void 0);
|
|
46
46
|
else video.pause();
|
|
47
47
|
}
|
|
48
48
|
attach(player) {
|
|
49
|
-
this.listen(player.
|
|
49
|
+
this.listen(player.media, [
|
|
50
50
|
"play",
|
|
51
51
|
"pause",
|
|
52
52
|
"ended",
|
|
@@ -62,7 +62,7 @@ var MbxPlayButton = class extends Component {
|
|
|
62
62
|
render() {
|
|
63
63
|
const player = this.player;
|
|
64
64
|
if (player === null) return;
|
|
65
|
-
const state = player.
|
|
65
|
+
const state = player.media.ended ? "replay" : shownPaused(player) ? "play" : "pause";
|
|
66
66
|
show(this.slots, state);
|
|
67
67
|
this.button.setAttribute("aria-label", this.word(`label-${state}`, state, LABELS[state]));
|
|
68
68
|
}
|
|
@@ -1 +1 @@
|
|
|
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, or a switch loads another source, the button shows the state from\n * before, which the player carries as `scrubbing` or `switching`.\n */\nimport { icon } from '../controls/icons.js';\nimport type { PlayerHost } from '../host.js';\nimport { Component } from './component.js';\nimport { BUTTON_STYLE, HELD, iconSlots, show, shownPaused, style } from './shared.js';\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?.
|
|
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, or a switch loads another source, the button shows the state from\n * before, which the player carries as `scrubbing` or `switching`.\n */\nimport { icon } from '../controls/icons.js';\nimport type { PlayerHost } from '../host.js';\nimport { Component } from './component.js';\nimport { BUTTON_STYLE, HELD, iconSlots, show, shownPaused, style } from './shared.js';\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?.media;\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.media, ['play', 'pause', 'ended', 'emptied'], () => {\n this.render();\n });\n this.observe(player, HELD, () => {\n this.render();\n });\n this.render();\n }\n\n protected override render(): void {\n const player = this.player;\n if (player === null) return;\n const state: State = player.media.ended ? 'replay' : shownPaused(player) ? 'play' : 'pause';\n show(this.slots, state);\n this.button.setAttribute('aria-label', this.word(`label-${state}`, 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;CAEQ,SAAe;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;CAEmB,OAAO,QAA0B;EAClD,KAAK,OAAO,OAAO,OAAO;GAAC;GAAQ;GAAS;GAAS;EAAS,SAAS;GACrE,KAAK,OAAO;EACd,CAAC;EACD,KAAK,QAAQ,QAAQ,YAAY;GAC/B,KAAK,OAAO;EACd,CAAC;EACD,KAAK,OAAO;CACd;CAEmB,SAAe;EAChC,MAAM,SAAS,KAAK;EACpB,IAAI,WAAW,MAAM;EACrB,MAAM,QAAe,OAAO,MAAM,QAAQ,WAAW,YAAY,MAAM,IAAI,SAAS;EACpF,KAAK,KAAK,OAAO,KAAK;EACtB,KAAK,OAAO,aAAa,cAAc,KAAK,KAAK,SAAS,SAAS,OAAO,OAAO,MAAM,CAAC;CAC1F;AACF"}
|
|
@@ -1 +1 @@
|
|
|
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,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,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;;
|
|
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,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,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;;cAWzB,IAAI,IAAI,SAAS,CAAC,MAAM,QAAQ,EAAE,MAAM,CAAC;cAIzC,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;cA6BhC,MAAM,IAAI,IAAI;IA4BjC,6FAA6F;IAC7F,OAAO,CAAC,WAAW;CAOpB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { show } from "./shared.js";
|
|
2
|
-
import { MenuElement, single } from "./menu-element.js";
|
|
3
1
|
import { qualityLabels, qualityNames } from "../controls/quality-names.js";
|
|
2
|
+
import { MenuElement, single } from "./menu-element.js";
|
|
3
|
+
import { show } from "./shared.js";
|
|
4
4
|
// src/elements/quality-menu.ts
|
|
5
5
|
const AUTO = "auto";
|
|
6
6
|
var MbxQualityMenu = class extends MenuElement {
|
|
@@ -13,6 +13,7 @@ var MbxQualityMenu = class extends MenuElement {
|
|
|
13
13
|
}
|
|
14
14
|
constructor() {
|
|
15
15
|
super(...single("quality"));
|
|
16
|
+
this.leaves = "device";
|
|
16
17
|
this.engine = null;
|
|
17
18
|
this.playing = void 0;
|
|
18
19
|
show(this.slots, "default");
|
|
@@ -31,9 +32,9 @@ var MbxQualityMenu = class extends MenuElement {
|
|
|
31
32
|
const clock = () => {
|
|
32
33
|
if (this.playingName() !== this.playing) this.render();
|
|
33
34
|
};
|
|
34
|
-
player.
|
|
35
|
+
player.media.addEventListener("timeupdate", clock);
|
|
35
36
|
const offs = [
|
|
36
|
-
() => player.
|
|
37
|
+
() => player.media.removeEventListener("timeupdate", clock),
|
|
37
38
|
engine.on("tracks:changed", tick),
|
|
38
39
|
engine.on("tracks:selected", tick),
|
|
39
40
|
engine.on("quality:constraints-unsatisfiable", tick),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quality-menu.js","names":[],"sources":["../../src/elements/quality-menu.ts"],"sourcesContent":["/**\n * <mbx-quality-menu>: the pin over `engine.quality`, where \"auto\" means\n * none. Hidden without renditions, and for a native session. The name\n * comes from `label`, the word for no pin from `label-auto`. It offers\n * `engine.quality.selectable`, labelled by `qualityNames`. Under Auto, the\n * Auto row names what plays, in its detail.\n */\nimport type { Mattebox } from 'mattebox';\nimport { qualityLabels, qualityNames } from '../controls/quality-names.js';\nimport type { PlayerHost } from '../host.js';\nimport type { Messages } from '../messages.js';\nimport { MenuElement, single } from './menu-element.js';\nimport { show } from './shared.js';\n\nconst AUTO = 'auto';\n\nexport class MbxQualityMenu extends MenuElement {\n static get observedAttributes(): readonly string[] {\n return ['label', 'label-auto', 'label-back'];\n }\n\n declare private engine: Mattebox | null;\n /** The name of what plays, as the Auto row last showed it. */\n declare private playing: string | undefined;\n\n constructor() {\n super(...single('quality'));\n this.engine = null;\n this.playing = undefined;\n show(this.slots, 'default');\n }\n\n protected override name(): readonly [keyof Messages, string] {\n return ['quality', '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.
|
|
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 type { Messages } from '../messages.js';\nimport { MenuElement, single } from './menu-element.js';\nimport { show } from './shared.js';\n\nconst AUTO = 'auto';\n\nexport class MbxQualityMenu extends MenuElement {\n static get observedAttributes(): readonly string[] {\n return ['label', 'label-auto', 'label-back'];\n }\n\n declare private engine: Mattebox | null;\n /** The name of what plays, as the Auto row last showed it. */\n declare private playing: string | undefined;\n\n constructor() {\n super(...single('quality'));\n // The device picks its own: nothing here reaches it.\n this.leaves = 'device';\n this.engine = null;\n this.playing = undefined;\n show(this.slots, 'default');\n }\n\n protected override name(): readonly [keyof Messages, string] {\n return ['quality', '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.media.addEventListener('timeupdate', clock);\n const offs = [\n () => player.media.removeEventListener('timeupdate', clock),\n engine.on('tracks:changed', tick),\n // A switch of the video track, such as to the I-frame track for a\n // scrub and back, changes the renditions without changing the list.\n engine.on('tracks:selected', 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.word('label-auto', 'qualityAuto', '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":";;;;AAcA,MAAM,OAAO;AAEb,IAAa,iBAAb,cAAoC,YAAY;CAC9C,WAAW,qBAAwC;EACjD,OAAO;GAAC;GAAS;GAAc;EAAY;CAC7C;CAMA,cAAc;EACZ,MAAM,GAAG,OAAO,SAAS,CAAC;EAE1B,KAAK,SAAS;EACd,KAAK,SAAS;EACd,KAAK,UAAU,KAAA;EACf,KAAK,KAAK,OAAO,SAAS;CAC5B;CAEmB,OAA0C;EAC3D,OAAO,CAAC,WAAW,SAAS;CAC9B;CAEmB,OAAO,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;IAGhC,OAAO,GAAG,mBAAmB,IAAI;IACjC,OAAO,GAAG,qCAAqC,IAAI;IACnD,OAAO,GAAG,6BAA6B,IAAI;GAC7C;GACA,aAAa;IACX,KAAK,MAAM,OAAO,MAAM,IAAI;GAC9B;EACF,CAAC;CACH;CAEmB,SAAe;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,KAAK,cAAc,eAAe,MAAM;GAAG,KAAK;EAAO,GACnE,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;;CAGQ,cAAkC;EACxC,MAAM,UAAU,KAAK,QAAQ;EAC7B,IAAI,YAAY,KAAA,KAAa,QAAQ,WAAW,MAAM,OAAO,KAAA;EAE7D,MAAM,KAAK,QAAQ,SAAS;EAC5B,OAAO,cAAc,QAAQ,UAAU,CAAC,CAAC,MAAM,CAAC,eAAe,cAAc,EAAE,CAAC,GAAG;CACrF;AACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { format } from "../controls/time.js";
|
|
2
1
|
import { live, span } from "../controls/session.js";
|
|
2
|
+
import { format } from "../controls/time.js";
|
|
3
3
|
import { TimeElement } from "./time-element.js";
|
|
4
4
|
// src/elements/remaining-time.ts
|
|
5
5
|
/**
|
|
@@ -16,7 +16,7 @@ var MbxRemainingTime = class extends TimeElement {
|
|
|
16
16
|
render() {
|
|
17
17
|
const player = this.player;
|
|
18
18
|
if (player === null) return;
|
|
19
|
-
const video = player.
|
|
19
|
+
const video = player.media;
|
|
20
20
|
const engine = player.engine;
|
|
21
21
|
const on = live(engine) !== void 0;
|
|
22
22
|
this.hidden = on;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remaining-time.js","names":[],"sources":["../../src/elements/remaining-time.ts"],"sourcesContent":["/**\n * <mbx-remaining-time>: what is left, \"-4:53\", once the metadata is in. A\n * bar that shows one number shows this one: a viewer asks how much is\n * left more often than where they are. A live stream has no end, so the\n * element hides while the stream is live, as the duration does.\n */\nimport { live, span } from '../controls/session.js';\nimport { format } from '../controls/time.js';\nimport { TimeElement } from './time-element.js';\nimport TRAILING from './trailing-time.css?inline';\n\nexport class MbxRemainingTime extends TimeElement {\n constructor() {\n super(TRAILING);\n }\n\n protected override render(): void {\n const player = this.player;\n if (player === null) return;\n const video = player.
|
|
1
|
+
{"version":3,"file":"remaining-time.js","names":[],"sources":["../../src/elements/remaining-time.ts"],"sourcesContent":["/**\n * <mbx-remaining-time>: what is left, \"-4:53\", once the metadata is in. A\n * bar that shows one number shows this one: a viewer asks how much is\n * left more often than where they are. A live stream has no end, so the\n * element hides while the stream is live, as the duration does.\n */\nimport { live, span } from '../controls/session.js';\nimport { format } from '../controls/time.js';\nimport { TimeElement } from './time-element.js';\nimport TRAILING from './trailing-time.css?inline';\n\nexport class MbxRemainingTime extends TimeElement {\n constructor() {\n super(TRAILING);\n }\n\n protected override render(): void {\n const player = this.player;\n if (player === null) return;\n const video = player.media;\n const engine = player.engine;\n const on = live(engine) !== undefined;\n this.hidden = on;\n if (!on)\n this.text.data = `-${format(Math.max(0, span(video, engine).end - video.currentTime))}`;\n }\n}\n"],"mappings":";;;;;;;;;;AASA,MAAA,WAAA;AAEA,IAAa,mBAAb,cAAsC,YAAY;CAChD,cAAc;EACZ,MAAM,QAAQ;CAChB;CAEmB,SAAe;EAChC,MAAM,SAAS,KAAK;EACpB,IAAI,WAAW,MAAM;EACrB,MAAM,QAAQ,OAAO;EACrB,MAAM,SAAS,OAAO;EACtB,MAAM,KAAK,KAAK,MAAM,MAAM,KAAA;EAC5B,KAAK,SAAS;EACd,IAAI,CAAC,IACH,KAAK,KAAK,OAAO,IAAI,OAAO,KAAK,IAAI,GAAG,KAAK,OAAO,MAAM,CAAC,CAAC,MAAM,MAAM,WAAW,CAAC;CACxF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scan-button.d.ts","sourceRoot":"","sources":["../../src/elements/scan-button.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAkB3C,qBAAa,aAAc,SAAQ,SAAS;IAC1C,MAAM,KAAK,kBAAkB,IAAI,SAAS,MAAM,EAAE,CAEjD;IAED,iBAAyB,MAAM,CAAoB;IACnD,iBAAyB,KAAK,CAAkB;IAChD,iBAAyB,KAAK,CAAc;;
|
|
1
|
+
{"version":3,"file":"scan-button.d.ts","sourceRoot":"","sources":["../../src/elements/scan-button.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAkB3C,qBAAa,aAAc,SAAQ,SAAS;IAC1C,MAAM,KAAK,kBAAkB,IAAI,SAAS,MAAM,EAAE,CAEjD;IAED,iBAAyB,MAAM,CAAoB;IACnD,iBAAyB,KAAK,CAAkB;IAChD,iBAAyB,KAAK,CAAc;;IAoBnC,iBAAiB,IAAI,IAAI;IAOlC,OAAO,CAAC,QAAQ;IAIhB,2EAA2E;IAC3E,OAAO,CAAC,KAAK;IAQb,OAAO,CAAC,IAAI;cAYO,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;cAgBhC,MAAM,IAAI,IAAI;CAkBlC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { el, setChildren } from "../dom.js";
|
|
2
1
|
import { icon } from "../controls/icons.js";
|
|
2
|
+
import { optional } from "../controls/session.js";
|
|
3
|
+
import { el, setChildren } from "../dom.js";
|
|
3
4
|
import { Component } from "./component.js";
|
|
4
5
|
import { BUTTON_STYLE, style } from "./shared.js";
|
|
5
|
-
import { optional } from "../controls/session.js";
|
|
6
6
|
// src/elements/scan-button.ts
|
|
7
7
|
/**
|
|
8
8
|
* <mbx-scan-button>: fast forward, or rewind with `direction="backward"`,
|
|
@@ -44,6 +44,7 @@ var MbxScanButton = class extends Component {
|
|
|
44
44
|
}
|
|
45
45
|
constructor() {
|
|
46
46
|
super();
|
|
47
|
+
this.leaves = "device";
|
|
47
48
|
const root = this.attachShadow({ mode: "open" });
|
|
48
49
|
this.button = el("button", "button");
|
|
49
50
|
this.button.type = "button";
|
|
@@ -83,7 +84,7 @@ var MbxScanButton = class extends Component {
|
|
|
83
84
|
const tick = () => {
|
|
84
85
|
this.render();
|
|
85
86
|
};
|
|
86
|
-
this.listen(player.
|
|
87
|
+
this.listen(player.media, ["emptied"], tick);
|
|
87
88
|
this.observe(player, ["live", "seekable"], tick);
|
|
88
89
|
this.follow(player, (engine) => {
|
|
89
90
|
tick();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scan-button.js","names":[],"sources":["../../src/elements/scan-button.ts"],"sourcesContent":["/**\n * <mbx-scan-button>: fast forward, or rewind with `direction=\"backward\"`,\n * through the I-frame track: `engine.trick.setRate`, see the engine guide's\n * trick play chapter. Each press steps up through `rates`, \"4 8 16\" by\n * default, and a press past the last one plays at normal speed again. A\n * press while the other button scans starts this one at its first rate.\n * Every rate must be above 2, the engine's own floor for a scan.\n *\n * The button shows only when the session has an I-frame track: without\n * one there is no picture to scan with, and the speed menu covers playback\n * speed. It hides too on a live stream whose window is too short to seek,\n * where the player carries `live` and not `seekable`, as the seek bar does. It carries `aria-pressed` and `scanning` while it scans, and its\n * `rate` part shows the rate, \"8×\". The name comes from `label`,\n * \"Fast forward\" or \"Rewind\".\n */\nimport { icon } from '../controls/icons.js';\nimport { optional } from '../controls/session.js';\nimport { el, setChildren } from '../dom.js';\nimport type { PlayerHost } from '../host.js';\nimport { Component } from './component.js';\nimport STYLE_CSS from './scan-button.css?inline';\nimport { BUTTON_STYLE, style } from './shared.js';\n\nconst RATES = [4, 8, 16];\n\n/** The engine's floor: a scan rate is above 2 or below -2. */\nconst FLOOR = 2;\n\n/**\n * What changes the rate or whether scanning is possible: every rate change,\n * from either button, the page, or the engine ending a scan, and a new track\n * list, which is when an I-frame track appears.\n */\nconst ENGINE_EVENTS = ['trick:rate', 'tracks:changed'];\n\nconst STYLE = BUTTON_STYLE + STYLE_CSS;\n\nexport class MbxScanButton extends Component {\n static get observedAttributes(): readonly string[] {\n return ['direction', 'rates', 'label'];\n }\n\n declare private readonly button: HTMLButtonElement;\n declare private readonly glyph: HTMLSlotElement;\n declare private readonly badge: HTMLElement;\n\n constructor() {\n super();\n const root = this.attachShadow({ mode: 'open' });\n this.button = el('button', 'button');\n this.button.type = 'button';\n this.glyph = document.createElement('slot');\n this.glyph.name = 'icon';\n this.badge = el('span', 'rate');\n this.badge.hidden = true;\n this.button.append(this.glyph, this.badge);\n this.button.addEventListener('click', () => {\n this.step();\n });\n root.append(style(STYLE), this.button);\n }\n\n override connectedCallback(): void {\n // Hidden until a session says it has an I-frame track. Not in the\n // constructor: a new custom element must not have attributes.\n this.hidden = true;\n super.connectedCallback();\n }\n\n private backward(): boolean {\n return this.getAttribute('direction') === 'backward';\n }\n\n /** The rates to step through, each above the floor, in the order given. */\n private rates(): number[] {\n const own = (this.getAttribute('rates') ?? '')\n .split(/\\s+/)\n .map(Number)\n .filter((rate) => Number.isFinite(rate) && rate > FLOOR);\n return own.length > 0 ? own : RATES;\n }\n\n private step(): void {\n const trick = optional(this.player?.engine ?? null).trick;\n if (trick?.available !== true) return;\n const sign = this.backward() ? -1 : 1;\n const rates = this.rates();\n const now = trick.rate * sign;\n // Scanning this way: the next rate up, or normal playback past the last.\n const next = now > FLOOR ? rates[rates.indexOf(now) + 1] : rates[0];\n trick.setRate(next === undefined ? 1 : next * sign);\n this.render();\n }\n\n protected override attach(player: PlayerHost): void {\n const tick = (): void => {\n this.render();\n };\n this.listen(player.
|
|
1
|
+
{"version":3,"file":"scan-button.js","names":[],"sources":["../../src/elements/scan-button.ts"],"sourcesContent":["/**\n * <mbx-scan-button>: fast forward, or rewind with `direction=\"backward\"`,\n * through the I-frame track: `engine.trick.setRate`, see the engine guide's\n * trick play chapter. Each press steps up through `rates`, \"4 8 16\" by\n * default, and a press past the last one plays at normal speed again. A\n * press while the other button scans starts this one at its first rate.\n * Every rate must be above 2, the engine's own floor for a scan.\n *\n * The button shows only when the session has an I-frame track: without\n * one there is no picture to scan with, and the speed menu covers playback\n * speed. It hides too on a live stream whose window is too short to seek,\n * where the player carries `live` and not `seekable`, as the seek bar does. It carries `aria-pressed` and `scanning` while it scans, and its\n * `rate` part shows the rate, \"8×\". The name comes from `label`,\n * \"Fast forward\" or \"Rewind\".\n */\nimport { icon } from '../controls/icons.js';\nimport { optional } from '../controls/session.js';\nimport { el, setChildren } from '../dom.js';\nimport type { PlayerHost } from '../host.js';\nimport { Component } from './component.js';\nimport STYLE_CSS from './scan-button.css?inline';\nimport { BUTTON_STYLE, style } from './shared.js';\n\nconst RATES = [4, 8, 16];\n\n/** The engine's floor: a scan rate is above 2 or below -2. */\nconst FLOOR = 2;\n\n/**\n * What changes the rate or whether scanning is possible: every rate change,\n * from either button, the page, or the engine ending a scan, and a new track\n * list, which is when an I-frame track appears.\n */\nconst ENGINE_EVENTS = ['trick:rate', 'tracks:changed'];\n\nconst STYLE = BUTTON_STYLE + STYLE_CSS;\n\nexport class MbxScanButton extends Component {\n static get observedAttributes(): readonly string[] {\n return ['direction', 'rates', 'label'];\n }\n\n declare private readonly button: HTMLButtonElement;\n declare private readonly glyph: HTMLSlotElement;\n declare private readonly badge: HTMLElement;\n\n constructor() {\n super();\n // The device picks its own: nothing here reaches it.\n this.leaves = 'device';\n const root = this.attachShadow({ mode: 'open' });\n this.button = el('button', 'button');\n this.button.type = 'button';\n this.glyph = document.createElement('slot');\n this.glyph.name = 'icon';\n this.badge = el('span', 'rate');\n this.badge.hidden = true;\n this.button.append(this.glyph, this.badge);\n this.button.addEventListener('click', () => {\n this.step();\n });\n root.append(style(STYLE), this.button);\n }\n\n override connectedCallback(): void {\n // Hidden until a session says it has an I-frame track. Not in the\n // constructor: a new custom element must not have attributes.\n this.hidden = true;\n super.connectedCallback();\n }\n\n private backward(): boolean {\n return this.getAttribute('direction') === 'backward';\n }\n\n /** The rates to step through, each above the floor, in the order given. */\n private rates(): number[] {\n const own = (this.getAttribute('rates') ?? '')\n .split(/\\s+/)\n .map(Number)\n .filter((rate) => Number.isFinite(rate) && rate > FLOOR);\n return own.length > 0 ? own : RATES;\n }\n\n private step(): void {\n const trick = optional(this.player?.engine ?? null).trick;\n if (trick?.available !== true) return;\n const sign = this.backward() ? -1 : 1;\n const rates = this.rates();\n const now = trick.rate * sign;\n // Scanning this way: the next rate up, or normal playback past the last.\n const next = now > FLOOR ? rates[rates.indexOf(now) + 1] : rates[0];\n trick.setRate(next === undefined ? 1 : next * sign);\n this.render();\n }\n\n protected override attach(player: PlayerHost): void {\n const tick = (): void => {\n this.render();\n };\n this.listen(player.media, ['emptied'], tick);\n this.observe(player, ['live', 'seekable'], tick);\n this.follow(player, (engine) => {\n tick();\n if (engine === null) return undefined;\n const offs = ENGINE_EVENTS.map((name) => engine.on(name, tick));\n return () => {\n for (const off of offs) off();\n };\n });\n }\n\n protected override render(): void {\n const trick = optional(this.player?.engine ?? null).trick;\n const backward = this.backward();\n const player = this.player;\n const unseekable = player?.hasAttribute('live') === true && !player.hasAttribute('seekable');\n this.hidden = trick?.available !== true || unseekable;\n const rate = trick?.rate ?? 1;\n const on = backward ? rate < -FLOOR : rate > FLOOR;\n this.toggleAttribute('scanning', on);\n this.button.setAttribute('aria-pressed', String(on));\n this.badge.hidden = !on;\n this.badge.textContent = on ? `${Math.abs(rate)}×` : '';\n setChildren(this.glyph, icon(backward ? 'fast-backward' : 'fast-forward'));\n const name = backward\n ? this.word('label', 'rewind', 'Rewind')\n : this.word('label', 'fastForward', 'Fast forward');\n this.button.setAttribute('aria-label', name);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAoBA,MAAA,YAAA;AAGA,MAAM,QAAQ;CAAC;CAAG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