@mattebox/player 0.7.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cdn/mattebox-player.min.js +3 -3
- package/dist/controls/icons.d.ts +5 -28
- package/dist/controls/icons.d.ts.map +1 -1
- package/dist/controls/icons.js +38 -29
- package/dist/controls/icons.js.map +1 -1
- package/dist/controls/markers.d.ts +39 -0
- package/dist/controls/markers.d.ts.map +1 -0
- package/dist/controls/markers.js +38 -0
- package/dist/controls/markers.js.map +1 -0
- package/dist/controls/menu.d.ts +14 -2
- package/dist/controls/menu.d.ts.map +1 -1
- package/dist/controls/menu.js +50 -4
- package/dist/controls/menu.js.map +1 -1
- package/dist/controls/native-tracks.d.ts +28 -0
- package/dist/controls/native-tracks.d.ts.map +1 -0
- package/dist/controls/native-tracks.js +30 -0
- package/dist/controls/native-tracks.js.map +1 -0
- package/dist/controls/quality-names.d.ts +15 -0
- package/dist/controls/quality-names.d.ts.map +1 -0
- package/dist/controls/quality-names.js +62 -0
- package/dist/controls/quality-names.js.map +1 -0
- package/dist/controls/track-names.d.ts +40 -0
- package/dist/controls/track-names.d.ts.map +1 -0
- package/dist/controls/track-names.js +59 -0
- package/dist/controls/track-names.js.map +1 -0
- package/dist/element.d.ts +60 -2
- package/dist/element.d.ts.map +1 -1
- package/dist/element.js +182 -23
- package/dist/element.js.map +1 -1
- package/dist/elements/audio-menu.d.ts +19 -8
- package/dist/elements/audio-menu.d.ts.map +1 -1
- package/dist/elements/audio-menu.js +60 -19
- package/dist/elements/audio-menu.js.map +1 -1
- package/dist/elements/component.d.ts.map +1 -1
- package/dist/elements/component.js +10 -0
- package/dist/elements/component.js.map +1 -1
- package/dist/elements/control-bar.d.ts +2 -0
- package/dist/elements/control-bar.d.ts.map +1 -1
- package/dist/elements/control-bar.js +23 -7
- package/dist/elements/control-bar.js.map +1 -1
- package/dist/elements/current-time.d.ts.map +1 -1
- package/dist/elements/current-time.js +1 -1
- package/dist/elements/current-time.js.map +1 -1
- package/dist/elements/drm-badge.d.ts +3 -2
- package/dist/elements/drm-badge.d.ts.map +1 -1
- package/dist/elements/drm-badge.js +11 -9
- package/dist/elements/drm-badge.js.map +1 -1
- package/dist/elements/duration.d.ts.map +1 -1
- package/dist/elements/duration.js +6 -2
- package/dist/elements/duration.js.map +1 -1
- package/dist/elements/error-screen.js +1 -1
- package/dist/elements/live-button.js +1 -1
- package/dist/elements/marker-button.d.ts +22 -0
- package/dist/elements/marker-button.d.ts.map +1 -0
- package/dist/elements/marker-button.js +95 -0
- package/dist/elements/marker-button.js.map +1 -0
- package/dist/elements/quality-menu.d.ts +4 -0
- package/dist/elements/quality-menu.d.ts.map +1 -1
- package/dist/elements/quality-menu.js +22 -8
- package/dist/elements/quality-menu.js.map +1 -1
- package/dist/elements/scan-button.js +1 -1
- package/dist/elements/seek-bar.d.ts +6 -1
- package/dist/elements/seek-bar.d.ts.map +1 -1
- package/dist/elements/seek-bar.js +37 -25
- package/dist/elements/seek-bar.js.map +1 -1
- package/dist/elements/shared.js +3 -3
- package/dist/elements/skip-button.js +2 -2
- package/dist/elements/skip-button.js.map +1 -1
- package/dist/elements/spinner.js +1 -1
- package/dist/elements/start-button.d.ts +5 -0
- package/dist/elements/start-button.d.ts.map +1 -1
- package/dist/elements/start-button.js +15 -2
- package/dist/elements/start-button.js.map +1 -1
- package/dist/elements/subtitles-menu.d.ts +7 -1
- package/dist/elements/subtitles-menu.d.ts.map +1 -1
- package/dist/elements/subtitles-menu.js +62 -20
- package/dist/elements/subtitles-menu.js.map +1 -1
- package/dist/elements/title.d.ts.map +1 -1
- package/dist/elements/title.js +3 -1
- package/dist/elements/title.js.map +1 -1
- package/dist/elements/volume-slider.js +1 -1
- package/dist/elements/volume.js +1 -1
- package/dist/entries/marker-button.d.ts +5 -0
- package/dist/entries/marker-button.d.ts.map +1 -0
- package/dist/entries/marker-button.js +9 -0
- package/dist/entries/marker-button.js.map +1 -0
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.150.0 → _@oxc-project_runtime@0.152.0}/helpers/esm/asyncToGenerator.js +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.150.0 → _@oxc-project_runtime@0.152.0}/helpers/esm/defineProperty.js +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.150.0 → _@oxc-project_runtime@0.152.0}/helpers/esm/objectSpread2.js +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.150.0 → _@oxc-project_runtime@0.152.0}/helpers/esm/toPrimitive.js +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.150.0 → _@oxc-project_runtime@0.152.0}/helpers/esm/toPropertyKey.js +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.150.0 → _@oxc-project_runtime@0.152.0}/helpers/esm/typeof.js +1 -1
- package/dist/es2015/controls/chapters.js +1 -1
- package/dist/es2015/controls/icons.js +38 -29
- package/dist/es2015/controls/markers.js +36 -0
- package/dist/es2015/controls/menu.js +52 -5
- package/dist/es2015/controls/native-tracks.js +29 -0
- package/dist/es2015/controls/quality-names.js +67 -0
- package/dist/es2015/controls/track-names.js +57 -0
- package/dist/es2015/element.js +185 -29
- package/dist/es2015/elements/audio-menu.js +66 -20
- package/dist/es2015/elements/component.js +10 -0
- package/dist/es2015/elements/control-bar.js +23 -7
- package/dist/es2015/elements/current-time.js +1 -1
- package/dist/es2015/elements/drm-badge.js +12 -9
- package/dist/es2015/elements/duration.js +6 -2
- package/dist/es2015/elements/error-screen.js +1 -1
- package/dist/es2015/elements/live-button.js +1 -1
- package/dist/es2015/elements/marker-button.js +96 -0
- package/dist/es2015/elements/quality-menu.js +23 -8
- package/dist/es2015/elements/scan-button.js +1 -1
- package/dist/es2015/elements/seek-bar.js +42 -29
- package/dist/es2015/elements/shared.js +3 -3
- package/dist/es2015/elements/skip-button.js +2 -2
- package/dist/es2015/elements/spinner.js +1 -1
- package/dist/es2015/elements/start-button.js +15 -2
- package/dist/es2015/elements/subtitles-menu.js +72 -26
- package/dist/es2015/elements/title.js +3 -1
- package/dist/es2015/elements/volume-slider.js +1 -1
- package/dist/es2015/elements/volume.js +1 -1
- package/dist/es2015/entries/marker-button.js +7 -0
- package/dist/es2015/index.js +3 -1
- package/dist/es2015/presets.js +1 -1
- package/dist/es2015/style.js +1 -1
- package/dist/es2015/tags.js +2 -1
- package/dist/host.d.ts +3 -0
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/style.js +1 -1
- package/dist/tags.d.ts +1 -0
- package/dist/tags.d.ts.map +1 -1
- package/dist/tags.js +2 -1
- package/dist/tags.js.map +1 -1
- package/package.json +4 -5
- package/NOTICE +0 -24
|
@@ -2,7 +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 = ":host{color:var(--mbx-text);font:400
|
|
5
|
+
const STYLE = ":host{color:var(--mbx-text);font:400 .9375em / 1.4 var(--mbx-font);text-align:center;background:#000000bf;justify-content:center;align-items:center;padding:1.0667em;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:.5333em}[part~=title]{font-size:1.2em;font-weight:600}[part~=detail]{color:var(--mbx-error);font-family:monospace;font-size:.8667em}[part~=retry]{height:2.4em;font:inherit;color:inherit;border-radius:var(--mbx-radius);cursor:pointer;background:0 0;border:1px solid;padding:0 1.0667em;font-weight:600}[part~=retry]:focus{outline:2px solid var(--mbx-accent);outline-offset:-2px}[part~=retry]:focus:not(:focus-visible){outline:none}";
|
|
6
6
|
var MbxErrorScreen = class extends Component {
|
|
7
7
|
static get observedAttributes() {
|
|
8
8
|
return ["label-title", "label-retry"];
|
|
@@ -16,7 +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 = ":host{display:inline-flex}:host([hidden]){display:none}[part~=button]{height:
|
|
19
|
+
const STYLE = ":host{display:inline-flex}:host([hidden]){display:none}[part~=button]{height:2.5em;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 .5em;font-size:.75em;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:.625em;height:.625em;margin-right:.375em;transition:background .2s}:host([at-edge]) [part~=dot]{background:var(--mbx-live);box-shadow:0 0 6px var(--mbx-live)}@media (prefers-reduced-motion:reduce){[part~=dot]{transition:none}}";
|
|
20
20
|
var MbxLiveButton = class extends Component {
|
|
21
21
|
static get observedAttributes() {
|
|
22
22
|
return [
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { PlayerHost } from '../host.js';
|
|
2
|
+
import { Component } from './component.js';
|
|
3
|
+
export declare class MbxMarkerButton extends Component {
|
|
4
|
+
static get observedAttributes(): readonly string[];
|
|
5
|
+
private readonly button;
|
|
6
|
+
/** The range the button skips, or null while playback is in none. */
|
|
7
|
+
private marker;
|
|
8
|
+
/** Watches the bar and the title: the button sits above whichever is taller. */
|
|
9
|
+
private resizer;
|
|
10
|
+
constructor();
|
|
11
|
+
connectedCallback(): void;
|
|
12
|
+
protected attach(player: PlayerHost): void;
|
|
13
|
+
protected detach(): void;
|
|
14
|
+
/**
|
|
15
|
+
* Lifts the button above the bar's rows: the bar's box less the padding
|
|
16
|
+
* over them, its fade. The title sits on the other side, so the button
|
|
17
|
+
* stays where it is while the title shows.
|
|
18
|
+
*/
|
|
19
|
+
private fit;
|
|
20
|
+
protected render(): void;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=marker-button.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"marker-button.d.ts","sourceRoot":"","sources":["../../src/elements/marker-button.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAS3C,qBAAa,eAAgB,SAAQ,SAAS;IAC5C,MAAM,KAAK,kBAAkB,IAAI,SAAS,MAAM,EAAE,CAEjD;IAED,iBAAyB,MAAM,CAAoB;IACnD,qEAAqE;IACrE,QAAgB,MAAM,CAAgB;IACtC,gFAAgF;IAChF,QAAgB,OAAO,CAAwB;;IAkBtC,iBAAiB,IAAI,IAAI;cAMf,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;cA6BhC,MAAM,IAAI,IAAI;IAKjC;;;;OAIG;IACH,OAAO,CAAC,GAAG;cAOQ,MAAM,IAAI,IAAI;CAoBlC"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { Component } from "./component.js";
|
|
2
|
+
import { BUTTON_STYLE, style } from "./shared.js";
|
|
3
|
+
//#region src/elements/marker-button.ts
|
|
4
|
+
const STYLE_CSS = ":host{right:calc(var(--mbx-pad,.5em) + .5em);bottom:calc(var(--mbx-marker-lift,3.5em) + .75em);z-index:1;transition:transform .3s;position:absolute}:host([idle]){transform:translateY(var(--mbx-marker-lift,3.5em))}:host([hidden]){display:none}[part~=button]{width:auto;height:2.5em;color:var(--mbx-text);font:inherit;white-space:nowrap;background:#0009;border:1px solid #ffffff80;padding:0 1.125em;font-weight:600}[part~=button]:hover{background:#000c}@media (prefers-reduced-motion:reduce){:host{transition:none}}";
|
|
5
|
+
const WORDS = {
|
|
6
|
+
"opening-credits": "Skip intro",
|
|
7
|
+
"closing-credits": "Skip credits"
|
|
8
|
+
};
|
|
9
|
+
var MbxMarkerButton = class extends Component {
|
|
10
|
+
static get observedAttributes() {
|
|
11
|
+
return [
|
|
12
|
+
"label-opening-credits",
|
|
13
|
+
"label-closing-credits",
|
|
14
|
+
"label-skip"
|
|
15
|
+
];
|
|
16
|
+
}
|
|
17
|
+
constructor() {
|
|
18
|
+
super();
|
|
19
|
+
this.marker = null;
|
|
20
|
+
this.resizer = null;
|
|
21
|
+
const root = this.attachShadow({ mode: "open" });
|
|
22
|
+
this.button = document.createElement("button");
|
|
23
|
+
this.button.type = "button";
|
|
24
|
+
this.button.setAttribute("part", "button");
|
|
25
|
+
this.button.textContent = "Skip";
|
|
26
|
+
this.button.addEventListener("click", () => {
|
|
27
|
+
const video = this.player?.video;
|
|
28
|
+
if (video !== void 0 && this.marker !== null) video.currentTime = this.marker.end;
|
|
29
|
+
});
|
|
30
|
+
root.append(style(BUTTON_STYLE + STYLE_CSS), this.button);
|
|
31
|
+
}
|
|
32
|
+
connectedCallback() {
|
|
33
|
+
this.hidden = true;
|
|
34
|
+
super.connectedCallback();
|
|
35
|
+
}
|
|
36
|
+
attach(player) {
|
|
37
|
+
this.listen(player.video, [
|
|
38
|
+
"timeupdate",
|
|
39
|
+
"seeking",
|
|
40
|
+
"emptied"
|
|
41
|
+
], () => {
|
|
42
|
+
this.render();
|
|
43
|
+
});
|
|
44
|
+
this.listen(player, ["markerschange"], () => {
|
|
45
|
+
this.render();
|
|
46
|
+
});
|
|
47
|
+
this.observe(player, ["upnext"], () => {
|
|
48
|
+
this.render();
|
|
49
|
+
});
|
|
50
|
+
const idle = () => {
|
|
51
|
+
this.toggleAttribute("idle", player.hasAttribute("idle"));
|
|
52
|
+
};
|
|
53
|
+
this.observe(player, ["idle"], idle);
|
|
54
|
+
idle();
|
|
55
|
+
if (typeof ResizeObserver !== "undefined") {
|
|
56
|
+
this.resizer = new ResizeObserver(() => {
|
|
57
|
+
this.fit(player);
|
|
58
|
+
});
|
|
59
|
+
this.resizer.observe(player);
|
|
60
|
+
const bar = player.querySelector("mbx-control-bar");
|
|
61
|
+
if (bar !== null) this.resizer.observe(bar);
|
|
62
|
+
}
|
|
63
|
+
this.fit(player);
|
|
64
|
+
this.render();
|
|
65
|
+
}
|
|
66
|
+
detach() {
|
|
67
|
+
this.resizer?.disconnect();
|
|
68
|
+
this.resizer = null;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Lifts the button above the bar's rows: the bar's box less the padding
|
|
72
|
+
* over them, its fade. The title sits on the other side, so the button
|
|
73
|
+
* stays where it is while the title shows.
|
|
74
|
+
*/
|
|
75
|
+
fit(player) {
|
|
76
|
+
const bar = player.querySelector("mbx-control-bar");
|
|
77
|
+
const fade = bar === null ? 0 : Number.parseFloat(getComputedStyle(bar).paddingTop) || 0;
|
|
78
|
+
const lift = bar === null ? 0 : bar.getBoundingClientRect().height - fade;
|
|
79
|
+
this.style.setProperty("--mbx-marker-lift", `${Math.max(0, lift)}px`);
|
|
80
|
+
}
|
|
81
|
+
render() {
|
|
82
|
+
const player = this.player;
|
|
83
|
+
this.marker = player?.markers.within(player.video.currentTime).find((marker) => marker.kind !== "blocked") ?? null;
|
|
84
|
+
if (this.marker?.kind === "closing-credits" && player?.hasAttribute("upnext") === true) this.marker = null;
|
|
85
|
+
this.hidden = this.marker === null;
|
|
86
|
+
if (this.marker === null) return;
|
|
87
|
+
const kind = this.marker.kind;
|
|
88
|
+
const skip = this.getAttribute("label-skip") ?? "Skip";
|
|
89
|
+
this.button.textContent = this.getAttribute(`label-${kind}`) ?? WORDS[kind] ?? (this.marker.label === void 0 ? skip : `${skip} ${this.marker.label}`);
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
//#endregion
|
|
93
|
+
export { MbxMarkerButton };
|
|
94
|
+
|
|
95
|
+
//# sourceMappingURL=marker-button.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"marker-button.js","names":[],"sources":["../../src/elements/marker-button.ts"],"sourcesContent":["/**\n * <mbx-marker-button>: \"Skip intro\" over the picture while playback is in\n * the opening credits, \"Skip credits\" in the closing ones, and \"Skip\" with\n * the marker's own label in any other range the page named. A press moves\n * the playhead to the range's end. Blocked ranges never show it: the\n * player moves past those itself. The words come from\n * `label-opening-credits`, `label-closing-credits` and `label-skip`.\n *\n * While the player carries `upnext`, set by a card that offers the next\n * item, the button leaves the closing credits to it.\n */\nimport type { Marker } from '../controls/markers.js';\nimport type { PlayerHost } from '../host.js';\nimport { Component } from './component.js';\nimport STYLE_CSS from './marker-button.css?inline';\nimport { BUTTON_STYLE, style } from './shared.js';\n\nconst WORDS: Readonly<Record<string, string>> = {\n 'opening-credits': 'Skip intro',\n 'closing-credits': 'Skip credits',\n};\n\nexport class MbxMarkerButton extends Component {\n static get observedAttributes(): readonly string[] {\n return ['label-opening-credits', 'label-closing-credits', 'label-skip'];\n }\n\n declare private readonly button: HTMLButtonElement;\n /** The range the button skips, or null while playback is in none. */\n declare private marker: Marker | null;\n /** Watches the bar and the title: the button sits above whichever is taller. */\n declare private resizer: ResizeObserver | null;\n\n constructor() {\n super();\n this.marker = null;\n this.resizer = null;\n const root = this.attachShadow({ mode: 'open' });\n this.button = document.createElement('button');\n this.button.type = 'button';\n this.button.setAttribute('part', 'button');\n this.button.textContent = 'Skip';\n this.button.addEventListener('click', () => {\n const video = this.player?.video;\n if (video !== undefined && this.marker !== null) video.currentTime = this.marker.end;\n });\n root.append(style(BUTTON_STYLE + STYLE_CSS), this.button);\n }\n\n override connectedCallback(): void {\n // Hidden until playback is in a marker; a constructor may not set attributes.\n this.hidden = true;\n super.connectedCallback();\n }\n\n protected override attach(player: PlayerHost): void {\n this.listen(player.video, ['timeupdate', 'seeking', 'emptied'], () => {\n this.render();\n });\n this.listen(player, ['markerschange'], () => {\n this.render();\n });\n // An up next card, from a playlist, takes over the closing credits.\n this.observe(player, ['upnext'], () => {\n this.render();\n });\n // With the bar hidden, the button slides down to where the bar was.\n const idle = (): void => {\n this.toggleAttribute('idle', player.hasAttribute('idle'));\n };\n this.observe(player, ['idle'], idle);\n idle();\n if (typeof ResizeObserver !== 'undefined') {\n this.resizer = new ResizeObserver(() => {\n this.fit(player);\n });\n this.resizer.observe(player);\n const bar = player.querySelector('mbx-control-bar');\n if (bar !== null) this.resizer.observe(bar);\n }\n this.fit(player);\n this.render();\n }\n\n protected override detach(): void {\n this.resizer?.disconnect();\n this.resizer = null;\n }\n\n /**\n * Lifts the button above the bar's rows: the bar's box less the padding\n * over them, its fade. The title sits on the other side, so the button\n * stays where it is while the title shows.\n */\n private fit(player: PlayerHost): void {\n const bar = player.querySelector('mbx-control-bar');\n const fade = bar === null ? 0 : Number.parseFloat(getComputedStyle(bar).paddingTop) || 0;\n const lift = bar === null ? 0 : bar.getBoundingClientRect().height - fade;\n this.style.setProperty('--mbx-marker-lift', `${Math.max(0, lift)}px`);\n }\n\n protected override render(): void {\n const player = this.player;\n this.marker =\n player?.markers\n .within(player.video.currentTime)\n .find((marker) => marker.kind !== 'blocked') ?? null;\n // A playlist's up next card offers the next item over the closing\n // credits, so this button steps aside while the player carries `upnext`.\n if (this.marker?.kind === 'closing-credits' && player?.hasAttribute('upnext') === true) {\n this.marker = null;\n }\n this.hidden = this.marker === null;\n if (this.marker === null) return;\n const kind = this.marker.kind;\n const skip = this.getAttribute('label-skip') ?? 'Skip';\n this.button.textContent =\n this.getAttribute(`label-${kind}`) ??\n WORDS[kind] ??\n (this.marker.label === undefined ? skip : `${skip} ${this.marker.label}`);\n }\n}\n"],"mappings":";;;AAcA,MAAA,YAAA;AAGA,MAAA,QAAA;CACA,mBAAA;CACA,mBAAA;AACA;AAEA,IAAA,kBAAA,cAAA,UAAA;CACA,WAAA,qBAAA;EACA,OAAA;GAAA;GAAA;GAAA;EAAA;CACA;CAQA,cAAA;EACA,MAAA;EACA,KAAA,SAAA;EACA,KAAA,UAAA;EACA,MAAA,OAAA,KAAA,aAAA,EAAA,MAAA,OAAA,CAAA;EACA,KAAA,SAAA,SAAA,cAAA,QAAA;EACA,KAAA,OAAA,OAAA;EACA,KAAA,OAAA,aAAA,QAAA,QAAA;EACA,KAAA,OAAA,cAAA;EACA,KAAA,OAAA,iBAAA,eAAA;GACA,MAAA,QAAA,KAAA,QAAA;GACA,IAAA,UAAA,KAAA,KAAA,KAAA,WAAA,MAAA,MAAA,cAAA,KAAA,OAAA;EACA,CAAA;EACA,KAAA,OAAA,MAAA,eAAA,SAAA,GAAA,KAAA,MAAA;CACA;CAEA,oBAAA;EAEA,KAAA,SAAA;EACA,MAAA,kBAAA;CACA;CAEA,OAAA,QAAA;EACA,KAAA,OAAA,OAAA,OAAA;GAAA;GAAA;GAAA;EAAA,SAAA;GACA,KAAA,OAAA;EACA,CAAA;EACA,KAAA,OAAA,QAAA,CAAA,eAAA,SAAA;GACA,KAAA,OAAA;EACA,CAAA;EAEA,KAAA,QAAA,QAAA,CAAA,QAAA,SAAA;GACA,KAAA,OAAA;EACA,CAAA;EAEA,MAAA,aAAA;GACA,KAAA,gBAAA,QAAA,OAAA,aAAA,MAAA,CAAA;EACA;EACA,KAAA,QAAA,QAAA,CAAA,MAAA,GAAA,IAAA;EACA,KAAA;EACA,IAAA,OAAA,mBAAA,aAAA;GACA,KAAA,UAAA,IAAA,qBAAA;IACA,KAAA,IAAA,MAAA;GACA,CAAA;GACA,KAAA,QAAA,QAAA,MAAA;GACA,MAAA,MAAA,OAAA,cAAA,iBAAA;GACA,IAAA,QAAA,MAAA,KAAA,QAAA,QAAA,GAAA;EACA;EACA,KAAA,IAAA,MAAA;EACA,KAAA,OAAA;CACA;CAEA,SAAA;EACA,KAAA,SAAA,WAAA;EACA,KAAA,UAAA;CACA;;;;;;CAOA,IAAA,QAAA;EACA,MAAA,MAAA,OAAA,cAAA,iBAAA;EACA,MAAA,OAAA,QAAA,OAAA,IAAA,OAAA,WAAA,iBAAA,GAAA,CAAA,CAAA,UAAA,KAAA;EACA,MAAA,OAAA,QAAA,OAAA,IAAA,IAAA,sBAAA,CAAA,CAAA,SAAA;EACA,KAAA,MAAA,YAAA,qBAAA,GAAA,KAAA,IAAA,GAAA,IAAA,EAAA,GAAA;CACA;CAEA,SAAA;EACA,MAAA,SAAA,KAAA;EACA,KAAA,SACA,QAAA,QACA,OAAA,OAAA,MAAA,WAAA,CAAA,CACA,MAAA,WAAA,OAAA,SAAA,SAAA,KAAA;EAGA,IAAA,KAAA,QAAA,SAAA,qBAAA,QAAA,aAAA,QAAA,MAAA,MACA,KAAA,SAAA;EAEA,KAAA,SAAA,KAAA,WAAA;EACA,IAAA,KAAA,WAAA,MAAA;EACA,MAAA,OAAA,KAAA,OAAA;EACA,MAAA,OAAA,KAAA,aAAA,YAAA,KAAA;EACA,KAAA,OAAA,cACA,KAAA,aAAA,SAAA,MAAA,KACA,MAAA,UACA,KAAA,OAAA,UAAA,KAAA,IAAA,OAAA,GAAA,KAAA,GAAA,KAAA,OAAA;CACA;AACA"}
|
|
@@ -3,9 +3,13 @@ import { MenuElement } from './menu-element.js';
|
|
|
3
3
|
export declare class MbxQualityMenu extends MenuElement {
|
|
4
4
|
static get observedAttributes(): readonly string[];
|
|
5
5
|
private engine;
|
|
6
|
+
/** The name of what plays, as the Auto row last showed it. */
|
|
7
|
+
private playing;
|
|
6
8
|
constructor();
|
|
7
9
|
protected name(): string;
|
|
8
10
|
protected attach(player: PlayerHost): void;
|
|
9
11
|
protected render(): void;
|
|
12
|
+
/** The name of the rendition that plays, under Auto only: a pin names itself by its tick. */
|
|
13
|
+
private playingName;
|
|
10
14
|
}
|
|
11
15
|
//# sourceMappingURL=quality-menu.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quality-menu.d.ts","sourceRoot":"","sources":["../../src/elements/quality-menu.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"quality-menu.d.ts","sourceRoot":"","sources":["../../src/elements/quality-menu.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAU,MAAM,mBAAmB,CAAC;AAKxD,qBAAa,cAAe,SAAQ,WAAW;IAC7C,MAAM,KAAK,kBAAkB,IAAI,SAAS,MAAM,EAAE,CAEjD;IAED,QAAgB,MAAM,CAAkB;IACxC,8DAA8D;IAC9D,QAAgB,OAAO,CAAqB;;cASzB,IAAI,IAAI,MAAM;cAId,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;cA0BhC,MAAM,IAAI,IAAI;IA4BjC,6FAA6F;IAC7F,OAAO,CAAC,WAAW;CAOpB"}
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import { show } from "./shared.js";
|
|
2
2
|
import { MenuElement, single } from "./menu-element.js";
|
|
3
|
+
import { qualityLabels, qualityNames } from "../controls/quality-names.js";
|
|
3
4
|
//#region src/elements/quality-menu.ts
|
|
4
5
|
const AUTO = "auto";
|
|
5
|
-
function renditionLabel(rendition) {
|
|
6
|
-
if (rendition.height !== void 0) return `${rendition.height}p`;
|
|
7
|
-
return `${Math.round(rendition.bitrate / 1e3)} kbps`;
|
|
8
|
-
}
|
|
9
6
|
var MbxQualityMenu = class extends MenuElement {
|
|
10
7
|
static get observedAttributes() {
|
|
11
8
|
return [
|
|
@@ -15,8 +12,9 @@ var MbxQualityMenu = class extends MenuElement {
|
|
|
15
12
|
];
|
|
16
13
|
}
|
|
17
14
|
constructor() {
|
|
18
|
-
super(...single("
|
|
15
|
+
super(...single("quality"));
|
|
19
16
|
this.engine = null;
|
|
17
|
+
this.playing = void 0;
|
|
20
18
|
show(this.slots, "default");
|
|
21
19
|
}
|
|
22
20
|
name() {
|
|
@@ -30,7 +28,12 @@ var MbxQualityMenu = class extends MenuElement {
|
|
|
30
28
|
const tick = () => {
|
|
31
29
|
this.render();
|
|
32
30
|
};
|
|
31
|
+
const clock = () => {
|
|
32
|
+
if (this.playingName() !== this.playing) this.render();
|
|
33
|
+
};
|
|
34
|
+
player.video.addEventListener("timeupdate", clock);
|
|
33
35
|
const offs = [
|
|
36
|
+
() => player.video.removeEventListener("timeupdate", clock),
|
|
34
37
|
engine.on("tracks:changed", tick),
|
|
35
38
|
engine.on("quality:constraints-unsatisfiable", tick),
|
|
36
39
|
engine.on("quality:pin-unsatisfiable", tick)
|
|
@@ -48,8 +51,12 @@ var MbxQualityMenu = class extends MenuElement {
|
|
|
48
51
|
return;
|
|
49
52
|
}
|
|
50
53
|
const quality = engine.quality;
|
|
51
|
-
|
|
52
|
-
|
|
54
|
+
this.playing = this.playingName();
|
|
55
|
+
const items = [[
|
|
56
|
+
AUTO,
|
|
57
|
+
this.getAttribute("label-auto") ?? "Auto",
|
|
58
|
+
this.playing
|
|
59
|
+
], ...qualityNames(quality.selectable)];
|
|
53
60
|
this.menu.fill([{
|
|
54
61
|
name: "rendition",
|
|
55
62
|
items,
|
|
@@ -60,7 +67,14 @@ var MbxQualityMenu = class extends MenuElement {
|
|
|
60
67
|
this.render();
|
|
61
68
|
}
|
|
62
69
|
}]);
|
|
63
|
-
this.hidden =
|
|
70
|
+
this.hidden = items.length === 1;
|
|
71
|
+
}
|
|
72
|
+
/** The name of the rendition that plays, under Auto only: a pin names itself by its tick. */
|
|
73
|
+
playingName() {
|
|
74
|
+
const quality = this.engine?.quality;
|
|
75
|
+
if (quality === void 0 || quality.pinned !== null) return void 0;
|
|
76
|
+
const id = quality.playing?.id;
|
|
77
|
+
return qualityLabels(quality.selectable).find(([candidate]) => candidate === id)?.[1];
|
|
64
78
|
}
|
|
65
79
|
};
|
|
66
80
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quality-menu.js","names":[],"sources":["../../src/elements/quality-menu.ts"],"sourcesContent":["/**\n * <mbx-quality-menu>: the pin over `engine.quality`, where \"auto\" means\n * none. Hidden without renditions, and for a native session. The name\n * comes from `label`, the word for no pin from `label-auto`.
|
|
1
|
+
{"version":3,"file":"quality-menu.js","names":[],"sources":["../../src/elements/quality-menu.ts"],"sourcesContent":["/**\n * <mbx-quality-menu>: the pin over `engine.quality`, where \"auto\" means\n * none. Hidden without renditions, and for a native session. The name\n * comes from `label`, the word for no pin from `label-auto`. It offers\n * `engine.quality.selectable`, labelled by `qualityNames`. Under Auto, the\n * Auto row names what plays, in its detail.\n */\nimport type { Mattebox } from 'mattebox';\nimport { qualityLabels, qualityNames } from '../controls/quality-names.js';\nimport type { PlayerHost } from '../host.js';\nimport { MenuElement, single } from './menu-element.js';\nimport { show } from './shared.js';\n\nconst AUTO = 'auto';\n\nexport class MbxQualityMenu extends MenuElement {\n static get observedAttributes(): readonly string[] {\n return ['label', 'label-auto', 'label-back'];\n }\n\n declare private engine: Mattebox | null;\n /** The name of what plays, as the Auto row last showed it. */\n declare private playing: string | undefined;\n\n constructor() {\n super(...single('quality'));\n this.engine = null;\n this.playing = undefined;\n show(this.slots, 'default');\n }\n\n protected override name(): string {\n return 'Quality';\n }\n\n protected override attach(player: PlayerHost): void {\n this.follow(player, (engine) => {\n this.engine = engine;\n this.render();\n if (engine === null) return undefined;\n const tick = (): void => {\n this.render();\n };\n // What plays changes as the playhead reaches another rendition's\n // segments, and no event says so: read it on the clock, draw on a change.\n const clock = (): void => {\n if (this.playingName() !== this.playing) this.render();\n };\n player.video.addEventListener('timeupdate', clock);\n const offs = [\n () => player.video.removeEventListener('timeupdate', clock),\n engine.on('tracks:changed', tick),\n engine.on('quality:constraints-unsatisfiable', tick),\n engine.on('quality:pin-unsatisfiable', tick),\n ];\n return () => {\n for (const off of offs) off();\n };\n });\n }\n\n protected override render(): void {\n super.render();\n const engine = this.engine;\n if (engine === null) {\n this.hidden = true;\n return;\n }\n const quality = engine.quality;\n this.playing = this.playingName();\n const items: Array<readonly [string, string, (string | undefined)?]> = [\n [AUTO, this.getAttribute('label-auto') ?? 'Auto', this.playing],\n ...qualityNames(quality.selectable),\n ];\n this.menu.fill([\n {\n name: 'rendition',\n items,\n value: quality.pinned ?? AUTO,\n onSelect: (value) => {\n if (value === AUTO) quality.auto();\n else quality.pin(value);\n this.render();\n },\n },\n ]);\n this.hidden = items.length === 1;\n }\n\n /** The name of the rendition that plays, under Auto only: a pin names itself by its tick. */\n private playingName(): string | undefined {\n const quality = this.engine?.quality;\n if (quality === undefined || quality.pinned !== null) return undefined;\n // Every label, twins too: what plays may be a twin the menu shows once.\n const id = quality.playing?.id;\n return qualityLabels(quality.selectable).find(([candidate]) => candidate === id)?.[1];\n }\n}\n"],"mappings":";;;;AAaA,MAAM,OAAO;AAEb,IAAa,iBAAb,cAAoC,YAAY;CAC9C,WAAW,qBAAwC;EACjD,OAAO;GAAC;GAAS;GAAc;EAAY;CAC7C;CAMA,cAAc;EACZ,MAAM,GAAG,OAAO,SAAS,CAAC;EAC1B,KAAK,SAAS;EACd,KAAK,UAAU,KAAA;EACf,KAAK,KAAK,OAAO,SAAS;CAC5B;CAEA,OAAkC;EAChC,OAAO;CACT;CAEA,OAA0B,QAA0B;EAClD,KAAK,OAAO,SAAS,WAAW;GAC9B,KAAK,SAAS;GACd,KAAK,OAAO;GACZ,IAAI,WAAW,MAAM,OAAO,KAAA;GAC5B,MAAM,aAAmB;IACvB,KAAK,OAAO;GACd;GAGA,MAAM,cAAoB;IACxB,IAAI,KAAK,YAAY,MAAM,KAAK,SAAS,KAAK,OAAO;GACvD;GACA,OAAO,MAAM,iBAAiB,cAAc,KAAK;GACjD,MAAM,OAAO;UACL,OAAO,MAAM,oBAAoB,cAAc,KAAK;IAC1D,OAAO,GAAG,kBAAkB,IAAI;IAChC,OAAO,GAAG,qCAAqC,IAAI;IACnD,OAAO,GAAG,6BAA6B,IAAI;GAC7C;GACA,aAAa;IACX,KAAK,MAAM,OAAO,MAAM,IAAI;GAC9B;EACF,CAAC;CACH;CAEA,SAAkC;EAChC,MAAM,OAAO;EACb,MAAM,SAAS,KAAK;EACpB,IAAI,WAAW,MAAM;GACnB,KAAK,SAAS;GACd;EACF;EACA,MAAM,UAAU,OAAO;EACvB,KAAK,UAAU,KAAK,YAAY;EAChC,MAAM,QAAiE,CACrE;GAAC;GAAM,KAAK,aAAa,YAAY,KAAK;GAAQ,KAAK;EAAO,GAC9D,GAAG,aAAa,QAAQ,UAAU,CACpC;EACA,KAAK,KAAK,KAAK,CACb;GACE,MAAM;GACN;GACA,OAAO,QAAQ,UAAU;GACzB,WAAW,UAAU;IACnB,IAAI,UAAU,MAAM,QAAQ,KAAK;SAC5B,QAAQ,IAAI,KAAK;IACtB,KAAK,OAAO;GACd;EACF,CACF,CAAC;EACD,KAAK,SAAS,MAAM,WAAW;CACjC;;CAGA,cAA0C;EACxC,MAAM,UAAU,KAAK,QAAQ;EAC7B,IAAI,YAAY,KAAA,KAAa,QAAQ,WAAW,MAAM,OAAO,KAAA;EAE7D,MAAM,KAAK,QAAQ,SAAS;EAC5B,OAAO,cAAc,QAAQ,UAAU,CAAC,CAAC,MAAM,CAAC,eAAe,cAAc,EAAE,CAAC,GAAG;CACrF;AACF"}
|
|
@@ -19,7 +19,7 @@ import { optional } from "../controls/session.js";
|
|
|
19
19
|
* `rate` part shows the rate, "8×". The name comes from `label`,
|
|
20
20
|
* "Fast forward" or "Rewind".
|
|
21
21
|
*/
|
|
22
|
-
const STYLE_CSS = "[part~=button]{position:relative}[part~=rate]{font-variant-numeric:tabular-nums;font-size
|
|
22
|
+
const STYLE_CSS = "[part~=button]{position:relative}[part~=rate]{font-variant-numeric:tabular-nums;font-size:.625em;font-weight:700;line-height:1;position:absolute;bottom:.2em;right:0}[part~=rate][hidden]{display:none}";
|
|
23
23
|
const RATES = [
|
|
24
24
|
4,
|
|
25
25
|
8,
|
|
@@ -61,6 +61,8 @@ export declare class MbxSeekBar extends Component {
|
|
|
61
61
|
static get observedAttributes(): readonly string[];
|
|
62
62
|
private readonly bar;
|
|
63
63
|
private readonly buffered;
|
|
64
|
+
/** The ranges the page marked blocked, drawn as a broken line: they never play. */
|
|
65
|
+
private readonly blocked;
|
|
64
66
|
private readonly hover;
|
|
65
67
|
private readonly edge;
|
|
66
68
|
private readonly preview;
|
|
@@ -147,7 +149,10 @@ export declare class MbxSeekBar extends Component {
|
|
|
147
149
|
* position in the video, so the preview shows none meanwhile.
|
|
148
150
|
*/
|
|
149
151
|
private paintPicture;
|
|
150
|
-
|
|
152
|
+
/** The ranges the page marked blocked. */
|
|
153
|
+
private blockedRanges;
|
|
154
|
+
/** One child of `layer` per range, each named `part`, placed along the track. */
|
|
155
|
+
private paintRanges;
|
|
151
156
|
/** Whether a live window is wide enough to be worth a bar. */
|
|
152
157
|
private worthSeeking;
|
|
153
158
|
/** The hover marker and the preview follow the pointer, clamped to the bar. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"seek-bar.d.ts","sourceRoot":"","sources":["../../src/elements/seek-bar.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AAYH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"seek-bar.d.ts","sourceRoot":"","sources":["../../src/elements/seek-bar.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AAYH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAoE3C,qBAAa,UAAW,SAAQ,SAAS;IACvC,MAAM,KAAK,kBAAkB,IAAI,SAAS,MAAM,EAAE,CAYjD;IAED,iBAAyB,GAAG,CAAS;IACrC,iBAAyB,QAAQ,CAAc;IAC/C,mFAAmF;IACnF,iBAAyB,OAAO,CAAc;IAC9C,iBAAyB,KAAK,CAAc;IAC5C,iBAAyB,IAAI,CAAc;IAC3C,iBAAyB,OAAO,CAAc;IAC9C,iBAAyB,KAAK,CAAc;IAC5C,iBAAyB,IAAI,CAAc;IAC3C,iBAAyB,IAAI,CAAc;IAC3C,iBAAyB,OAAO,CAAc;IAC9C,iBAAyB,WAAW,CAAoB;IACxD,QAAgB,IAAI,CAAO;IAC3B,wEAAwE;IACxE,QAAgB,OAAO,CAAgB;IACvC,qFAAqF;IACrF,QAAgB,MAAM,CAAU;IAChC,kGAAkG;IAClG,QAAgB,KAAK,CAAS;IAC9B,kFAAkF;IAClF,QAAgB,MAAM,CAAgB;IACtC,QAAgB,WAAW,CAAS;IACpC,iEAAiE;IACjE,QAAgB,KAAK,CAAS;IAC9B,QAAgB,QAAQ,CAAS;IACjC,QAAgB,KAAK,CAAS;IAC9B,QAAgB,KAAK,CAAO;IAC5B,gFAAgF;IAChF,QAAgB,OAAO,CAAS;IAChC,QAAgB,IAAI,CAAY;IAChC,QAAgB,OAAO,CAAgB;IACvC,QAAgB,KAAK,CAAS;;IAoErB,iBAAiB,IAAI,IAAI;IAKlC,OAAO,CAAC,MAAM;IAId,mGAAmG;IACnG,OAAO,CAAC,SAAS;IAYjB,+EAA+E;IAC/E,OAAO,CAAC,aAAa;IAerB,4CAA4C;IAC5C,OAAO,CAAC,GAAG;IAeX,wCAAwC;IACxC,OAAO,CAAC,KAAK;IAKb,4FAA4F;IAC5F,OAAO,CAAC,SAAS;IAoBjB;;;;OAIG;IACH,OAAO,CAAC,OAAO;IAMf,uEAAuE;IACvE,OAAO,CAAC,MAAM;IAoBd,6EAA6E;IAC7E,OAAO,CAAC,UAAU;IAIlB,+CAA+C;IAC/C,OAAO,CAAC,OAAO;IAKf;;;;OAIG;IACH,OAAO,CAAC,MAAM;IAQd;;;;OAIG;IACH,OAAO,CAAC,GAAG;IAYX,4CAA4C;IAC5C,OAAO,CAAC,MAAM;IAOd,6DAA6D;IAC7D,OAAO,CAAC,MAAM;IAKd,OAAO,CAAC,UAAU;IAQlB,OAAO,CAAC,KAAK;IA2Bb,OAAO,CAAC,KAAK;IAQb,sEAAsE;IACtE,OAAO,CAAC,YAAY;IAQpB,0GAA0G;IAC1G,OAAO,CAAC,OAAO;IASf,4DAA4D;IAC5D,OAAO,CAAC,SAAS;IAajB;;;;;;OAMG;IACH,OAAO,CAAC,YAAY;IA6CpB,0CAA0C;IAC1C,OAAO,CAAC,aAAa;IAIrB,iFAAiF;IACjF,OAAO,CAAC,WAAW;IAenB,8DAA8D;IAC9D,OAAO,CAAC,YAAY;IAOpB,+EAA+E;IAC/E,OAAO,CAAC,KAAK;IASb,kFAAkF;IAClF,OAAO,CAAC,SAAS;IAyBjB,OAAO,CAAC,KAAK;cAOM,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;cAqChC,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;cAWhC,MAAM,IAAI,IAAI;CA0BlC"}
|
|
@@ -2,13 +2,13 @@ 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 { EMPTY, at, clip, fraction } from "../controls/ranges.js";
|
|
5
|
+
import { EMPTY, at, clip, fraction, spans } from "../controls/ranges.js";
|
|
6
6
|
import { format } from "../controls/time.js";
|
|
7
7
|
import { bufferGoal, live, optional, span, wall } from "../controls/session.js";
|
|
8
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:
|
|
11
|
+
const STYLE_CSS = ":host,[part~=slider]{flex:1}[part~=thumb]{width:1em;height:1em;margin:-.5em 0 0 -.5em;box-shadow:0 1px 3px #0006}[part~=buffered]{position:absolute;top:0;bottom:0;left:0;right:0}[part~=blocked]{pointer-events:none;position:absolute;top:0;bottom:0;left:0;right:0}[part~=blocked-range]{background:var(--mbx-blocked,#000000bf);position:absolute;top:0;bottom:0}[part~=buffered-range]{background:#ffffff4d;position:absolute;top:0;bottom:0}[part~=hover]{background:var(--mbx-text);width:.125em;margin-left:-1px;position:absolute;top:0;bottom:0}[part~=edge]{background:var(--mbx-live);width:.125em;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:.3077em;padding:.1538em;font-size:.8125em;display:flex;position:absolute;bottom:100%;transform:translate(-50%)}[part~=preview]>:not([hidden])~:not([hidden]){margin-top:.125em}[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 .3077em}[part~=preview-title]{text-overflow:ellipsis;max-width:18.4615em;padding:0 .3077em;overflow:hidden}[hidden]{display:none}";
|
|
12
12
|
const STEP = 5;
|
|
13
13
|
/** Under `key-mode="preview"`, a target seeks this long after the last key. */
|
|
14
14
|
const KEY_COMMIT_MS = 1e3;
|
|
@@ -26,8 +26,8 @@ const CANCEL_KEYS = [
|
|
|
26
26
|
];
|
|
27
27
|
const PAGE = 30;
|
|
28
28
|
const LIVE_WINDOW = 3;
|
|
29
|
-
/** What the tile scales down to when the page sets no `--mbx-preview-width`. */
|
|
30
|
-
const PREVIEW_WIDTH =
|
|
29
|
+
/** What the tile scales down to, in em, when the page sets no `--mbx-preview-width`. */
|
|
30
|
+
const PREVIEW_WIDTH = 10;
|
|
31
31
|
/** The buffer goal assumed for a session that reports none. */
|
|
32
32
|
const BUFFER_GOAL = 30;
|
|
33
33
|
/** The gap cut at a chapter boundary, in pixels. */
|
|
@@ -46,13 +46,14 @@ function percent(part) {
|
|
|
46
46
|
return `${part * 100}%`;
|
|
47
47
|
}
|
|
48
48
|
/**
|
|
49
|
-
* A mask that cuts a gap at each boundary
|
|
50
|
-
*
|
|
49
|
+
* A mask that cuts a gap at each chapter boundary, as stops along the
|
|
50
|
+
* track: opaque up to a boundary, clear for the gap, opaque after.
|
|
51
51
|
*/
|
|
52
|
-
function gaps(
|
|
52
|
+
function gaps(boundaries, span) {
|
|
53
|
+
if (boundaries.length === 0) return "";
|
|
53
54
|
const stops = ["#000 0"];
|
|
54
|
-
for (const
|
|
55
|
-
const at = percent(fraction(
|
|
55
|
+
for (const time of boundaries) {
|
|
56
|
+
const at = percent(fraction(time, span));
|
|
56
57
|
const before = `calc(${at} - ${GAP / 2}px)`;
|
|
57
58
|
const after = `calc(${at} + ${GAP / 2}px)`;
|
|
58
59
|
stops.push(`#000 ${before}`, `transparent ${before}`, `transparent ${after}`, `#000 ${after}`);
|
|
@@ -66,6 +67,7 @@ var MbxSeekBar = class extends Component {
|
|
|
66
67
|
"label",
|
|
67
68
|
"label-of",
|
|
68
69
|
"label-behind",
|
|
70
|
+
"label-blocked",
|
|
69
71
|
"live-window",
|
|
70
72
|
"chapters",
|
|
71
73
|
"scrub",
|
|
@@ -104,12 +106,13 @@ var MbxSeekBar = class extends Component {
|
|
|
104
106
|
}
|
|
105
107
|
});
|
|
106
108
|
this.buffered = el("div", "buffered");
|
|
109
|
+
this.blocked = el("div", "blocked");
|
|
107
110
|
this.hover = el("div", "hover");
|
|
108
111
|
this.edge = el("div", "edge");
|
|
109
112
|
this.hover.hidden = true;
|
|
110
113
|
this.edge.hidden = true;
|
|
111
114
|
this.bar.track.prepend(this.buffered);
|
|
112
|
-
this.bar.track.append(this.hover, this.edge);
|
|
115
|
+
this.bar.track.append(this.blocked, this.hover, this.edge);
|
|
113
116
|
this.preview = el("div", "preview");
|
|
114
117
|
this.image = el("div", "preview-image");
|
|
115
118
|
this.tile = el("div", "preview-tile");
|
|
@@ -151,7 +154,7 @@ var MbxSeekBar = class extends Component {
|
|
|
151
154
|
}
|
|
152
155
|
/** The gaps at the chapter boundaries, on every layer of the track at once. */
|
|
153
156
|
paintChapters() {
|
|
154
|
-
const mask = this.chaptered("divided") && this.list.length > 1 ?
|
|
157
|
+
const mask = gaps(this.chaptered("divided") && this.list.length > 1 ? this.list.slice(1).map((chapter) => chapter.start) : [], this.range);
|
|
155
158
|
const key = `${mask}|${this.range.start}|${this.range.end}`;
|
|
156
159
|
if (key === this.divided) return;
|
|
157
160
|
this.divided = key;
|
|
@@ -308,7 +311,8 @@ var MbxSeekBar = class extends Component {
|
|
|
308
311
|
/** The width the page asked for through the token, or the default. */
|
|
309
312
|
previewWidth() {
|
|
310
313
|
const set = Number.parseFloat(getComputedStyle(this.preview).getPropertyValue("--mbx-preview-width"));
|
|
311
|
-
|
|
314
|
+
if (Number.isFinite(set) && set > 0) return set;
|
|
315
|
+
return PREVIEW_WIDTH * (Number.parseFloat(getComputedStyle(this).fontSize) || 16);
|
|
312
316
|
}
|
|
313
317
|
/** The preview's picture sources from `preview`, in order of preference: frames then tiles by default. */
|
|
314
318
|
sources() {
|
|
@@ -372,16 +376,17 @@ var MbxSeekBar = class extends Component {
|
|
|
372
376
|
}, () => void 0);
|
|
373
377
|
if (this.frameCanvas.hidden) this.paintTile(tile);
|
|
374
378
|
}
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
while (
|
|
379
|
+
/** The ranges the page marked blocked. */
|
|
380
|
+
blockedRanges() {
|
|
381
|
+
return (this.player?.markers.list ?? []).filter((marker) => marker.kind === "blocked");
|
|
382
|
+
}
|
|
383
|
+
/** One child of `layer` per range, each named `part`, placed along the track. */
|
|
384
|
+
paintRanges(layer, ranges, part) {
|
|
385
|
+
const parts = clip(ranges, this.range);
|
|
386
|
+
while (layer.childElementCount > parts.length) layer.lastElementChild?.remove();
|
|
387
|
+
while (layer.childElementCount < parts.length) layer.append(el("div", part));
|
|
383
388
|
let i = 0;
|
|
384
|
-
for (const child of
|
|
389
|
+
for (const child of layer.children) {
|
|
385
390
|
const part = parts[i];
|
|
386
391
|
i += 1;
|
|
387
392
|
if (part === void 0) break;
|
|
@@ -414,9 +419,14 @@ var MbxSeekBar = class extends Component {
|
|
|
414
419
|
const when = at(part, this.range);
|
|
415
420
|
this.time.textContent = this.label(when);
|
|
416
421
|
const chapter = this.chaptered("titles") ? this.list[chapterAt(this.list, when)] : void 0;
|
|
417
|
-
this.
|
|
418
|
-
this.
|
|
419
|
-
this.
|
|
422
|
+
const blocked = this.player?.markers.within(when).find((marker) => marker.kind === "blocked");
|
|
423
|
+
const title = blocked ? blocked.label ?? this.getAttribute("label-blocked") ?? "Not available" : chapter?.title ?? "";
|
|
424
|
+
this.caption.hidden = title === "";
|
|
425
|
+
this.caption.textContent = title;
|
|
426
|
+
if (blocked) {
|
|
427
|
+
this.image.hidden = true;
|
|
428
|
+
this.frameCanvas.hidden = true;
|
|
429
|
+
} else this.paintPicture(when);
|
|
420
430
|
const whole = this.bar.root.getBoundingClientRect();
|
|
421
431
|
const half = this.preview.offsetWidth / 2;
|
|
422
432
|
const x = rect.left - whole.left + part * rect.width;
|
|
@@ -433,6 +443,7 @@ var MbxSeekBar = class extends Component {
|
|
|
433
443
|
};
|
|
434
444
|
this.listen(player.video, EVENTS, tick);
|
|
435
445
|
this.keep(followChapters(player, tick));
|
|
446
|
+
this.listen(player, ["markerschange"], tick);
|
|
436
447
|
this.listen(player, ["sourcechange"], () => {
|
|
437
448
|
this.drag = "none";
|
|
438
449
|
this.stopAiming();
|
|
@@ -475,7 +486,8 @@ var MbxSeekBar = class extends Component {
|
|
|
475
486
|
this.list = chapters(video, engine);
|
|
476
487
|
this.bar.label(this.getAttribute("label") ?? "Seek");
|
|
477
488
|
this.bar.range(this.range.start, this.range.end);
|
|
478
|
-
this.
|
|
489
|
+
this.paintRanges(this.buffered, spans(video.buffered), "buffered-range");
|
|
490
|
+
this.paintRanges(this.blocked, this.blockedRanges(), "blocked-range");
|
|
479
491
|
this.paintChapters();
|
|
480
492
|
this.edge.hidden = !on;
|
|
481
493
|
if (api !== void 0 && api.edge !== null) this.edge.style.left = percent(fraction(api.edge, this.range));
|