@mattebox/player 0.9.1 → 0.11.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/announcer.d.ts +7 -0
- package/dist/announcer.d.ts.map +1 -0
- package/dist/announcer.js +44 -0
- package/dist/announcer.js.map +1 -0
- package/dist/cdn/mattebox-player.min.js +3 -3
- package/dist/controls/icons.d.ts +1 -1
- package/dist/controls/icons.d.ts.map +1 -1
- package/dist/controls/icons.js +1 -0
- package/dist/controls/icons.js.map +1 -1
- package/dist/controls/native-tracks.d.ts +8 -7
- package/dist/controls/native-tracks.d.ts.map +1 -1
- package/dist/controls/native-tracks.js.map +1 -1
- package/dist/element.d.ts +63 -1
- package/dist/element.d.ts.map +1 -1
- package/dist/element.js +211 -12
- package/dist/element.js.map +1 -1
- package/dist/elements/audio-menu.js +1 -1
- package/dist/elements/control-bar.d.ts.map +1 -1
- package/dist/elements/control-bar.js +8 -6
- package/dist/elements/control-bar.js.map +1 -1
- package/dist/elements/drm-badge.js +2 -2
- package/dist/elements/error-screen.d.ts.map +1 -1
- package/dist/elements/error-screen.js +1 -3
- package/dist/elements/error-screen.js.map +1 -1
- package/dist/elements/menu-element.js +1 -1
- package/dist/elements/play-button.d.ts.map +1 -1
- package/dist/elements/play-button.js +7 -9
- package/dist/elements/play-button.js.map +1 -1
- package/dist/elements/seek-bar.js +1 -1
- package/dist/elements/shared.d.ts +18 -0
- package/dist/elements/shared.d.ts.map +1 -1
- package/dist/elements/shared.js +16 -9
- package/dist/elements/shared.js.map +1 -1
- package/dist/elements/skip-button.js +1 -1
- package/dist/elements/start-button.d.ts.map +1 -1
- package/dist/elements/start-button.js +3 -3
- package/dist/elements/start-button.js.map +1 -1
- package/dist/elements/subtitles-menu.js +1 -1
- package/dist/elements/title.d.ts.map +1 -1
- package/dist/elements/title.js +5 -2
- package/dist/elements/title.js.map +1 -1
- package/dist/elements/video-menu.d.ts +23 -0
- package/dist/elements/video-menu.d.ts.map +1 -0
- package/dist/elements/video-menu.js +146 -0
- package/dist/elements/video-menu.js.map +1 -0
- package/dist/entries/video-menu.d.ts +5 -0
- package/dist/entries/video-menu.d.ts.map +1 -0
- package/dist/entries/video-menu.js +9 -0
- package/dist/entries/video-menu.js.map +1 -0
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.153.0 → _@oxc-project_runtime@0.154.0}/helpers/esm/asyncToGenerator.js +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.153.0 → _@oxc-project_runtime@0.154.0}/helpers/esm/defineProperty.js +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.153.0 → _@oxc-project_runtime@0.154.0}/helpers/esm/objectSpread2.js +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.153.0 → _@oxc-project_runtime@0.154.0}/helpers/esm/toPrimitive.js +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.153.0 → _@oxc-project_runtime@0.154.0}/helpers/esm/toPropertyKey.js +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.153.0 → _@oxc-project_runtime@0.154.0}/helpers/esm/typeof.js +1 -1
- package/dist/es2015/announcer.js +43 -0
- package/dist/es2015/controls/chapters.js +1 -1
- package/dist/es2015/controls/icons.js +1 -0
- package/dist/es2015/controls/menu.js +1 -1
- package/dist/es2015/element.js +258 -57
- package/dist/es2015/elements/audio-menu.js +1 -1
- package/dist/es2015/elements/control-bar.js +8 -6
- package/dist/es2015/elements/drm-badge.js +2 -2
- package/dist/es2015/elements/error-screen.js +2 -3
- package/dist/es2015/elements/menu-element.js +1 -1
- package/dist/es2015/elements/play-button.js +8 -10
- package/dist/es2015/elements/seek-bar.js +1 -1
- package/dist/es2015/elements/shared.js +16 -9
- package/dist/es2015/elements/skip-button.js +1 -1
- package/dist/es2015/elements/start-button.js +3 -3
- package/dist/es2015/elements/subtitles-menu.js +1 -1
- package/dist/es2015/elements/title.js +5 -2
- package/dist/es2015/elements/video-menu.js +152 -0
- package/dist/es2015/entries/video-menu.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/es2015/video-sources.js +128 -0
- package/dist/host.d.ts +10 -1
- package/dist/host.d.ts.map +1 -1
- 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 +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/dist/video-sources.d.ts +48 -0
- package/dist/video-sources.d.ts.map +1 -0
- package/dist/video-sources.js +134 -0
- package/dist/video-sources.js.map +1 -0
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/elements/shared.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/elements/shared.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAI7C,eAAO,MAAM,YAAY,QAAmB,CAAC;AAE7C,+EAA+E;AAC/E,eAAO,MAAM,YAAY,QAAmB,CAAC;AAE7C,iEAAiE;AACjE,wBAAgB,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAI5E;AAED,gGAAgG;AAChG,eAAO,MAAM,UAAU,QAAgC,CAAC;AAExD,2GAA2G;AAC3G,wBAAgB,OAAO,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI,CAI/C;AAED,kDAAkD;AAClD,wBAAgB,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,gBAAgB,CAIpD;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,MAAM,EACxC,MAAM,EAAE,SAAS,CAAC,EAAE,EACpB,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,aAAa,GACpC,MAAM,CAAC,CAAC,EAAE,eAAe,CAAC,CAU5B;AAED,wBAAgB,IAAI,CAAC,CAAC,SAAS,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC,EAAE,eAAe,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI,CAExF;AAED;;;;;GAKG;AACH,eAAO,MAAM,IAAI,qCAAsC,CAAC;AAExD,iGAAiG;AACjG,wBAAgB,WAAW,CAAC,MAAM,EAAE,UAAU,EAAE,KAAK,GAAE,SAAS,MAAM,EAAS,GAAG,OAAO,CAMxF"}
|
package/dist/elements/shared.js
CHANGED
|
@@ -1,12 +1,4 @@
|
|
|
1
1
|
//#region src/elements/shared.ts
|
|
2
|
-
/**
|
|
3
|
-
* The style every button control shares. Each element carries its own
|
|
4
|
-
* copy in its shadow root, so the rules are short and the tokens come
|
|
5
|
-
* through the `--mbx-*` custom properties the player sets, which inherit
|
|
6
|
-
* through light DOM into every control.
|
|
7
|
-
*
|
|
8
|
-
* Nothing carries `!important`: a page's `::part()` rule must win.
|
|
9
|
-
*/
|
|
10
2
|
const BUTTON_STYLE_CSS = ":host{display:inline-flex}:host([hidden]){display:none}[part~=button]{width:2.5em;height:2.5em;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;position:relative}[part~=button][aria-label]:after{content:attr(aria-label);display:var(--mbx-tooltip,block);background:var(--mbx-surface);border-radius:var(--mbx-radius);white-space:nowrap;pointer-events:none;opacity:0;margin-bottom:.4615em;padding:.3077em .6154em;font-size:.8125em;transition:opacity .1s;position:absolute;bottom:100%;left:50%;transform:translate(-50%)}[part~=button][aria-label]:focus:after{opacity:1;transition-delay:.4s}[part~=button][aria-label]:focus:not(:focus-visible):after{opacity:0;transition-delay:0s}@media (hover:hover){[part~=button][aria-label]:hover:after{opacity:1;transition-delay:.4s}}:host(:last-child) [part~=button][aria-label]:after{left:auto;right:0;transform:none}[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
3
|
const SLIDER_STYLE_CSS = ":host{display:block}:host([hidden]){display:none}[part~=slider]{border-radius:var(--mbx-radius);cursor:pointer;touch-action:none;height:2.5em;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:.5em;right:.5em}[part~=track]{background:#ffffff59;border-radius:2px;height:.25em;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:.75em;height:.75em;margin:-.375em 0 0 -.375em;position:absolute;top:50%}";
|
|
12
4
|
const BUTTON_STYLE = BUTTON_STYLE_CSS;
|
|
@@ -49,7 +41,22 @@ function iconSlots(states, fallback) {
|
|
|
49
41
|
function show(slots, state) {
|
|
50
42
|
for (const key of Object.keys(slots)) slots[key].hidden = key !== state;
|
|
51
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* The attributes the player carries while it holds the video in another
|
|
46
|
+
* state than the one shown: `scrubbing` through a drag, `switching` through
|
|
47
|
+
* the load of `switchSource` or a version. Each holds the state from
|
|
48
|
+
* before, `playing` or `paused`.
|
|
49
|
+
*/
|
|
50
|
+
const HELD = ["scrubbing", "switching"];
|
|
51
|
+
/** Whether the controls show the video as paused: the held state, if one of `names` holds it. */
|
|
52
|
+
function shownPaused(player, names = HELD) {
|
|
53
|
+
for (const name of names) {
|
|
54
|
+
const held = player.getAttribute(name);
|
|
55
|
+
if (held !== null) return held === "paused";
|
|
56
|
+
}
|
|
57
|
+
return player.video.paused;
|
|
58
|
+
}
|
|
52
59
|
//#endregion
|
|
53
|
-
export { BUTTON_STYLE, MENU_STYLE, SLIDER_STYLE, iconSlots, number, seekRow, show, style };
|
|
60
|
+
export { BUTTON_STYLE, HELD, MENU_STYLE, SLIDER_STYLE, iconSlots, number, seekRow, show, shownPaused, style };
|
|
54
61
|
|
|
55
62
|
//# sourceMappingURL=shared.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.js","names":[],"sources":["../../src/elements/shared.ts"],"sourcesContent":["/**\n * The style every button control shares. Each element carries its own\n * copy in its shadow root, so the rules are short and the tokens come\n * through the `--mbx-*` custom properties the player sets, which inherit\n * through light DOM into every control.\n *\n * Nothing carries `!important`: a page's `::part()` rule must win.\n */\nimport BUTTON_STYLE_CSS from './button.css?inline';\nimport MENU_STYLE_CSS from './menu.css?inline';\nimport SLIDER_STYLE_CSS from './slider.css?inline';\nexport const BUTTON_STYLE = BUTTON_STYLE_CSS;\n\n/** The style of a slider: the rail, the track with its fill, and the thumb. */\nexport const SLIDER_STYLE = SLIDER_STYLE_CSS;\n\n/** A non-negative number from an attribute, else the default. */\nexport function number(node: Element, name: string, fallback: number): number {\n const raw = node.getAttribute(name);\n const value = raw === null ? Number.NaN : Number(raw);\n return Number.isFinite(value) && value >= 0 ? value : fallback;\n}\n\n/** The style of a menu: the button from BUTTON_STYLE, and the popup above it with its items. */\nexport const MENU_STYLE = BUTTON_STYLE + MENU_STYLE_CSS;\n\n/** Puts a control in the bar's seek row when it is in a bar, unless the page wrote a `slot` of its own. */\nexport function seekRow(node: HTMLElement): void {\n if (node.parentElement?.localName === 'mbx-control-bar' && !node.hasAttribute('slot')) {\n node.slot = 'seek';\n }\n}\n\n/** A `<style>` with `text`, for a shadow root. */\nexport function style(text: string): HTMLStyleElement {\n const node = document.createElement('style');\n node.textContent = text;\n return node;\n}\n\n/**\n * A named slot per state with the default glyph as its fallback, so a page\n * drops its own SVG into `slot=\"icon-<state>\"` and the button keeps the\n * name. Returns the slots by state; `show` hides all but one.\n */\nexport function iconSlots<S extends string>(\n states: readonly S[],\n fallback: (state: S) => SVGSVGElement,\n): Record<S, HTMLSlotElement> {\n const out = {} as Record<S, HTMLSlotElement>;\n for (const state of states) {\n const slot = document.createElement('slot');\n slot.name = `icon-${state}`;\n slot.append(fallback(state));\n slot.hidden = true;\n out[state] = slot;\n }\n return out;\n}\n\nexport function show<S extends string>(slots: Record<S, HTMLSlotElement>, state: S): void {\n for (const key of Object.keys(slots) as S[]) slots[key].hidden = key !== state;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"shared.js","names":[],"sources":["../../src/elements/shared.ts"],"sourcesContent":["/**\n * The style every button control shares. Each element carries its own\n * copy in its shadow root, so the rules are short and the tokens come\n * through the `--mbx-*` custom properties the player sets, which inherit\n * through light DOM into every control.\n *\n * Nothing carries `!important`: a page's `::part()` rule must win.\n */\nimport type { PlayerHost } from '../host.js';\nimport BUTTON_STYLE_CSS from './button.css?inline';\nimport MENU_STYLE_CSS from './menu.css?inline';\nimport SLIDER_STYLE_CSS from './slider.css?inline';\nexport const BUTTON_STYLE = BUTTON_STYLE_CSS;\n\n/** The style of a slider: the rail, the track with its fill, and the thumb. */\nexport const SLIDER_STYLE = SLIDER_STYLE_CSS;\n\n/** A non-negative number from an attribute, else the default. */\nexport function number(node: Element, name: string, fallback: number): number {\n const raw = node.getAttribute(name);\n const value = raw === null ? Number.NaN : Number(raw);\n return Number.isFinite(value) && value >= 0 ? value : fallback;\n}\n\n/** The style of a menu: the button from BUTTON_STYLE, and the popup above it with its items. */\nexport const MENU_STYLE = BUTTON_STYLE + MENU_STYLE_CSS;\n\n/** Puts a control in the bar's seek row when it is in a bar, unless the page wrote a `slot` of its own. */\nexport function seekRow(node: HTMLElement): void {\n if (node.parentElement?.localName === 'mbx-control-bar' && !node.hasAttribute('slot')) {\n node.slot = 'seek';\n }\n}\n\n/** A `<style>` with `text`, for a shadow root. */\nexport function style(text: string): HTMLStyleElement {\n const node = document.createElement('style');\n node.textContent = text;\n return node;\n}\n\n/**\n * A named slot per state with the default glyph as its fallback, so a page\n * drops its own SVG into `slot=\"icon-<state>\"` and the button keeps the\n * name. Returns the slots by state; `show` hides all but one.\n */\nexport function iconSlots<S extends string>(\n states: readonly S[],\n fallback: (state: S) => SVGSVGElement,\n): Record<S, HTMLSlotElement> {\n const out = {} as Record<S, HTMLSlotElement>;\n for (const state of states) {\n const slot = document.createElement('slot');\n slot.name = `icon-${state}`;\n slot.append(fallback(state));\n slot.hidden = true;\n out[state] = slot;\n }\n return out;\n}\n\nexport function show<S extends string>(slots: Record<S, HTMLSlotElement>, state: S): void {\n for (const key of Object.keys(slots) as S[]) slots[key].hidden = key !== state;\n}\n\n/**\n * The attributes the player carries while it holds the video in another\n * state than the one shown: `scrubbing` through a drag, `switching` through\n * the load of `switchSource` or a version. Each holds the state from\n * before, `playing` or `paused`.\n */\nexport const HELD = ['scrubbing', 'switching'] as const;\n\n/** Whether the controls show the video as paused: the held state, if one of `names` holds it. */\nexport function shownPaused(player: PlayerHost, names: readonly string[] = HELD): boolean {\n for (const name of names) {\n const held = player.getAttribute(name);\n if (held !== null) return held === 'paused';\n }\n return player.video.paused;\n}\n"],"mappings":";AASA,MAAA,mBAAA;AAEA,MAAA,mBAAA;AACA,MAAA,eAAA;;AAGA,MAAA,eAAA;;AAGA,SAAA,OAAA,MAAA,MAAA,UAAA;CACA,MAAA,MAAA,KAAA,aAAA,IAAA;CACA,MAAA,QAAA,QAAA,OAAA,MAAA,OAAA,GAAA;CACA,OAAA,OAAA,SAAA,KAAA,KAAA,SAAA,IAAA,QAAA;AACA;;AAGA,MAAA,aAAA;;AAGA,SAAA,QAAA,MAAA;CACA,IAAA,KAAA,eAAA,cAAA,qBAAA,CAAA,KAAA,aAAA,MAAA,GACA,KAAA,OAAA;AAEA;;AAGA,SAAA,MAAA,MAAA;CACA,MAAA,OAAA,SAAA,cAAA,OAAA;CACA,KAAA,cAAA;CACA,OAAA;AACA;;;;;;AAOA,SAAA,UACA,QACA,UACA;CACA,MAAA,MAAA,CAAA;CACA,KAAA,MAAA,SAAA,QAAA;EACA,MAAA,OAAA,SAAA,cAAA,MAAA;EACA,KAAA,OAAA,QAAA;EACA,KAAA,OAAA,SAAA,KAAA,CAAA;EACA,KAAA,SAAA;EACA,IAAA,SAAA;CACA;CACA,OAAA;AACA;AAEA,SAAA,KAAA,OAAA,OAAA;CACA,KAAA,MAAA,OAAA,OAAA,KAAA,KAAA,GAAA,MAAA,IAAA,CAAA,SAAA,QAAA;AACA;;;;;;;AAQA,MAAA,OAAA,CAAA,aAAA,WAAA;;AAGA,SAAA,YAAA,QAAA,QAAA,MAAA;CACA,KAAA,MAAA,QAAA,OAAA;EACA,MAAA,OAAA,OAAA,aAAA,IAAA;EACA,IAAA,SAAA,MAAA,OAAA,SAAA;CACA;CACA,OAAA,OAAA,MAAA;AACA"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { setChildren } from "../dom.js";
|
|
2
|
+
import { fill } from "../labels.js";
|
|
2
3
|
import { icon } from "../controls/icons.js";
|
|
3
4
|
import { Component } from "./component.js";
|
|
4
5
|
import { BUTTON_STYLE, style } from "./shared.js";
|
|
5
|
-
import { fill } from "../labels.js";
|
|
6
6
|
//#region src/elements/skip-button.ts
|
|
7
7
|
const SECONDS = 10;
|
|
8
8
|
/** The glyph for a skip amount: the set draws 5, 10, 15 and 30, and a plain arrow says the rest. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"start-button.d.ts","sourceRoot":"","sources":["../../src/elements/start-button.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"start-button.d.ts","sourceRoot":"","sources":["../../src/elements/start-button.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAS3C,qBAAa,cAAe,SAAQ,SAAS;IAC3C,MAAM,KAAK,kBAAkB,IAAI,SAAS,MAAM,EAAE,CAEjD;IAED,iBAAyB,MAAM,CAAoB;IACnD,iBAAyB,KAAK,CAAiC;IAC/D,8FAA8F;IAC9F,QAAgB,MAAM,CAAU;IAChC,kFAAkF;IAClF,QAAgB,OAAO,CAAwB;;cAkB5B,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;cAwChC,MAAM,IAAI,IAAI;IAOjC;;;;;;;;;;;;;OAaG;IACH,OAAO,CAAC,GAAG;cAqBQ,MAAM,IAAI,IAAI;CAiBlC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { icon } from "../controls/icons.js";
|
|
2
2
|
import { Component } from "./component.js";
|
|
3
|
-
import { BUTTON_STYLE, iconSlots, show, style } from "./shared.js";
|
|
3
|
+
import { BUTTON_STYLE, HELD, iconSlots, show, shownPaused, style } from "./shared.js";
|
|
4
4
|
//#region src/elements/start-button.ts
|
|
5
5
|
const STYLE_CSS = ":host{--mbx-tooltip:none;top:var(--mbx-start-top,50%);margin:-2.5em 0 0 -2.5em;position:absolute;left:50%}[part~=button]{z-index:0;width:5em;height:5em;color:var(--mbx-text);background:0 0;border:0;transition:color .15s;position:relative}[part~=button]:before{content:\"\";z-index:-1;background:var(--mbx-surface);opacity:.88;clip-path:polygon(0 0,79% 0,100% 21%,100% 100%,21% 100%,0 79%);transition:opacity .15s,background .15s;position:absolute;top:0;bottom:0;left:0;right:0}[part~=button]:hover{color:var(--mbx-surface)}[part~=button]:hover:before{background:var(--mbx-accent);opacity:1}:host([cramped]){display:none}[part~=icon],::slotted(*){width:3em;height:3em}slot[name=icon-play]>[part~=icon]{margin-left:.125em}@media (prefers-reduced-motion:reduce){[part~=button],[part~=button]:before{transition:none}}";
|
|
6
6
|
const STATES = ["play", "replay"];
|
|
@@ -44,7 +44,7 @@ var MbxStartButton = class extends Component {
|
|
|
44
44
|
this.failed = false;
|
|
45
45
|
this.render();
|
|
46
46
|
});
|
|
47
|
-
this.observe(player,
|
|
47
|
+
this.observe(player, HELD, () => {
|
|
48
48
|
this.render();
|
|
49
49
|
});
|
|
50
50
|
const failure = (event) => {
|
|
@@ -115,7 +115,7 @@ var MbxStartButton = class extends Component {
|
|
|
115
115
|
show(this.slots, state);
|
|
116
116
|
this.button.setAttribute("aria-label", this.getAttribute(`label-${state}`) ?? (state === "play" ? "Play" : "Replay"));
|
|
117
117
|
const player = this.player;
|
|
118
|
-
this.hidden = this.failed || !
|
|
118
|
+
this.hidden = this.failed || player !== null && !shownPaused(player, ["switching"]) || player?.hasAttribute("waiting") === true || player?.hasAttribute("scrubbing") === true;
|
|
119
119
|
}
|
|
120
120
|
};
|
|
121
121
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"start-button.js","names":[],"sources":["../../src/elements/start-button.ts"],"sourcesContent":["/**\n * <mbx-start-button>: the large play in the middle of the picture, shown\n * while the video is paused, a replay once it has ended, gone while it\n * plays, while a fatal error is on screen, and while the seek bar holds\n * the video paused for a drag (the player carries `scrubbing`). It sits in the player\n * beside the video, not in the bar, so it is over the poster and inside\n * fullscreen, and gone while the player waits for data, where the spinner\n * takes the centre. The glyph is `icon-play` or `icon-replay`, the name\n * `label-play` or `label-replay`.\n */\nimport type { PlayerError } from '@mattebox/player-core';\nimport { icon } from '../controls/icons.js';\nimport type { PlayerHost } from '../host.js';\nimport { Component } from './component.js';\nimport { BUTTON_STYLE, iconSlots, show, style } from './shared.js';\nimport STYLE_CSS from './start-button.css?inline';\n\ntype State = 'play' | 'replay';\nconst STATES: readonly State[] = ['play', 'replay'];\n\nconst STYLE = BUTTON_STYLE + STYLE_CSS;\n\nexport class MbxStartButton extends Component {\n static get observedAttributes(): readonly string[] {\n return ['label-play', 'label-replay'];\n }\n\n declare private readonly button: HTMLButtonElement;\n declare private readonly slots: Record<State, HTMLSlotElement>;\n /** A fatal error is on screen, and the play stays out of its way until playback or a load. */\n declare private failed: boolean;\n /** Watches the player's box: in a short one the button would sit over the bar. */\n declare private resizer: ResizeObserver | null;\n\n constructor() {\n super();\n this.failed = false;\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.slots = iconSlots(STATES, icon);\n for (const state of STATES) this.button.append(this.slots[state]);\n this.button.addEventListener('click', () => {\n this.player?.video.play().catch(() => undefined);\n });\n root.append(style(STYLE), this.button);\n }\n\n protected override attach(player: PlayerHost): void {\n const video = player.video;\n this.listen(video, ['play', 'pause', 'ended', 'waiting', 'stalled', 'canplay'], () => {\n this.render();\n });\n this.listen(video, ['playing', 'loadstart'], () => {\n this.failed = false;\n this.render();\n });\n this.listen(player, ['sourcechange'], () => {\n this.failed = false;\n this.render();\n });\n this.observe(player,
|
|
1
|
+
{"version":3,"file":"start-button.js","names":[],"sources":["../../src/elements/start-button.ts"],"sourcesContent":["/**\n * <mbx-start-button>: the large play in the middle of the picture, shown\n * while the video is paused, a replay once it has ended, gone while it\n * plays, while a fatal error is on screen, and while the seek bar holds\n * the video paused for a drag (the player carries `scrubbing`). Through a\n * switch to another source it keeps the state from before. It sits in the player\n * beside the video, not in the bar, so it is over the poster and inside\n * fullscreen, and gone while the player waits for data, where the spinner\n * takes the centre. The glyph is `icon-play` or `icon-replay`, the name\n * `label-play` or `label-replay`.\n */\nimport type { PlayerError } from '@mattebox/player-core';\nimport { icon } from '../controls/icons.js';\nimport type { PlayerHost } from '../host.js';\nimport { Component } from './component.js';\nimport { BUTTON_STYLE, HELD, iconSlots, show, shownPaused, style } from './shared.js';\nimport STYLE_CSS from './start-button.css?inline';\n\ntype State = 'play' | 'replay';\nconst STATES: readonly State[] = ['play', 'replay'];\n\nconst STYLE = BUTTON_STYLE + STYLE_CSS;\n\nexport class MbxStartButton extends Component {\n static get observedAttributes(): readonly string[] {\n return ['label-play', 'label-replay'];\n }\n\n declare private readonly button: HTMLButtonElement;\n declare private readonly slots: Record<State, HTMLSlotElement>;\n /** A fatal error is on screen, and the play stays out of its way until playback or a load. */\n declare private failed: boolean;\n /** Watches the player's box: in a short one the button would sit over the bar. */\n declare private resizer: ResizeObserver | null;\n\n constructor() {\n super();\n this.failed = false;\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.slots = iconSlots(STATES, icon);\n for (const state of STATES) this.button.append(this.slots[state]);\n this.button.addEventListener('click', () => {\n this.player?.video.play().catch(() => undefined);\n });\n root.append(style(STYLE), this.button);\n }\n\n protected override attach(player: PlayerHost): void {\n const video = player.video;\n this.listen(video, ['play', 'pause', 'ended', 'waiting', 'stalled', 'canplay'], () => {\n this.render();\n });\n this.listen(video, ['playing', 'loadstart'], () => {\n this.failed = false;\n this.render();\n });\n this.listen(player, ['sourcechange'], () => {\n this.failed = false;\n this.render();\n });\n this.observe(player, HELD, () => {\n this.render();\n });\n const failure = (event: Event): void => {\n const error = (event as CustomEvent<PlayerError>).detail;\n if (!error.fatal) return;\n this.failed = true;\n this.render();\n };\n player.addEventListener('error', failure);\n this.keep(() => {\n player.removeEventListener('error', failure);\n });\n this.failed = player.error !== null;\n if (typeof ResizeObserver !== 'undefined') {\n this.resizer = new ResizeObserver(() => {\n this.fit(player);\n });\n this.resizer.observe(player);\n // The bar's height moves the middle too, when its rows wrap or a tier changes.\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 this.removeAttribute('cramped');\n this.style.removeProperty('--mbx-start-top');\n }\n\n /**\n * The button sits between two middles: the player's own, and the middle\n * of the picture left over the bar's controls. With the bar at the foot,\n * the player's middle reads as too low. The bar is light, a line and a\n * few glyphs over a gradient, so the middle of what it leaves reads as\n * too high, most of all in a short player. Halfway between them is where\n * the eye puts the centre. The bar's top padding is the lead-in of its\n * gradient, so the controls start under it.\n *\n * Cramped when the button's foot would be inside the bar's box, which\n * starts at the top of its gradient: then the bar's own play button is\n * the one to press. Measured with the button shown, since a hidden one\n * has no box.\n */\n private fit(player: PlayerHost): void {\n const bar = player.querySelector('mbx-control-bar');\n if (bar === null) {\n this.removeAttribute('cramped');\n this.style.removeProperty('--mbx-start-top');\n return;\n }\n const box = player.getBoundingClientRect();\n const barBox = bar.getBoundingClientRect();\n const controls = barBox.top + (Number.parseFloat(getComputedStyle(bar).paddingTop) || 0);\n this.style.setProperty('--mbx-start-top', `${(box.height + controls - box.top) / 4}px`);\n const wasHidden = this.hidden;\n const wasCramped = this.hasAttribute('cramped');\n this.hidden = false;\n this.removeAttribute('cramped');\n const cramped = this.button.getBoundingClientRect().bottom > barBox.top;\n this.hidden = wasHidden;\n this.toggleAttribute('cramped', cramped);\n if (cramped !== wasCramped) this.render();\n }\n\n protected override render(): void {\n const video = this.player?.video;\n if (video === undefined) return;\n const state: State = video.ended ? 'replay' : 'play';\n show(this.slots, state);\n this.button.setAttribute(\n 'aria-label',\n this.getAttribute(`label-${state}`) ?? (state === 'play' ? 'Play' : 'Replay'),\n );\n // The player reflects `waiting` first: it listens from its constructor.\n const player = this.player;\n this.hidden =\n this.failed ||\n (player !== null && !shownPaused(player, ['switching'])) ||\n player?.hasAttribute('waiting') === true ||\n player?.hasAttribute('scrubbing') === true;\n }\n}\n"],"mappings":";;;;AAgBA,MAAA,YAAA;AAGA,MAAA,SAAA,CAAA,QAAA,QAAA;AAEA,MAAA,QAAA,eAAA;AAEA,IAAA,iBAAA,cAAA,UAAA;CACA,WAAA,qBAAA;EACA,OAAA,CAAA,cAAA,cAAA;CACA;CASA,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,OA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AAA;CACA;;;;;;;;;;;;;;;CAgBA,IAAA,QAAA;EACA,MAAA,MAAA,OAAA,cAAA,iBAAA;EACA,IAAA,QAAA,MAAA;GACA,KAAA,gBAAA,SAAA;GACA,KAAA,MAAA,eAAA,iBAAA;GACA;EACA;EACA,MAAA,MAAA,OAAA,sBAAA;EACA,MAAA,SAAA,IAAA,sBAAA;EACA,MAAA,WAAA,OAAA,OAAA,OAAA,WAAA,iBAAA,GAAA,CAAA,CAAA,UAAA,KAAA;EACA,KAAA,MAAA,YAAA,mBAAA,IAAA,IAAA,SAAA,WAAA,IAAA,OAAA,EAAA,GAAA;EACA,MAAA,YAAA,KAAA;EACA,MAAA,aAAA,KAAA,aAAA,SAAA;EACA,KAAA,SAAA;EACA,KAAA,gBAAA,SAAA;EACA,MAAA,UAAA,KAAA,OAAA,sBAAA,CAAA,CAAA,SAAA,OAAA;EACA,KAAA,SAAA;EACA,KAAA,gBAAA,WAAA,OAAA;EACA,IAAA,YAAA,YAAA,KAAA,OAAA;CACA;CAEA,SAAA;EACA,MAAA,QAAA,KAAA,QAAA;EACA,IAAA,UAAA,KAAA,GAAA;EACA,MAAA,QAAA,MAAA,QAAA,WAAA;EACA,KAAA,KAAA,OAAA,KAAA;EACA,KAAA,OAAA,aACA,cACA,KAAA,aAAA,SAAA,OAAA,MAAA,UAAA,SAAA,SAAA,SACA;EAEA,MAAA,SAAA,KAAA;EACA,KAAA,SACA,KAAA,UACA,WAAA,QAAA,CAAA,YAAA,QAAA,CAAA,WAAA,CAAA,KACA,QAAA,aAAA,SAAA,MAAA,QACA,QAAA,aAAA,WAAA,MAAA;CACA;AACA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { trackNames } from "../controls/track-names.js";
|
|
1
2
|
import { icon } from "../controls/icons.js";
|
|
2
3
|
import { show } from "./shared.js";
|
|
3
4
|
import { nativeTracks, onNativeTracks } from "../controls/native-tracks.js";
|
|
4
|
-
import { trackNames } from "../controls/track-names.js";
|
|
5
5
|
import { MenuElement } from "./menu-element.js";
|
|
6
6
|
import { onTracks, trackItems } from "./audio-menu.js";
|
|
7
7
|
import { isSdh } from "mattebox";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"title.d.ts","sourceRoot":"","sources":["../../src/elements/title.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAI3C,qBAAa,QAAS,SAAQ,SAAS;IACrC,MAAM,KAAK,kBAAkB,IAAI,SAAS,MAAM,EAAE,CAEjD;IAED,iBAAyB,OAAO,CAAmB;IACnD,iBAAyB,OAAO,CAAc;IAC9C,iBAAyB,UAAU,CAAc;IACjD,0FAA0F;IAC1F,QAAgB,OAAO,CAAwB;;cAgB5B,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;
|
|
1
|
+
{"version":3,"file":"title.d.ts","sourceRoot":"","sources":["../../src/elements/title.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAI3C,qBAAa,QAAS,SAAQ,SAAS;IACrC,MAAM,KAAK,kBAAkB,IAAI,SAAS,MAAM,EAAE,CAEjD;IAED,iBAAyB,OAAO,CAAmB;IACnD,iBAAyB,OAAO,CAAc;IAC9C,iBAAyB,UAAU,CAAc;IACjD,0FAA0F;IAC1F,QAAgB,OAAO,CAAwB;;cAgB5B,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;cAsBhC,MAAM,IAAI,IAAI;IAOjC,uEAAuE;IACvE,OAAO,CAAC,KAAK;IAKb,gHAAgH;IAChH,OAAO,CAAC,GAAG;cAUQ,MAAM,IAAI,IAAI;CAelC"}
|
package/dist/elements/title.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { el } from "../dom.js";
|
|
2
2
|
import { Component } from "./component.js";
|
|
3
|
-
import { style } from "./shared.js";
|
|
3
|
+
import { shownPaused, style } from "./shared.js";
|
|
4
4
|
//#region src/elements/title.ts
|
|
5
5
|
/**
|
|
6
6
|
* <mbx-title>: the heading, the subheading and the artwork of what plays,
|
|
@@ -55,6 +55,9 @@ var MbxTitle = class extends Component {
|
|
|
55
55
|
], () => {
|
|
56
56
|
this.state(player);
|
|
57
57
|
});
|
|
58
|
+
this.observe(player, ["switching"], () => {
|
|
59
|
+
this.state(player);
|
|
60
|
+
});
|
|
58
61
|
if (typeof ResizeObserver !== "undefined") {
|
|
59
62
|
this.resizer = new ResizeObserver(() => {
|
|
60
63
|
this.fit(player);
|
|
@@ -75,7 +78,7 @@ var MbxTitle = class extends Component {
|
|
|
75
78
|
}
|
|
76
79
|
/** `playing` on the element, for its own stylesheet and the page's. */
|
|
77
80
|
state(player) {
|
|
78
|
-
this.toggleAttribute("playing", !player
|
|
81
|
+
this.toggleAttribute("playing", !shownPaused(player, ["switching"]));
|
|
79
82
|
}
|
|
80
83
|
/** The height of the bar's rows: its box less the padding above them, which is its fade. Zero without a bar. */
|
|
81
84
|
fit(player) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"title.js","names":[],"sources":["../../src/elements/title.ts"],"sourcesContent":["/**\n * <mbx-title>: the heading, the subheading and the artwork of what plays,\n * as a lower third across the picture above the bar: a scrim that fades\n * upward, the artwork in the first column, the two lines in the second,\n * so a heading alone sits on a band and never floats. The content comes\n * from attributes, `heading`,\n * `subheading` and `artwork`, because the stream carries none of it: a page\n * writes what it knows, and a Cast receiver writes what the sender said.\n * With none of the three the element draws nothing.\n *\n * Shown while the video is paused, which includes before the first play,\n * and hidden while it plays. The element carries `playing` for that rule,\n * so a page changes it in CSS: `mattebox-player[started] mbx-title\n * { display: none }` keeps it to the time before the first play, like the\n * poster, and `mattebox-player:hover mbx-title { display: flex }` brings it\n * back on hover. The height of the bar's rows, its box less the fade it\n * pads itself with, goes on the host as `--mbx-bar-rows`, so the text sits\n * just above the seek row while the band runs under the bar to the bottom\n * edge, one ramp with the bar's own fade. The scrim is the page's to\n * override. Placed first among the screens, so the start button, the\n * error screen and the spinner paint over its band.\n */\nimport { el } from '../dom.js';\nimport type { PlayerHost } from '../host.js';\nimport { Component } from './component.js';\nimport { style } from './shared.js';\nimport STYLE from './title.css?inline';\n\nexport class MbxTitle extends Component {\n static get observedAttributes(): readonly string[] {\n return ['heading', 'subheading', 'artwork'];\n }\n\n declare private readonly artwork: HTMLImageElement;\n declare private readonly heading: HTMLElement;\n declare private readonly subheading: HTMLElement;\n /** Watches the player's box: the height of the bar's rows decides where the text sits. */\n declare private resizer: ResizeObserver | null;\n\n constructor() {\n super();\n this.resizer = null;\n const root = this.attachShadow({ mode: 'open' });\n this.artwork = el('img', 'artwork');\n this.artwork.alt = '';\n this.artwork.hidden = true;\n const text = el('div', 'text');\n this.heading = el('div', 'heading');\n this.subheading = el('div', 'subheading');\n text.append(this.heading, this.subheading);\n root.append(style(STYLE), this.artwork, text);\n }\n\n protected override attach(player: PlayerHost): void {\n this.listen(player.video, ['play', 'pause', 'ended', 'emptied'], () => {\n this.state(player);\n });\n if (typeof ResizeObserver !== 'undefined') {\n this.resizer = new ResizeObserver(() => {\n this.fit(player);\n });\n this.resizer.observe(player);\n // The bar's rows change height with the player's size tier, without\n // the player's box changing.\n const bar = player.querySelector('mbx-control-bar');\n if (bar !== null) this.resizer.observe(bar);\n }\n this.fit(player);\n this.state(player);\n this.render();\n }\n\n protected override detach(): void {\n this.resizer?.disconnect();\n this.resizer = null;\n this.removeAttribute('playing');\n this.style.removeProperty('--mbx-bar-rows');\n }\n\n /** `playing` on the element, for its own stylesheet and the page's. */\n private state(player: PlayerHost): void {\n this.toggleAttribute('playing', !player
|
|
1
|
+
{"version":3,"file":"title.js","names":[],"sources":["../../src/elements/title.ts"],"sourcesContent":["/**\n * <mbx-title>: the heading, the subheading and the artwork of what plays,\n * as a lower third across the picture above the bar: a scrim that fades\n * upward, the artwork in the first column, the two lines in the second,\n * so a heading alone sits on a band and never floats. The content comes\n * from attributes, `heading`,\n * `subheading` and `artwork`, because the stream carries none of it: a page\n * writes what it knows, and a Cast receiver writes what the sender said.\n * With none of the three the element draws nothing.\n *\n * Shown while the video is paused, which includes before the first play,\n * and hidden while it plays. The element carries `playing` for that rule,\n * so a page changes it in CSS: `mattebox-player[started] mbx-title\n * { display: none }` keeps it to the time before the first play, like the\n * poster, and `mattebox-player:hover mbx-title { display: flex }` brings it\n * back on hover. The height of the bar's rows, its box less the fade it\n * pads itself with, goes on the host as `--mbx-bar-rows`, so the text sits\n * just above the seek row while the band runs under the bar to the bottom\n * edge, one ramp with the bar's own fade. The scrim is the page's to\n * override. Placed first among the screens, so the start button, the\n * error screen and the spinner paint over its band.\n */\nimport { el } from '../dom.js';\nimport type { PlayerHost } from '../host.js';\nimport { Component } from './component.js';\nimport { shownPaused, style } from './shared.js';\nimport STYLE from './title.css?inline';\n\nexport class MbxTitle extends Component {\n static get observedAttributes(): readonly string[] {\n return ['heading', 'subheading', 'artwork'];\n }\n\n declare private readonly artwork: HTMLImageElement;\n declare private readonly heading: HTMLElement;\n declare private readonly subheading: HTMLElement;\n /** Watches the player's box: the height of the bar's rows decides where the text sits. */\n declare private resizer: ResizeObserver | null;\n\n constructor() {\n super();\n this.resizer = null;\n const root = this.attachShadow({ mode: 'open' });\n this.artwork = el('img', 'artwork');\n this.artwork.alt = '';\n this.artwork.hidden = true;\n const text = el('div', 'text');\n this.heading = el('div', 'heading');\n this.subheading = el('div', 'subheading');\n text.append(this.heading, this.subheading);\n root.append(style(STYLE), this.artwork, text);\n }\n\n protected override attach(player: PlayerHost): void {\n this.listen(player.video, ['play', 'pause', 'ended', 'emptied'], () => {\n this.state(player);\n });\n this.observe(player, ['switching'], () => {\n this.state(player);\n });\n if (typeof ResizeObserver !== 'undefined') {\n this.resizer = new ResizeObserver(() => {\n this.fit(player);\n });\n this.resizer.observe(player);\n // The bar's rows change height with the player's size tier, without\n // the player's box changing.\n const bar = player.querySelector('mbx-control-bar');\n if (bar !== null) this.resizer.observe(bar);\n }\n this.fit(player);\n this.state(player);\n this.render();\n }\n\n protected override detach(): void {\n this.resizer?.disconnect();\n this.resizer = null;\n this.removeAttribute('playing');\n this.style.removeProperty('--mbx-bar-rows');\n }\n\n /** `playing` on the element, for its own stylesheet and the page's. */\n private state(player: PlayerHost): void {\n // A switch to another source of the same programme is no pause.\n this.toggleAttribute('playing', !shownPaused(player, ['switching']));\n }\n\n /** The height of the bar's rows: its box less the padding above them, which is its fade. Zero without a bar. */\n private fit(player: PlayerHost): void {\n const bar = player.querySelector('mbx-control-bar');\n let rows = 0;\n if (bar !== null) {\n const top = Number.parseFloat(getComputedStyle(bar).paddingTop) || 0;\n rows = Math.max(0, bar.getBoundingClientRect().height - top);\n }\n this.style.setProperty('--mbx-bar-rows', `${rows}px`);\n }\n\n protected override render(): void {\n const heading = this.getAttribute('heading') ?? '';\n const subheading = this.getAttribute('subheading') ?? '';\n const artwork = this.getAttribute('artwork');\n this.heading.textContent = heading;\n this.subheading.textContent = subheading;\n if (artwork === null) {\n this.artwork.removeAttribute('src');\n this.artwork.hidden = true;\n } else {\n this.artwork.src = artwork;\n this.artwork.hidden = false;\n }\n this.toggleAttribute('empty', heading === '' && subheading === '' && artwork === null);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,MAAA,QAAA;AAEA,IAAA,WAAA,cAAA,UAAA;CACA,WAAA,qBAAA;EACA,OAAA;GAAA;GAAA;GAAA;EAAA;CACA;CAQA,cAAA;EACA,MAAA;EACA,KAAA,UAAA;EACA,MAAA,OAAA,KAAA,aAAA,EAAA,MAAA,OAAA,CAAA;EACA,KAAA,UAAA,GAAA,OAAA,SAAA;EACA,KAAA,QAAA,MAAA;EACA,KAAA,QAAA,SAAA;EACA,MAAA,OAAA,GAAA,OAAA,MAAA;EACA,KAAA,UAAA,GAAA,OAAA,SAAA;EACA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,cAAA;EACA,KAAA,WAAA,cAAA;EACA,IAAA,YAAA,MAAA;GACA,KAAA,QAAA,gBAAA,KAAA;GACA,KAAA,QAAA,SAAA;EACA,OAAA;GACA,KAAA,QAAA,MAAA;GACA,KAAA,QAAA,SAAA;EACA;EACA,KAAA,gBAAA,SAAA,YAAA,MAAA,eAAA,MAAA,YAAA,IAAA;CACA;AACA"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { PlayerHost } from '../host.js';
|
|
2
|
+
import { MenuElement } from './menu-element.js';
|
|
3
|
+
export declare class MbxVideoMenu extends MenuElement {
|
|
4
|
+
static get observedAttributes(): readonly string[];
|
|
5
|
+
private engine;
|
|
6
|
+
constructor();
|
|
7
|
+
protected name(): string;
|
|
8
|
+
protected attach(player: PlayerHost): void;
|
|
9
|
+
/** The name of `kind`, from its attribute; an empty kind is the main picture. */
|
|
10
|
+
private kindName;
|
|
11
|
+
/**
|
|
12
|
+
* The engine's video tracks as entries, one per version: the same version
|
|
13
|
+
* in another codec (an AVC and an HEVC set) is one entry, the active one
|
|
14
|
+
* when it is among them.
|
|
15
|
+
*/
|
|
16
|
+
private tracks;
|
|
17
|
+
/** The native session's video tracks as entries, and the selected one's. */
|
|
18
|
+
private native;
|
|
19
|
+
/** The versions at their own URLs as entries, after the ones of the stream. */
|
|
20
|
+
private sources;
|
|
21
|
+
protected render(): void;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=video-menu.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"video-menu.d.ts","sourceRoot":"","sources":["../../src/elements/video-menu.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,OAAO,EAAE,WAAW,EAAU,MAAM,mBAAmB,CAAC;AAqBxD,qBAAa,YAAa,SAAQ,WAAW;IAC3C,MAAM,KAAK,kBAAkB,IAAI,SAAS,MAAM,EAAE,CAEjD;IAED,QAAgB,MAAM,CAAkB;;cAQrB,IAAI,IAAI,MAAM;cAId,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;IAgBnD,iFAAiF;IACjF,OAAO,CAAC,QAAQ;IAKhB;;;;OAIG;IACH,OAAO,CAAC,MAAM;IAsBd,4EAA4E;IAC5E,OAAO,CAAC,MAAM;IAcd,+EAA+E;IAC/E,OAAO,CAAC,OAAO;cAYI,MAAM,IAAI,IAAI;CA8ClC"}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { trackNames } from "../controls/track-names.js";
|
|
2
|
+
import { show } from "./shared.js";
|
|
3
|
+
import { nativeTracks, onNativeTracks } from "../controls/native-tracks.js";
|
|
4
|
+
import { MenuElement, single } from "./menu-element.js";
|
|
5
|
+
import { onTracks } from "./audio-menu.js";
|
|
6
|
+
import { videoKind } from "mattebox";
|
|
7
|
+
//#region src/elements/video-menu.ts
|
|
8
|
+
/** The default name of each kind of HTML's `VideoTrack.kind`. */
|
|
9
|
+
const KINDS = {
|
|
10
|
+
main: "Main",
|
|
11
|
+
alternative: "Alternative",
|
|
12
|
+
sign: "Sign language",
|
|
13
|
+
captions: "Captions",
|
|
14
|
+
subtitles: "Subtitles",
|
|
15
|
+
commentary: "Commentary"
|
|
16
|
+
};
|
|
17
|
+
/** The value of a version at its own URL, by its place; the source itself is `source:`. */
|
|
18
|
+
const SOURCE = "source:";
|
|
19
|
+
var MbxVideoMenu = class extends MenuElement {
|
|
20
|
+
static get observedAttributes() {
|
|
21
|
+
return [
|
|
22
|
+
"label",
|
|
23
|
+
"label-back",
|
|
24
|
+
"label-track",
|
|
25
|
+
...Object.keys(KINDS).map((k) => `label-${k}`)
|
|
26
|
+
];
|
|
27
|
+
}
|
|
28
|
+
constructor() {
|
|
29
|
+
super(...single("video"));
|
|
30
|
+
this.engine = null;
|
|
31
|
+
show(this.slots, "default");
|
|
32
|
+
}
|
|
33
|
+
name() {
|
|
34
|
+
return "Video";
|
|
35
|
+
}
|
|
36
|
+
attach(player) {
|
|
37
|
+
this.listen(player, ["videosourcechange"], () => {
|
|
38
|
+
this.render();
|
|
39
|
+
});
|
|
40
|
+
this.follow(player, (engine) => {
|
|
41
|
+
this.engine = engine;
|
|
42
|
+
this.render();
|
|
43
|
+
const tick = () => {
|
|
44
|
+
this.render();
|
|
45
|
+
};
|
|
46
|
+
return engine === null ? onNativeTracks(player.video, "videoTracks", tick) : onTracks(engine, tick);
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
/** The name of `kind`, from its attribute; an empty kind is the main picture. */
|
|
50
|
+
kindName(kind) {
|
|
51
|
+
const key = kind === "" ? "main" : kind;
|
|
52
|
+
return this.getAttribute(`label-${key}`) ?? KINDS[key];
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* The engine's video tracks as entries, one per version: the same version
|
|
56
|
+
* in another codec (an AVC and an HEVC set) is one entry, the active one
|
|
57
|
+
* when it is among them.
|
|
58
|
+
*/
|
|
59
|
+
tracks(engine) {
|
|
60
|
+
const active = engine.tracks.active("video")?.id ?? null;
|
|
61
|
+
const versions = /* @__PURE__ */ new Map();
|
|
62
|
+
for (const track of engine.tracks.available) {
|
|
63
|
+
if (track.contentType !== "video" || track.role === "trick") continue;
|
|
64
|
+
if (!engine.tracks.selectable(track.id)) continue;
|
|
65
|
+
const key = [
|
|
66
|
+
videoKind(track),
|
|
67
|
+
track.lang,
|
|
68
|
+
track.name
|
|
69
|
+
].join("|");
|
|
70
|
+
if (versions.get(key) === void 0 || track.id === active) versions.set(key, track);
|
|
71
|
+
}
|
|
72
|
+
const entries = [...versions.values()].map((track) => [
|
|
73
|
+
track.id,
|
|
74
|
+
track.name ?? this.kindName(videoKind(track)),
|
|
75
|
+
track.lang,
|
|
76
|
+
[],
|
|
77
|
+
[]
|
|
78
|
+
]);
|
|
79
|
+
return [entries, entries.some(([id]) => id === active) ? active : null];
|
|
80
|
+
}
|
|
81
|
+
/** The native session's video tracks as entries, and the selected one's. */
|
|
82
|
+
native(tracks) {
|
|
83
|
+
const entries = tracks.map((track, index) => [
|
|
84
|
+
String(index),
|
|
85
|
+
track.label || this.kindName(track.kind),
|
|
86
|
+
track.language,
|
|
87
|
+
[],
|
|
88
|
+
[]
|
|
89
|
+
]);
|
|
90
|
+
const on = tracks.findIndex((track) => track.selected);
|
|
91
|
+
return [entries, on === -1 ? null : String(on)];
|
|
92
|
+
}
|
|
93
|
+
/** The versions at their own URLs as entries, after the ones of the stream. */
|
|
94
|
+
sources(versions) {
|
|
95
|
+
return versions.map((version, index) => [
|
|
96
|
+
`${SOURCE}${index}`,
|
|
97
|
+
version.label ?? this.kindName(version.kind),
|
|
98
|
+
version.language,
|
|
99
|
+
[],
|
|
100
|
+
[]
|
|
101
|
+
]);
|
|
102
|
+
}
|
|
103
|
+
render() {
|
|
104
|
+
super.render();
|
|
105
|
+
const player = this.player;
|
|
106
|
+
if (player === null) {
|
|
107
|
+
this.hidden = true;
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
const engine = this.engine;
|
|
111
|
+
const versions = player.videoSources;
|
|
112
|
+
const playing = player.videoSource;
|
|
113
|
+
const tracks = engine === null ? nativeTracks(player, "videoTracks") : void 0;
|
|
114
|
+
const [own, active] = playing !== null ? [[[
|
|
115
|
+
SOURCE,
|
|
116
|
+
this.kindName("main"),
|
|
117
|
+
void 0,
|
|
118
|
+
[],
|
|
119
|
+
[]
|
|
120
|
+
]], null] : tracks !== void 0 ? this.native(tracks) : engine !== null ? this.tracks(engine) : [[], null];
|
|
121
|
+
const entries = [...own, ...this.sources(versions)];
|
|
122
|
+
const value = playing !== null ? `${SOURCE}${versions.indexOf(playing)}` : active;
|
|
123
|
+
const items = trackNames(entries, this.getAttribute("label-track"));
|
|
124
|
+
this.menu.fill([{
|
|
125
|
+
name: "track",
|
|
126
|
+
items,
|
|
127
|
+
value: value ?? "",
|
|
128
|
+
onSelect: (picked) => {
|
|
129
|
+
if (picked === SOURCE) player.selectVideoSource(null);
|
|
130
|
+
else if (picked.startsWith(SOURCE)) {
|
|
131
|
+
const version = versions[Number(picked.slice(7))];
|
|
132
|
+
if (version !== void 0) player.selectVideoSource(version);
|
|
133
|
+
} else if (tracks !== void 0) {
|
|
134
|
+
const track = tracks[Number(picked)];
|
|
135
|
+
if (track !== void 0) track.selected = true;
|
|
136
|
+
} else engine?.tracks.select(picked);
|
|
137
|
+
this.render();
|
|
138
|
+
}
|
|
139
|
+
}]);
|
|
140
|
+
this.hidden = items.length < 2;
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
//#endregion
|
|
144
|
+
export { MbxVideoMenu };
|
|
145
|
+
|
|
146
|
+
//# sourceMappingURL=video-menu.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"video-menu.js","names":[],"sources":["../../src/elements/video-menu.ts"],"sourcesContent":["/**\n * <mbx-video-menu>: the version of the picture, such as a sign-language\n * version or a camera angle. It lists the video tracks of `engine.tracks`,\n * or the video's `videoTracks` for a native session, and the versions the\n * source names at their own URLs (`Source.videoTracks`, or\n * `<mbx-video-track>` children). It is not the quality menu: a video track\n * has its own bitrates, and ABR picks among those. Hidden unless there is a\n * choice to make. The name comes from `label`. A version reads as its name\n * in the manifest or its `label`, else the name of its kind (`label-main`,\n * `label-alternative`, `label-sign`, `label-captions`, `label-subtitles`,\n * `label-commentary`), else its language's name, else \"Track\"\n * (`label-track`) and its place.\n */\nimport type { SourceVideoTrack } from '@mattebox/player-core';\nimport type { Mattebox, Track } from 'mattebox';\nimport { videoKind } from 'mattebox';\nimport type { NativeTrack } from '../controls/native-tracks.js';\nimport { nativeTracks, onNativeTracks } from '../controls/native-tracks.js';\nimport type { TrackEntry } from '../controls/track-names.js';\nimport { trackNames } from '../controls/track-names.js';\nimport type { PlayerHost } from '../host.js';\nimport { onTracks } from './audio-menu.js';\nimport { MenuElement, single } from './menu-element.js';\nimport { show } from './shared.js';\n\n/** The default name of each kind of HTML's `VideoTrack.kind`. */\nconst KINDS: Readonly<Record<string, string>> = {\n main: 'Main',\n alternative: 'Alternative',\n sign: 'Sign language',\n captions: 'Captions',\n subtitles: 'Subtitles',\n commentary: 'Commentary',\n};\n\n/** The value of a version at its own URL, by its place; the source itself is `source:`. */\nconst SOURCE = 'source:';\n\n/** What the menu reads and writes of Safari's `VideoTrack`. */\ninterface NativeVideoTrack extends NativeTrack {\n selected: boolean;\n}\n\nexport class MbxVideoMenu extends MenuElement {\n static get observedAttributes(): readonly string[] {\n return ['label', 'label-back', 'label-track', ...Object.keys(KINDS).map((k) => `label-${k}`)];\n }\n\n declare private engine: Mattebox | null;\n\n constructor() {\n super(...single('video'));\n this.engine = null;\n show(this.slots, 'default');\n }\n\n protected override name(): string {\n return 'Video';\n }\n\n protected override attach(player: PlayerHost): void {\n this.listen(player, ['videosourcechange'], () => {\n this.render();\n });\n this.follow(player, (engine) => {\n this.engine = engine;\n this.render();\n const tick = (): void => {\n this.render();\n };\n return engine === null\n ? onNativeTracks(player.video, 'videoTracks', tick)\n : onTracks(engine, tick);\n });\n }\n\n /** The name of `kind`, from its attribute; an empty kind is the main picture. */\n private kindName(kind: string): string | undefined {\n const key = kind === '' ? 'main' : kind;\n return this.getAttribute(`label-${key}`) ?? KINDS[key];\n }\n\n /**\n * The engine's video tracks as entries, one per version: the same version\n * in another codec (an AVC and an HEVC set) is one entry, the active one\n * when it is among them.\n */\n private tracks(engine: Mattebox): [TrackEntry[], string | null] {\n const active = engine.tracks.active('video')?.id ?? null;\n const versions = new Map<string, Track>();\n for (const track of engine.tracks.available) {\n if (track.contentType !== 'video' || track.role === 'trick') continue;\n if (!engine.tracks.selectable(track.id)) continue;\n const key = [videoKind(track), track.lang, track.name].join('|');\n const held = versions.get(key);\n if (held === undefined || track.id === active) versions.set(key, track);\n }\n const entries = [...versions.values()].map(\n (track): TrackEntry => [\n track.id,\n track.name ?? this.kindName(videoKind(track)),\n track.lang,\n [],\n [],\n ],\n );\n return [entries, entries.some(([id]) => id === active) ? active : null];\n }\n\n /** The native session's video tracks as entries, and the selected one's. */\n private native(tracks: readonly NativeVideoTrack[]): [TrackEntry[], string | null] {\n const entries = tracks.map(\n (track, index): TrackEntry => [\n String(index),\n track.label || this.kindName(track.kind),\n track.language,\n [],\n [],\n ],\n );\n const on = tracks.findIndex((track) => track.selected);\n return [entries, on === -1 ? null : String(on)];\n }\n\n /** The versions at their own URLs as entries, after the ones of the stream. */\n private sources(versions: readonly SourceVideoTrack[]): TrackEntry[] {\n return versions.map(\n (version, index): TrackEntry => [\n `${SOURCE}${index}`,\n version.label ?? this.kindName(version.kind),\n version.language,\n [],\n [],\n ],\n );\n }\n\n protected override render(): void {\n super.render();\n const player = this.player;\n if (player === null) {\n this.hidden = true;\n return;\n }\n const engine = this.engine;\n const versions = player.videoSources;\n const playing = player.videoSource;\n const tracks =\n engine === null ? nativeTracks<NativeVideoTrack>(player, 'videoTracks') : undefined;\n // On a version at its own URL, the stream's tracks are that version's:\n // the menu offers the way back to the source instead.\n const [own, active]: [TrackEntry[], string | null] =\n playing !== null\n ? [[[SOURCE, this.kindName('main'), undefined, [], []]], null]\n : tracks !== undefined\n ? this.native(tracks)\n : engine !== null\n ? this.tracks(engine)\n : [[], null];\n const entries = [...own, ...this.sources(versions)];\n const value = playing !== null ? `${SOURCE}${versions.indexOf(playing)}` : active;\n const items = trackNames(entries, this.getAttribute('label-track'));\n this.menu.fill([\n {\n name: 'track',\n items,\n value: value ?? '',\n onSelect: (picked) => {\n if (picked === SOURCE) player.selectVideoSource(null);\n else if (picked.startsWith(SOURCE)) {\n const version = versions[Number(picked.slice(SOURCE.length))];\n if (version !== undefined) player.selectVideoSource(version);\n } else if (tracks !== undefined) {\n // Setting one track's `selected` clears the others'.\n const track = tracks[Number(picked)];\n if (track !== undefined) track.selected = true;\n } else engine?.tracks.select(picked);\n this.render();\n },\n },\n ]);\n this.hidden = items.length < 2;\n }\n}\n"],"mappings":";;;;;;;;AA0BA,MAAM,QAA0C;CAC9C,MAAM;CACN,aAAa;CACb,MAAM;CACN,UAAU;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AAQ,QAAQ,CAAC;EAClD,MAAM,QAAQ,YAAY,OAAO,GAAG,SAAS,SAAS,QAAQ,OAAO,MAAM;EAC3E,MAAM,QAAQ,WAAW,SAAS,KAAK,aAAa,aAAa,CAAC;EAClE,KAAK,KAAK,KAAK,CACb;GACE,MAAM;GACN;GACA,OAAO,SAAS;GAChB,WAAW,WAAW;IACpB,IAAI,WAAW,QAAQ,OAAO,kBAAkB,IAAI;SAC/C,IAAI,OAAO,WAAW,MAAM,GAAG;KAClC,MAAM,UAAU,SAAS,OAAO,OAAO,MAAM,CAAa,CAAC;KAC3D,IAAI,YAAY,KAAA,GAAW,OAAO,kBAAkB,OAAO;IAC7D,OAAO,IAAI,WAAW,KAAA,GAAW;KAE/B,MAAM,QAAQ,OAAO,OAAO,MAAM;KAClC,IAAI,UAAU,KAAA,GAAW,MAAM,WAAW;IAC5C,OAAO,QAAQ,OAAO,OAAO,MAAM;IACnC,KAAK,OAAO;GACd;EACF,CACF,CAAC;EACD,KAAK,SAAS,MAAM,SAAS;CAC/B;AACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"video-menu.d.ts","sourceRoot":"","sources":["../../src/entries/video-menu.ts"],"names":[],"mappings":"AAAA,kGAAkG;AAClG,OAAO,qBAAqB,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAKzD,OAAO,EAAE,YAAY,EAAE,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { VIDEO_MENU } from "../tags.js";
|
|
2
|
+
import "../element-entry.js";
|
|
3
|
+
import { MbxVideoMenu } from "../elements/video-menu.js";
|
|
4
|
+
//#region src/entries/video-menu.ts
|
|
5
|
+
if (customElements.get("mbx-video-menu") === void 0) customElements.define(VIDEO_MENU, MbxVideoMenu);
|
|
6
|
+
//#endregion
|
|
7
|
+
export { MbxVideoMenu };
|
|
8
|
+
|
|
9
|
+
//# sourceMappingURL=video-menu.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"video-menu.js","names":[],"sources":["../../src/entries/video-menu.ts"],"sourcesContent":["/** `@mattebox/player/elements/video-menu`: registers <mbx-video-menu>, and the player with it. */\nimport '../element-entry.js';\nimport { MbxVideoMenu } from '../elements/video-menu.js';\nimport { VIDEO_MENU } from '../tags.js';\n\nif (customElements.get(VIDEO_MENU) === undefined) customElements.define(VIDEO_MENU, MbxVideoMenu);\n\nexport { MbxVideoMenu };\n"],"mappings":";;;;AAKA,IAAI,eAAe,IAAA,gBAAc,MAAM,KAAA,GAAW,eAAe,OAAO,YAAY,YAAY"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import toPropertyKey from "./toPropertyKey.js";
|
|
2
|
-
//#region \0@oxc-project+runtime@0.
|
|
2
|
+
//#region \0@oxc-project+runtime@0.154.0/helpers/esm/defineProperty.js
|
|
3
3
|
function _defineProperty(e, r, t) {
|
|
4
4
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
5
5
|
value: t,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _defineProperty from "./defineProperty.js";
|
|
2
|
-
//#region \0@oxc-project+runtime@0.
|
|
2
|
+
//#region \0@oxc-project+runtime@0.154.0/helpers/esm/objectSpread2.js
|
|
3
3
|
function ownKeys(e, r) {
|
|
4
4
|
var t = Object.keys(e);
|
|
5
5
|
if (Object.getOwnPropertySymbols) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _typeof from "./typeof.js";
|
|
2
|
-
//#region \0@oxc-project+runtime@0.
|
|
2
|
+
//#region \0@oxc-project+runtime@0.154.0/helpers/esm/toPrimitive.js
|
|
3
3
|
function toPrimitive(t, r) {
|
|
4
4
|
if ("object" != _typeof(t) || !t) return t;
|
|
5
5
|
var e = t[Symbol.toPrimitive];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _typeof from "./typeof.js";
|
|
2
2
|
import toPrimitive from "./toPrimitive.js";
|
|
3
|
-
//#region \0@oxc-project+runtime@0.
|
|
3
|
+
//#region \0@oxc-project+runtime@0.154.0/helpers/esm/toPropertyKey.js
|
|
4
4
|
function toPropertyKey(t) {
|
|
5
5
|
var i = toPrimitive(t, "string");
|
|
6
6
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//#region \0@oxc-project+runtime@0.
|
|
1
|
+
//#region \0@oxc-project+runtime@0.154.0/helpers/esm/typeof.js
|
|
2
2
|
function _typeof(o) {
|
|
3
3
|
"@babel/helpers - typeof";
|
|
4
4
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { el } from "./dom.js";
|
|
2
|
+
import { fill } from "./labels.js";
|
|
3
|
+
//#region src/announcer.ts
|
|
4
|
+
/**
|
|
5
|
+
* The live region: what changed on the player, said to a screen reader.
|
|
6
|
+
* A shortcut key or a remote changes the playback with no focused control
|
|
7
|
+
* to read, so the element says it here: play, pause, loading, a fatal
|
|
8
|
+
* error and a track change (WCAG 2.2 SC 4.1.3, Status Messages). Vidstack's
|
|
9
|
+
* media announcer says the same things.
|
|
10
|
+
*
|
|
11
|
+
* Every phrase is an attribute on the player, `label-playing`,
|
|
12
|
+
* `label-paused`, `label-loading`, `label-error`, `label-audio`,
|
|
13
|
+
* `label-subtitles` and `label-subtitles-off`; `{track}` in the last
|
|
14
|
+
* three's text is the track's name. `announce="off"` keeps it quiet, for
|
|
15
|
+
* a page that announces on its own.
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* A screen reader reads a live region when its text changes, so the same
|
|
19
|
+
* phrase twice in a row, such as two pauses, has to empty the region
|
|
20
|
+
* first. The delay lets the reader see the empty region.
|
|
21
|
+
*/
|
|
22
|
+
const REFILL_MS = 100;
|
|
23
|
+
function announcer(host) {
|
|
24
|
+
const root = el("div", "announcer");
|
|
25
|
+
root.setAttribute("role", "status");
|
|
26
|
+
root.setAttribute("aria-live", "polite");
|
|
27
|
+
let timer;
|
|
28
|
+
return {
|
|
29
|
+
root,
|
|
30
|
+
say(name, fallback, track = "") {
|
|
31
|
+
var _host$getAttribute;
|
|
32
|
+
if (host.getAttribute("announce") === "off") return;
|
|
33
|
+
const text = fill((_host$getAttribute = host.getAttribute(`label-${name}`)) !== null && _host$getAttribute !== void 0 ? _host$getAttribute : fallback, { track });
|
|
34
|
+
root.textContent = "";
|
|
35
|
+
clearTimeout(timer);
|
|
36
|
+
timer = setTimeout(() => {
|
|
37
|
+
root.textContent = text;
|
|
38
|
+
}, REFILL_MS);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
//#endregion
|
|
43
|
+
export { announcer };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.
|
|
1
|
+
import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.154.0/helpers/esm/objectSpread2.js";
|
|
2
2
|
import { optional } from "./session.js";
|
|
3
3
|
//#region src/controls/chapters.ts
|
|
4
4
|
/** The first chapters track on the video, or null. */
|
|
@@ -15,6 +15,7 @@ const PATHS = {
|
|
|
15
15
|
"fullscreen-exit": "M13 4L13 13L4 13L7 10L10 10L10 7zM19 4L22 7L22 10L25 10L28 13L19 13zM4 19L13 19L13 28L10 25L10 22L7 22zM19 19L28 19L25 22L22 22L22 25L19 28z",
|
|
16
16
|
quality: "M5 22L10 18.1L10 27L5 27zM13.5 15.4L18.5 11.6L18.5 27L13.5 27zM22 8.9L27 5L27 27L22 27z",
|
|
17
17
|
audio: "M4.75 13h2.5v6h-2.5zM9.75 9h2.5v14h-2.5zM14.75 5h2.5v22h-2.5zM19.75 10.5h2.5v11h-2.5zM24.75 13.5h2.5v5h-2.5z",
|
|
18
|
+
video: "M4 9h16v14H4zM6.5 11.5h11v9h-11zM21 14l7-4v12l-7-4z",
|
|
18
19
|
subtitles: "M4 6h20l4 4v16H4zM6.5 8.5H22.96L25.5 11.04V23.5H6.5zM9 14h8v2.5h-8zM19 14h4v2.5h-4zM9 18.5h4v2.5h-4zM15 18.5h8v2.5h-8z",
|
|
19
20
|
"subtitles-on": "M4 6h20l4 4v16H4zM9 14h8v2.5h-8zM19 14h4v2.5h-4zM9 18.5h4v2.5h-4zM15 18.5h8v2.5h-8z",
|
|
20
21
|
"lock-closed": "M7 14h18v13H7zM14.75 18.5v4.5h2.5v-4.5zM9.75 14V11A6.25 6.25 0 0 1 22.25 11V14H19.75V11A3.75 3.75 0 0 0 12.25 11V14z",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { el, setChildren, state } from "../dom.js";
|
|
2
|
-
import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.
|
|
2
|
+
import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.154.0/helpers/esm/objectSpread2.js";
|
|
3
3
|
//#region src/controls/menu.ts
|
|
4
4
|
/**
|
|
5
5
|
* The menu primitive the quality, audio, subtitles and speed menus share: a
|