@mattebox/player 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cdn/mattebox-player.min.js +3 -435
- 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 +4 -2
- package/dist/element.d.ts.map +1 -1
- package/dist/element.js +384 -443
- 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/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 +27 -8
- 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 +23 -7
- 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 -1
- package/dist/es2015/style.js +1 -101
- package/dist/es2015/tags.js +2 -1
- package/dist/host.js +19 -17
- package/dist/host.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +55 -27
- 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 -100
- 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 -0
- package/dist/tags.d.ts.map +1 -1
- package/dist/tags.js +31 -26
- package/dist/tags.js.map +1 -1
- package/package.json +4 -4
- package/dist/index.js.map +0 -1
|
@@ -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
|
@@ -23,11 +23,12 @@ const OWN = [
|
|
|
23
23
|
"thumbnails"
|
|
24
24
|
];
|
|
25
25
|
/**
|
|
26
|
-
* The chapters
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
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.
|
|
31
32
|
*/
|
|
32
33
|
const CHAPTERS = "chapters";
|
|
33
34
|
/**
|
|
@@ -98,6 +99,7 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
|
|
|
98
99
|
this.options = options !== null && options !== void 0 ? options : defaults;
|
|
99
100
|
this.focusable = false;
|
|
100
101
|
this.track = null;
|
|
102
|
+
this.given = null;
|
|
101
103
|
this.core = null;
|
|
102
104
|
this.current = null;
|
|
103
105
|
this.failure = null;
|
|
@@ -238,13 +240,26 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
|
|
|
238
240
|
this.focusable = true;
|
|
239
241
|
}
|
|
240
242
|
}
|
|
241
|
-
/**
|
|
243
|
+
/** Hands the `chapters` attribute to the engine, or keeps a hidden chapters track on the video for it. */
|
|
242
244
|
chapters() {
|
|
245
|
+
var _this$current$engine2, _this$current2;
|
|
243
246
|
const url = this.getAttribute(CHAPTERS);
|
|
244
|
-
|
|
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) {
|
|
245
250
|
var _this$track;
|
|
246
251
|
(_this$track = this.track) === null || _this$track === void 0 || _this$track.remove();
|
|
247
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;
|
|
248
263
|
return;
|
|
249
264
|
}
|
|
250
265
|
const held = this.track;
|
|
@@ -319,6 +334,7 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
|
|
|
319
334
|
return;
|
|
320
335
|
}
|
|
321
336
|
_this.current = session;
|
|
337
|
+
_this.given = null;
|
|
322
338
|
_this.configure(session);
|
|
323
339
|
_this.chapters();
|
|
324
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"];
|
|
@@ -16,35 +16,7 @@ import { live } from "../controls/session.js";
|
|
|
16
16
|
* `text`, the name from `label-live` and `label-at-edge`. It sits in the
|
|
17
17
|
* bar's seek row unless the page says otherwise.
|
|
18
18
|
*/
|
|
19
|
-
const STYLE =
|
|
20
|
-
:host { display: inline-flex; }
|
|
21
|
-
:host([hidden]) { display: none; }
|
|
22
|
-
[part~="button"] {
|
|
23
|
-
display: inline-flex;
|
|
24
|
-
align-items: center;
|
|
25
|
-
gap: 6px;
|
|
26
|
-
height: 40px;
|
|
27
|
-
padding: 0 8px;
|
|
28
|
-
font: inherit;
|
|
29
|
-
font-size: 12px;
|
|
30
|
-
font-weight: 700;
|
|
31
|
-
letter-spacing: 0.06em;
|
|
32
|
-
color: inherit;
|
|
33
|
-
background: transparent;
|
|
34
|
-
border: 0;
|
|
35
|
-
border-radius: var(--mbx-radius);
|
|
36
|
-
cursor: pointer;
|
|
37
|
-
opacity: 0.9;
|
|
38
|
-
}
|
|
39
|
-
[part~="button"]:hover { opacity: 1; }
|
|
40
|
-
[part~="button"]:disabled { cursor: default; opacity: 1; }
|
|
41
|
-
[part~="button"]:focus-visible { outline: 2px solid var(--mbx-accent); outline-offset: -2px; }
|
|
42
|
-
[part~="dot"] { width: 10px; height: 10px; border-radius: 50%; background: var(--mbx-muted); transition: background 0.2s; }
|
|
43
|
-
:host([at-edge]) [part~="dot"] { background: var(--mbx-live); box-shadow: 0 0 6px var(--mbx-live); }
|
|
44
|
-
@media (prefers-reduced-motion: reduce) {
|
|
45
|
-
[part~="dot"] { transition: none; }
|
|
46
|
-
}
|
|
47
|
-
`;
|
|
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}}";
|
|
48
20
|
var MbxLiveButton = class extends Component {
|
|
49
21
|
static get observedAttributes() {
|
|
50
22
|
return [
|
|
@@ -10,9 +10,9 @@ var MenuElement = class extends Component {
|
|
|
10
10
|
const root = this.attachShadow({ mode: "open" });
|
|
11
11
|
this.menu = menu({
|
|
12
12
|
host: this,
|
|
13
|
-
|
|
13
|
+
picture: () => {
|
|
14
14
|
var _this$player$video$ge, _this$player;
|
|
15
|
-
return (_this$player$video$ge = (_this$player = this.player) === null || _this$player === void 0 ? void 0 : _this$player.video.getBoundingClientRect()
|
|
15
|
+
return (_this$player$video$ge = (_this$player = this.player) === null || _this$player === void 0 ? void 0 : _this$player.video.getBoundingClientRect()) !== null && _this$player$video$ge !== void 0 ? _this$player$video$ge : null;
|
|
16
16
|
},
|
|
17
17
|
back: (page) => {
|
|
18
18
|
var _this$getAttribute;
|
|
@@ -8,7 +8,9 @@ import { BUTTON_STYLE, iconSlots, show, style } from "./shared.js";
|
|
|
8
8
|
* thing back on click. The glyph is a slot per state, so a page drops its
|
|
9
9
|
* own SVG into `icon-play`, `icon-pause` or `icon-replay`; the name is on
|
|
10
10
|
* the button, from `label-play`, `label-pause` and `label-replay`, where a
|
|
11
|
-
* screen reader reads it.
|
|
11
|
+
* screen reader reads it. While the seek bar holds the video paused for a
|
|
12
|
+
* drag, the button shows the state from before the drag, which the player
|
|
13
|
+
* carries as `scrubbing`.
|
|
12
14
|
*/
|
|
13
15
|
const STATES = [
|
|
14
16
|
"play",
|
|
@@ -53,13 +55,18 @@ var MbxPlayButton = class extends Component {
|
|
|
53
55
|
], () => {
|
|
54
56
|
this.render();
|
|
55
57
|
});
|
|
58
|
+
this.observe(player, ["scrubbing"], () => {
|
|
59
|
+
this.render();
|
|
60
|
+
});
|
|
56
61
|
this.render();
|
|
57
62
|
}
|
|
58
63
|
render() {
|
|
59
|
-
var _this$player2, _this$getAttribute;
|
|
64
|
+
var _this$player2, _this$player$getAttri, _this$player3, _this$getAttribute;
|
|
60
65
|
const video = (_this$player2 = this.player) === null || _this$player2 === void 0 ? void 0 : _this$player2.video;
|
|
61
66
|
if (video === void 0) return;
|
|
62
|
-
const
|
|
67
|
+
const held = (_this$player$getAttri = (_this$player3 = this.player) === null || _this$player3 === void 0 ? void 0 : _this$player3.getAttribute("scrubbing")) !== null && _this$player$getAttri !== void 0 ? _this$player$getAttri : null;
|
|
68
|
+
const paused = held === null ? video.paused : held === "paused";
|
|
69
|
+
const state = video.ended ? "replay" : paused ? "play" : "pause";
|
|
63
70
|
show(this.slots, state);
|
|
64
71
|
this.button.setAttribute("aria-label", (_this$getAttribute = this.getAttribute(`label-${state}`)) !== null && _this$getAttribute !== void 0 ? _this$getAttribute : LABELS[state]);
|
|
65
72
|
}
|
|
@@ -8,9 +8,10 @@ import { TimeElement } from "./time-element.js";
|
|
|
8
8
|
* left more often than where they are. A live stream has no end, so the
|
|
9
9
|
* element hides while the stream is live, as the duration does.
|
|
10
10
|
*/
|
|
11
|
+
const TRAILING = ":host{text-align:right}";
|
|
11
12
|
var MbxRemainingTime = class extends TimeElement {
|
|
12
13
|
constructor() {
|
|
13
|
-
super(
|
|
14
|
+
super(TRAILING);
|
|
14
15
|
}
|
|
15
16
|
render() {
|
|
16
17
|
const player = this.player;
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { el, setChildren } from "../dom.js";
|
|
2
|
+
import { icon } from "../controls/icons.js";
|
|
3
|
+
import { Component } from "./component.js";
|
|
4
|
+
import { BUTTON_STYLE, style } from "./shared.js";
|
|
5
|
+
import { optional } from "../controls/session.js";
|
|
6
|
+
//#region src/elements/scan-button.ts
|
|
7
|
+
/**
|
|
8
|
+
* <mbx-scan-button>: fast forward, or rewind with `direction="backward"`,
|
|
9
|
+
* through the I-frame track: `engine.trick.setRate`, see the engine guide's
|
|
10
|
+
* trick play chapter. Each press steps up through `rates`, "4 8 16" by
|
|
11
|
+
* default, and a press past the last one plays at normal speed again. A
|
|
12
|
+
* press while the other button scans starts this one at its first rate.
|
|
13
|
+
* Every rate must be above 2, the engine's own floor for a scan.
|
|
14
|
+
*
|
|
15
|
+
* The button shows only when the session has an I-frame track: without
|
|
16
|
+
* one there is no picture to scan with, and the speed menu covers playback
|
|
17
|
+
* speed. It hides too on a live stream whose window is too short to seek,
|
|
18
|
+
* where the player carries `live` and not `seekable`, as the seek bar does. It carries `aria-pressed` and `scanning` while it scans, and its
|
|
19
|
+
* `rate` part shows the rate, "8×". The name comes from `label`,
|
|
20
|
+
* "Fast forward" or "Rewind".
|
|
21
|
+
*/
|
|
22
|
+
const STYLE_CSS = "[part~=button]{position:relative}[part~=rate]{font-variant-numeric:tabular-nums;font-size:10px;font-weight:700;line-height:1;position:absolute;bottom:2px;right:0}[part~=rate][hidden]{display:none}";
|
|
23
|
+
const RATES = [
|
|
24
|
+
4,
|
|
25
|
+
8,
|
|
26
|
+
16
|
|
27
|
+
];
|
|
28
|
+
/** The engine's floor: a scan rate is above 2 or below -2. */
|
|
29
|
+
const FLOOR = 2;
|
|
30
|
+
/**
|
|
31
|
+
* What changes the rate or whether scanning is possible: every rate change,
|
|
32
|
+
* from either button, the page, or the engine ending a scan, and a new track
|
|
33
|
+
* list, which is when an I-frame track appears.
|
|
34
|
+
*/
|
|
35
|
+
const ENGINE_EVENTS = ["trick:rate", "tracks:changed"];
|
|
36
|
+
const STYLE = BUTTON_STYLE + STYLE_CSS;
|
|
37
|
+
var MbxScanButton = class extends Component {
|
|
38
|
+
static get observedAttributes() {
|
|
39
|
+
return [
|
|
40
|
+
"direction",
|
|
41
|
+
"rates",
|
|
42
|
+
"label"
|
|
43
|
+
];
|
|
44
|
+
}
|
|
45
|
+
constructor() {
|
|
46
|
+
super();
|
|
47
|
+
const root = this.attachShadow({ mode: "open" });
|
|
48
|
+
this.button = el("button", "button");
|
|
49
|
+
this.button.type = "button";
|
|
50
|
+
this.glyph = document.createElement("slot");
|
|
51
|
+
this.glyph.name = "icon";
|
|
52
|
+
this.badge = el("span", "rate");
|
|
53
|
+
this.badge.hidden = true;
|
|
54
|
+
this.button.append(this.glyph, this.badge);
|
|
55
|
+
this.button.addEventListener("click", () => {
|
|
56
|
+
this.step();
|
|
57
|
+
});
|
|
58
|
+
root.append(style(STYLE), this.button);
|
|
59
|
+
}
|
|
60
|
+
connectedCallback() {
|
|
61
|
+
this.hidden = true;
|
|
62
|
+
super.connectedCallback();
|
|
63
|
+
}
|
|
64
|
+
backward() {
|
|
65
|
+
return this.getAttribute("direction") === "backward";
|
|
66
|
+
}
|
|
67
|
+
/** The rates to step through, each above the floor, in the order given. */
|
|
68
|
+
rates() {
|
|
69
|
+
var _this$getAttribute;
|
|
70
|
+
const own = ((_this$getAttribute = this.getAttribute("rates")) !== null && _this$getAttribute !== void 0 ? _this$getAttribute : "").split(/\s+/).map(Number).filter((rate) => Number.isFinite(rate) && rate > FLOOR);
|
|
71
|
+
return own.length > 0 ? own : RATES;
|
|
72
|
+
}
|
|
73
|
+
step() {
|
|
74
|
+
var _this$player$engine, _this$player;
|
|
75
|
+
const trick = optional((_this$player$engine = (_this$player = this.player) === null || _this$player === void 0 ? void 0 : _this$player.engine) !== null && _this$player$engine !== void 0 ? _this$player$engine : null).trick;
|
|
76
|
+
if ((trick === null || trick === void 0 ? void 0 : trick.available) !== true) return;
|
|
77
|
+
const sign = this.backward() ? -1 : 1;
|
|
78
|
+
const rates = this.rates();
|
|
79
|
+
const now = trick.rate * sign;
|
|
80
|
+
const next = now > FLOOR ? rates[rates.indexOf(now) + 1] : rates[0];
|
|
81
|
+
trick.setRate(next === void 0 ? 1 : next * sign);
|
|
82
|
+
this.render();
|
|
83
|
+
}
|
|
84
|
+
attach(player) {
|
|
85
|
+
const tick = () => {
|
|
86
|
+
this.render();
|
|
87
|
+
};
|
|
88
|
+
this.listen(player.video, ["emptied"], tick);
|
|
89
|
+
this.observe(player, ["live", "seekable"], tick);
|
|
90
|
+
this.follow(player, (engine) => {
|
|
91
|
+
tick();
|
|
92
|
+
if (engine === null) return void 0;
|
|
93
|
+
const offs = ENGINE_EVENTS.map((name) => engine.on(name, tick));
|
|
94
|
+
return () => {
|
|
95
|
+
for (const off of offs) off();
|
|
96
|
+
};
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
render() {
|
|
100
|
+
var _this$player$engine2, _this$player2, _trick$rate, _this$getAttribute2;
|
|
101
|
+
const trick = optional((_this$player$engine2 = (_this$player2 = this.player) === null || _this$player2 === void 0 ? void 0 : _this$player2.engine) !== null && _this$player$engine2 !== void 0 ? _this$player$engine2 : null).trick;
|
|
102
|
+
const backward = this.backward();
|
|
103
|
+
const player = this.player;
|
|
104
|
+
const unseekable = (player === null || player === void 0 ? void 0 : player.hasAttribute("live")) === true && !player.hasAttribute("seekable");
|
|
105
|
+
this.hidden = (trick === null || trick === void 0 ? void 0 : trick.available) !== true || unseekable;
|
|
106
|
+
const rate = (_trick$rate = trick === null || trick === void 0 ? void 0 : trick.rate) !== null && _trick$rate !== void 0 ? _trick$rate : 1;
|
|
107
|
+
const on = backward ? rate < -2 : rate > FLOOR;
|
|
108
|
+
this.toggleAttribute("scanning", on);
|
|
109
|
+
this.button.setAttribute("aria-pressed", String(on));
|
|
110
|
+
this.badge.hidden = !on;
|
|
111
|
+
this.badge.textContent = on ? `${Math.abs(rate)}×` : "";
|
|
112
|
+
setChildren(this.glyph, icon(backward ? "fast-backward" : "fast-forward"));
|
|
113
|
+
const name = (_this$getAttribute2 = this.getAttribute("label")) !== null && _this$getAttribute2 !== void 0 ? _this$getAttribute2 : backward ? "Rewind" : "Fast forward";
|
|
114
|
+
this.button.setAttribute("aria-label", name);
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
//#endregion
|
|
118
|
+
export { MbxScanButton };
|