@mattebox/player 0.5.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.
- package/README.md +9 -6
- package/dist/cdn/mattebox-player.min.js +3 -444
- package/dist/controls/airplay.js +28 -44
- package/dist/controls/airplay.js.map +1 -1
- package/dist/controls/chapters.d.ts +22 -11
- package/dist/controls/chapters.d.ts.map +1 -1
- package/dist/controls/chapters.js +87 -73
- package/dist/controls/chapters.js.map +1 -1
- package/dist/controls/cues.d.ts +0 -22
- package/dist/controls/cues.d.ts.map +1 -1
- package/dist/controls/cues.js +161 -191
- package/dist/controls/cues.js.map +1 -1
- package/dist/controls/fullscreen.js +52 -70
- package/dist/controls/fullscreen.js.map +1 -1
- package/dist/controls/icons.d.ts +1 -1
- package/dist/controls/icons.d.ts.map +1 -1
- package/dist/controls/icons.js +46 -70
- package/dist/controls/icons.js.map +1 -1
- package/dist/controls/menu.d.ts +7 -4
- package/dist/controls/menu.d.ts.map +1 -1
- package/dist/controls/menu.js +241 -223
- package/dist/controls/menu.js.map +1 -1
- package/dist/controls/pip.js +35 -49
- package/dist/controls/pip.js.map +1 -1
- package/dist/controls/ranges.js +42 -37
- package/dist/controls/ranges.js.map +1 -1
- package/dist/controls/session.d.ts +6 -1
- package/dist/controls/session.d.ts.map +1 -1
- package/dist/controls/session.js +41 -26
- package/dist/controls/session.js.map +1 -1
- package/dist/controls/slider.d.ts +2 -2
- package/dist/controls/slider.d.ts.map +1 -1
- package/dist/controls/slider.js +151 -159
- package/dist/controls/slider.js.map +1 -1
- package/dist/controls/time.js +17 -17
- package/dist/controls/time.js.map +1 -1
- package/dist/dom.d.ts +6 -0
- package/dist/dom.d.ts.map +1 -1
- package/dist/dom.js +28 -19
- package/dist/dom.js.map +1 -1
- package/dist/element-entry.js +9 -6
- package/dist/element-entry.js.map +1 -1
- package/dist/element.d.ts +15 -24
- package/dist/element.d.ts.map +1 -1
- package/dist/element.js +385 -454
- package/dist/element.js.map +1 -1
- package/dist/elements/airplay-button.js +51 -53
- package/dist/elements/airplay-button.js.map +1 -1
- package/dist/elements/audio-menu.js +62 -63
- package/dist/elements/audio-menu.js.map +1 -1
- package/dist/elements/chapters-menu.d.ts.map +1 -1
- package/dist/elements/chapters-menu.js +75 -65
- package/dist/elements/chapters-menu.js.map +1 -1
- package/dist/elements/component.d.ts +1 -1
- package/dist/elements/component.d.ts.map +1 -1
- package/dist/elements/component.js +86 -89
- package/dist/elements/component.js.map +1 -1
- package/dist/elements/control-bar.d.ts +18 -5
- package/dist/elements/control-bar.d.ts.map +1 -1
- package/dist/elements/control-bar.js +282 -319
- package/dist/elements/control-bar.js.map +1 -1
- package/dist/elements/current-time.js +26 -25
- package/dist/elements/current-time.js.map +1 -1
- package/dist/elements/drm-badge.d.ts.map +1 -1
- package/dist/elements/drm-badge.js +107 -141
- package/dist/elements/drm-badge.js.map +1 -1
- package/dist/elements/duration.d.ts.map +1 -1
- package/dist/elements/duration.js +24 -21
- package/dist/elements/duration.js.map +1 -1
- package/dist/elements/error-screen.d.ts.map +1 -1
- package/dist/elements/error-screen.js +68 -102
- package/dist/elements/error-screen.js.map +1 -1
- package/dist/elements/fullscreen-button.js +48 -54
- package/dist/elements/fullscreen-button.js.map +1 -1
- package/dist/elements/live-button.d.ts.map +1 -1
- package/dist/elements/live-button.js +67 -94
- package/dist/elements/live-button.js.map +1 -1
- package/dist/elements/menu-element.js +31 -28
- package/dist/elements/menu-element.js.map +1 -1
- package/dist/elements/mute-button.js +58 -59
- package/dist/elements/mute-button.js.map +1 -1
- package/dist/elements/pip-button.js +54 -54
- package/dist/elements/pip-button.js.map +1 -1
- package/dist/elements/play-button.d.ts.map +1 -1
- package/dist/elements/play-button.js +73 -58
- package/dist/elements/play-button.js.map +1 -1
- package/dist/elements/quality-menu.js +66 -69
- package/dist/elements/quality-menu.js.map +1 -1
- package/dist/elements/remaining-time.d.ts.map +1 -1
- package/dist/elements/remaining-time.js +27 -24
- package/dist/elements/remaining-time.js.map +1 -1
- package/dist/elements/scan-button.d.ts +17 -0
- package/dist/elements/scan-button.d.ts.map +1 -0
- package/dist/elements/scan-button.js +117 -0
- package/dist/elements/scan-button.js.map +1 -0
- package/dist/elements/seek-bar.d.ts +93 -14
- package/dist/elements/seek-bar.d.ts.map +1 -1
- package/dist/elements/seek-bar.js +475 -335
- package/dist/elements/seek-bar.js.map +1 -1
- package/dist/elements/shared.d.ts +3 -11
- package/dist/elements/shared.d.ts.map +1 -1
- package/dist/elements/shared.js +44 -144
- package/dist/elements/shared.js.map +1 -1
- package/dist/elements/skip-button.d.ts.map +1 -1
- package/dist/elements/skip-button.js +54 -55
- package/dist/elements/skip-button.js.map +1 -1
- package/dist/elements/spacer.d.ts.map +1 -1
- package/dist/elements/spacer.js +12 -7
- package/dist/elements/spacer.js.map +1 -1
- package/dist/elements/speed-menu.js +60 -55
- package/dist/elements/speed-menu.js.map +1 -1
- package/dist/elements/spinner.d.ts.map +1 -1
- package/dist/elements/spinner.js +52 -78
- package/dist/elements/spinner.js.map +1 -1
- package/dist/elements/start-button.d.ts.map +1 -1
- package/dist/elements/start-button.js +107 -120
- package/dist/elements/start-button.js.map +1 -1
- package/dist/elements/subtitles-menu.js +95 -103
- package/dist/elements/subtitles-menu.js.map +1 -1
- package/dist/elements/time-element.d.ts.map +1 -1
- package/dist/elements/time-element.js +36 -28
- package/dist/elements/time-element.js.map +1 -1
- package/dist/elements/title.d.ts.map +1 -1
- package/dist/elements/title.js +105 -137
- package/dist/elements/title.js.map +1 -1
- package/dist/elements/volume-slider.d.ts.map +1 -1
- package/dist/elements/volume-slider.js +47 -45
- package/dist/elements/volume-slider.js.map +1 -1
- package/dist/elements/volume.d.ts.map +1 -1
- package/dist/elements/volume.js +42 -50
- package/dist/elements/volume.js.map +1 -1
- package/dist/entries/airplay-button.js +7 -7
- package/dist/entries/airplay-button.js.map +1 -1
- package/dist/entries/audio-menu.js +7 -6
- package/dist/entries/audio-menu.js.map +1 -1
- package/dist/entries/chapters-menu.js +7 -7
- package/dist/entries/chapters-menu.js.map +1 -1
- package/dist/entries/control-bar.js +7 -6
- package/dist/entries/control-bar.js.map +1 -1
- package/dist/entries/current-time.js +7 -6
- package/dist/entries/current-time.js.map +1 -1
- package/dist/entries/drm-badge.js +7 -6
- package/dist/entries/drm-badge.js.map +1 -1
- package/dist/entries/duration.js +7 -6
- package/dist/entries/duration.js.map +1 -1
- package/dist/entries/error-screen.js +7 -6
- package/dist/entries/error-screen.js.map +1 -1
- package/dist/entries/fullscreen-button.js +7 -6
- package/dist/entries/fullscreen-button.js.map +1 -1
- package/dist/entries/live-button.js +7 -6
- package/dist/entries/live-button.js.map +1 -1
- package/dist/entries/mute-button.js +7 -6
- package/dist/entries/mute-button.js.map +1 -1
- package/dist/entries/pip-button.js +7 -6
- package/dist/entries/pip-button.js.map +1 -1
- package/dist/entries/play-button.js +7 -6
- package/dist/entries/play-button.js.map +1 -1
- package/dist/entries/quality-menu.js +7 -6
- package/dist/entries/quality-menu.js.map +1 -1
- package/dist/entries/remaining-time.js +7 -7
- package/dist/entries/remaining-time.js.map +1 -1
- package/dist/entries/scan-button.d.ts +5 -0
- package/dist/entries/scan-button.d.ts.map +1 -0
- package/dist/entries/scan-button.js +9 -0
- package/dist/entries/scan-button.js.map +1 -0
- package/dist/entries/seek-bar.js +7 -6
- package/dist/entries/seek-bar.js.map +1 -1
- package/dist/entries/skip-button.js +7 -6
- package/dist/entries/skip-button.js.map +1 -1
- package/dist/entries/spacer.js +7 -6
- package/dist/entries/spacer.js.map +1 -1
- package/dist/entries/speed-menu.js +7 -6
- package/dist/entries/speed-menu.js.map +1 -1
- package/dist/entries/spinner.js +7 -7
- package/dist/entries/spinner.js.map +1 -1
- package/dist/entries/start-button.js +7 -6
- package/dist/entries/start-button.js.map +1 -1
- package/dist/entries/subtitles-menu.js +7 -6
- package/dist/entries/subtitles-menu.js.map +1 -1
- package/dist/entries/title.js +7 -7
- package/dist/entries/title.js.map +1 -1
- package/dist/entries/volume-slider.js +7 -6
- package/dist/entries/volume-slider.js.map +1 -1
- package/dist/entries/volume.js +9 -8
- package/dist/entries/volume.js.map +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.149.0 → _@oxc-project_runtime@0.150.0}/helpers/esm/asyncToGenerator.js +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.149.0 → _@oxc-project_runtime@0.150.0}/helpers/esm/defineProperty.js +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.149.0 → _@oxc-project_runtime@0.150.0}/helpers/esm/objectSpread2.js +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.149.0 → _@oxc-project_runtime@0.150.0}/helpers/esm/toPrimitive.js +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.149.0 → _@oxc-project_runtime@0.150.0}/helpers/esm/toPropertyKey.js +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.149.0 → _@oxc-project_runtime@0.150.0}/helpers/esm/typeof.js +1 -1
- package/dist/es2015/controls/chapters.js +40 -7
- package/dist/es2015/controls/cues.js +1 -8
- package/dist/es2015/controls/icons.js +3 -1
- package/dist/es2015/controls/menu.js +28 -9
- package/dist/es2015/controls/session.js +16 -4
- package/dist/es2015/controls/slider.js +5 -4
- package/dist/es2015/dom.js +10 -1
- package/dist/es2015/element.js +49 -40
- package/dist/es2015/elements/chapters-menu.js +18 -10
- package/dist/es2015/elements/control-bar.js +41 -35
- package/dist/es2015/elements/drm-badge.js +1 -25
- package/dist/es2015/elements/duration.js +2 -1
- package/dist/es2015/elements/error-screen.js +1 -30
- package/dist/es2015/elements/live-button.js +1 -29
- package/dist/es2015/elements/menu-element.js +2 -2
- package/dist/es2015/elements/play-button.js +10 -3
- package/dist/es2015/elements/remaining-time.js +2 -1
- package/dist/es2015/elements/scan-button.js +118 -0
- package/dist/es2015/elements/seek-bar.js +264 -71
- package/dist/es2015/elements/shared.js +5 -106
- package/dist/es2015/elements/skip-button.js +2 -1
- package/dist/es2015/elements/spacer.js +2 -1
- package/dist/es2015/elements/spinner.js +1 -32
- package/dist/es2015/elements/start-button.js +8 -26
- package/dist/es2015/elements/time-element.js +1 -4
- package/dist/es2015/elements/title.js +1 -45
- package/dist/es2015/elements/volume-slider.js +2 -1
- package/dist/es2015/elements/volume.js +1 -11
- package/dist/es2015/entries/scan-button.js +7 -0
- package/dist/es2015/index.js +3 -3
- package/dist/es2015/presets.js +1 -1
- package/dist/es2015/style.js +1 -98
- package/dist/es2015/tags.js +2 -2
- package/dist/host.js +19 -17
- package/dist/host.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +55 -28
- package/dist/labels.js +13 -9
- package/dist/labels.js.map +1 -1
- package/dist/namespaces.d.ts +9 -26
- package/dist/namespaces.d.ts.map +1 -1
- package/dist/namespaces.js +6 -2
- package/dist/namespaces.js.map +1 -1
- package/dist/presets.js +33 -28
- package/dist/presets.js.map +1 -1
- package/dist/style.d.ts +1 -20
- package/dist/style.d.ts.map +1 -1
- package/dist/style.js +4 -97
- package/dist/style.js.map +1 -1
- package/dist/surface.js +25 -21
- package/dist/surface.js.map +1 -1
- package/dist/tags.d.ts +1 -1
- package/dist/tags.d.ts.map +1 -1
- package/dist/tags.js +31 -27
- package/dist/tags.js.map +1 -1
- package/package.json +4 -4
- package/dist/compose.d.ts +0 -5
- package/dist/compose.d.ts.map +0 -1
- package/dist/compose.js +0 -31
- package/dist/compose.js.map +0 -1
- package/dist/elements/panels.d.ts +0 -15
- package/dist/elements/panels.d.ts.map +0 -1
- package/dist/elements/panels.js +0 -55
- package/dist/elements/panels.js.map +0 -1
- package/dist/entries/panels.d.ts +0 -5
- package/dist/entries/panels.d.ts.map +0 -1
- package/dist/entries/panels.js +0 -8
- package/dist/entries/panels.js.map +0 -1
- package/dist/es2015/compose.js +0 -33
- package/dist/es2015/elements/panels.js +0 -52
- package/dist/es2015/entries/panels.js +0 -7
- package/dist/index.js.map +0 -1
|
@@ -1,103 +1,69 @@
|
|
|
1
|
-
import { el } from
|
|
2
|
-
import { Component } from
|
|
3
|
-
import { style } from
|
|
4
|
-
|
|
5
|
-
:host {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
this.code.textContent = error.code;
|
|
70
|
-
this.hidden = false;
|
|
71
|
-
}
|
|
72
|
-
attach(player) {
|
|
73
|
-
const failure = (event) => {
|
|
74
|
-
const error = event.detail;
|
|
75
|
-
if (error.fatal)
|
|
76
|
-
this.show(error);
|
|
77
|
-
};
|
|
78
|
-
player.addEventListener('error', failure);
|
|
79
|
-
this.keep(() => {
|
|
80
|
-
player.removeEventListener('error', failure);
|
|
81
|
-
});
|
|
82
|
-
// Not `emptied`: the old session's teardown fires it after the new
|
|
83
|
-
// source's error, and would hide the error it should leave.
|
|
84
|
-
this.listen(player.video, ['playing', 'loadstart'], () => {
|
|
85
|
-
this.hidden = true;
|
|
86
|
-
});
|
|
87
|
-
this.listen(player, ['sourcechange'], () => {
|
|
88
|
-
this.hidden = true;
|
|
89
|
-
});
|
|
90
|
-
// The error may have come before this element did.
|
|
91
|
-
if (player.error !== null)
|
|
92
|
-
this.show(player.error);
|
|
93
|
-
this.render();
|
|
94
|
-
}
|
|
95
|
-
detach() {
|
|
96
|
-
this.hidden = true;
|
|
97
|
-
}
|
|
98
|
-
render() {
|
|
99
|
-
this.title_.textContent = this.getAttribute('label-title') ?? 'Playback failed';
|
|
100
|
-
this.retry.textContent = this.getAttribute('label-retry') ?? 'Retry';
|
|
101
|
-
}
|
|
102
|
-
}
|
|
1
|
+
import { el } from "../dom.js";
|
|
2
|
+
import { Component } from "./component.js";
|
|
3
|
+
import { style } from "./shared.js";
|
|
4
|
+
//#region src/elements/error-screen.ts
|
|
5
|
+
const STYLE = ":host{color:var(--mbx-text);font:400 15px / 1.4 var(--mbx-font);text-align:center;background:#000000bf;justify-content:center;align-items:center;padding:16px;display:flex;position:absolute;top:0;bottom:0;left:0;right:0}:host([hidden]){display:none}[part~=box]{flex-direction:column;align-items:center;display:flex}[part~=box]>:not([hidden])~:not([hidden]){margin-top:8px}[part~=title]{font-size:18px;font-weight:600}[part~=detail]{color:var(--mbx-error);font-family:monospace;font-size:13px}[part~=retry]{height:36px;font:inherit;color:inherit;border-radius:var(--mbx-radius);cursor:pointer;background:0 0;border:1px solid;padding:0 16px;font-weight:600}[part~=retry]:focus{outline:2px solid var(--mbx-accent);outline-offset:-2px}[part~=retry]:focus:not(:focus-visible){outline:none}";
|
|
6
|
+
var MbxErrorScreen = class extends Component {
|
|
7
|
+
static get observedAttributes() {
|
|
8
|
+
return ["label-title", "label-retry"];
|
|
9
|
+
}
|
|
10
|
+
constructor() {
|
|
11
|
+
super();
|
|
12
|
+
const root = this.attachShadow({ mode: "open" });
|
|
13
|
+
const box = el("div", "box");
|
|
14
|
+
this.title_ = el("div", "title");
|
|
15
|
+
this.category = el("span", "category");
|
|
16
|
+
this.code = el("span", "code");
|
|
17
|
+
const detail = el("div", "detail");
|
|
18
|
+
detail.append(this.category, el("span", "separator", " · "), this.code);
|
|
19
|
+
this.retry = el("button", "retry");
|
|
20
|
+
this.retry.type = "button";
|
|
21
|
+
this.retry.addEventListener("click", () => {
|
|
22
|
+
const player = this.player;
|
|
23
|
+
const src = player?.getAttribute("src");
|
|
24
|
+
if (player !== null && player !== void 0 && src !== null && src !== void 0) player.setAttribute("src", src);
|
|
25
|
+
});
|
|
26
|
+
box.append(this.title_, detail, this.retry);
|
|
27
|
+
root.append(style(STYLE), box);
|
|
28
|
+
}
|
|
29
|
+
/** Hidden and named before attaching: a constructor must not add attributes. */
|
|
30
|
+
connectedCallback() {
|
|
31
|
+
if (this.player === null) this.hidden = true;
|
|
32
|
+
if (!this.hasAttribute("role")) this.setAttribute("role", "alert");
|
|
33
|
+
super.connectedCallback();
|
|
34
|
+
}
|
|
35
|
+
show(error) {
|
|
36
|
+
this.category.textContent = error.category;
|
|
37
|
+
this.code.textContent = error.code;
|
|
38
|
+
this.hidden = false;
|
|
39
|
+
}
|
|
40
|
+
attach(player) {
|
|
41
|
+
const failure = (event) => {
|
|
42
|
+
const error = event.detail;
|
|
43
|
+
if (error.fatal) this.show(error);
|
|
44
|
+
};
|
|
45
|
+
player.addEventListener("error", failure);
|
|
46
|
+
this.keep(() => {
|
|
47
|
+
player.removeEventListener("error", failure);
|
|
48
|
+
});
|
|
49
|
+
this.listen(player.video, ["playing", "loadstart"], () => {
|
|
50
|
+
this.hidden = true;
|
|
51
|
+
});
|
|
52
|
+
this.listen(player, ["sourcechange"], () => {
|
|
53
|
+
this.hidden = true;
|
|
54
|
+
});
|
|
55
|
+
if (player.error !== null) this.show(player.error);
|
|
56
|
+
this.render();
|
|
57
|
+
}
|
|
58
|
+
detach() {
|
|
59
|
+
this.hidden = true;
|
|
60
|
+
}
|
|
61
|
+
render() {
|
|
62
|
+
this.title_.textContent = this.getAttribute("label-title") ?? "Playback failed";
|
|
63
|
+
this.retry.textContent = this.getAttribute("label-retry") ?? "Retry";
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
//#endregion
|
|
67
|
+
export { MbxErrorScreen };
|
|
68
|
+
|
|
103
69
|
//# sourceMappingURL=error-screen.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-screen.js","
|
|
1
|
+
{"version":3,"file":"error-screen.js","names":[],"sources":["../../src/elements/error-screen.ts"],"sourcesContent":["/**\n * <mbx-error-screen>: a fatal error over the picture, with the category,\n * the code and a retry. It sits in the player beside the video, hidden\n * until the player reports a fatal error, and clears when a session\n * arrives, a resource starts loading, or playback resumes: an error over\n * a picture that then plays is wrong by definition. The title comes from `label-title`, the button's text\n * from `label-retry`.\n *\n * Retry sets the player's `src` to its own value again, which is the one\n * public way to load a source again: the element reloads on every write\n * to `src`, equal or not.\n */\nimport type { PlayerError } from '@mattebox/player-core';\nimport { el } from '../dom.js';\nimport type { PlayerHost } from '../host.js';\nimport { Component } from './component.js';\nimport STYLE from './error-screen.css?inline';\nimport { style } from './shared.js';\n\nexport class MbxErrorScreen extends Component {\n static get observedAttributes(): readonly string[] {\n return ['label-title', 'label-retry'];\n }\n\n declare private readonly title_: HTMLElement;\n declare private readonly category: HTMLElement;\n declare private readonly code: HTMLElement;\n declare private readonly retry: HTMLButtonElement;\n\n constructor() {\n super();\n const root = this.attachShadow({ mode: 'open' });\n const box = el('div', 'box');\n this.title_ = el('div', 'title');\n this.category = el('span', 'category');\n this.code = el('span', 'code');\n const detail = el('div', 'detail');\n detail.append(this.category, el('span', 'separator', ' · '), this.code);\n this.retry = el('button', 'retry');\n this.retry.type = 'button';\n this.retry.addEventListener('click', () => {\n const player = this.player;\n const src = player?.getAttribute('src');\n if (player !== null && player !== undefined && src !== null && src !== undefined) {\n player.setAttribute('src', src);\n }\n });\n box.append(this.title_, detail, this.retry);\n root.append(style(STYLE), box);\n }\n\n /** Hidden and named before attaching: a constructor must not add attributes. */\n override connectedCallback(): void {\n if (this.player === null) this.hidden = true;\n if (!this.hasAttribute('role')) this.setAttribute('role', 'alert');\n super.connectedCallback();\n }\n\n private show(error: PlayerError): void {\n this.category.textContent = error.category;\n this.code.textContent = error.code;\n this.hidden = false;\n }\n\n protected override attach(player: PlayerHost): void {\n const failure = (event: Event): void => {\n const error = (event as CustomEvent<PlayerError>).detail;\n if (error.fatal) this.show(error);\n };\n player.addEventListener('error', failure);\n this.keep(() => {\n player.removeEventListener('error', failure);\n });\n // Not `emptied`: the old session's teardown fires it after the new\n // source's error, and would hide the error it should leave.\n this.listen(player.video, ['playing', 'loadstart'], () => {\n this.hidden = true;\n });\n this.listen(player, ['sourcechange'], () => {\n this.hidden = true;\n });\n // The error may have come before this element did.\n if (player.error !== null) this.show(player.error);\n this.render();\n }\n\n protected override detach(): void {\n this.hidden = true;\n }\n\n protected override render(): void {\n this.title_.textContent = this.getAttribute('label-title') ?? 'Playback failed';\n this.retry.textContent = this.getAttribute('label-retry') ?? 'Retry';\n }\n}\n"],"mappings":";;;;AAgBA,MAAA,QAAA;AAGA,IAAA,iBAAA,cAAA,UAAA;CACA,WAAA,qBAAA;EACA,OAAA,CAAA,eAAA,aAAA;CACA;CAOA,cAAA;EACA,MAAA;EACA,MAAA,OAAA,KAAA,aAAA,EAAA,MAAA,OAAA,CAAA;EACA,MAAA,MAAA,GAAA,OAAA,KAAA;EACA,KAAA,SAAA,GAAA,OAAA,OAAA;EACA,KAAA,WAAA,GAAA,QAAA,UAAA;EACA,KAAA,OAAA,GAAA,QAAA,MAAA;EACA,MAAA,SAAA,GAAA,OAAA,QAAA;EACA,OAAA,OAAA,KAAA,UAAA,GAAA,QAAA,aAAA,KAAA,GAAA,KAAA,IAAA;EACA,KAAA,QAAA,GAAA,UAAA,OAAA;EACA,KAAA,MAAA,OAAA;EACA,KAAA,MAAA,iBAAA,eAAA;GACA,MAAA,SAAA,KAAA;GACA,MAAA,MAAA,QAAA,aAAA,KAAA;GACA,IAAA,WAAA,QAAA,WAAA,KAAA,KAAA,QAAA,QAAA,QAAA,KAAA,GACA,OAAA,aAAA,OAAA,GAAA;EAEA,CAAA;EACA,IAAA,OAAA,KAAA,QAAA,QAAA,KAAA,KAAA;EACA,KAAA,OAAA,MAAA,KAAA,GAAA,GAAA;CACA;;CAGA,oBAAA;EACA,IAAA,KAAA,WAAA,MAAA,KAAA,SAAA;EACA,IAAA,CAAA,KAAA,aAAA,MAAA,GAAA,KAAA,aAAA,QAAA,OAAA;EACA,MAAA,kBAAA;CACA;CAEA,KAAA,OAAA;EACA,KAAA,SAAA,cAAA,MAAA;EACA,KAAA,KAAA,cAAA,MAAA;EACA,KAAA,SAAA;CACA;CAEA,OAAA,QAAA;EACA,MAAA,WAAA,UAAA;GACA,MAAA,QAAA,MAAA;GACA,IAAA,MAAA,OAAA,KAAA,KAAA,KAAA;EACA;EACA,OAAA,iBAAA,SAAA,OAAA;EACA,KAAA,WAAA;GACA,OAAA,oBAAA,SAAA,OAAA;EACA,CAAA;EAGA,KAAA,OAAA,OAAA,OAAA,CAAA,WAAA,WAAA,SAAA;GACA,KAAA,SAAA;EACA,CAAA;EACA,KAAA,OAAA,QAAA,CAAA,cAAA,SAAA;GACA,KAAA,SAAA;EACA,CAAA;EAEA,IAAA,OAAA,UAAA,MAAA,KAAA,KAAA,OAAA,KAAA;EACA,KAAA,OAAA;CACA;CAEA,SAAA;EACA,KAAA,SAAA;CACA;CAEA,SAAA;EACA,KAAA,OAAA,cAAA,KAAA,aAAA,aAAA,KAAA;EACA,KAAA,MAAA,cAAA,KAAA,aAAA,aAAA,KAAA;CACA;AACA"}
|
|
@@ -1,55 +1,49 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
this.button.setAttribute('aria-label', active
|
|
50
|
-
? (this.getAttribute('label-exit') ?? 'Exit fullscreen')
|
|
51
|
-
: (this.getAttribute('label-enter') ?? 'Enter fullscreen'));
|
|
52
|
-
player.toggleAttribute('fullscreen', active);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
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 { fullscreen } from "../controls/fullscreen.js";
|
|
5
|
+
//#region src/elements/fullscreen-button.ts
|
|
6
|
+
const STATES = ["enter", "exit"];
|
|
7
|
+
var MbxFullscreenButton = class extends Component {
|
|
8
|
+
static get observedAttributes() {
|
|
9
|
+
return ["label-enter", "label-exit"];
|
|
10
|
+
}
|
|
11
|
+
constructor() {
|
|
12
|
+
super();
|
|
13
|
+
this.api = null;
|
|
14
|
+
const root = this.attachShadow({ mode: "open" });
|
|
15
|
+
this.button = document.createElement("button");
|
|
16
|
+
this.button.type = "button";
|
|
17
|
+
this.button.setAttribute("part", "button");
|
|
18
|
+
this.slots = iconSlots(STATES, (state) => icon(state === "enter" ? "fullscreen" : "fullscreen-exit"));
|
|
19
|
+
for (const state of STATES) this.button.append(this.slots[state]);
|
|
20
|
+
this.button.addEventListener("click", () => {
|
|
21
|
+
this.api?.toggle();
|
|
22
|
+
});
|
|
23
|
+
root.append(style(BUTTON_STYLE), this.button);
|
|
24
|
+
}
|
|
25
|
+
attach(player) {
|
|
26
|
+
const api = fullscreen(player, player.video);
|
|
27
|
+
this.api = api;
|
|
28
|
+
this.hidden = !api.supported;
|
|
29
|
+
this.keep(api.watch(() => {
|
|
30
|
+
this.render();
|
|
31
|
+
}));
|
|
32
|
+
this.render();
|
|
33
|
+
}
|
|
34
|
+
detach() {
|
|
35
|
+
this.api = null;
|
|
36
|
+
}
|
|
37
|
+
render() {
|
|
38
|
+
const player = this.player;
|
|
39
|
+
if (player === null || this.api === null) return;
|
|
40
|
+
const active = this.api.active();
|
|
41
|
+
show(this.slots, active ? "exit" : "enter");
|
|
42
|
+
this.button.setAttribute("aria-label", active ? this.getAttribute("label-exit") ?? "Exit fullscreen" : this.getAttribute("label-enter") ?? "Enter fullscreen");
|
|
43
|
+
player.toggleAttribute("fullscreen", active);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
//#endregion
|
|
47
|
+
export { MbxFullscreenButton };
|
|
48
|
+
|
|
55
49
|
//# sourceMappingURL=fullscreen-button.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fullscreen-button.js","
|
|
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.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(): 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.getAttribute('label-exit') ?? 'Exit fullscreen')\n : (this.getAttribute('label-enter') ?? 'Enter fullscreen'),\n );\n player.toggleAttribute('fullscreen', active);\n }\n}\n"],"mappings":";;;;;AAeA,MAAM,SAA2B,CAAC,SAAS,MAAM;AAEjD,IAAa,sBAAb,cAAyC,UAAU;CACjD,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,KAAK,UAAU,UAAU,eAAe,iBAAiB,CAC3D;EACA,KAAK,MAAM,SAAS,QAAQ,KAAK,OAAO,OAAO,KAAK,MAAM,MAAM;EAChE,KAAK,OAAO,iBAAiB,eAAe;GAC1C,KAAK,KAAK,OAAO;EACnB,CAAC;EACD,KAAK,OAAO,MAAM,YAAY,GAAG,KAAK,MAAM;CAC9C;CAEA,OAA0B,QAA0B;EAClD,MAAM,MAAM,WAAW,QAAQ,OAAO,KAAK;EAC3C,KAAK,MAAM;EACX,KAAK,SAAS,CAAC,IAAI;EACnB,KAAK,KACH,IAAI,YAAY;GACd,KAAK,OAAO;EACd,CAAC,CACH;EACA,KAAK,OAAO;CACd;CAEA,SAAkC;EAChC,KAAK,MAAM;CACb;CAEA,SAAkC;EAChC,MAAM,SAAS,KAAK;EACpB,IAAI,WAAW,QAAQ,KAAK,QAAQ,MAAM;EAC1C,MAAM,SAAS,KAAK,IAAI,OAAO;EAC/B,KAAK,KAAK,OAAO,SAAS,SAAS,OAAO;EAC1C,KAAK,OAAO,aACV,cACA,SACK,KAAK,aAAa,YAAY,KAAK,oBACnC,KAAK,aAAa,aAAa,KAAK,kBAC3C;EACA,OAAO,gBAAgB,cAAc,MAAM;CAC7C;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"live-button.d.ts","sourceRoot":"","sources":["../../src/elements/live-button.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"live-button.d.ts","sourceRoot":"","sources":["../../src/elements/live-button.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAI3C,qBAAa,aAAc,SAAQ,SAAS;IAC1C,MAAM,KAAK,kBAAkB,IAAI,SAAS,MAAM,EAAE,CAEjD;IAED,iBAAyB,MAAM,CAAoB;IACnD,iBAAyB,IAAI,CAAc;;IAelC,iBAAiB,IAAI,IAAI;cAKf,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;cAUhC,MAAM,IAAI,IAAI;CAoBlC"}
|
|
@@ -1,96 +1,69 @@
|
|
|
1
|
+
import { el } from "../dom.js";
|
|
2
|
+
import { Component } from "./component.js";
|
|
3
|
+
import { seekRow, style } from "./shared.js";
|
|
4
|
+
import { live } from "../controls/session.js";
|
|
5
|
+
//#region src/elements/live-button.ts
|
|
1
6
|
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
seekRow(this);
|
|
65
|
-
super.connectedCallback();
|
|
66
|
-
}
|
|
67
|
-
attach(player) {
|
|
68
|
-
const tick = () => {
|
|
69
|
-
this.render();
|
|
70
|
-
};
|
|
71
|
-
this.listen(player.video, ['timeupdate', 'emptied'], tick);
|
|
72
|
-
this.listen(player, ['sourcechange'], tick);
|
|
73
|
-
this.observe(player, ['live', 'seekable'], tick);
|
|
74
|
-
this.render();
|
|
75
|
-
}
|
|
76
|
-
render() {
|
|
77
|
-
const player = this.player;
|
|
78
|
-
if (player === null)
|
|
79
|
-
return;
|
|
80
|
-
const api = live(player.engine);
|
|
81
|
-
this.hidden = api === undefined;
|
|
82
|
-
this.text.textContent = this.getAttribute('text') ?? 'LIVE';
|
|
83
|
-
if (api === undefined)
|
|
84
|
-
return;
|
|
85
|
-
// The seek bar decides seekability; while the player says live and not
|
|
86
|
-
// seekable there is no bar to come back from.
|
|
87
|
-
const stuck = player.hasAttribute('live') && !player.hasAttribute('seekable');
|
|
88
|
-
const atEdge = stuck || api.atEdge;
|
|
89
|
-
this.button.disabled = atEdge;
|
|
90
|
-
this.toggleAttribute('at-edge', atEdge);
|
|
91
|
-
this.button.setAttribute('aria-label', atEdge
|
|
92
|
-
? (this.getAttribute('label-at-edge') ?? 'At the live edge')
|
|
93
|
-
: (this.getAttribute('label-live') ?? 'Go to the live edge'));
|
|
94
|
-
}
|
|
95
|
-
}
|
|
7
|
+
* <mbx-live-button>: a dot and the word, the dot red at the edge and grey
|
|
8
|
+
* behind it, the way viewers read it everywhere. Shown once the stream has
|
|
9
|
+
* an availability window, which is what makes it live; disabled at the
|
|
10
|
+
* edge, where there is nowhere to go; a click seeks to the edge, the one
|
|
11
|
+
* engine write the row makes. The element carries `at-edge` meanwhile.
|
|
12
|
+
*
|
|
13
|
+
* Without a seek bar, when the player says the stream is not seekable,
|
|
14
|
+
* there is nowhere to come back from either: the dot stays red and the
|
|
15
|
+
* button stays inert, whatever the playhead does. The word comes from
|
|
16
|
+
* `text`, the name from `label-live` and `label-at-edge`. It sits in the
|
|
17
|
+
* bar's seek row unless the page says otherwise.
|
|
18
|
+
*/
|
|
19
|
+
const STYLE = ":host{display:inline-flex}:host([hidden]){display:none}[part~=button]{height:40px;font:inherit;letter-spacing:.06em;color:inherit;border-radius:var(--mbx-radius);cursor:pointer;opacity:.9;background:0 0;border:0;align-items:center;padding:0 8px;font-size:12px;font-weight:700;display:inline-flex}[part~=button]:hover{opacity:1}[part~=button]:disabled{cursor:default;opacity:1}[part~=button]:focus{outline:2px solid var(--mbx-accent);outline-offset:-2px}[part~=button]:focus:not(:focus-visible){outline:none}[part~=dot]{background:var(--mbx-muted);border-radius:50%;width:10px;height:10px;margin-right:6px;transition:background .2s}:host([at-edge]) [part~=dot]{background:var(--mbx-live);box-shadow:0 0 6px var(--mbx-live)}@media (prefers-reduced-motion:reduce){[part~=dot]{transition:none}}";
|
|
20
|
+
var MbxLiveButton = class extends Component {
|
|
21
|
+
static get observedAttributes() {
|
|
22
|
+
return [
|
|
23
|
+
"text",
|
|
24
|
+
"label-live",
|
|
25
|
+
"label-at-edge"
|
|
26
|
+
];
|
|
27
|
+
}
|
|
28
|
+
constructor() {
|
|
29
|
+
super();
|
|
30
|
+
const root = this.attachShadow({ mode: "open" });
|
|
31
|
+
this.button = el("button", "button");
|
|
32
|
+
this.button.type = "button";
|
|
33
|
+
this.text = el("span", "text");
|
|
34
|
+
this.button.append(el("span", "dot"), this.text);
|
|
35
|
+
this.button.addEventListener("click", () => {
|
|
36
|
+
live(this.player?.engine ?? null)?.seekToEdge();
|
|
37
|
+
});
|
|
38
|
+
root.append(style(STYLE), this.button);
|
|
39
|
+
}
|
|
40
|
+
connectedCallback() {
|
|
41
|
+
seekRow(this);
|
|
42
|
+
super.connectedCallback();
|
|
43
|
+
}
|
|
44
|
+
attach(player) {
|
|
45
|
+
const tick = () => {
|
|
46
|
+
this.render();
|
|
47
|
+
};
|
|
48
|
+
this.listen(player.video, ["timeupdate", "emptied"], tick);
|
|
49
|
+
this.listen(player, ["sourcechange"], tick);
|
|
50
|
+
this.observe(player, ["live", "seekable"], tick);
|
|
51
|
+
this.render();
|
|
52
|
+
}
|
|
53
|
+
render() {
|
|
54
|
+
const player = this.player;
|
|
55
|
+
if (player === null) return;
|
|
56
|
+
const api = live(player.engine);
|
|
57
|
+
this.hidden = api === void 0;
|
|
58
|
+
this.text.textContent = this.getAttribute("text") ?? "LIVE";
|
|
59
|
+
if (api === void 0) return;
|
|
60
|
+
const atEdge = player.hasAttribute("live") && !player.hasAttribute("seekable") || api.atEdge;
|
|
61
|
+
this.button.disabled = atEdge;
|
|
62
|
+
this.toggleAttribute("at-edge", atEdge);
|
|
63
|
+
this.button.setAttribute("aria-label", atEdge ? this.getAttribute("label-at-edge") ?? "At the live edge" : this.getAttribute("label-live") ?? "Go to the live edge");
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
//#endregion
|
|
67
|
+
export { MbxLiveButton };
|
|
68
|
+
|
|
96
69
|
//# sourceMappingURL=live-button.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"live-button.js","
|
|
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.video, ['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.getAttribute('text') ?? '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.getAttribute('label-at-edge') ?? 'At the live edge')\n : (this.getAttribute('label-live') ?? 'Go to the live edge'),\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAiBA,MAAA,QAAA;AAGA,IAAA,gBAAA,cAAA,UAAA;CACA,WAAA,qBAAA;EACA,OAAA;GAAA;GAAA;GAAA;EAAA;CACA;CAKA,cAAA;EACA,MAAA;EACA,MAAA,OAAA,KAAA,aAAA,EAAA,MAAA,OAAA,CAAA;EACA,KAAA,SAAA,GAAA,UAAA,QAAA;EACA,KAAA,OAAA,OAAA;EACA,KAAA,OAAA,GAAA,QAAA,MAAA;EACA,KAAA,OAAA,OAAA,GAAA,QAAA,KAAA,GAAA,KAAA,IAAA;EACA,KAAA,OAAA,iBAAA,eAAA;GACA,KAAA,KAAA,QAAA,UAAA,IAAA,CAAA,EAAA,WAAA;EACA,CAAA;EACA,KAAA,OAAA,MAAA,KAAA,GAAA,KAAA,MAAA;CACA;CAEA,oBAAA;EACA,QAAA,IAAA;EACA,MAAA,kBAAA;CACA;CAEA,OAAA,QAAA;EACA,MAAA,aAAA;GACA,KAAA,OAAA;EACA;EACA,KAAA,OAAA,OAAA,OAAA,CAAA,cAAA,SAAA,GAAA,IAAA;EACA,KAAA,OAAA,QAAA,CAAA,cAAA,GAAA,IAAA;EACA,KAAA,QAAA,QAAA,CAAA,QAAA,UAAA,GAAA,IAAA;EACA,KAAA,OAAA;CACA;CAEA,SAAA;EACA,MAAA,SAAA,KAAA;EACA,IAAA,WAAA,MAAA;EACA,MAAA,MAAA,KAAA,OAAA,MAAA;EACA,KAAA,SAAA,QAAA,KAAA;EACA,KAAA,KAAA,cAAA,KAAA,aAAA,MAAA,KAAA;EACA,IAAA,QAAA,KAAA,GAAA;EAIA,MAAA,SADA,OAAA,aAAA,MAAA,KAAA,CAAA,OAAA,aAAA,UAAA,KACA,IAAA;EACA,KAAA,OAAA,WAAA;EACA,KAAA,gBAAA,WAAA,MAAA;EACA,KAAA,OAAA,aACA,cACA,SACA,KAAA,aAAA,eAAA,KAAA,qBACA,KAAA,aAAA,YAAA,KAAA,qBACA;CACA;AACA"}
|
|
@@ -1,31 +1,34 @@
|
|
|
1
|
-
import { icon } from
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
1
|
+
import { icon } from "../controls/icons.js";
|
|
2
|
+
import { Component } from "./component.js";
|
|
3
|
+
import { MENU_STYLE, iconSlots, style } from "./shared.js";
|
|
4
|
+
import { menu } from "../controls/menu.js";
|
|
5
|
+
import { fill } from "../labels.js";
|
|
6
|
+
//#region src/elements/menu-element.ts
|
|
7
|
+
var MenuElement = class extends Component {
|
|
8
|
+
constructor(states, glyphs) {
|
|
9
|
+
super();
|
|
10
|
+
const root = this.attachShadow({ mode: "open" });
|
|
11
|
+
this.menu = menu({
|
|
12
|
+
host: this,
|
|
13
|
+
picture: () => this.player?.video.getBoundingClientRect() ?? null,
|
|
14
|
+
back: (page) => fill(this.getAttribute("label-back") ?? "Back from {page}", { page })
|
|
15
|
+
});
|
|
16
|
+
this.slots = iconSlots(states, glyphs);
|
|
17
|
+
for (const state of states) this.menu.button.append(this.slots[state]);
|
|
18
|
+
root.append(style(MENU_STYLE), this.menu.button, this.menu.popup);
|
|
19
|
+
}
|
|
20
|
+
detach() {
|
|
21
|
+
this.menu.close();
|
|
22
|
+
}
|
|
23
|
+
render() {
|
|
24
|
+
this.menu.label(this.getAttribute("label") ?? this.name());
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
27
|
/** A glyph that never changes, for a menu of one state. */
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
function single(name) {
|
|
29
|
+
return [["default"], () => icon(name)];
|
|
30
30
|
}
|
|
31
|
+
//#endregion
|
|
32
|
+
export { MenuElement, single };
|
|
33
|
+
|
|
31
34
|
//# sourceMappingURL=menu-element.js.map
|