@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,5 +1,5 @@
|
|
|
1
|
-
import { el, state } from "../dom.js";
|
|
2
|
-
import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.
|
|
1
|
+
import { el, setChildren, state } from "../dom.js";
|
|
2
|
+
import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.150.0/helpers/esm/objectSpread2.js";
|
|
3
3
|
//#region src/controls/menu.ts
|
|
4
4
|
/**
|
|
5
5
|
* The menu primitive the quality, audio, subtitles and speed menus share: a
|
|
@@ -17,12 +17,23 @@ import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.149.0/helpers/es
|
|
|
17
17
|
* anywhere else closes it too.
|
|
18
18
|
*
|
|
19
19
|
* The popup never leaves the picture: on opening it takes the room above
|
|
20
|
-
* the button
|
|
20
|
+
* the button up to the top of `picture()` as its height and scrolls past
|
|
21
|
+
* that, and the room from its right edge to the picture's left as its
|
|
22
|
+
* width, where a long item ends in an ellipsis. The
|
|
21
23
|
* element that owns the menu carries `open` while the popup shows, which
|
|
22
24
|
* the bar reads to hold its fade.
|
|
23
25
|
*/
|
|
24
26
|
/** Air between the popup's top and the picture's. */
|
|
25
27
|
const AIR = 8;
|
|
28
|
+
/** An item's picture. Decorative: the item's text names it. Loaded when the popup first shows it. */
|
|
29
|
+
function picture(url) {
|
|
30
|
+
const node = el("img", "item-image");
|
|
31
|
+
node.alt = "";
|
|
32
|
+
node.loading = "lazy";
|
|
33
|
+
node.decoding = "async";
|
|
34
|
+
node.src = url;
|
|
35
|
+
return node;
|
|
36
|
+
}
|
|
26
37
|
function isPage(entry) {
|
|
27
38
|
return "entries" in entry;
|
|
28
39
|
}
|
|
@@ -54,19 +65,21 @@ function menu(options) {
|
|
|
54
65
|
function outside(event) {
|
|
55
66
|
if (!event.composedPath().includes(host)) close();
|
|
56
67
|
}
|
|
57
|
-
/** Whatever room there is above the button
|
|
68
|
+
/** Whatever room there is above the button and left of the popup's right edge, so the popup never leaves the picture. */
|
|
58
69
|
function fit() {
|
|
59
|
-
const
|
|
60
|
-
if (
|
|
61
|
-
const room = button.getBoundingClientRect().top - top - AIR;
|
|
70
|
+
const picture = options.picture();
|
|
71
|
+
if (picture === null) return;
|
|
72
|
+
const room = button.getBoundingClientRect().top - picture.top - AIR;
|
|
62
73
|
popup.style.maxHeight = `${Math.max(0, Math.floor(room))}px`;
|
|
74
|
+
const wide = host.getBoundingClientRect().right - picture.left - AIR;
|
|
75
|
+
popup.style.maxWidth = `${Math.max(0, Math.floor(wide))}px`;
|
|
63
76
|
}
|
|
64
77
|
function clear() {
|
|
65
78
|
for (const item of items()) {
|
|
66
79
|
const handler = handlers.get(item);
|
|
67
80
|
if (handler !== void 0) item.removeEventListener("click", handler);
|
|
68
81
|
}
|
|
69
|
-
popup
|
|
82
|
+
setChildren(popup);
|
|
70
83
|
}
|
|
71
84
|
function item(part, text, handler) {
|
|
72
85
|
const node = el("button", part, text);
|
|
@@ -112,13 +125,18 @@ function menu(options) {
|
|
|
112
125
|
section.setAttribute("aria-label", entry.label);
|
|
113
126
|
section.append(el("div", `section-label ${entry.name}-label`, entry.label));
|
|
114
127
|
}
|
|
115
|
-
for (const [id, text, detail] of entry.items) {
|
|
128
|
+
for (const [id, text, detail, image] of entry.items) {
|
|
116
129
|
const choice = item(`item ${entry.name}-item`, text, () => {
|
|
117
130
|
close();
|
|
118
131
|
button.focus();
|
|
119
132
|
entry.onSelect(id);
|
|
120
133
|
});
|
|
121
134
|
if (detail !== void 0) choice.append(el("span", "item-detail", detail));
|
|
135
|
+
if (image !== void 0) {
|
|
136
|
+
const [, ...rest] = choice.childNodes;
|
|
137
|
+
setChildren(choice, el("span", "item-text", text), ...rest);
|
|
138
|
+
choice.prepend(picture(image));
|
|
139
|
+
}
|
|
122
140
|
choice.value = id;
|
|
123
141
|
choice.setAttribute("role", "menuitemradio");
|
|
124
142
|
const on = id === entry.value;
|
|
@@ -163,6 +181,7 @@ function menu(options) {
|
|
|
163
181
|
}
|
|
164
182
|
function key(event) {
|
|
165
183
|
var _list$next;
|
|
184
|
+
if (event.defaultPrevented) return;
|
|
166
185
|
const list = items();
|
|
167
186
|
const index = list.indexOf(focused());
|
|
168
187
|
let next;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { namespaces } from "../namespaces.js";
|
|
2
|
-
import { clock } from "./time.js";
|
|
3
2
|
import { spans, window } from "./ranges.js";
|
|
3
|
+
import { clock } from "./time.js";
|
|
4
4
|
//#region src/controls/session.ts
|
|
5
5
|
/** The optional namespaces of an engine, or none for a native session. */
|
|
6
6
|
function optional(engine) {
|
|
@@ -25,10 +25,22 @@ function span(video, engine) {
|
|
|
25
25
|
if (own !== null && own.end > own.start) return own;
|
|
26
26
|
return window(video.duration, spans(video.seekable), on);
|
|
27
27
|
}
|
|
28
|
-
/** The
|
|
28
|
+
/** The goal each engine had outside a scan or a scrub. */
|
|
29
|
+
const settled = /* @__PURE__ */ new WeakMap();
|
|
30
|
+
/**
|
|
31
|
+
* The engine's forward buffer goal in seconds, which lives on the
|
|
32
|
+
* diagnostics snapshot and nowhere else. A scan multiplies the goal by its
|
|
33
|
+
* rate and a scrub shrinks it (engine guide, trick play), so meanwhile the
|
|
34
|
+
* goal from before stands: a live bar must not hide in the middle of a scan.
|
|
35
|
+
*/
|
|
29
36
|
function bufferGoal(engine) {
|
|
30
|
-
var
|
|
31
|
-
|
|
37
|
+
var _settled$get;
|
|
38
|
+
if (engine === null) return null;
|
|
39
|
+
const trick = optional(engine).trick;
|
|
40
|
+
if (trick !== void 0 && (trick.rate !== 1 || trick.scrubbing)) return (_settled$get = settled.get(engine)) !== null && _settled$get !== void 0 ? _settled$get : null;
|
|
41
|
+
const goal = engine.stats.snapshot().scheduling.bufferGoal;
|
|
42
|
+
settled.set(engine, goal);
|
|
43
|
+
return goal;
|
|
32
44
|
}
|
|
33
45
|
/** The wall clock at a presentation time, when the session can say it. */
|
|
34
46
|
function wall(engine, time) {
|
|
@@ -64,7 +64,7 @@ function slider(options) {
|
|
|
64
64
|
try {
|
|
65
65
|
root.setPointerCapture(event.pointerId);
|
|
66
66
|
} catch (_unused) {}
|
|
67
|
-
onInput(at(event.clientX));
|
|
67
|
+
onInput(at(event.clientX), false);
|
|
68
68
|
}
|
|
69
69
|
function move(event) {
|
|
70
70
|
if (!held) return;
|
|
@@ -72,17 +72,18 @@ function slider(options) {
|
|
|
72
72
|
up(event);
|
|
73
73
|
return;
|
|
74
74
|
}
|
|
75
|
-
onInput(at(event.clientX));
|
|
75
|
+
onInput(at(event.clientX), false);
|
|
76
76
|
}
|
|
77
77
|
function up(event) {
|
|
78
78
|
if (!held) return;
|
|
79
79
|
hold(false);
|
|
80
|
-
onInput(at(event.clientX));
|
|
80
|
+
onInput(at(event.clientX), false);
|
|
81
81
|
}
|
|
82
82
|
function cancel() {
|
|
83
83
|
if (held) hold(false);
|
|
84
84
|
}
|
|
85
85
|
function key(event) {
|
|
86
|
+
if (event.defaultPrevented) return;
|
|
86
87
|
let next;
|
|
87
88
|
switch (event.key) {
|
|
88
89
|
case "ArrowRight":
|
|
@@ -108,7 +109,7 @@ function slider(options) {
|
|
|
108
109
|
default: return;
|
|
109
110
|
}
|
|
110
111
|
event.preventDefault();
|
|
111
|
-
onInput(clamp(next, min, max));
|
|
112
|
+
onInput(clamp(next, min, max), true);
|
|
112
113
|
}
|
|
113
114
|
root.addEventListener("pointerdown", down);
|
|
114
115
|
root.addEventListener("pointermove", move);
|
package/dist/es2015/dom.js
CHANGED
|
@@ -6,6 +6,15 @@
|
|
|
6
6
|
* cannot descend: an element without a name of its own is unreachable from
|
|
7
7
|
* the page's stylesheet. Names are public API.
|
|
8
8
|
*/
|
|
9
|
+
/**
|
|
10
|
+
* Replaces the children of `node`: the ones it has go, then `children` come.
|
|
11
|
+
* `replaceChildren` does this in one call, from Chromium 86 (AGENTS.md,
|
|
12
|
+
* rule 9).
|
|
13
|
+
*/
|
|
14
|
+
function setChildren(node, ...children) {
|
|
15
|
+
while (node.firstChild !== null) node.firstChild.remove();
|
|
16
|
+
node.append(...children);
|
|
17
|
+
}
|
|
9
18
|
/** An element with its part names, and its text when it has any. */
|
|
10
19
|
function el(tag, part, text) {
|
|
11
20
|
const node = document.createElement(tag);
|
|
@@ -20,4 +29,4 @@ function state(node, base, on) {
|
|
|
20
29
|
node.setAttribute("part", names.join(" "));
|
|
21
30
|
}
|
|
22
31
|
//#endregion
|
|
23
|
-
export { el, state };
|
|
32
|
+
export { el, setChildren, state };
|
package/dist/es2015/element.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { CONTROL_BAR, PANELS, PLAYER } from "./tags.js";
|
|
2
|
-
import { composeBar, composePanels } from "./compose.js";
|
|
3
1
|
import { namespaces } from "./namespaces.js";
|
|
4
|
-
import _asyncToGenerator from "./_virtual/_@oxc-project_runtime@0.
|
|
2
|
+
import _asyncToGenerator from "./_virtual/_@oxc-project_runtime@0.150.0/helpers/esm/asyncToGenerator.js";
|
|
5
3
|
import { drmGuard, resolvePreset } from "./presets.js";
|
|
6
4
|
import { STYLE } from "./style.js";
|
|
7
5
|
import { errorSurface } from "./surface.js";
|
|
8
|
-
import
|
|
6
|
+
import { PLAYER } from "./tags.js";
|
|
7
|
+
import _objectSpread2 from "./_virtual/_@oxc-project_runtime@0.150.0/helpers/esm/objectSpread2.js";
|
|
9
8
|
import { createPlayer, inferType, matteboxHandler, nativeHandler } from "@mattebox/player-core";
|
|
10
9
|
//#region src/element.ts
|
|
11
10
|
/** Attributes forwarded onto the video as attributes, never as properties. */
|
|
@@ -24,20 +23,29 @@ const OWN = [
|
|
|
24
23
|
"thumbnails"
|
|
25
24
|
];
|
|
26
25
|
/**
|
|
27
|
-
* The chapters
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
26
|
+
* The chapters file URL. A session with the engine's `chapters` namespace
|
|
27
|
+
* loads it there: through the engine's transport, so request hooks apply,
|
|
28
|
+
* and in every format the engine reads. Any other session gets a
|
|
29
|
+
* `<track kind="chapters">` on the video, hidden so its cues load and
|
|
30
|
+
* nothing is drawn. The seek bar and the chapters menu read either.
|
|
31
|
+
* Changing it never reloads the source.
|
|
32
32
|
*/
|
|
33
33
|
const CHAPTERS = "chapters";
|
|
34
34
|
/**
|
|
35
35
|
* The one attribute whose meaning the element owns: `native` keeps the
|
|
36
|
-
* browser's controls on the video, `custom` swaps them for the
|
|
37
|
-
*
|
|
38
|
-
* `native`. Changing it
|
|
36
|
+
* browser's controls on the video, `custom` swaps them for the controls the
|
|
37
|
+
* page placed inside, `none` takes the browser's off and hides every child
|
|
38
|
+
* but the video. Anything else is `native`. Changing it never touches the
|
|
39
|
+
* session.
|
|
39
40
|
*/
|
|
40
41
|
const CONTROLS = "controls";
|
|
42
|
+
/**
|
|
43
|
+
* Inline playback, on until the page writes `playsinline="false"`, the way
|
|
44
|
+
* `spellcheck` and `draggable` are on until told otherwise. An iPhone takes
|
|
45
|
+
* a video without `playsinline` to its own fullscreen on play, where no
|
|
46
|
+
* control the page placed shows. Changing it never reloads.
|
|
47
|
+
*/
|
|
48
|
+
const PLAYSINLINE = "playsinline";
|
|
41
49
|
/** The video's state, as attributes on the element, read on the events the video fires for it. */
|
|
42
50
|
const STATE_EVENTS = [
|
|
43
51
|
"play",
|
|
@@ -72,7 +80,8 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
|
|
|
72
80
|
...FORWARDED,
|
|
73
81
|
...OWN,
|
|
74
82
|
CONTROLS,
|
|
75
|
-
CHAPTERS
|
|
83
|
+
CHAPTERS,
|
|
84
|
+
PLAYSINLINE
|
|
76
85
|
];
|
|
77
86
|
}
|
|
78
87
|
/**
|
|
@@ -88,10 +97,9 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
|
|
|
88
97
|
constructor(options) {
|
|
89
98
|
super();
|
|
90
99
|
this.options = options !== null && options !== void 0 ? options : defaults;
|
|
91
|
-
this.composed = [];
|
|
92
|
-
this.settled = false;
|
|
93
100
|
this.focusable = false;
|
|
94
101
|
this.track = null;
|
|
102
|
+
this.given = null;
|
|
95
103
|
this.core = null;
|
|
96
104
|
this.current = null;
|
|
97
105
|
this.failure = null;
|
|
@@ -103,6 +111,7 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
|
|
|
103
111
|
this.pending = false;
|
|
104
112
|
this.media = document.createElement("video");
|
|
105
113
|
this.media.controls = true;
|
|
114
|
+
this.media.setAttribute(PLAYSINLINE, "");
|
|
106
115
|
for (const name of STATE_EVENTS) this.media.addEventListener(name, () => {
|
|
107
116
|
this.note(name);
|
|
108
117
|
this.reflect();
|
|
@@ -137,8 +146,8 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
|
|
|
137
146
|
/**
|
|
138
147
|
* The fatal error of the current load, or null once a load starts or
|
|
139
148
|
* playback resumes. The `error` event says when; this says what, for a
|
|
140
|
-
* control that attaches after the event, such as
|
|
141
|
-
*
|
|
149
|
+
* control that attaches after the event, such as an error screen parsed
|
|
150
|
+
* after a source that failed while the page was still loading.
|
|
142
151
|
*/
|
|
143
152
|
get error() {
|
|
144
153
|
return this.failure;
|
|
@@ -147,18 +156,8 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
|
|
|
147
156
|
if (this.media.parentNode !== this) this.append(this.media);
|
|
148
157
|
for (const name of FORWARDED) this.forward(name);
|
|
149
158
|
this.reflect();
|
|
150
|
-
if (!this.settled) this.settle();
|
|
151
159
|
this.reload();
|
|
152
160
|
}
|
|
153
|
-
/** Decides on the default composition once the children are all in, then on every mode change. */
|
|
154
|
-
settle() {
|
|
155
|
-
const done = () => {
|
|
156
|
-
this.settled = true;
|
|
157
|
-
this.mode();
|
|
158
|
-
};
|
|
159
|
-
if (document.readyState === "loading") document.addEventListener("DOMContentLoaded", done, { once: true });
|
|
160
|
-
else queueMicrotask(done);
|
|
161
|
-
}
|
|
162
161
|
/** The two states the video does not hold: whether it has played once, and whether it waits for data. */
|
|
163
162
|
note(event) {
|
|
164
163
|
if (event === "playing") {
|
|
@@ -215,14 +214,18 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
|
|
|
215
214
|
this.chapters();
|
|
216
215
|
return;
|
|
217
216
|
}
|
|
217
|
+
if (name === PLAYSINLINE) {
|
|
218
|
+
this.media.toggleAttribute(PLAYSINLINE, this.getAttribute(PLAYSINLINE) !== "false");
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
218
221
|
if (name === "preset") this.enqueue(() => this.discard());
|
|
219
222
|
if (name === "src" || name === "type") this.toggleAttribute("audio", this.audio());
|
|
220
223
|
this.reload();
|
|
221
224
|
}
|
|
222
225
|
/**
|
|
223
|
-
* Applies the `controls` attribute: the video's own controls
|
|
224
|
-
* tabindex
|
|
225
|
-
*
|
|
226
|
+
* Applies the `controls` attribute: the video's own controls and the
|
|
227
|
+
* tabindex. The controls themselves are elements the page placed, and
|
|
228
|
+
* they attach on their own; the element appends none.
|
|
226
229
|
*/
|
|
227
230
|
mode() {
|
|
228
231
|
const value = this.getAttribute(CONTROLS);
|
|
@@ -236,22 +239,27 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
|
|
|
236
239
|
this.tabIndex = 0;
|
|
237
240
|
this.focusable = true;
|
|
238
241
|
}
|
|
239
|
-
if (!this.settled) return;
|
|
240
|
-
for (const node of this.composed) node.remove();
|
|
241
|
-
this.composed = [];
|
|
242
|
-
const own = custom ? CONTROL_BAR : PANELS;
|
|
243
|
-
if (this.querySelector(`:scope > ${own}`) === null) {
|
|
244
|
-
this.composed = custom ? composeBar() : composePanels();
|
|
245
|
-
this.append(...this.composed);
|
|
246
|
-
}
|
|
247
242
|
}
|
|
248
|
-
/**
|
|
243
|
+
/** Hands the `chapters` attribute to the engine, or keeps a hidden chapters track on the video for it. */
|
|
249
244
|
chapters() {
|
|
245
|
+
var _this$current$engine2, _this$current2;
|
|
250
246
|
const url = this.getAttribute(CHAPTERS);
|
|
251
|
-
|
|
247
|
+
const engine = (_this$current$engine2 = (_this$current2 = this.current) === null || _this$current2 === void 0 ? void 0 : _this$current2.engine) !== null && _this$current$engine2 !== void 0 ? _this$current$engine2 : null;
|
|
248
|
+
const api = engine === null ? void 0 : namespaces(engine).chapters;
|
|
249
|
+
if (api !== void 0) {
|
|
252
250
|
var _this$track;
|
|
253
251
|
(_this$track = this.track) === null || _this$track === void 0 || _this$track.remove();
|
|
254
252
|
this.track = null;
|
|
253
|
+
if (url === this.given) return;
|
|
254
|
+
this.given = url;
|
|
255
|
+
if (url === null) api.set([]);
|
|
256
|
+
else api.load(url).catch(() => void 0);
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
if (url === null) {
|
|
260
|
+
var _this$track2;
|
|
261
|
+
(_this$track2 = this.track) === null || _this$track2 === void 0 || _this$track2.remove();
|
|
262
|
+
this.track = null;
|
|
255
263
|
return;
|
|
256
264
|
}
|
|
257
265
|
const held = this.track;
|
|
@@ -326,6 +334,7 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
|
|
|
326
334
|
return;
|
|
327
335
|
}
|
|
328
336
|
_this.current = session;
|
|
337
|
+
_this.given = null;
|
|
329
338
|
_this.configure(session);
|
|
330
339
|
_this.chapters();
|
|
331
340
|
})();
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import { show } from "./shared.js";
|
|
2
2
|
import { MenuElement, single } from "./menu-element.js";
|
|
3
|
-
import { chapterAt, chapters, followChapters } from "../controls/chapters.js";
|
|
4
3
|
import { format } from "../controls/time.js";
|
|
4
|
+
import { chapterAt, chapters, followChapters } from "../controls/chapters.js";
|
|
5
5
|
//#region src/elements/chapters-menu.ts
|
|
6
6
|
/**
|
|
7
7
|
* <mbx-chapters-menu>: the chapters of the video as a list, each with its
|
|
8
8
|
* start time, the one the playhead is in checked; choosing one seeks to its
|
|
9
|
-
* start. The chapters are the
|
|
10
|
-
*
|
|
11
|
-
* menu works for every session, native included, and hides while
|
|
12
|
-
*
|
|
9
|
+
* start. The chapters are the engine's when the session holds some, and
|
|
10
|
+
* the video's own chapters text track otherwise, see `controls/chapters.ts`,
|
|
11
|
+
* so the menu works for every session, native included, and hides while
|
|
12
|
+
* there are none. Each item shows the chapter's picture when every chapter
|
|
13
|
+
* has one: a list where some rows have a picture and some do not reads as
|
|
14
|
+
* broken. The name comes from `label`.
|
|
13
15
|
*/
|
|
14
16
|
var MbxChaptersMenu = class extends MenuElement {
|
|
15
17
|
static get observedAttributes() {
|
|
@@ -27,7 +29,7 @@ var MbxChaptersMenu = class extends MenuElement {
|
|
|
27
29
|
const tick = () => {
|
|
28
30
|
this.render();
|
|
29
31
|
};
|
|
30
|
-
this.keep(followChapters(player
|
|
32
|
+
this.keep(followChapters(player, tick));
|
|
31
33
|
this.listen(player.video, [
|
|
32
34
|
"timeupdate",
|
|
33
35
|
"seeked",
|
|
@@ -38,19 +40,25 @@ var MbxChaptersMenu = class extends MenuElement {
|
|
|
38
40
|
this.render();
|
|
39
41
|
}
|
|
40
42
|
render() {
|
|
41
|
-
var _this$player;
|
|
43
|
+
var _this$player, _this$player$engine, _this$player2;
|
|
42
44
|
super.render();
|
|
43
45
|
const video = (_this$player = this.player) === null || _this$player === void 0 ? void 0 : _this$player.video;
|
|
44
46
|
if (video === void 0) return;
|
|
45
|
-
const list = chapters(video);
|
|
47
|
+
const list = chapters(video, (_this$player$engine = (_this$player2 = this.player) === null || _this$player2 === void 0 ? void 0 : _this$player2.engine) !== null && _this$player$engine !== void 0 ? _this$player$engine : null);
|
|
46
48
|
this.hidden = list.length === 0;
|
|
47
49
|
const current = String(chapterAt(list, video.currentTime));
|
|
48
|
-
const
|
|
50
|
+
const pictured = list.every((chapter) => chapter.image !== void 0);
|
|
51
|
+
const items = list.map((chapter, i) => pictured && chapter.image !== void 0 ? [
|
|
52
|
+
String(i),
|
|
53
|
+
chapter.title,
|
|
54
|
+
format(chapter.start),
|
|
55
|
+
chapter.image
|
|
56
|
+
] : [
|
|
49
57
|
String(i),
|
|
50
58
|
chapter.title,
|
|
51
59
|
format(chapter.start)
|
|
52
60
|
]);
|
|
53
|
-
const key = `${current}|${items.map((
|
|
61
|
+
const key = `${current}|${items.map((item) => item.slice(1).join(" ")).join("\n")}`;
|
|
54
62
|
if (key === this.drawn) return;
|
|
55
63
|
this.drawn = key;
|
|
56
64
|
this.menu.fill([{
|
|
@@ -1,21 +1,24 @@
|
|
|
1
|
-
import { AIRPLAY_BUTTON, AUDIO_MENU, CHAPTERS_MENU, DRM_BADGE, MUTE_BUTTON, PIP_BUTTON, QUALITY_MENU, SKIP_BUTTON, SPEED_MENU, SUBTITLES_MENU, VOLUME, VOLUME_SLIDER } from "../tags.js";
|
|
1
|
+
import { AIRPLAY_BUTTON, AUDIO_MENU, CHAPTERS_MENU, DRM_BADGE, MUTE_BUTTON, PIP_BUTTON, QUALITY_MENU, SCAN_BUTTON, SKIP_BUTTON, SPEED_MENU, SUBTITLES_MENU, VOLUME, VOLUME_SLIDER } from "../tags.js";
|
|
2
2
|
import { Component } from "./component.js";
|
|
3
3
|
import { number, style } from "./shared.js";
|
|
4
4
|
import { cueLift, cueStyle } from "../controls/cues.js";
|
|
5
5
|
import { fullscreen } from "../controls/fullscreen.js";
|
|
6
6
|
//#region src/elements/control-bar.ts
|
|
7
|
+
const STYLE = ":host{box-sizing:border-box;color:var(--mbx-text);font:500 16px / 1.2 var(--mbx-font);background:linear-gradient(#0000,#0009);flex-direction:column;padding:40px 16px 12px;transition:opacity .2s;display:flex;position:absolute;bottom:0;left:0;right:0}:host([idle]){opacity:0;pointer-events:none}[part~=row]{align-items:center;margin:0 -4px;display:flex}[part~=buttons-row]{margin-top:4px}[part~=seek-row]{margin:0 -8px}slot:not([name])::slotted(*){margin:0 4px}slot[name=seek]::slotted(*){margin:0 8px}::slotted([collapsed]){display:none}@media (prefers-reduced-motion:reduce){:host{transition:none}}";
|
|
7
8
|
const IDLE_MS = 3e3;
|
|
8
9
|
const SEEK_STEP = 5;
|
|
9
10
|
/**
|
|
10
|
-
* What goes first when the row is too narrow, by tag: the
|
|
11
|
-
*
|
|
12
|
-
* the
|
|
11
|
+
* What goes first when the row is too narrow, by tag: the scans, which
|
|
12
|
+
* suit a TV remote more than a small screen; then the slider, which takes
|
|
13
|
+
* the most room for the least; then the diagnostics, the lock and the
|
|
14
|
+
* menus a viewer rarely opens; then the menus for the picture and the
|
|
13
15
|
* sound; then the skips; then the mute and the subtitles. The subtitles
|
|
14
16
|
* menu goes last of the menus because it is the one a viewer may need.
|
|
15
17
|
* The diagnostics is another package's, named here as a string. A
|
|
16
18
|
* `priority` attribute on the control replaces its default.
|
|
17
19
|
*/
|
|
18
20
|
const PRIORITY = {
|
|
21
|
+
[SCAN_BUTTON]: 6,
|
|
19
22
|
[VOLUME_SLIDER]: 5,
|
|
20
23
|
"mbx-diagnostics": 4,
|
|
21
24
|
[DRM_BADGE]: 4,
|
|
@@ -51,28 +54,6 @@ function priority(child) {
|
|
|
51
54
|
}
|
|
52
55
|
return (_PRIORITY$child$local = PRIORITY[child.localName]) !== null && _PRIORITY$child$local !== void 0 ? _PRIORITY$child$local : 0;
|
|
53
56
|
}
|
|
54
|
-
const STYLE = `
|
|
55
|
-
:host {
|
|
56
|
-
position: absolute;
|
|
57
|
-
inset: auto 0 0 0;
|
|
58
|
-
box-sizing: border-box;
|
|
59
|
-
display: flex;
|
|
60
|
-
flex-direction: column;
|
|
61
|
-
gap: 4px;
|
|
62
|
-
padding: 40px 16px 12px;
|
|
63
|
-
color: var(--mbx-text);
|
|
64
|
-
background: linear-gradient(transparent, rgba(0, 0, 0, 0.6));
|
|
65
|
-
font: 500 16px/1.2 var(--mbx-font);
|
|
66
|
-
transition: opacity 0.2s;
|
|
67
|
-
}
|
|
68
|
-
:host([idle]) { opacity: 0; pointer-events: none; }
|
|
69
|
-
[part~="row"] { display: flex; align-items: center; gap: 8px; }
|
|
70
|
-
[part~="seek-row"] { gap: 16px; }
|
|
71
|
-
::slotted([collapsed]) { display: none; }
|
|
72
|
-
@media (prefers-reduced-motion: reduce) {
|
|
73
|
-
:host { transition: none; }
|
|
74
|
-
}
|
|
75
|
-
`;
|
|
76
57
|
function end(video) {
|
|
77
58
|
if (Number.isFinite(video.duration)) return video.duration;
|
|
78
59
|
const ranges = video.seekable;
|
|
@@ -106,23 +87,22 @@ var MbxControlBar = class extends Component {
|
|
|
106
87
|
root.append(style(STYLE), this.seekRow, this.buttonsRow);
|
|
107
88
|
}
|
|
108
89
|
/**
|
|
109
|
-
* What the buttons need: their widths and
|
|
110
|
-
* spacer aside since it takes what is left, and a
|
|
111
|
-
* width it unfolds to. The row's own width says nothing, because the
|
|
90
|
+
* What the buttons need: their widths and their margins, which are the
|
|
91
|
+
* gaps between them, the spacer aside since it takes what is left, and a
|
|
92
|
+
* folded slider at the width it unfolds to. The row's own width says nothing, because the
|
|
112
93
|
* spacer fills it whatever the buttons take.
|
|
113
94
|
*/
|
|
114
95
|
needed(children) {
|
|
115
|
-
const gap = Number.parseFloat(getComputedStyle(this.buttonsRow).columnGap) || 0;
|
|
116
96
|
let sum = 0;
|
|
117
|
-
let count = 0;
|
|
118
97
|
for (const child of children) {
|
|
119
98
|
if (child.localName === "mbx-spacer" || !shown(child)) continue;
|
|
99
|
+
const margins = getComputedStyle(child);
|
|
120
100
|
sum += child.getBoundingClientRect().width;
|
|
121
|
-
|
|
101
|
+
sum += Number.parseFloat(margins.marginLeft) + Number.parseFloat(margins.marginRight);
|
|
122
102
|
const folded = slider(child);
|
|
123
103
|
if (folded !== null && shown(folded)) sum += Math.max(0, SLIDER_WIDTH - folded.getBoundingClientRect().width);
|
|
124
104
|
}
|
|
125
|
-
return sum
|
|
105
|
+
return sum;
|
|
126
106
|
}
|
|
127
107
|
/**
|
|
128
108
|
* Collapses the buttons row to its width. Everything is shown first, so
|
|
@@ -191,6 +171,20 @@ var MbxControlBar = class extends Component {
|
|
|
191
171
|
this.idle(player, false);
|
|
192
172
|
this.timer = setTimeout(() => this.sleep(player), number(this, "idle-ms", IDLE_MS));
|
|
193
173
|
}
|
|
174
|
+
/**
|
|
175
|
+
* A seeking key: `seekkey` on the player first, cancellable, with the
|
|
176
|
+
* seconds in `detail.by`. A seek bar under `key-mode="preview"` takes it
|
|
177
|
+
* to aim instead. Nobody took it: the playhead moves now.
|
|
178
|
+
*/
|
|
179
|
+
seekBy(player, by) {
|
|
180
|
+
const asked = new CustomEvent("seekkey", {
|
|
181
|
+
detail: { by },
|
|
182
|
+
cancelable: true
|
|
183
|
+
});
|
|
184
|
+
if (!player.dispatchEvent(asked)) return;
|
|
185
|
+
const video = player.video;
|
|
186
|
+
video.currentTime = Math.min(end(video), Math.max(0, video.currentTime + by));
|
|
187
|
+
}
|
|
194
188
|
key(player, event) {
|
|
195
189
|
this.keyboard = true;
|
|
196
190
|
this.wake(player);
|
|
@@ -215,11 +209,23 @@ var MbxControlBar = class extends Component {
|
|
|
215
209
|
var _this$screen;
|
|
216
210
|
(_this$screen = this.screen) === null || _this$screen === void 0 || _this$screen.toggle();
|
|
217
211
|
break;
|
|
212
|
+
case "MediaPlayPause":
|
|
213
|
+
toggle(video);
|
|
214
|
+
break;
|
|
215
|
+
case "MediaPlay":
|
|
216
|
+
video.play().catch(() => void 0);
|
|
217
|
+
break;
|
|
218
|
+
case "MediaPause":
|
|
219
|
+
case "MediaStop":
|
|
220
|
+
video.pause();
|
|
221
|
+
break;
|
|
218
222
|
case "ArrowLeft":
|
|
219
|
-
|
|
223
|
+
case "MediaRewind":
|
|
224
|
+
this.seekBy(player, -number(this, "seek-step", SEEK_STEP));
|
|
220
225
|
break;
|
|
221
226
|
case "ArrowRight":
|
|
222
|
-
|
|
227
|
+
case "MediaFastForward":
|
|
228
|
+
this.seekBy(player, number(this, "seek-step", SEEK_STEP));
|
|
223
229
|
break;
|
|
224
230
|
default: return;
|
|
225
231
|
}
|
|
@@ -5,31 +5,7 @@ import { Component } from "./component.js";
|
|
|
5
5
|
import { style } from "./shared.js";
|
|
6
6
|
import { fill } from "../labels.js";
|
|
7
7
|
//#region src/elements/drm-badge.ts
|
|
8
|
-
const STYLE =
|
|
9
|
-
:host { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; color: var(--mbx-muted); border-radius: var(--mbx-radius); cursor: default; }
|
|
10
|
-
:host([hidden]) { display: none; }
|
|
11
|
-
:host(:focus-visible) { outline: 2px solid var(--mbx-accent); outline-offset: -2px; }
|
|
12
|
-
[part~="icon"], ::slotted(*) { width: 1.75em; height: 1.75em; fill: currentColor; }
|
|
13
|
-
[part~="tooltip"] {
|
|
14
|
-
position: absolute;
|
|
15
|
-
right: 0;
|
|
16
|
-
bottom: 100%;
|
|
17
|
-
margin-bottom: 8px;
|
|
18
|
-
padding: 8px 10px;
|
|
19
|
-
background: rgba(16, 17, 20, 0.95);
|
|
20
|
-
border-radius: var(--mbx-radius);
|
|
21
|
-
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
|
|
22
|
-
color: var(--mbx-text);
|
|
23
|
-
font-size: 13px;
|
|
24
|
-
line-height: 1.4;
|
|
25
|
-
text-align: left;
|
|
26
|
-
white-space: nowrap;
|
|
27
|
-
pointer-events: none;
|
|
28
|
-
}
|
|
29
|
-
[part~="tooltip"][hidden] { display: none; }
|
|
30
|
-
[part~="tooltip-title"] { font-weight: 600; }
|
|
31
|
-
[part~="tooltip-text"] { color: var(--mbx-muted); }
|
|
32
|
-
`;
|
|
8
|
+
const STYLE = ":host{width:40px;height:40px;color:var(--mbx-muted);border-radius:var(--mbx-radius);cursor:default;justify-content:center;align-items:center;display:inline-flex;position:relative}:host([hidden]){display:none}:host(:focus){outline:2px solid var(--mbx-accent);outline-offset:-2px}:host(:focus:not(:focus-visible)){outline:none}[part~=icon],::slotted(*){fill:currentColor;width:1.75em;height:1.75em}[part~=tooltip]{border-radius:var(--mbx-radius);color:var(--mbx-text);text-align:left;white-space:nowrap;pointer-events:none;background:#101114f2;margin-bottom:8px;padding:8px 10px;font-size:13px;line-height:1.4;position:absolute;bottom:100%;right:0;box-shadow:0 4px 16px #00000080}[part~=tooltip][hidden]{display:none}[part~=tooltip-title]{font-weight:600}[part~=tooltip-text]{color:var(--mbx-muted)}";
|
|
33
9
|
/** The name a viewer knows a key system by. */
|
|
34
10
|
function keySystemName(id) {
|
|
35
11
|
if (id.startsWith("com.widevine")) return "Widevine";
|
|
@@ -6,9 +6,10 @@ import { TimeElement } from "./time-element.js";
|
|
|
6
6
|
* <mbx-duration>: the duration, "4:56", once the metadata is in. A live
|
|
7
7
|
* stream has none, so the element hides while the stream is live.
|
|
8
8
|
*/
|
|
9
|
+
const TRAILING = ":host{text-align:right}";
|
|
9
10
|
var MbxDuration = class extends TimeElement {
|
|
10
11
|
constructor() {
|
|
11
|
-
super(
|
|
12
|
+
super(TRAILING);
|
|
12
13
|
}
|
|
13
14
|
render() {
|
|
14
15
|
const player = this.player;
|
|
@@ -2,36 +2,7 @@ import { el } from "../dom.js";
|
|
|
2
2
|
import { Component } from "./component.js";
|
|
3
3
|
import { style } from "./shared.js";
|
|
4
4
|
//#region src/elements/error-screen.ts
|
|
5
|
-
const STYLE =
|
|
6
|
-
:host {
|
|
7
|
-
position: absolute;
|
|
8
|
-
inset: 0;
|
|
9
|
-
display: flex;
|
|
10
|
-
align-items: center;
|
|
11
|
-
justify-content: center;
|
|
12
|
-
padding: 16px;
|
|
13
|
-
background: rgba(0, 0, 0, 0.75);
|
|
14
|
-
color: var(--mbx-text);
|
|
15
|
-
font: 400 15px/1.4 var(--mbx-font);
|
|
16
|
-
text-align: center;
|
|
17
|
-
}
|
|
18
|
-
:host([hidden]) { display: none; }
|
|
19
|
-
[part~="box"] { display: flex; flex-direction: column; align-items: center; gap: 8px; }
|
|
20
|
-
[part~="title"] { font-size: 18px; font-weight: 600; }
|
|
21
|
-
[part~="detail"] { font-family: monospace; font-size: 13px; color: var(--mbx-error); }
|
|
22
|
-
[part~="retry"] {
|
|
23
|
-
height: 36px;
|
|
24
|
-
padding: 0 16px;
|
|
25
|
-
font: inherit;
|
|
26
|
-
font-weight: 600;
|
|
27
|
-
color: inherit;
|
|
28
|
-
background: transparent;
|
|
29
|
-
border: 1px solid currentColor;
|
|
30
|
-
border-radius: var(--mbx-radius);
|
|
31
|
-
cursor: pointer;
|
|
32
|
-
}
|
|
33
|
-
[part~="retry"]:focus-visible { outline: 2px solid var(--mbx-accent); outline-offset: -2px; }
|
|
34
|
-
`;
|
|
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}";
|
|
35
6
|
var MbxErrorScreen = class extends Component {
|
|
36
7
|
static get observedAttributes() {
|
|
37
8
|
return ["label-title", "label-retry"];
|