@mattebox/player 0.8.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 -30
- 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/menu.d.ts +11 -0
- package/dist/controls/menu.d.ts.map +1 -1
- package/dist/controls/menu.js +31 -5
- package/dist/controls/menu.js.map +1 -1
- package/dist/element.d.ts +36 -2
- package/dist/element.d.ts.map +1 -1
- package/dist/element.js +140 -24
- package/dist/element.js.map +1 -1
- package/dist/elements/audio-menu.d.ts.map +1 -1
- package/dist/elements/audio-menu.js +3 -1
- 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.js +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 +3 -3
- package/dist/elements/marker-button.d.ts.map +1 -1
- package/dist/elements/marker-button.js +18 -22
- package/dist/elements/marker-button.js.map +1 -1
- package/dist/elements/quality-menu.js +1 -1
- package/dist/elements/quality-menu.js.map +1 -1
- package/dist/elements/scan-button.js +1 -1
- package/dist/elements/seek-bar.d.ts.map +1 -1
- package/dist/elements/seek-bar.js +5 -4
- 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 +5 -1
- package/dist/elements/subtitles-menu.d.ts.map +1 -1
- package/dist/elements/subtitles-menu.js +29 -11
- 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/es2015/controls/icons.js +38 -29
- package/dist/es2015/controls/menu.js +32 -5
- package/dist/es2015/element.js +142 -28
- package/dist/es2015/elements/audio-menu.js +4 -1
- 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 +1 -1
- 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 +19 -23
- package/dist/es2015/elements/quality-menu.js +1 -1
- package/dist/es2015/elements/scan-button.js +1 -1
- package/dist/es2015/elements/seek-bar.js +5 -4
- 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 +35 -17
- 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/style.js +1 -1
- package/dist/style.js +1 -1
- package/package.json +4 -5
- package/NOTICE +0 -24
|
@@ -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 }\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.video.paused);\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,KAAA,aAAA,GAAA,OAAA,YAAA;EACA,KAAA,OAAA,KAAA,SAAA,KAAA,UAAA;EACA,KAAA,OAAA,MAAA,KAAA,GAAA,KAAA,SAAA,IAAA;CACA;CAEA,OAAA,QAAA;EACA,KAAA,OAAA,OAAA,OAAA;GAAA;GAAA;GAAA;GAAA;EAAA,SAAA;GACA,KAAA,MAAA,MAAA;EACA,CAAA;EACA,IAAA,OAAA,mBAAA,aAAA;GACA,KAAA,UAAA,IAAA,qBAAA;IACA,KAAA,IAAA,MAAA;GACA,CAAA;GACA,KAAA,QAAA,QAAA,MAAA;EACA;EACA,KAAA,IAAA,MAAA;EACA,KAAA,MAAA,MAAA;EACA,KAAA,OAAA;CACA;CAEA,SAAA;EACA,KAAA,SAAA,WAAA;EACA,KAAA,UAAA;EACA,KAAA,gBAAA,SAAA;EACA,KAAA,MAAA,eAAA,gBAAA;CACA;;CAGA,MAAA,QAAA;EACA,KAAA,gBAAA,WAAA,CAAA,OAAA,MAAA,MAAA;CACA;;CAGA,IAAA,QAAA;EACA,MAAA,MAAA,OAAA,cAAA,iBAAA;EACA,IAAA,OAAA;EACA,IAAA,QAAA,MAAA;GACA,MAAA,MAAA,OAAA,WAAA,iBAAA,GAAA,CAAA,CAAA,UAAA,KAAA;GACA,OAAA,KAAA,IAAA,GAAA,IAAA,sBAAA,CAAA,CAAA,SAAA,GAAA;EACA;EACA,KAAA,MAAA,YAAA,kBAAA,GAAA,KAAA,GAAA;CACA;CAEA,SAAA;EACA,MAAA,UAAA,KAAA,aAAA,SAAA,KAAA;EACA,MAAA,aAAA,KAAA,aAAA,YAAA,KAAA;EACA,MAAA,UAAA,KAAA,aAAA,SAAA;EACA,KAAA,QAAA,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"}
|
|
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.video.paused);\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,KAAA,aAAA,GAAA,OAAA,YAAA;EACA,KAAA,OAAA,KAAA,SAAA,KAAA,UAAA;EACA,KAAA,OAAA,MAAA,KAAA,GAAA,KAAA,SAAA,IAAA;CACA;CAEA,OAAA,QAAA;EACA,KAAA,OAAA,OAAA,OAAA;GAAA;GAAA;GAAA;GAAA;EAAA,SAAA;GACA,KAAA,MAAA,MAAA;EACA,CAAA;EACA,IAAA,OAAA,mBAAA,aAAA;GACA,KAAA,UAAA,IAAA,qBAAA;IACA,KAAA,IAAA,MAAA;GACA,CAAA;GACA,KAAA,QAAA,QAAA,MAAA;GAGA,MAAA,MAAA,OAAA,cAAA,iBAAA;GACA,IAAA,QAAA,MAAA,KAAA,QAAA,QAAA,GAAA;EACA;EACA,KAAA,IAAA,MAAA;EACA,KAAA,MAAA,MAAA;EACA,KAAA,OAAA;CACA;CAEA,SAAA;EACA,KAAA,SAAA,WAAA;EACA,KAAA,UAAA;EACA,KAAA,gBAAA,SAAA;EACA,KAAA,MAAA,eAAA,gBAAA;CACA;;CAGA,MAAA,QAAA;EACA,KAAA,gBAAA,WAAA,CAAA,OAAA,MAAA,MAAA;CACA;;CAGA,IAAA,QAAA;EACA,MAAA,MAAA,OAAA,cAAA,iBAAA;EACA,IAAA,OAAA;EACA,IAAA,QAAA,MAAA;GACA,MAAA,MAAA,OAAA,WAAA,iBAAA,GAAA,CAAA,CAAA,UAAA,KAAA;GACA,OAAA,KAAA,IAAA,GAAA,IAAA,sBAAA,CAAA,CAAA,SAAA,GAAA;EACA;EACA,KAAA,MAAA,YAAA,kBAAA,GAAA,KAAA,GAAA;CACA;CAEA,SAAA;EACA,MAAA,UAAA,KAAA,aAAA,SAAA,KAAA;EACA,MAAA,aAAA,KAAA,aAAA,YAAA,KAAA;EACA,MAAA,UAAA,KAAA,aAAA,SAAA;EACA,KAAA,QAAA,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"}
|
|
@@ -2,7 +2,7 @@ import { Component } from "./component.js";
|
|
|
2
2
|
import { SLIDER_STYLE, number, style } from "./shared.js";
|
|
3
3
|
import { slider } from "../controls/slider.js";
|
|
4
4
|
//#region src/elements/volume-slider.ts
|
|
5
|
-
const VOLUME_SLIDER_CSS = ":host{flex:none;width:
|
|
5
|
+
const VOLUME_SLIDER_CSS = ":host{flex:none;width:5em}";
|
|
6
6
|
const STEP = .05;
|
|
7
7
|
const PAGE = .2;
|
|
8
8
|
var MbxVolumeSlider = class extends Component {
|
package/dist/elements/volume.js
CHANGED
|
@@ -15,7 +15,7 @@ import { style } from "./shared.js";
|
|
|
15
15
|
* stuck. So the group carries `pointer` from a pointer press until a key
|
|
16
16
|
* is pressed or focus leaves, and focus unfolds the slider only without it.
|
|
17
17
|
*/
|
|
18
|
-
const STYLE = ":host{align-items:center;display:inline-flex}:host([hidden]){display:none}::slotted(mbx-volume-slider){opacity:0;width:0;transition:width .2s,opacity .2s;overflow:hidden}::slotted(mbx-volume-slider[collapsed]){display:none}:host(:hover) ::slotted(mbx-volume-slider),:host(:focus-within:not([pointer])) ::slotted(mbx-volume-slider){opacity:1;width:
|
|
18
|
+
const STYLE = ":host{align-items:center;display:inline-flex}:host([hidden]){display:none}::slotted(mbx-volume-slider){opacity:0;width:0;transition:width .2s,opacity .2s;overflow:hidden}::slotted(mbx-volume-slider[collapsed]){display:none}:host(:hover) ::slotted(mbx-volume-slider),:host(:focus-within:not([pointer])) ::slotted(mbx-volume-slider){opacity:1;width:5em}@media (prefers-reduced-motion:reduce){::slotted(mbx-volume-slider){transition:none}}";
|
|
19
19
|
var MbxVolume = class extends Component {
|
|
20
20
|
constructor() {
|
|
21
21
|
super();
|
|
@@ -1,37 +1,46 @@
|
|
|
1
1
|
//#region src/controls/icons.ts
|
|
2
2
|
/**
|
|
3
3
|
* Each glyph's subpaths joined into one `d`. The path is drawn even-odd:
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* a frame, a ring or a letter cuts its hole with a nested subpath, and no
|
|
5
|
+
* two filled subpaths overlap.
|
|
6
6
|
*/
|
|
7
7
|
const PATHS = {
|
|
8
|
-
play: "
|
|
9
|
-
pause: "M8
|
|
10
|
-
replay: "
|
|
11
|
-
mute: "
|
|
12
|
-
"volume-low": "
|
|
13
|
-
"volume-high": "
|
|
14
|
-
fullscreen: "
|
|
15
|
-
"fullscreen-exit": "
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
"
|
|
20
|
-
"lock-closed": "
|
|
21
|
-
"seek-backward": "
|
|
22
|
-
"seek-forward": "
|
|
23
|
-
"seek-backward-
|
|
24
|
-
"seek-forward-
|
|
25
|
-
"seek-backward-
|
|
26
|
-
"seek-forward-
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
|
|
31
|
-
"
|
|
32
|
-
|
|
33
|
-
"
|
|
34
|
-
|
|
8
|
+
play: "M9 5L26 16L9 27z",
|
|
9
|
+
pause: "M8 6h5.5v20h-5.5zM18.5 6h5.5v20h-5.5z",
|
|
10
|
+
replay: "M16 6.75A10.25 10.25 0 1 1 7.12 11.88L9.29 13.12A7.75 7.75 0 1 0 16 9.25zM16 3.5L16 12.5L10 8z",
|
|
11
|
+
mute: "M4 12L9 12L16 6L16 26L9 20L4 20zM24 17.77L20.99 20.77L19.23 19.01L22.23 16L19.23 12.99L20.99 11.23L24 14.23L27.01 11.23L28.77 12.99L25.77 16L28.77 19.01L27.01 20.77z",
|
|
12
|
+
"volume-low": "M4 12L9 12L16 6L16 26L9 20L4 20zM21.13 10.87A7.25 7.25 0 0 1 21.13 21.13L19.36 19.36A4.75 4.75 0 0 0 19.36 12.64z",
|
|
13
|
+
"volume-high": "M4 12L9 12L16 6L16 26L9 20L4 20zM21.13 10.87A7.25 7.25 0 0 1 21.13 21.13L19.36 19.36A4.75 4.75 0 0 0 19.36 12.64zM24.31 7.69A11.75 11.75 0 0 1 24.31 24.31L22.54 22.54A9.25 9.25 0 0 0 22.54 9.46z",
|
|
14
|
+
fullscreen: "M5 5L14 5L11 8L8 8L8 11L5 14zM18 5L27 5L27 14L24 11L24 8L21 8zM5 18L8 21L8 24L11 24L14 27L5 27zM27 18L27 27L18 27L21 24L24 24L24 21z",
|
|
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
|
+
quality: "M5 22L10 18.1L10 27L5 27zM13.5 15.4L18.5 11.6L18.5 27L13.5 27zM22 8.9L27 5L27 27L22 27z",
|
|
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
|
+
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
|
+
"subtitles-on": "M4 6h20l4 4v16H4zM9 14h8v2.5h-8zM19 14h4v2.5h-4zM9 18.5h4v2.5h-4zM15 18.5h8v2.5h-8z",
|
|
20
|
+
"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",
|
|
21
|
+
"seek-backward": "M16 6.75A10.25 10.25 0 1 1 7.12 11.88L9.29 13.12A7.75 7.75 0 1 0 16 9.25zM16 3.5L16 12.5L10 8z",
|
|
22
|
+
"seek-forward": "M24.88 11.88A10.25 10.25 0 1 1 16 6.75L16 9.25A7.75 7.75 0 1 0 22.71 13.12zM16 3.5L22 8L16 12.5z",
|
|
23
|
+
"seek-backward-5": "M16 6.75A10.25 10.25 0 1 1 7.12 11.88L9.29 13.12A7.75 7.75 0 1 0 16 9.25zM16 3.5L16 12.5L10 8zM13 13.5h6v2h-6zM13 15.5h2v0.5h-2zM13 16h6v2h-6zM17 18h2v0.5h-2zM13 18.5h6v2h-6z",
|
|
24
|
+
"seek-forward-5": "M24.88 11.88A10.25 10.25 0 1 1 16 6.75L16 9.25A7.75 7.75 0 1 0 22.71 13.12zM16 3.5L22 8L16 12.5zM13 13.5h6v2h-6zM13 15.5h2v0.5h-2zM13 16h6v2h-6zM17 18h2v0.5h-2zM13 18.5h6v2h-6z",
|
|
25
|
+
"seek-backward-10": "M16 6.75A10.25 10.25 0 1 1 7.12 11.88L9.29 13.12A7.75 7.75 0 1 0 16 9.25zM16 3.5L16 12.5L10 8zM11.5 13.5h2.2v7h-2.2zM15.5 13.5h5.5v7h-5.5zM17.6 15.6v2.8h1.3v-2.8z",
|
|
26
|
+
"seek-forward-10": "M24.88 11.88A10.25 10.25 0 1 1 16 6.75L16 9.25A7.75 7.75 0 1 0 22.71 13.12zM16 3.5L22 8L16 12.5zM11.5 13.5h2.2v7h-2.2zM15.5 13.5h5.5v7h-5.5zM17.6 15.6v2.8h1.3v-2.8z",
|
|
27
|
+
"seek-backward-15": "M16 6.75A10.25 10.25 0 1 1 7.12 11.88L9.29 13.12A7.75 7.75 0 1 0 16 9.25zM16 3.5L16 12.5L10 8zM10.5 13.5h2.2v7h-2.2zM14.7 13.5h5.8v2h-5.8zM14.7 15.5h2v0.5h-2zM14.7 16h5.8v2h-5.8zM18.5 18h2v0.5h-2zM14.7 18.5h5.8v2h-5.8z",
|
|
28
|
+
"seek-forward-15": "M24.88 11.88A10.25 10.25 0 1 1 16 6.75L16 9.25A7.75 7.75 0 1 0 22.71 13.12zM16 3.5L22 8L16 12.5zM10.5 13.5h2.2v7h-2.2zM14.7 13.5h5.8v2h-5.8zM14.7 15.5h2v0.5h-2zM14.7 16h5.8v2h-5.8zM18.5 18h2v0.5h-2zM14.7 18.5h5.8v2h-5.8z",
|
|
29
|
+
"seek-backward-30": "M16 6.75A10.25 10.25 0 1 1 7.12 11.88L9.29 13.12A7.75 7.75 0 1 0 16 9.25zM16 3.5L16 12.5L10 8zM13 13.5h2v7h-2zM10 13.5h3v2h-3zM11 16h2v2h-2zM10 18.5h3v2h-3zM16.5 13.5h5.5v7h-5.5zM18.6 15.6v2.8h1.3v-2.8z",
|
|
30
|
+
"seek-forward-30": "M24.88 11.88A10.25 10.25 0 1 1 16 6.75L16 9.25A7.75 7.75 0 1 0 22.71 13.12zM16 3.5L22 8L16 12.5zM13 13.5h2v7h-2zM10 13.5h3v2h-3zM11 16h2v2h-2zM10 18.5h3v2h-3zM16.5 13.5h5.5v7h-5.5zM18.6 15.6v2.8h1.3v-2.8z",
|
|
31
|
+
"playback-speed": "M7.69 26.31A11.75 11.75 0 1 1 24.31 26.31L22.54 24.54A9.25 9.25 0 1 0 9.46 24.54zM16.41 20.31L21.14 11.87L13.66 17.99z",
|
|
32
|
+
"picture-in-picture": "M4 6h24v20H4zM6.5 8.5v15h19v-15zM15 15h8v6h-8z",
|
|
33
|
+
"picture-in-picture-exit": "M4 6h24v20H4zM6.5 8.5v15h19v-15zM9.5 11.5L16 11.5L9.5 18zM13.63 13.87L19.29 19.52L17.52 21.29L11.87 15.63z",
|
|
34
|
+
airplay: "M4 6H28V23.25H23V20.75H25.5V8.5H6.5V20.75H9V23.25H4zM16 17.5L23.5 27L8.5 27z",
|
|
35
|
+
"airplay-active": "M4 6H28V23.25H22.1L16 15.5L9.9 23.25H4zM16 17.5L23.5 27L8.5 27z",
|
|
36
|
+
chapters: "M5 6.5h4v4h-4zM12 7.25h15v2.5h-15zM5 14h4v4h-4zM12 14.75h15v2.5h-15zM5 21.5h4v4h-4zM12 22.25h15v2.5h-15z",
|
|
37
|
+
"fast-forward": "M4 7L15 16L4 25zM16 7L27 16L16 25z",
|
|
38
|
+
"fast-backward": "M28 7L17 16L28 25zM16 7L5 16L16 25z",
|
|
39
|
+
"audio-description": "M1.5 23L4.8 9h2.6L10.7 23H8.4l-.75-3.2H4.55L3.8 23zM5.1 17.4h2L6.1 12.9zM12.2 9h2.8a7 7 0 0 1 0 14h-2.8zM14.6 11.4v9.2h.4a4.6 4.6 0 0 0 0-9.2zM24.2 9.96A9.4 9.4 0 0 1 24.2 22.04L22.82 20.89A7.6 7.6 0 0 0 22.82 11.11zM27.11 7.52A13.2 13.2 0 0 1 27.11 24.48L25.73 23.33A11.4 11.4 0 0 0 25.73 8.67z",
|
|
40
|
+
sdh: "M9.7 13.2L10.3 10.4L11.6 8.5L13.6 7.2L16 6.8L18.7 7.3L20.8 8.6L22.2 10.6L22.7 13L22.5 14.9L21.8 16.3L20.8 17.5L19.6 18.7L18.5 19.9L17.9 21.3L17.5 22.5L17.1 23.5L16.7 24.5L16 25.2L15.2 25.6L14.3 25.7L13.3 25.6L12.6 25.1L12 24.4L11.7 23.4L9.3 24.2L9.8 25.7L10.9 27L12.5 27.9L14.3 28.3L16 28L17.6 27.2L18.7 26L19.5 24.5L19.8 23.3L20.2 22.2L20.6 21.3L21.4 20.3L22.6 19.2L23.9 17.7L24.9 15.7L25.3 13L24.6 9.5L22.6 6.7L19.6 4.9L16 4.2L12.7 4.9L9.9 6.6L7.9 9.4L7.3 12.8zM13.7 13.2L13.9 12.1L14.4 11.4L15.1 10.9L16 10.8L16.9 10.9L17.6 11.4L18.1 12.1L18.3 13.2L20.7 12.8L20.4 11.1L19.4 9.6L17.9 8.6L16 8.2L14.1 8.6L12.6 9.6L11.6 11.1L11.3 12.8z",
|
|
41
|
+
"closed-captions": "M14.24 20.24A6 6 0 1 1 14.24 11.76L12.47 13.53A3.5 3.5 0 1 0 12.47 18.47zM26.24 20.24A6 6 0 1 1 26.24 11.76L24.47 13.53A3.5 3.5 0 1 0 24.47 18.47z",
|
|
42
|
+
"text-size": "M2.5 23L5.9 13L8.1 13L11.5 23zM7 16.53L7.64 18.4L6.36 18.4zM5.65 20.5L8.35 20.5L9.2 23L4.8 23zM12.5 23L19.5 6L22.5 6L29.5 23zM21 9.64L23.45 15.6L18.55 15.6zM17.48 18.2L24.52 18.2L26.5 23L15.5 23z",
|
|
43
|
+
"text-background": "M4 6h24v20h-24zM9 22.5L14.6 9.5L17.4 9.5L23 22.5zM16 12.75L17.66 16.6L14.34 16.6zM13.35 18.9L18.65 18.9L20.2 22.5L11.8 22.5z"
|
|
35
44
|
};
|
|
36
45
|
const SVG = "http://www.w3.org/2000/svg";
|
|
37
46
|
/** A glyph, hidden from the accessibility tree: the button it sits in carries the name. */
|
|
@@ -26,11 +26,11 @@ import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.152.0/helpers/es
|
|
|
26
26
|
/** Air between the popup's top and the picture's. */
|
|
27
27
|
const AIR = 8;
|
|
28
28
|
/**
|
|
29
|
-
* The tallest a popup grows, in pixels: about seven and a half rows, so
|
|
29
|
+
* The tallest a popup grows, in pixels: the title and about seven and a half rows, so
|
|
30
30
|
* the half row at the foot says the list goes on. A page sets its own
|
|
31
31
|
* with `--mbx-menu-max-height`.
|
|
32
32
|
*/
|
|
33
|
-
const MAX_HEIGHT =
|
|
33
|
+
const MAX_HEIGHT = 22;
|
|
34
34
|
/** An item's picture. Decorative: the item's text names it. Loaded when the popup first shows it. */
|
|
35
35
|
function picture(url) {
|
|
36
36
|
const node = el("img", "item-image");
|
|
@@ -80,10 +80,16 @@ function menu(options) {
|
|
|
80
80
|
* left of its right edge.
|
|
81
81
|
*/
|
|
82
82
|
function fit() {
|
|
83
|
+
if (host.getAttribute("layout") === "compact") {
|
|
84
|
+
popup.style.maxHeight = "";
|
|
85
|
+
popup.style.maxWidth = "";
|
|
86
|
+
more();
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
83
89
|
const picture = options.picture();
|
|
84
90
|
if (picture === null) return;
|
|
85
91
|
const room = button.getBoundingClientRect().top - picture.top - AIR;
|
|
86
|
-
const most = Number.parseFloat(getComputedStyle(host).getPropertyValue("--mbx-menu-max-height")) || MAX_HEIGHT;
|
|
92
|
+
const most = Number.parseFloat(getComputedStyle(host).getPropertyValue("--mbx-menu-max-height")) || MAX_HEIGHT * (Number.parseFloat(getComputedStyle(host).fontSize) || 16);
|
|
87
93
|
popup.style.maxHeight = `${Math.max(0, Math.floor(Math.min(most, room)))}px`;
|
|
88
94
|
more();
|
|
89
95
|
const wide = host.getBoundingClientRect().right - picture.left - AIR;
|
|
@@ -114,6 +120,11 @@ function menu(options) {
|
|
|
114
120
|
const page = stack[stack.length - 1];
|
|
115
121
|
if (page === void 0) return;
|
|
116
122
|
let tab = true;
|
|
123
|
+
if (stack.length === 1 && name !== "") {
|
|
124
|
+
const title = el("div", "title", name);
|
|
125
|
+
title.setAttribute("aria-hidden", "true");
|
|
126
|
+
popup.append(title);
|
|
127
|
+
}
|
|
117
128
|
if (stack.length > 1) {
|
|
118
129
|
const back = item("item back-item", page.label, () => {
|
|
119
130
|
var _items$;
|
|
@@ -135,6 +146,11 @@ function menu(options) {
|
|
|
135
146
|
});
|
|
136
147
|
link.setAttribute("role", "menuitem");
|
|
137
148
|
link.setAttribute("aria-haspopup", "menu");
|
|
149
|
+
if (entry.glyph !== void 0) {
|
|
150
|
+
link.prepend(entry.glyph());
|
|
151
|
+
state(link, `item page-item ${entry.name}-item`, { "glyph-item": true });
|
|
152
|
+
}
|
|
153
|
+
if (entry.detail !== void 0) link.append(el("span", "item-detail", entry.detail));
|
|
138
154
|
popup.append(link);
|
|
139
155
|
continue;
|
|
140
156
|
}
|
|
@@ -142,7 +158,7 @@ function menu(options) {
|
|
|
142
158
|
section.setAttribute("role", "group");
|
|
143
159
|
if (entry.label !== void 0) {
|
|
144
160
|
section.setAttribute("aria-label", entry.label);
|
|
145
|
-
section.append(el("div", `section-label ${entry.name}-label`, entry.label));
|
|
161
|
+
if (entry.hideLabel !== true) section.append(el("div", `section-label ${entry.name}-label`, entry.label));
|
|
146
162
|
}
|
|
147
163
|
for (const [id, text, detail, image, badges] of entry.items) {
|
|
148
164
|
const choice = item(`item ${entry.name}-item`, text, () => {
|
|
@@ -150,7 +166,18 @@ function menu(options) {
|
|
|
150
166
|
button.focus();
|
|
151
167
|
entry.onSelect(id);
|
|
152
168
|
});
|
|
153
|
-
for (const badge of badges !== null && badges !== void 0 ? badges : [])
|
|
169
|
+
for (const badge of badges !== null && badges !== void 0 ? badges : []) {
|
|
170
|
+
var _entry$badgeGlyphs;
|
|
171
|
+
const glyph = (_entry$badgeGlyphs = entry.badgeGlyphs) === null || _entry$badgeGlyphs === void 0 ? void 0 : _entry$badgeGlyphs[badge];
|
|
172
|
+
if (glyph === void 0) {
|
|
173
|
+
choice.append(el("span", "item-badge", badge));
|
|
174
|
+
continue;
|
|
175
|
+
}
|
|
176
|
+
const drawn = el("span", "item-badge item-glyph");
|
|
177
|
+
drawn.title = badge;
|
|
178
|
+
drawn.append(glyph(), el("span", "badge-text", badge));
|
|
179
|
+
choice.append(drawn);
|
|
180
|
+
}
|
|
154
181
|
if (detail !== void 0) choice.append(el("span", "item-detail", detail));
|
|
155
182
|
if (image !== void 0) {
|
|
156
183
|
const [, ...rest] = choice.childNodes;
|
package/dist/es2015/element.js
CHANGED
|
@@ -21,13 +21,15 @@ const FORWARDED = [
|
|
|
21
21
|
"poster",
|
|
22
22
|
"crossorigin"
|
|
23
23
|
];
|
|
24
|
+
const LICENSE_URL = "license-url";
|
|
25
|
+
const CERTIFICATE_URL = "certificate-url";
|
|
24
26
|
/** Everything else the element watches. Changing any of them reloads. */
|
|
25
27
|
const OWN = [
|
|
26
28
|
"src",
|
|
27
29
|
"type",
|
|
28
30
|
"preset",
|
|
29
|
-
|
|
30
|
-
|
|
31
|
+
LICENSE_URL,
|
|
32
|
+
CERTIFICATE_URL,
|
|
31
33
|
"thumbnails",
|
|
32
34
|
NATIVE_HLS
|
|
33
35
|
];
|
|
@@ -55,6 +57,27 @@ const CONTROLS = "controls";
|
|
|
55
57
|
* control the page placed shows. Changing it never reloads.
|
|
56
58
|
*/
|
|
57
59
|
const PLAYSINLINE = "playsinline";
|
|
60
|
+
/**
|
|
61
|
+
* The size tier the controls draw for: `compact` on a small player, such
|
|
62
|
+
* as a phone held upright, `wide` on a large one, such as a TV or
|
|
63
|
+
* fullscreen, and `regular` between. The element measures itself and sets
|
|
64
|
+
* the attribute, so a stylesheet matches `mattebox-player[layout="compact"]`.
|
|
65
|
+
* A page that writes one of the three values fixes it, and removing the
|
|
66
|
+
* attribute hands it back. The player's own box decides, not the screen:
|
|
67
|
+
* a small embed on a desktop is compact, and a phone in fullscreen is not.
|
|
68
|
+
*/
|
|
69
|
+
const LAYOUT = "layout";
|
|
70
|
+
const LAYOUTS = [
|
|
71
|
+
"compact",
|
|
72
|
+
"regular",
|
|
73
|
+
"wide"
|
|
74
|
+
];
|
|
75
|
+
/** Under either, the player is compact. */
|
|
76
|
+
const COMPACT_WIDTH = 480;
|
|
77
|
+
const COMPACT_HEIGHT = 320;
|
|
78
|
+
/** From both, the player is wide. */
|
|
79
|
+
const WIDE_WIDTH = 1280;
|
|
80
|
+
const WIDE_HEIGHT = 700;
|
|
58
81
|
/** The video's state, as attributes on the element, read on the events the video fires for it. */
|
|
59
82
|
const STATE_EVENTS = [
|
|
60
83
|
"play",
|
|
@@ -93,7 +116,8 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
|
|
|
93
116
|
...OWN,
|
|
94
117
|
CONTROLS,
|
|
95
118
|
CHAPTERS,
|
|
96
|
-
PLAYSINLINE
|
|
119
|
+
PLAYSINLINE,
|
|
120
|
+
LAYOUT
|
|
97
121
|
];
|
|
98
122
|
}
|
|
99
123
|
/**
|
|
@@ -108,14 +132,18 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
|
|
|
108
132
|
}
|
|
109
133
|
constructor(options) {
|
|
110
134
|
super();
|
|
111
|
-
this.
|
|
135
|
+
this.own = options !== null && options !== void 0 ? options : null;
|
|
112
136
|
this.focusable = false;
|
|
113
137
|
this.track = null;
|
|
114
138
|
this.given = null;
|
|
139
|
+
this.list = null;
|
|
140
|
+
this.tried = "";
|
|
115
141
|
this.core = null;
|
|
116
142
|
this.current = null;
|
|
117
143
|
this.failure = null;
|
|
118
144
|
this.reflecting = false;
|
|
145
|
+
this.sizes = null;
|
|
146
|
+
this.fixed = false;
|
|
119
147
|
this.started = false;
|
|
120
148
|
this.waiting = false;
|
|
121
149
|
this.offs = [];
|
|
@@ -134,7 +162,11 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
|
|
|
134
162
|
this.marks = createMarkers(this.media, (name, detail) => this.emit(name, detail));
|
|
135
163
|
this.stage = document.createElement("div");
|
|
136
164
|
this.stage.setAttribute("part", "stage");
|
|
137
|
-
|
|
165
|
+
const slot = document.createElement("slot");
|
|
166
|
+
slot.addEventListener("slotchange", () => {
|
|
167
|
+
if (this.current === null && JSON.stringify(this.wanted()) !== this.tried) this.reload();
|
|
168
|
+
});
|
|
169
|
+
this.stage.append(slot);
|
|
138
170
|
this.surface = errorSurface(() => {
|
|
139
171
|
this.reload();
|
|
140
172
|
});
|
|
@@ -151,6 +183,19 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
|
|
|
151
183
|
get markers() {
|
|
152
184
|
return this.marks;
|
|
153
185
|
}
|
|
186
|
+
/**
|
|
187
|
+
* The sources to try in order, set from script. The `src` attribute wins
|
|
188
|
+
* over them, and they win over the `<source>` children. Setting them
|
|
189
|
+
* loads, and null returns to the children.
|
|
190
|
+
*/
|
|
191
|
+
get sources() {
|
|
192
|
+
return this.list;
|
|
193
|
+
}
|
|
194
|
+
set sources(value) {
|
|
195
|
+
this.list = value;
|
|
196
|
+
if (this.marks.list.length > 0) this.marks.set([]);
|
|
197
|
+
this.reload();
|
|
198
|
+
}
|
|
154
199
|
/** The core, or null until the first source has been set up: resolving a preset is asynchronous. */
|
|
155
200
|
get player() {
|
|
156
201
|
return this.core;
|
|
@@ -173,8 +218,28 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
|
|
|
173
218
|
if (this.media.parentNode !== this) this.append(this.media);
|
|
174
219
|
for (const name of FORWARDED) this.forward(name);
|
|
175
220
|
this.reflect();
|
|
221
|
+
if (typeof ResizeObserver !== "undefined") {
|
|
222
|
+
this.sizes = new ResizeObserver(() => {
|
|
223
|
+
this.measure();
|
|
224
|
+
});
|
|
225
|
+
this.sizes.observe(this);
|
|
226
|
+
}
|
|
227
|
+
this.measure();
|
|
176
228
|
this.reload();
|
|
177
229
|
}
|
|
230
|
+
/** Sets `layout` from the element's box, unless the page fixed it. */
|
|
231
|
+
measure() {
|
|
232
|
+
if (this.fixed) return;
|
|
233
|
+
const width = this.clientWidth;
|
|
234
|
+
const height = this.clientHeight;
|
|
235
|
+
if (width === 0 || height === 0) return;
|
|
236
|
+
const layout = width < COMPACT_WIDTH || height < COMPACT_HEIGHT ? "compact" : width >= WIDE_WIDTH && height >= WIDE_HEIGHT ? "wide" : "regular";
|
|
237
|
+
if (this.getAttribute(LAYOUT) === layout) return;
|
|
238
|
+
this.reflecting = true;
|
|
239
|
+
this.setAttribute(LAYOUT, layout);
|
|
240
|
+
this.reflecting = false;
|
|
241
|
+
this.emit("layoutchange", layout);
|
|
242
|
+
}
|
|
178
243
|
/** The two states the video does not hold: whether it has played once, and whether it waits for data. */
|
|
179
244
|
note(event) {
|
|
180
245
|
if (event === "playing") {
|
|
@@ -216,6 +281,9 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
|
|
|
216
281
|
return (type === null || type === void 0 ? void 0 : type.startsWith("audio/")) === true;
|
|
217
282
|
}
|
|
218
283
|
disconnectedCallback() {
|
|
284
|
+
var _this$sizes;
|
|
285
|
+
(_this$sizes = this.sizes) === null || _this$sizes === void 0 || _this$sizes.disconnect();
|
|
286
|
+
this.sizes = null;
|
|
219
287
|
this.enqueue(() => this.teardown());
|
|
220
288
|
}
|
|
221
289
|
attributeChangedCallback(name) {
|
|
@@ -231,6 +299,14 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
|
|
|
231
299
|
this.chapters();
|
|
232
300
|
return;
|
|
233
301
|
}
|
|
302
|
+
if (name === LAYOUT) {
|
|
303
|
+
if (this.reflecting) return;
|
|
304
|
+
const value = this.getAttribute(LAYOUT);
|
|
305
|
+
this.fixed = value !== null && LAYOUTS.includes(value);
|
|
306
|
+
if (this.fixed) this.emit("layoutchange", value);
|
|
307
|
+
else this.measure();
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
234
310
|
if (name === PLAYSINLINE) {
|
|
235
311
|
this.media.toggleAttribute(PLAYSINLINE, this.getAttribute(PLAYSINLINE) !== "false");
|
|
236
312
|
return;
|
|
@@ -331,32 +407,56 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
|
|
|
331
407
|
return _asyncToGenerator(function* () {
|
|
332
408
|
_this.unmount();
|
|
333
409
|
if (!_this.isConnected) return;
|
|
334
|
-
const
|
|
335
|
-
|
|
410
|
+
const sources = _this.wanted();
|
|
411
|
+
_this.tried = JSON.stringify(sources);
|
|
412
|
+
if (sources.length === 0) return;
|
|
336
413
|
const core = yield _this.ensure();
|
|
337
|
-
const type = _this.getAttribute("type");
|
|
338
|
-
const source = type === null ? { url } : {
|
|
339
|
-
url,
|
|
340
|
-
type
|
|
341
|
-
};
|
|
342
414
|
_this.failure = null;
|
|
343
415
|
_this.surface.clear();
|
|
344
|
-
let session;
|
|
345
416
|
try {
|
|
346
|
-
|
|
417
|
+
yield core.load(sources);
|
|
347
418
|
} catch (_unused) {
|
|
348
419
|
return;
|
|
349
420
|
}
|
|
350
|
-
if (!_this.isConnected)
|
|
351
|
-
yield core.unload();
|
|
352
|
-
return;
|
|
353
|
-
}
|
|
354
|
-
_this.current = session;
|
|
355
|
-
_this.given = null;
|
|
356
|
-
_this.configure(session);
|
|
357
|
-
_this.chapters();
|
|
421
|
+
if (!_this.isConnected) yield core.unload();
|
|
358
422
|
})();
|
|
359
423
|
}
|
|
424
|
+
/**
|
|
425
|
+
* What to load, ranked as a video ranks them: the `src` attribute, then
|
|
426
|
+
* the `sources` property, then the `<source>` children in their order.
|
|
427
|
+
* A child carries its own `license-url` and `certificate-url`.
|
|
428
|
+
*/
|
|
429
|
+
wanted() {
|
|
430
|
+
const url = this.getAttribute("src");
|
|
431
|
+
if (url !== null) {
|
|
432
|
+
const type = this.getAttribute("type");
|
|
433
|
+
return [type === null ? { url } : {
|
|
434
|
+
url,
|
|
435
|
+
type
|
|
436
|
+
}];
|
|
437
|
+
}
|
|
438
|
+
const eme = drmGuard().without === void 0;
|
|
439
|
+
if (this.list !== null) return eme ? this.list : this.list.map(({ url, type }) => type === void 0 ? { url } : {
|
|
440
|
+
url,
|
|
441
|
+
type
|
|
442
|
+
});
|
|
443
|
+
const found = [];
|
|
444
|
+
for (const child of Array.from(this.children)) {
|
|
445
|
+
const src = child.localName === "source" ? child.getAttribute("src") : null;
|
|
446
|
+
if (src === null) continue;
|
|
447
|
+
const type = child.getAttribute("type");
|
|
448
|
+
const license = child.getAttribute(LICENSE_URL);
|
|
449
|
+
const certificate = child.getAttribute(CERTIFICATE_URL);
|
|
450
|
+
found.push(_objectSpread2(_objectSpread2({ url: src }, type === null ? {} : { type }), !eme || license === null && certificate === null ? {} : { drm: _objectSpread2(_objectSpread2({}, license === null ? {} : { licenseUrl: license }), certificate === null ? {} : { certificateUrl: certificate }) }));
|
|
451
|
+
}
|
|
452
|
+
return found;
|
|
453
|
+
}
|
|
454
|
+
/** Sets a session up. It runs for every session, the one that replaces a failed source included. */
|
|
455
|
+
adopt(session) {
|
|
456
|
+
this.given = null;
|
|
457
|
+
this.configure(session);
|
|
458
|
+
this.chapters();
|
|
459
|
+
}
|
|
360
460
|
ensure() {
|
|
361
461
|
var _this2 = this;
|
|
362
462
|
return _asyncToGenerator(function* () {
|
|
@@ -364,6 +464,7 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
|
|
|
364
464
|
const core = createPlayer(_this2.media, { handlers: yield _this2.chain() });
|
|
365
465
|
_this2.offs.push(core.on("sourcechange", (session) => {
|
|
366
466
|
_this2.current = session;
|
|
467
|
+
if (session !== null && _this2.isConnected) _this2.adopt(session);
|
|
367
468
|
_this2.emit("sourcechange", session);
|
|
368
469
|
}), core.on("error", (error) => {
|
|
369
470
|
_this2.report(error);
|
|
@@ -372,6 +473,15 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
|
|
|
372
473
|
return core;
|
|
373
474
|
})();
|
|
374
475
|
}
|
|
476
|
+
/**
|
|
477
|
+
* Read at each use, not once in the constructor. Importing the package
|
|
478
|
+
* registers the element, and the parser's elements are constructed then,
|
|
479
|
+
* before the page's own `define()` call can run.
|
|
480
|
+
*/
|
|
481
|
+
get options() {
|
|
482
|
+
var _this$own;
|
|
483
|
+
return (_this$own = this.own) !== null && _this$own !== void 0 ? _this$own : defaults;
|
|
484
|
+
}
|
|
375
485
|
chain() {
|
|
376
486
|
var _this3 = this;
|
|
377
487
|
return _asyncToGenerator(function* () {
|
|
@@ -410,8 +520,8 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
|
|
|
410
520
|
drm(stages) {
|
|
411
521
|
if (drmGuard().without !== void 0) return void 0;
|
|
412
522
|
const keySystems = stages().filter((stage) => KEY_SYSTEMS.includes(stage.name));
|
|
413
|
-
const license = this.getAttribute(
|
|
414
|
-
const certificate = this.getAttribute(
|
|
523
|
+
const license = this.getAttribute(LICENSE_URL);
|
|
524
|
+
const certificate = this.getAttribute(CERTIFICATE_URL);
|
|
415
525
|
const page = this.options.drm;
|
|
416
526
|
if (keySystems.length === 0 && license === null && page === void 0) return void 0;
|
|
417
527
|
return _objectSpread2(_objectSpread2(_objectSpread2({ keySystems }, page), license === null ? {} : { licenseUrl: license }), certificate === null ? {} : { certificateUrl: certificate });
|
|
@@ -422,10 +532,14 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
|
|
|
422
532
|
const engine = session.engine;
|
|
423
533
|
if (engine === null) return;
|
|
424
534
|
const optional = namespaces(engine);
|
|
425
|
-
const
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
535
|
+
const own = session.source.drm;
|
|
536
|
+
const license = this.getAttribute(LICENSE_URL);
|
|
537
|
+
if (license !== null && (own === null || own === void 0 ? void 0 : own.licenseUrl) === void 0) (_optional$drm = optional.drm) === null || _optional$drm === void 0 || _optional$drm.setLicenseUrl(license);
|
|
538
|
+
const certificate = this.getAttribute(CERTIFICATE_URL);
|
|
539
|
+
if (certificate !== null && (own === null || own === void 0 ? void 0 : own.certificateUrl) === void 0) {
|
|
540
|
+
var _optional$drm2;
|
|
541
|
+
(_optional$drm2 = optional.drm) === null || _optional$drm2 === void 0 || _optional$drm2.setCertificateUrl(certificate);
|
|
542
|
+
}
|
|
429
543
|
const track = this.getAttribute("thumbnails");
|
|
430
544
|
if (track !== null && optional.thumbnails !== void 0) optional.thumbnails.load(track).catch(() => void 0);
|
|
431
545
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { icon } from "../controls/icons.js";
|
|
1
2
|
import { show } from "./shared.js";
|
|
2
3
|
import { nativeTracks, onNativeTracks } from "../controls/native-tracks.js";
|
|
3
4
|
import { layout, trackNames } from "../controls/track-names.js";
|
|
@@ -47,7 +48,7 @@ var MbxAudioMenu = class extends MenuElement {
|
|
|
47
48
|
];
|
|
48
49
|
}
|
|
49
50
|
constructor() {
|
|
50
|
-
super(...single("
|
|
51
|
+
super(...single("audio"));
|
|
51
52
|
this.engine = null;
|
|
52
53
|
show(this.slots, "default");
|
|
53
54
|
}
|
|
@@ -79,6 +80,7 @@ var MbxAudioMenu = class extends MenuElement {
|
|
|
79
80
|
return [entries, on === -1 ? null : String(on)];
|
|
80
81
|
}
|
|
81
82
|
render() {
|
|
83
|
+
var _this$getAttribute4;
|
|
82
84
|
super.render();
|
|
83
85
|
const engine = this.engine;
|
|
84
86
|
const player = this.player;
|
|
@@ -95,6 +97,7 @@ var MbxAudioMenu = class extends MenuElement {
|
|
|
95
97
|
this.menu.fill([{
|
|
96
98
|
name: "track",
|
|
97
99
|
items,
|
|
100
|
+
badgeGlyphs: { [(_this$getAttribute4 = this.getAttribute("label-ad")) !== null && _this$getAttribute4 !== void 0 ? _this$getAttribute4 : "AD"]: () => icon("audio-description") },
|
|
98
101
|
value: active !== null && active !== void 0 ? active : "",
|
|
99
102
|
onSelect: (value) => {
|
|
100
103
|
if (tracks !== void 0) tracks.forEach((track, index) => {
|
|
@@ -18,6 +18,16 @@ var Component = class extends HTMLElement {
|
|
|
18
18
|
customElements.upgrade(found);
|
|
19
19
|
if (!("video" in found)) return;
|
|
20
20
|
this.player = found;
|
|
21
|
+
const tier = () => {
|
|
22
|
+
const layout = found.getAttribute("layout");
|
|
23
|
+
if (layout === null) this.removeAttribute("layout");
|
|
24
|
+
else this.setAttribute("layout", layout);
|
|
25
|
+
};
|
|
26
|
+
this.listen(found, ["layoutchange"], () => {
|
|
27
|
+
tier();
|
|
28
|
+
this.render();
|
|
29
|
+
});
|
|
30
|
+
tier();
|
|
21
31
|
this.attach(this.player);
|
|
22
32
|
};
|
|
23
33
|
if ("video" in found) attach();
|