@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
|
@@ -2,13 +2,28 @@ import { el } from "../dom.js";
|
|
|
2
2
|
import { Component } from "./component.js";
|
|
3
3
|
import { SLIDER_STYLE, number, seekRow, style } from "./shared.js";
|
|
4
4
|
import { fill } from "../labels.js";
|
|
5
|
-
import { chapterAt, chapters, followChapters } from "../controls/chapters.js";
|
|
6
|
-
import { format } from "../controls/time.js";
|
|
7
5
|
import { EMPTY, at, clip, fraction } from "../controls/ranges.js";
|
|
6
|
+
import { format } from "../controls/time.js";
|
|
8
7
|
import { bufferGoal, live, optional, span, wall } from "../controls/session.js";
|
|
8
|
+
import { chapterAt, chapters, followChapters } from "../controls/chapters.js";
|
|
9
9
|
import { slider } from "../controls/slider.js";
|
|
10
10
|
//#region src/elements/seek-bar.ts
|
|
11
|
+
const STYLE_CSS = ":host,[part~=slider]{flex:1}[part~=thumb]{width:16px;height:16px;margin:-8px 0 0 -8px;box-shadow:0 1px 3px #0006}[part~=buffered]{position:absolute;top:0;bottom:0;left:0;right:0}[part~=buffered-range]{background:#ffffff4d;position:absolute;top:0;bottom:0}[part~=hover]{background:var(--mbx-text);width:2px;margin-left:-1px;position:absolute;top:0;bottom:0}[part~=edge]{background:var(--mbx-live);width:2px;margin-left:-1px;position:absolute;top:0;bottom:0}[part~=preview]{background:var(--mbx-surface);border-radius:var(--mbx-radius);font-variant-numeric:tabular-nums;white-space:nowrap;pointer-events:none;flex-direction:column;align-items:center;margin-bottom:4px;padding:2px;font-size:13px;display:flex;position:absolute;bottom:100%;transform:translate(-50%)}[part~=preview]>:not([hidden])~:not([hidden]){margin-top:2px}[part~=preview-image]{border-radius:2px;position:relative;overflow:hidden}[part~=preview-frame]{border-radius:2px;display:block}[part~=preview-tile]{transform-origin:0 0;background-repeat:no-repeat;position:absolute;top:0;left:0}[part~=preview-time]{padding:0 4px}[part~=preview-title]{text-overflow:ellipsis;max-width:240px;padding:0 4px;overflow:hidden}[hidden]{display:none}";
|
|
11
12
|
const STEP = 5;
|
|
13
|
+
/** Under `key-mode="preview"`, a target seeks this long after the last key. */
|
|
14
|
+
const KEY_COMMIT_MS = 1e3;
|
|
15
|
+
/** Key moves closer together than this are one hold, whose step grows. */
|
|
16
|
+
const REPEAT_GAP_MS = 400;
|
|
17
|
+
/** A held key's step grows by one step every this many moves... */
|
|
18
|
+
const MOVES_PER_STEP = 8;
|
|
19
|
+
/** ...up to this many steps a move. */
|
|
20
|
+
const MAX_STEPS = 12;
|
|
21
|
+
/** The keys that cancel a target: Escape, and Back as a remote sends it. */
|
|
22
|
+
const CANCEL_KEYS = [
|
|
23
|
+
"Escape",
|
|
24
|
+
"GoBack",
|
|
25
|
+
"BrowserBack"
|
|
26
|
+
];
|
|
12
27
|
const PAGE = 30;
|
|
13
28
|
const LIVE_WINDOW = 3;
|
|
14
29
|
/** What the tile scales down to when the page sets no `--mbx-preview-width`. */
|
|
@@ -26,37 +41,7 @@ const EVENTS = [
|
|
|
26
41
|
"seeked",
|
|
27
42
|
"emptied"
|
|
28
43
|
];
|
|
29
|
-
const STYLE =
|
|
30
|
-
:host { flex: 1; }
|
|
31
|
-
[part~="slider"] { flex: 1; }
|
|
32
|
-
[part~="thumb"] { width: 16px; height: 16px; margin: -8px 0 0 -8px; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4); }
|
|
33
|
-
[part~="buffered"] { position: absolute; top: 0; right: 0; bottom: 0; left: 0; }
|
|
34
|
-
[part~="buffered-range"] { position: absolute; top: 0; bottom: 0; background: rgba(255, 255, 255, 0.3); }
|
|
35
|
-
[part~="hover"] { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--mbx-text); }
|
|
36
|
-
[part~="edge"] { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--mbx-live); }
|
|
37
|
-
[part~="preview"] {
|
|
38
|
-
position: absolute;
|
|
39
|
-
bottom: 100%;
|
|
40
|
-
margin-bottom: 4px;
|
|
41
|
-
transform: translateX(-50%);
|
|
42
|
-
display: flex;
|
|
43
|
-
flex-direction: column;
|
|
44
|
-
align-items: center;
|
|
45
|
-
gap: 2px;
|
|
46
|
-
padding: 2px;
|
|
47
|
-
background: var(--mbx-surface);
|
|
48
|
-
border-radius: var(--mbx-radius);
|
|
49
|
-
font-size: 13px;
|
|
50
|
-
font-variant-numeric: tabular-nums;
|
|
51
|
-
white-space: nowrap;
|
|
52
|
-
pointer-events: none;
|
|
53
|
-
}
|
|
54
|
-
[part~="preview-image"] { position: relative; overflow: hidden; border-radius: 2px; }
|
|
55
|
-
[part~="preview-tile"] { position: absolute; top: 0; left: 0; transform-origin: top left; background-repeat: no-repeat; }
|
|
56
|
-
[part~="preview-time"] { padding: 0 4px; }
|
|
57
|
-
[part~="preview-title"] { max-width: 240px; padding: 0 4px; overflow: hidden; text-overflow: ellipsis; }
|
|
58
|
-
[hidden] { display: none; }
|
|
59
|
-
`;
|
|
44
|
+
const STYLE = SLIDER_STYLE + STYLE_CSS;
|
|
60
45
|
function percent(part) {
|
|
61
46
|
return `${part * 100}%`;
|
|
62
47
|
}
|
|
@@ -82,7 +67,10 @@ var MbxSeekBar = class extends Component {
|
|
|
82
67
|
"label-of",
|
|
83
68
|
"label-behind",
|
|
84
69
|
"live-window",
|
|
85
|
-
"chapters"
|
|
70
|
+
"chapters",
|
|
71
|
+
"scrub",
|
|
72
|
+
"preview",
|
|
73
|
+
"key-mode"
|
|
86
74
|
];
|
|
87
75
|
}
|
|
88
76
|
constructor() {
|
|
@@ -92,15 +80,27 @@ var MbxSeekBar = class extends Component {
|
|
|
92
80
|
this.frame = 0;
|
|
93
81
|
this.divided = "";
|
|
94
82
|
this.list = [];
|
|
83
|
+
this.drag = "none";
|
|
84
|
+
this.dragged = null;
|
|
85
|
+
this.resume = false;
|
|
86
|
+
this.asked = 0;
|
|
87
|
+
this.shown = 0;
|
|
88
|
+
this.target = null;
|
|
89
|
+
this.commitTimer = 0;
|
|
90
|
+
this.moves = 0;
|
|
91
|
+
this.lastMove = 0;
|
|
95
92
|
const root = this.attachShadow({ mode: "open" });
|
|
96
93
|
this.bar = slider({
|
|
97
|
-
step: () =>
|
|
94
|
+
step: () => this.keyStep(),
|
|
98
95
|
page: () => number(this, "page", PAGE),
|
|
99
|
-
onInput: (value) => {
|
|
100
|
-
this.
|
|
96
|
+
onInput: (value, key) => {
|
|
97
|
+
if (key && this.previewing()) this.aim(value);
|
|
98
|
+
else this.input(value);
|
|
101
99
|
},
|
|
102
100
|
onDrag: (on) => {
|
|
103
101
|
this.toggleAttribute("dragging", on);
|
|
102
|
+
if (on) this.dragStart();
|
|
103
|
+
else this.dragEnd();
|
|
104
104
|
}
|
|
105
105
|
});
|
|
106
106
|
this.buffered = el("div", "buffered");
|
|
@@ -118,14 +118,19 @@ var MbxSeekBar = class extends Component {
|
|
|
118
118
|
this.caption.hidden = true;
|
|
119
119
|
this.image.append(this.tile);
|
|
120
120
|
this.image.hidden = true;
|
|
121
|
-
this.
|
|
121
|
+
this.frameCanvas = el("canvas", "preview-frame");
|
|
122
|
+
this.frameCanvas.hidden = true;
|
|
123
|
+
this.preview.append(this.frameCanvas, this.image, this.caption, this.time);
|
|
122
124
|
this.preview.hidden = true;
|
|
123
125
|
this.bar.root.append(this.preview);
|
|
124
126
|
this.bar.root.addEventListener("pointermove", (event) => {
|
|
125
127
|
this.point(event);
|
|
126
128
|
});
|
|
127
129
|
this.bar.root.addEventListener("pointerleave", () => {
|
|
128
|
-
this.leave();
|
|
130
|
+
if (this.target === null) this.leave();
|
|
131
|
+
});
|
|
132
|
+
this.bar.root.addEventListener("blur", () => {
|
|
133
|
+
if (this.target !== null) this.commit();
|
|
129
134
|
});
|
|
130
135
|
root.append(style(STYLE), this.bar.root);
|
|
131
136
|
}
|
|
@@ -137,13 +142,17 @@ var MbxSeekBar = class extends Component {
|
|
|
137
142
|
var _this$player$engine, _this$player;
|
|
138
143
|
return live((_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) !== void 0;
|
|
139
144
|
}
|
|
140
|
-
/** Whether the chapters
|
|
141
|
-
chaptered() {
|
|
142
|
-
|
|
145
|
+
/** Whether the chapters do `use`: `divided` the track, or name the preview with their `titles`. */
|
|
146
|
+
chaptered(use) {
|
|
147
|
+
if (this.list.length === 0) return false;
|
|
148
|
+
const value = this.getAttribute("chapters");
|
|
149
|
+
if (value === null) return true;
|
|
150
|
+
const words = value.split(/\s+/);
|
|
151
|
+
return words.includes(use) || !words.some((word) => word === "divided" || word === "titles" || word === "none");
|
|
143
152
|
}
|
|
144
153
|
/** The gaps at the chapter boundaries, on every layer of the track at once. */
|
|
145
154
|
paintChapters() {
|
|
146
|
-
const mask = this.chaptered() && this.list.length > 1 ? gaps(this.list, this.range) : "";
|
|
155
|
+
const mask = this.chaptered("divided") && this.list.length > 1 ? gaps(this.list, this.range) : "";
|
|
147
156
|
const key = `${mask}|${this.range.start}|${this.range.end}`;
|
|
148
157
|
if (key === this.divided) return;
|
|
149
158
|
this.divided = key;
|
|
@@ -173,14 +182,124 @@ var MbxSeekBar = class extends Component {
|
|
|
173
182
|
if (!this.isLive()) return format(time);
|
|
174
183
|
return (_wall = wall((_this$player$engine3 = (_this$player3 = this.player) === null || _this$player3 === void 0 ? void 0 : _this$player3.engine) !== null && _this$player$engine3 !== void 0 ? _this$player$engine3 : null, time)) !== null && _wall !== void 0 ? _wall : `-${format(this.range.end - time)}`;
|
|
175
184
|
}
|
|
185
|
+
/** Scrubs when the session has an I-frame track and the page allows it; seeks otherwise. */
|
|
186
|
+
dragStart() {
|
|
187
|
+
var _this$player$engine4, _this$player4, _this$player5, _this$player6;
|
|
188
|
+
const trick = optional((_this$player$engine4 = (_this$player4 = this.player) === null || _this$player4 === void 0 ? void 0 : _this$player4.engine) !== null && _this$player$engine4 !== void 0 ? _this$player$engine4 : null).trick;
|
|
189
|
+
this.dragged = null;
|
|
190
|
+
const before = ((_this$player5 = this.player) === null || _this$player5 === void 0 ? void 0 : _this$player5.video.paused) === false ? "playing" : "paused";
|
|
191
|
+
(_this$player6 = this.player) === null || _this$player6 === void 0 || _this$player6.setAttribute("scrubbing", before);
|
|
192
|
+
if ((trick === null || trick === void 0 ? void 0 : trick.available) === true && this.getAttribute("scrub") !== "false") {
|
|
193
|
+
trick.scrubStart();
|
|
194
|
+
this.drag = "scrub";
|
|
195
|
+
} else {
|
|
196
|
+
var _this$player7;
|
|
197
|
+
const video = (_this$player7 = this.player) === null || _this$player7 === void 0 ? void 0 : _this$player7.video;
|
|
198
|
+
this.resume = video !== void 0 && !video.paused;
|
|
199
|
+
video === null || video === void 0 || video.pause();
|
|
200
|
+
this.drag = "seek";
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* The pointer let go. A release writes its own input next, in the same
|
|
205
|
+
* task, and that settles the drag. A cancelled drag writes none, so the
|
|
206
|
+
* drag settles at its last position once the task is over.
|
|
207
|
+
*/
|
|
208
|
+
dragEnd() {
|
|
209
|
+
queueMicrotask(() => {
|
|
210
|
+
if (this.drag !== "none") this.settle(this.dragged);
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
/** Ends the drag at `value`, or where it stands when there is none. */
|
|
214
|
+
settle(value) {
|
|
215
|
+
const drag = this.drag;
|
|
216
|
+
this.drag = "none";
|
|
217
|
+
this.dragged = null;
|
|
218
|
+
const player = this.player;
|
|
219
|
+
if (player === null) return;
|
|
220
|
+
if (drag === "scrub") {
|
|
221
|
+
const trick = optional(player.engine).trick;
|
|
222
|
+
if (value === null) trick === null || trick === void 0 || trick.scrubEnd();
|
|
223
|
+
else trick === null || trick === void 0 || trick.scrubEnd(value);
|
|
224
|
+
} else {
|
|
225
|
+
if (value !== null) player.video.currentTime = value;
|
|
226
|
+
if (this.resume) player.video.play().catch(() => void 0);
|
|
227
|
+
this.resume = false;
|
|
228
|
+
}
|
|
229
|
+
player.removeAttribute("scrubbing");
|
|
230
|
+
}
|
|
231
|
+
/** Whether keys aim a target with the preview instead of seeking at once. */
|
|
232
|
+
previewing() {
|
|
233
|
+
return this.getAttribute("key-mode") === "preview";
|
|
234
|
+
}
|
|
235
|
+
/** The step for a key on the slider itself. */
|
|
236
|
+
keyStep() {
|
|
237
|
+
const base = number(this, "step", STEP);
|
|
238
|
+
return this.previewing() ? base * this.growth() : base;
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* How many steps a key moves the target under `key-mode="preview"`. It
|
|
242
|
+
* grows while the viewer holds the key, so a long film takes seconds to
|
|
243
|
+
* cross, not minutes; a pause restarts it.
|
|
244
|
+
*/
|
|
245
|
+
growth() {
|
|
246
|
+
const now = performance.now();
|
|
247
|
+
if (now - this.lastMove > REPEAT_GAP_MS) this.moves = 0;
|
|
248
|
+
this.moves += 1;
|
|
249
|
+
this.lastMove = now;
|
|
250
|
+
return Math.min(MAX_STEPS, 1 + Math.floor(this.moves / MOVES_PER_STEP));
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Aims at `value` without seeking: the thumb and the preview show it, and
|
|
254
|
+
* the seek comes on Enter or once the keys pause. A TV decodes slowly, so
|
|
255
|
+
* a seek per key would stutter where the preview already shows the place.
|
|
256
|
+
*/
|
|
257
|
+
aim(value) {
|
|
258
|
+
const time = Math.min(this.range.end, Math.max(this.range.start, value));
|
|
259
|
+
this.target = time;
|
|
260
|
+
this.bar.set(time, this.say(time));
|
|
261
|
+
const span = this.range.end - this.range.start;
|
|
262
|
+
if (span > 0) this.previewAt((time - this.range.start) / span);
|
|
263
|
+
clearTimeout(this.commitTimer);
|
|
264
|
+
this.commitTimer = window.setTimeout(() => {
|
|
265
|
+
this.commit();
|
|
266
|
+
}, KEY_COMMIT_MS);
|
|
267
|
+
}
|
|
268
|
+
/** Seeks to the target, if there is one. */
|
|
269
|
+
commit() {
|
|
270
|
+
var _this$player8;
|
|
271
|
+
const target = this.target;
|
|
272
|
+
this.stopAiming();
|
|
273
|
+
const video = (_this$player8 = this.player) === null || _this$player8 === void 0 ? void 0 : _this$player8.video;
|
|
274
|
+
if (target !== null && video !== void 0) video.currentTime = target;
|
|
275
|
+
}
|
|
276
|
+
/** Drops the target: the thumb goes back to the playhead. */
|
|
277
|
+
cancel() {
|
|
278
|
+
this.stopAiming();
|
|
279
|
+
this.render();
|
|
280
|
+
}
|
|
281
|
+
stopAiming() {
|
|
282
|
+
clearTimeout(this.commitTimer);
|
|
283
|
+
this.commitTimer = 0;
|
|
284
|
+
this.target = null;
|
|
285
|
+
this.moves = 0;
|
|
286
|
+
this.leave();
|
|
287
|
+
}
|
|
176
288
|
input(value) {
|
|
177
|
-
var _this$
|
|
178
|
-
const video = (_this$
|
|
289
|
+
var _this$player9;
|
|
290
|
+
const video = (_this$player9 = this.player) === null || _this$player9 === void 0 ? void 0 : _this$player9.video;
|
|
179
291
|
if (video === void 0) return;
|
|
180
292
|
this.bar.set(value, this.say(value));
|
|
181
293
|
if (!this.bar.dragging()) {
|
|
182
294
|
this.pending = null;
|
|
183
|
-
|
|
295
|
+
if (this.drag !== "none") this.settle(value);
|
|
296
|
+
else video.currentTime = value;
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
299
|
+
this.dragged = value;
|
|
300
|
+
if (this.drag === "scrub") {
|
|
301
|
+
var _optional$trick, _this$player$engine5, _this$player10;
|
|
302
|
+
(_optional$trick = optional((_this$player$engine5 = (_this$player10 = this.player) === null || _this$player10 === void 0 ? void 0 : _this$player10.engine) !== null && _this$player$engine5 !== void 0 ? _this$player$engine5 : null).trick) === null || _optional$trick === void 0 || _optional$trick.scrubTo(value);
|
|
184
303
|
return;
|
|
185
304
|
}
|
|
186
305
|
this.pending = value;
|
|
@@ -189,9 +308,9 @@ var MbxSeekBar = class extends Component {
|
|
|
189
308
|
});
|
|
190
309
|
}
|
|
191
310
|
flush() {
|
|
192
|
-
var _this$
|
|
311
|
+
var _this$player11;
|
|
193
312
|
this.frame = 0;
|
|
194
|
-
const video = (_this$
|
|
313
|
+
const video = (_this$player11 = this.player) === null || _this$player11 === void 0 ? void 0 : _this$player11.video;
|
|
195
314
|
if (this.pending === null || video === void 0) return;
|
|
196
315
|
video.currentTime = this.pending;
|
|
197
316
|
this.pending = null;
|
|
@@ -201,21 +320,70 @@ var MbxSeekBar = class extends Component {
|
|
|
201
320
|
const set = Number.parseFloat(getComputedStyle(this.preview).getPropertyValue("--mbx-preview-width"));
|
|
202
321
|
return Number.isFinite(set) && set > 0 ? set : PREVIEW_WIDTH;
|
|
203
322
|
}
|
|
204
|
-
/** The
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
this.
|
|
214
|
-
|
|
215
|
-
this.
|
|
216
|
-
this.
|
|
323
|
+
/** The preview's picture sources from `preview`, in order of preference: frames then tiles by default. */
|
|
324
|
+
sources() {
|
|
325
|
+
const value = this.getAttribute("preview");
|
|
326
|
+
if (value === "none") return [];
|
|
327
|
+
const own = (value !== null && value !== void 0 ? value : "").split(/\s+/).filter((word) => word === "frames" || word === "tiles");
|
|
328
|
+
return own.length > 0 ? own : ["frames", "tiles"];
|
|
329
|
+
}
|
|
330
|
+
/** `tile`, or none, drawn at its size and scaled to fit. */
|
|
331
|
+
paintTile(tile) {
|
|
332
|
+
this.image.hidden = tile === null;
|
|
333
|
+
if (tile === null) return;
|
|
334
|
+
const scale = this.previewWidth() / tile.width;
|
|
335
|
+
this.image.style.width = `${tile.width * scale}px`;
|
|
336
|
+
this.image.style.height = `${tile.height * scale}px`;
|
|
337
|
+
this.tile.style.width = `${tile.width}px`;
|
|
338
|
+
this.tile.style.height = `${tile.height}px`;
|
|
339
|
+
this.tile.style.backgroundImage = `url("${tile.url}")`;
|
|
340
|
+
this.tile.style.backgroundPosition = `-${tile.x}px -${tile.y}px`;
|
|
217
341
|
this.tile.style.transform = `scale(${scale})`;
|
|
218
342
|
}
|
|
343
|
+
/**
|
|
344
|
+
* The picture in the preview, from the sources `preview` names, the first
|
|
345
|
+
* that answers winning. A decoded frame arrives later than a tile, so
|
|
346
|
+
* while frames lead, the tile stands in until one is on screen, and the
|
|
347
|
+
* last frame stays until the next one arrives. A scrub already shows the
|
|
348
|
+
* position in the video, so the preview shows none meanwhile.
|
|
349
|
+
*/
|
|
350
|
+
paintPicture(when) {
|
|
351
|
+
var _this$player$engine6, _this$player12, _api$thumbnails$at, _api$thumbnails;
|
|
352
|
+
const sources = this.drag === "scrub" ? [] : this.sources();
|
|
353
|
+
const api = optional((_this$player$engine6 = (_this$player12 = this.player) === null || _this$player12 === void 0 ? void 0 : _this$player12.engine) !== null && _this$player$engine6 !== void 0 ? _this$player$engine6 : null);
|
|
354
|
+
const trick = api.trick;
|
|
355
|
+
const frames = sources.includes("frames") && (trick === null || trick === void 0 ? void 0 : trick.previews) === true;
|
|
356
|
+
const tile = sources.includes("tiles") ? (_api$thumbnails$at = (_api$thumbnails = api.thumbnails) === null || _api$thumbnails === void 0 ? void 0 : _api$thumbnails.at(when)) !== null && _api$thumbnails$at !== void 0 ? _api$thumbnails$at : null : null;
|
|
357
|
+
if (tile !== null && (sources[0] === "tiles" || !frames)) {
|
|
358
|
+
this.asked += 1;
|
|
359
|
+
this.shown = this.asked;
|
|
360
|
+
this.frameCanvas.hidden = true;
|
|
361
|
+
this.paintTile(tile);
|
|
362
|
+
return;
|
|
363
|
+
}
|
|
364
|
+
if (!frames || trick === void 0) {
|
|
365
|
+
this.frameCanvas.hidden = true;
|
|
366
|
+
this.paintTile(null);
|
|
367
|
+
return;
|
|
368
|
+
}
|
|
369
|
+
this.asked += 1;
|
|
370
|
+
const request = this.asked;
|
|
371
|
+
const width = this.previewWidth();
|
|
372
|
+
trick.frameAt(when, { width: Math.round(width * devicePixelRatio) }).then((bitmap) => {
|
|
373
|
+
var _canvas$getContext;
|
|
374
|
+
if (bitmap === null || request < this.shown || this.preview.hidden) return;
|
|
375
|
+
this.shown = request;
|
|
376
|
+
const canvas = this.frameCanvas;
|
|
377
|
+
canvas.width = bitmap.width;
|
|
378
|
+
canvas.height = bitmap.height;
|
|
379
|
+
canvas.style.width = `${width}px`;
|
|
380
|
+
canvas.style.height = `${bitmap.height / bitmap.width * width}px`;
|
|
381
|
+
(_canvas$getContext = canvas.getContext("2d")) === null || _canvas$getContext === void 0 || _canvas$getContext.drawImage(bitmap, 0, 0);
|
|
382
|
+
canvas.hidden = false;
|
|
383
|
+
this.image.hidden = true;
|
|
384
|
+
}, () => void 0);
|
|
385
|
+
if (this.frameCanvas.hidden) this.paintTile(tile);
|
|
386
|
+
}
|
|
219
387
|
paintBuffered(video) {
|
|
220
388
|
var _buffered$lastElement;
|
|
221
389
|
const parts = clip(Array.from({ length: video.buffered.length }, (_, i) => ({
|
|
@@ -237,27 +405,33 @@ var MbxSeekBar = class extends Component {
|
|
|
237
405
|
}
|
|
238
406
|
/** Whether a live window is wide enough to be worth a bar. */
|
|
239
407
|
worthSeeking() {
|
|
240
|
-
var _bufferGoal, _this$player$
|
|
408
|
+
var _bufferGoal, _this$player$engine7, _this$player13;
|
|
241
409
|
const goals = number(this, "live-window", LIVE_WINDOW);
|
|
242
410
|
if (goals === 0) return true;
|
|
243
|
-
const goal = (_bufferGoal = bufferGoal((_this$player$
|
|
411
|
+
const goal = (_bufferGoal = bufferGoal((_this$player$engine7 = (_this$player13 = this.player) === null || _this$player13 === void 0 ? void 0 : _this$player13.engine) !== null && _this$player$engine7 !== void 0 ? _this$player$engine7 : null)) !== null && _bufferGoal !== void 0 ? _bufferGoal : BUFFER_GOAL;
|
|
244
412
|
return this.range.end - this.range.start >= goals * goal;
|
|
245
413
|
}
|
|
246
414
|
/** The hover marker and the preview follow the pointer, clamped to the bar. */
|
|
247
415
|
point(event) {
|
|
248
|
-
var _chapter$title;
|
|
249
416
|
const rect = this.bar.rail.getBoundingClientRect();
|
|
250
417
|
if (rect.width === 0 || this.range.end <= this.range.start) return;
|
|
251
418
|
const part = Math.min(1, Math.max(0, (event.clientX - rect.left) / rect.width));
|
|
252
419
|
this.hover.hidden = false;
|
|
253
420
|
this.hover.style.left = percent(part);
|
|
421
|
+
this.previewAt(part);
|
|
422
|
+
}
|
|
423
|
+
/** The preview over `part` of the bar: the time, the chapter, and the picture. */
|
|
424
|
+
previewAt(part) {
|
|
425
|
+
var _chapter$title;
|
|
426
|
+
const rect = this.bar.rail.getBoundingClientRect();
|
|
427
|
+
if (rect.width === 0 || this.range.end <= this.range.start) return;
|
|
254
428
|
this.preview.hidden = false;
|
|
255
429
|
const when = at(part, this.range);
|
|
256
430
|
this.time.textContent = this.label(when);
|
|
257
|
-
const chapter = this.chaptered() ? this.list[chapterAt(this.list, when)] : void 0;
|
|
431
|
+
const chapter = this.chaptered("titles") ? this.list[chapterAt(this.list, when)] : void 0;
|
|
258
432
|
this.caption.hidden = chapter === void 0 || chapter.title === "";
|
|
259
433
|
this.caption.textContent = (_chapter$title = chapter === null || chapter === void 0 ? void 0 : chapter.title) !== null && _chapter$title !== void 0 ? _chapter$title : "";
|
|
260
|
-
this.
|
|
434
|
+
this.paintPicture(when);
|
|
261
435
|
const whole = this.bar.root.getBoundingClientRect();
|
|
262
436
|
const half = this.preview.offsetWidth / 2;
|
|
263
437
|
const x = rect.left - whole.left + part * rect.width;
|
|
@@ -266,26 +440,45 @@ var MbxSeekBar = class extends Component {
|
|
|
266
440
|
leave() {
|
|
267
441
|
this.hover.hidden = true;
|
|
268
442
|
this.preview.hidden = true;
|
|
443
|
+
this.frameCanvas.hidden = true;
|
|
269
444
|
}
|
|
270
445
|
attach(player) {
|
|
271
446
|
const tick = () => {
|
|
272
447
|
this.render();
|
|
273
448
|
};
|
|
274
449
|
this.listen(player.video, EVENTS, tick);
|
|
275
|
-
this.keep(followChapters(player
|
|
450
|
+
this.keep(followChapters(player, tick));
|
|
276
451
|
this.listen(player, ["sourcechange"], () => {
|
|
277
|
-
this.
|
|
452
|
+
this.drag = "none";
|
|
453
|
+
this.stopAiming();
|
|
278
454
|
this.render();
|
|
279
455
|
});
|
|
456
|
+
this.listen(player, ["seekkey"], (event) => {
|
|
457
|
+
var _this$target;
|
|
458
|
+
const asked = event;
|
|
459
|
+
if (!this.previewing() || this.hidden || asked.defaultPrevented) return;
|
|
460
|
+
asked.preventDefault();
|
|
461
|
+
this.aim(((_this$target = this.target) !== null && _this$target !== void 0 ? _this$target : player.video.currentTime) + asked.detail.by * this.growth());
|
|
462
|
+
});
|
|
463
|
+
this.listen(player, ["keydown"], (event) => {
|
|
464
|
+
const key = event;
|
|
465
|
+
if (this.target === null || key.defaultPrevented) return;
|
|
466
|
+
if (key.key === "Enter" && !(key.composedPath()[0] instanceof HTMLButtonElement)) this.commit();
|
|
467
|
+
else if (CANCEL_KEYS.includes(key.key)) this.cancel();
|
|
468
|
+
else return;
|
|
469
|
+
key.preventDefault();
|
|
470
|
+
});
|
|
280
471
|
this.render();
|
|
281
472
|
}
|
|
282
473
|
detach(player) {
|
|
283
474
|
cancelAnimationFrame(this.frame);
|
|
284
475
|
this.frame = 0;
|
|
285
476
|
this.pending = null;
|
|
286
|
-
this.
|
|
477
|
+
if (this.drag !== "none") this.settle(null);
|
|
478
|
+
this.stopAiming();
|
|
287
479
|
player.removeAttribute("live");
|
|
288
480
|
player.removeAttribute("seekable");
|
|
481
|
+
player.removeAttribute("scrubbing");
|
|
289
482
|
}
|
|
290
483
|
render() {
|
|
291
484
|
var _this$getAttribute3;
|
|
@@ -296,7 +489,7 @@ var MbxSeekBar = class extends Component {
|
|
|
296
489
|
const api = live(engine);
|
|
297
490
|
const on = api !== void 0;
|
|
298
491
|
this.range = span(video, engine);
|
|
299
|
-
this.list = chapters(video);
|
|
492
|
+
this.list = chapters(video, engine);
|
|
300
493
|
this.bar.label((_this$getAttribute3 = this.getAttribute("label")) !== null && _this$getAttribute3 !== void 0 ? _this$getAttribute3 : "Seek");
|
|
301
494
|
this.bar.range(this.range.start, this.range.end);
|
|
302
495
|
this.paintBuffered(video);
|
|
@@ -307,7 +500,7 @@ var MbxSeekBar = class extends Component {
|
|
|
307
500
|
this.hidden = !seekable;
|
|
308
501
|
player.toggleAttribute("live", on);
|
|
309
502
|
player.toggleAttribute("seekable", seekable);
|
|
310
|
-
if (!this.bar.dragging()) this.bar.set(video.currentTime, this.say(video.currentTime));
|
|
503
|
+
if (!this.bar.dragging() && this.target === null) this.bar.set(video.currentTime, this.say(video.currentTime));
|
|
311
504
|
}
|
|
312
505
|
};
|
|
313
506
|
//#endregion
|
|
@@ -7,66 +7,11 @@
|
|
|
7
7
|
*
|
|
8
8
|
* Nothing carries `!important`: a page's `::part()` rule must win.
|
|
9
9
|
*/
|
|
10
|
-
const
|
|
11
|
-
:host
|
|
12
|
-
|
|
13
|
-
[part~="button"] {
|
|
14
|
-
display: inline-flex;
|
|
15
|
-
align-items: center;
|
|
16
|
-
justify-content: center;
|
|
17
|
-
flex: none;
|
|
18
|
-
width: 40px;
|
|
19
|
-
height: 40px;
|
|
20
|
-
padding: 0;
|
|
21
|
-
font: inherit;
|
|
22
|
-
color: inherit;
|
|
23
|
-
background: transparent;
|
|
24
|
-
border: 0;
|
|
25
|
-
border-radius: var(--mbx-radius);
|
|
26
|
-
cursor: pointer;
|
|
27
|
-
opacity: 0.9;
|
|
28
|
-
}
|
|
29
|
-
[part~="button"]:hover { opacity: 1; }
|
|
30
|
-
[part~="button"]:focus-visible { outline: 2px solid var(--mbx-accent); outline-offset: -2px; }
|
|
31
|
-
[part~="icon"], ::slotted(*) { width: 1.75em; height: 1.75em; fill: currentColor; }
|
|
32
|
-
slot[hidden] { display: none; }
|
|
33
|
-
`;
|
|
10
|
+
const BUTTON_STYLE_CSS = ":host{display:inline-flex}:host([hidden]){display:none}[part~=button]{width:40px;height:40px;font:inherit;color:inherit;border-radius:var(--mbx-radius);cursor:pointer;opacity:.9;background:0 0;border:0;flex:none;justify-content:center;align-items:center;padding:0;display:inline-flex}[part~=button]:hover{opacity:1}[part~=button]:focus{outline:2px solid var(--mbx-accent);outline-offset:-2px}[part~=button]:focus:not(:focus-visible){outline:none}[part~=icon],::slotted(*){fill:currentColor;width:1.75em;height:1.75em}slot[hidden]{display:none}";
|
|
11
|
+
const SLIDER_STYLE_CSS = ":host{display:block}:host([hidden]){display:none}[part~=slider]{border-radius:var(--mbx-radius);cursor:pointer;touch-action:none;height:40px;position:relative}[part~=slider]:focus{outline:2px solid var(--mbx-accent);outline-offset:-2px}[part~=slider]:focus:not(:focus-visible){outline:none}[part~=rail]{position:absolute;top:0;bottom:0;left:8px;right:8px}[part~=track]{background:#ffffff59;border-radius:2px;height:4px;position:absolute;top:50%;left:0;right:0;overflow:hidden;transform:translateY(-50%)}[part~=fill]{background:var(--mbx-accent);position:absolute;top:0;bottom:0;left:0}[part~=thumb]{background:var(--mbx-text);pointer-events:none;border-radius:50%;width:12px;height:12px;margin:-6px 0 0 -6px;position:absolute;top:50%}";
|
|
12
|
+
const BUTTON_STYLE = BUTTON_STYLE_CSS;
|
|
34
13
|
/** The style of a slider: the rail, the track with its fill, and the thumb. */
|
|
35
|
-
const SLIDER_STYLE =
|
|
36
|
-
:host { display: block; }
|
|
37
|
-
:host([hidden]) { display: none; }
|
|
38
|
-
[part~="slider"] {
|
|
39
|
-
position: relative;
|
|
40
|
-
height: 40px;
|
|
41
|
-
border-radius: var(--mbx-radius);
|
|
42
|
-
cursor: pointer;
|
|
43
|
-
touch-action: none;
|
|
44
|
-
}
|
|
45
|
-
[part~="slider"]:focus-visible { outline: 2px solid var(--mbx-accent); outline-offset: -2px; }
|
|
46
|
-
[part~="rail"] { position: absolute; top: 0; bottom: 0; left: 8px; right: 8px; }
|
|
47
|
-
[part~="track"] {
|
|
48
|
-
position: absolute;
|
|
49
|
-
top: 50%;
|
|
50
|
-
left: 0;
|
|
51
|
-
right: 0;
|
|
52
|
-
height: 4px;
|
|
53
|
-
transform: translateY(-50%);
|
|
54
|
-
background: rgba(255, 255, 255, 0.35);
|
|
55
|
-
border-radius: 2px;
|
|
56
|
-
overflow: hidden;
|
|
57
|
-
}
|
|
58
|
-
[part~="fill"] { position: absolute; top: 0; bottom: 0; left: 0; background: var(--mbx-accent); }
|
|
59
|
-
[part~="thumb"] {
|
|
60
|
-
position: absolute;
|
|
61
|
-
top: 50%;
|
|
62
|
-
width: 12px;
|
|
63
|
-
height: 12px;
|
|
64
|
-
margin: -6px 0 0 -6px;
|
|
65
|
-
border-radius: 50%;
|
|
66
|
-
background: var(--mbx-text);
|
|
67
|
-
pointer-events: none;
|
|
68
|
-
}
|
|
69
|
-
`;
|
|
14
|
+
const SLIDER_STYLE = SLIDER_STYLE_CSS;
|
|
70
15
|
/** A non-negative number from an attribute, else the default. */
|
|
71
16
|
function number(node, name, fallback) {
|
|
72
17
|
const raw = node.getAttribute(name);
|
|
@@ -74,53 +19,7 @@ function number(node, name, fallback) {
|
|
|
74
19
|
return Number.isFinite(value) && value >= 0 ? value : fallback;
|
|
75
20
|
}
|
|
76
21
|
/** The style of a menu: the button from BUTTON_STYLE, and the popup above it with its items. */
|
|
77
|
-
const MENU_STYLE =
|
|
78
|
-
:host { position: relative; }
|
|
79
|
-
[part~="popup"] {
|
|
80
|
-
position: absolute;
|
|
81
|
-
right: 0;
|
|
82
|
-
bottom: 100%;
|
|
83
|
-
margin-bottom: 8px;
|
|
84
|
-
min-width: 160px;
|
|
85
|
-
padding: 6px;
|
|
86
|
-
display: flex;
|
|
87
|
-
flex-direction: column;
|
|
88
|
-
overflow-y: auto;
|
|
89
|
-
overscroll-behavior: contain;
|
|
90
|
-
background: rgba(16, 17, 20, 0.95);
|
|
91
|
-
border-radius: var(--mbx-radius);
|
|
92
|
-
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
|
|
93
|
-
font-size: 14px;
|
|
94
|
-
}
|
|
95
|
-
[part~="popup"][hidden] { display: none; }
|
|
96
|
-
[part~="section"] { display: flex; flex-direction: column; }
|
|
97
|
-
[part~="section"] + [part~="section"] { margin-top: 6px; padding-top: 6px; border-top: 1px solid rgba(255, 255, 255, 0.12); }
|
|
98
|
-
[part~="section-label"] { padding: 4px 12px 2px; font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--mbx-muted); }
|
|
99
|
-
[part~="item"] {
|
|
100
|
-
display: flex;
|
|
101
|
-
align-items: center;
|
|
102
|
-
gap: 12px;
|
|
103
|
-
width: 100%;
|
|
104
|
-
padding: 8px 12px 8px 28px;
|
|
105
|
-
font: inherit;
|
|
106
|
-
color: inherit;
|
|
107
|
-
text-align: left;
|
|
108
|
-
white-space: nowrap;
|
|
109
|
-
background: transparent;
|
|
110
|
-
border: 0;
|
|
111
|
-
border-radius: var(--mbx-radius);
|
|
112
|
-
cursor: pointer;
|
|
113
|
-
}
|
|
114
|
-
[part~="item"]:hover { background: rgba(255, 255, 255, 0.12); }
|
|
115
|
-
[part~="item-detail"] { margin-left: auto; color: var(--mbx-muted); font-variant-numeric: tabular-nums; }
|
|
116
|
-
[part~="item"]:focus-visible { outline: 2px solid var(--mbx-accent); outline-offset: -2px; }
|
|
117
|
-
[part~="page-item"] { position: relative; padding-right: 28px; }
|
|
118
|
-
[part~="page-item"]::after { content: ""; position: absolute; right: 12px; top: 50%; width: 7px; height: 7px; margin-top: -4px; border: solid currentColor; border-width: 1.5px 1.5px 0 0; transform: rotate(45deg); opacity: 0.7; }
|
|
119
|
-
[part~="back-item"] { position: relative; font-weight: 600; border-bottom: 1px solid rgba(255, 255, 255, 0.12); border-radius: 0; margin-bottom: 6px; }
|
|
120
|
-
[part~="back-item"]::before { content: ""; position: absolute; left: 12px; top: 50%; width: 7px; height: 7px; margin-top: -4px; border: solid currentColor; border-width: 1.5px 0 0 1.5px; transform: rotate(-45deg); opacity: 0.7; }
|
|
121
|
-
[part~="checked"] { position: relative; }
|
|
122
|
-
[part~="checked"]::before { content: ""; position: absolute; left: 12px; top: 50%; width: 6px; height: 6px; margin-top: -3px; border-radius: 50%; background: var(--mbx-accent); }
|
|
123
|
-
`;
|
|
22
|
+
const MENU_STYLE = ":host{display:inline-flex}:host([hidden]){display:none}[part~=button]{width:40px;height:40px;font:inherit;color:inherit;border-radius:var(--mbx-radius);cursor:pointer;opacity:.9;background:0 0;border:0;flex:none;justify-content:center;align-items:center;padding:0;display:inline-flex}[part~=button]:hover{opacity:1}[part~=button]:focus{outline:2px solid var(--mbx-accent);outline-offset:-2px}[part~=button]:focus:not(:focus-visible){outline:none}[part~=icon],::slotted(*){fill:currentColor;width:1.75em;height:1.75em}slot[hidden]{display:none}:host{position:relative}[part~=popup]{overscroll-behavior:contain;border-radius:var(--mbx-radius);background:#101114f2;flex-direction:column;min-width:160px;margin-bottom:8px;padding:6px;font-size:14px;display:flex;position:absolute;bottom:100%;right:0;overflow-y:auto;box-shadow:0 4px 16px #00000080}[part~=popup][hidden]{display:none}[part~=section]{flex-direction:column;display:flex}[part~=section]+[part~=section]{border-top:1px solid #ffffff1f;margin-top:6px;padding-top:6px}[part~=section-label]{letter-spacing:.06em;text-transform:uppercase;color:var(--mbx-muted);padding:4px 12px 2px;font-size:11px;font-weight:600}[part~=item]{width:100%;font:inherit;color:inherit;text-align:left;white-space:nowrap;border-radius:var(--mbx-radius);cursor:pointer;background:0 0;border:0;align-items:center;padding:8px 12px 8px 28px;display:flex}[part~=item]:hover{background:#ffffff1f}[part~=item-text]{text-overflow:ellipsis;min-width:0;overflow:hidden}[part~=item-image]{object-fit:cover;background:#ffffff14;border-radius:2px;flex:none;width:64px;height:36px;margin-right:12px}[part~=item-detail]{color:var(--mbx-muted);font-variant-numeric:tabular-nums;margin-left:auto;padding-left:12px}[part~=item]:focus{outline:2px solid var(--mbx-accent);outline-offset:-2px}[part~=item]:focus:not(:focus-visible){outline:none}[part~=page-item]{padding-right:28px;position:relative}[part~=page-item]:after{content:\"\";opacity:.7;border:1.5px solid;border-width:1.5px 1.5px 0 0;width:7px;height:7px;margin-top:-4px;position:absolute;top:50%;right:12px;transform:rotate(45deg)}[part~=back-item]{border-bottom:1px solid #ffffff1f;border-radius:0;margin-bottom:6px;font-weight:600;position:relative}[part~=back-item]:before{content:\"\";opacity:.7;border:0 solid;border-width:1.5px 0 0 1.5px;width:7px;height:7px;margin-top:-4px;position:absolute;top:50%;left:12px;transform:rotate(-45deg)}[part~=checked]{position:relative}[part~=checked]:before{content:\"\";background:var(--mbx-accent);border-radius:50%;width:6px;height:6px;margin-top:-3px;position:absolute;top:50%;left:12px}";
|
|
124
23
|
/** Puts a control in the bar's seek row when it is in a bar, unless the page wrote a `slot` of its own. */
|
|
125
24
|
function seekRow(node) {
|
|
126
25
|
var _node$parentElement;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { setChildren } from "../dom.js";
|
|
1
2
|
import { icon } from "../controls/icons.js";
|
|
2
3
|
import { Component } from "./component.js";
|
|
3
4
|
import { BUTTON_STYLE, style } from "./shared.js";
|
|
@@ -50,7 +51,7 @@ var MbxSkipButton = class extends Component {
|
|
|
50
51
|
const seconds = this.seconds();
|
|
51
52
|
const back = seconds < 0;
|
|
52
53
|
const amount = Math.abs(seconds);
|
|
53
|
-
this.glyph
|
|
54
|
+
setChildren(this.glyph, icon(glyphFor(back, amount)));
|
|
54
55
|
const template = (_this$getAttribute2 = this.getAttribute("label")) !== null && _this$getAttribute2 !== void 0 ? _this$getAttribute2 : back ? "Back {seconds} seconds" : "Forward {seconds} seconds";
|
|
55
56
|
this.button.setAttribute("aria-label", fill(template, { seconds: amount }));
|
|
56
57
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { style } from "./shared.js";
|
|
2
2
|
//#region src/elements/spacer.ts
|
|
3
3
|
/** <mbx-spacer>: takes the room in a row, so what follows sits at the far end. */
|
|
4
|
+
const STYLE = ":host{flex:auto;display:block}";
|
|
4
5
|
var MbxSpacer = class extends HTMLElement {
|
|
5
6
|
constructor() {
|
|
6
7
|
super();
|
|
7
|
-
this.attachShadow({ mode: "open" }).append(style(
|
|
8
|
+
this.attachShadow({ mode: "open" }).append(style(STYLE));
|
|
8
9
|
}
|
|
9
10
|
};
|
|
10
11
|
//#endregion
|