@mattebox/player 0.13.0 → 0.14.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/pip.d.ts +6 -0
- package/dist/controls/pip.d.ts.map +1 -1
- package/dist/controls/pip.js +16 -3
- package/dist/controls/pip.js.map +1 -1
- package/dist/element.d.ts.map +1 -1
- package/dist/element.js +7 -2
- package/dist/element.js.map +1 -1
- package/dist/elements/pip-button.d.ts.map +1 -1
- package/dist/elements/pip-button.js +3 -2
- package/dist/elements/pip-button.js.map +1 -1
- package/dist/elements/quality-menu.d.ts.map +1 -1
- package/dist/elements/quality-menu.js +1 -0
- package/dist/elements/quality-menu.js.map +1 -1
- package/dist/elements/spinner.d.ts +11 -9
- package/dist/elements/spinner.d.ts.map +1 -1
- package/dist/elements/spinner.js +8 -3
- package/dist/elements/spinner.js.map +1 -1
- package/dist/elements/start-button.d.ts.map +1 -1
- package/dist/elements/start-button.js +1 -1
- package/dist/elements/start-button.js.map +1 -1
- package/dist/elements/title.d.ts.map +1 -1
- package/dist/elements/title.js +6 -4
- package/dist/elements/title.js.map +1 -1
- package/dist/es2015/controls/pip.js +16 -3
- package/dist/es2015/element.js +7 -2
- package/dist/es2015/elements/pip-button.js +3 -2
- package/dist/es2015/elements/quality-menu.js +1 -0
- package/dist/es2015/elements/spinner.js +8 -3
- package/dist/es2015/elements/start-button.js +1 -1
- package/dist/es2015/elements/title.js +6 -4
- package/dist/trackers.d.ts +2 -3
- package/dist/trackers.d.ts.map +1 -1
- package/dist/trackers.js.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quality-menu.js","names":[],"sources":["../../src/elements/quality-menu.ts"],"sourcesContent":["/**\n * <mbx-quality-menu>: the pin over `engine.quality`, where \"auto\" means\n * none. Hidden without renditions, and for a native session. The name\n * comes from `label`, the word for no pin from `label-auto`. It offers\n * `engine.quality.selectable`, labelled by `qualityNames`. Under Auto, the\n * Auto row names what plays, in its detail.\n */\nimport type { Mattebox } from 'mattebox';\nimport { qualityLabels, qualityNames } from '../controls/quality-names.js';\nimport type { PlayerHost } from '../host.js';\nimport type { Messages } from '../messages.js';\nimport { MenuElement, single } from './menu-element.js';\nimport { show } from './shared.js';\n\nconst AUTO = 'auto';\n\nexport class MbxQualityMenu extends MenuElement {\n static get observedAttributes(): readonly string[] {\n return ['label', 'label-auto', 'label-back'];\n }\n\n declare private engine: Mattebox | null;\n /** The name of what plays, as the Auto row last showed it. */\n declare private playing: string | undefined;\n\n constructor() {\n super(...single('quality'));\n this.engine = null;\n this.playing = undefined;\n show(this.slots, 'default');\n }\n\n protected override name(): readonly [keyof Messages, string] {\n return ['quality', 'Quality'];\n }\n\n protected override attach(player: PlayerHost): void {\n this.follow(player, (engine) => {\n this.engine = engine;\n this.render();\n if (engine === null) return undefined;\n const tick = (): void => {\n this.render();\n };\n // What plays changes as the playhead reaches another rendition's\n // segments, and no event says so: read it on the clock, draw on a change.\n const clock = (): void => {\n if (this.playingName() !== this.playing) this.render();\n };\n player.video.addEventListener('timeupdate', clock);\n const offs = [\n () => player.video.removeEventListener('timeupdate', clock),\n engine.on('tracks:changed', tick),\n engine.on('quality:constraints-unsatisfiable', tick),\n engine.on('quality:pin-unsatisfiable', tick),\n ];\n return () => {\n for (const off of offs) off();\n };\n });\n }\n\n protected override render(): void {\n super.render();\n const engine = this.engine;\n if (engine === null) {\n this.hidden = true;\n return;\n }\n const quality = engine.quality;\n this.playing = this.playingName();\n const items: Array<readonly [string, string, (string | undefined)?]> = [\n [AUTO, this.word('label-auto', 'qualityAuto', 'Auto'), this.playing],\n ...qualityNames(quality.selectable),\n ];\n this.menu.fill([\n {\n name: 'rendition',\n items,\n value: quality.pinned ?? AUTO,\n onSelect: (value) => {\n if (value === AUTO) quality.auto();\n else quality.pin(value);\n this.render();\n },\n },\n ]);\n this.hidden = items.length === 1;\n }\n\n /** The name of the rendition that plays, under Auto only: a pin names itself by its tick. */\n private playingName(): string | undefined {\n const quality = this.engine?.quality;\n if (quality === undefined || quality.pinned !== null) return undefined;\n // Every label, twins too: what plays may be a twin the menu shows once.\n const id = quality.playing?.id;\n return qualityLabels(quality.selectable).find(([candidate]) => candidate === id)?.[1];\n }\n}\n"],"mappings":";;;;AAcA,MAAM,OAAO;AAEb,IAAa,iBAAb,cAAoC,YAAY;CAC9C,WAAW,qBAAwC;EACjD,OAAO;GAAC;GAAS;GAAc;EAAY;CAC7C;CAMA,cAAc;EACZ,MAAM,GAAG,OAAO,SAAS,CAAC;EAC1B,KAAK,SAAS;EACd,KAAK,UAAU,KAAA;EACf,KAAK,KAAK,OAAO,SAAS;CAC5B;CAEA,OAA6D;EAC3D,OAAO,CAAC,WAAW,SAAS;CAC9B;CAEA,OAA0B,QAA0B;EAClD,KAAK,OAAO,SAAS,WAAW;GAC9B,KAAK,SAAS;GACd,KAAK,OAAO;GACZ,IAAI,WAAW,MAAM,OAAO,KAAA;GAC5B,MAAM,aAAmB;IACvB,KAAK,OAAO;GACd;GAGA,MAAM,cAAoB;IACxB,IAAI,KAAK,YAAY,MAAM,KAAK,SAAS,KAAK,OAAO;GACvD;GACA,OAAO,MAAM,iBAAiB,cAAc,KAAK;GACjD,MAAM,OAAO;UACL,OAAO,MAAM,oBAAoB,cAAc,KAAK;IAC1D,OAAO,GAAG,kBAAkB,IAAI;
|
|
1
|
+
{"version":3,"file":"quality-menu.js","names":[],"sources":["../../src/elements/quality-menu.ts"],"sourcesContent":["/**\n * <mbx-quality-menu>: the pin over `engine.quality`, where \"auto\" means\n * none. Hidden without renditions, and for a native session. The name\n * comes from `label`, the word for no pin from `label-auto`. It offers\n * `engine.quality.selectable`, labelled by `qualityNames`. Under Auto, the\n * Auto row names what plays, in its detail.\n */\nimport type { Mattebox } from 'mattebox';\nimport { qualityLabels, qualityNames } from '../controls/quality-names.js';\nimport type { PlayerHost } from '../host.js';\nimport type { Messages } from '../messages.js';\nimport { MenuElement, single } from './menu-element.js';\nimport { show } from './shared.js';\n\nconst AUTO = 'auto';\n\nexport class MbxQualityMenu extends MenuElement {\n static get observedAttributes(): readonly string[] {\n return ['label', 'label-auto', 'label-back'];\n }\n\n declare private engine: Mattebox | null;\n /** The name of what plays, as the Auto row last showed it. */\n declare private playing: string | undefined;\n\n constructor() {\n super(...single('quality'));\n this.engine = null;\n this.playing = undefined;\n show(this.slots, 'default');\n }\n\n protected override name(): readonly [keyof Messages, string] {\n return ['quality', 'Quality'];\n }\n\n protected override attach(player: PlayerHost): void {\n this.follow(player, (engine) => {\n this.engine = engine;\n this.render();\n if (engine === null) return undefined;\n const tick = (): void => {\n this.render();\n };\n // What plays changes as the playhead reaches another rendition's\n // segments, and no event says so: read it on the clock, draw on a change.\n const clock = (): void => {\n if (this.playingName() !== this.playing) this.render();\n };\n player.video.addEventListener('timeupdate', clock);\n const offs = [\n () => player.video.removeEventListener('timeupdate', clock),\n engine.on('tracks:changed', tick),\n // A switch of the video track, such as to the I-frame track for a\n // scrub and back, changes the renditions without changing the list.\n engine.on('tracks:selected', tick),\n engine.on('quality:constraints-unsatisfiable', tick),\n engine.on('quality:pin-unsatisfiable', tick),\n ];\n return () => {\n for (const off of offs) off();\n };\n });\n }\n\n protected override render(): void {\n super.render();\n const engine = this.engine;\n if (engine === null) {\n this.hidden = true;\n return;\n }\n const quality = engine.quality;\n this.playing = this.playingName();\n const items: Array<readonly [string, string, (string | undefined)?]> = [\n [AUTO, this.word('label-auto', 'qualityAuto', 'Auto'), this.playing],\n ...qualityNames(quality.selectable),\n ];\n this.menu.fill([\n {\n name: 'rendition',\n items,\n value: quality.pinned ?? AUTO,\n onSelect: (value) => {\n if (value === AUTO) quality.auto();\n else quality.pin(value);\n this.render();\n },\n },\n ]);\n this.hidden = items.length === 1;\n }\n\n /** The name of the rendition that plays, under Auto only: a pin names itself by its tick. */\n private playingName(): string | undefined {\n const quality = this.engine?.quality;\n if (quality === undefined || quality.pinned !== null) return undefined;\n // Every label, twins too: what plays may be a twin the menu shows once.\n const id = quality.playing?.id;\n return qualityLabels(quality.selectable).find(([candidate]) => candidate === id)?.[1];\n }\n}\n"],"mappings":";;;;AAcA,MAAM,OAAO;AAEb,IAAa,iBAAb,cAAoC,YAAY;CAC9C,WAAW,qBAAwC;EACjD,OAAO;GAAC;GAAS;GAAc;EAAY;CAC7C;CAMA,cAAc;EACZ,MAAM,GAAG,OAAO,SAAS,CAAC;EAC1B,KAAK,SAAS;EACd,KAAK,UAAU,KAAA;EACf,KAAK,KAAK,OAAO,SAAS;CAC5B;CAEA,OAA6D;EAC3D,OAAO,CAAC,WAAW,SAAS;CAC9B;CAEA,OAA0B,QAA0B;EAClD,KAAK,OAAO,SAAS,WAAW;GAC9B,KAAK,SAAS;GACd,KAAK,OAAO;GACZ,IAAI,WAAW,MAAM,OAAO,KAAA;GAC5B,MAAM,aAAmB;IACvB,KAAK,OAAO;GACd;GAGA,MAAM,cAAoB;IACxB,IAAI,KAAK,YAAY,MAAM,KAAK,SAAS,KAAK,OAAO;GACvD;GACA,OAAO,MAAM,iBAAiB,cAAc,KAAK;GACjD,MAAM,OAAO;UACL,OAAO,MAAM,oBAAoB,cAAc,KAAK;IAC1D,OAAO,GAAG,kBAAkB,IAAI;IAGhC,OAAO,GAAG,mBAAmB,IAAI;IACjC,OAAO,GAAG,qCAAqC,IAAI;IACnD,OAAO,GAAG,6BAA6B,IAAI;GAC7C;GACA,aAAa;IACX,KAAK,MAAM,OAAO,MAAM,IAAI;GAC9B;EACF,CAAC;CACH;CAEA,SAAkC;EAChC,MAAM,OAAO;EACb,MAAM,SAAS,KAAK;EACpB,IAAI,WAAW,MAAM;GACnB,KAAK,SAAS;GACd;EACF;EACA,MAAM,UAAU,OAAO;EACvB,KAAK,UAAU,KAAK,YAAY;EAChC,MAAM,QAAiE,CACrE;GAAC;GAAM,KAAK,KAAK,cAAc,eAAe,MAAM;GAAG,KAAK;EAAO,GACnE,GAAG,aAAa,QAAQ,UAAU,CACpC;EACA,KAAK,KAAK,KAAK,CACb;GACE,MAAM;GACN;GACA,OAAO,QAAQ,UAAU;GACzB,WAAW,UAAU;IACnB,IAAI,UAAU,MAAM,QAAQ,KAAK;SAC5B,QAAQ,IAAI,KAAK;IACtB,KAAK,OAAO;GACd;EACF,CACF,CAAC;EACD,KAAK,SAAS,MAAM,WAAW;CACjC;;CAGA,cAA0C;EACxC,MAAM,UAAU,KAAK,QAAQ;EAC7B,IAAI,YAAY,KAAA,KAAa,QAAQ,WAAW,MAAM,OAAO,KAAA;EAE7D,MAAM,KAAK,QAAQ,SAAS;EAC5B,OAAO,cAAc,QAAQ,UAAU,CAAC,CAAC,MAAM,CAAC,eAAe,cAAc,EAAE,CAAC,GAAG;CACrF;AACF"}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* <mbx-spinner>: shows while the video waits for data
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
2
|
+
* <mbx-spinner>: shows while the video plays and waits for data. A wait
|
|
3
|
+
* while paused, such as a seek, leaves the start button in place. A drag on
|
|
4
|
+
* the seek bar and a switch to another source count as the state from
|
|
5
|
+
* before, as they do for the play buttons. It sits in the player beside the
|
|
6
|
+
* video, centred over the picture, so it is over the poster and inside
|
|
7
|
+
* fullscreen. It reads the video's `waiting`, `playing`, `canplay`,
|
|
8
|
+
* `emptied`, `play` and `pause`, and carries `waiting` on itself so its
|
|
9
|
+
* stylesheet shows it. It takes the start button's place: a thin ring
|
|
10
|
+
* turns there, a white head on a faint track, in the same monochrome as the
|
|
11
|
+
* controls. The glyph is the `icon` slot, for a page's own; the name comes
|
|
12
|
+
* from `label`.
|
|
11
13
|
*/
|
|
12
14
|
import type { PlayerHost } from '../host.js';
|
|
13
15
|
import { Component } from './component.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spinner.d.ts","sourceRoot":"","sources":["../../src/elements/spinner.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"spinner.d.ts","sourceRoot":"","sources":["../../src/elements/spinner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAO3C,qBAAa,UAAW,SAAQ,SAAS;IACvC,MAAM,KAAK,kBAAkB,IAAI,SAAS,MAAM,EAAE,CAEjD;IAED,iBAAyB,IAAI,CAAc;IAC3C,iBAAyB,KAAK,CAAkB;;IAgBhD,qEAAqE;IAC5D,iBAAiB,IAAI,IAAI;cAKf,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;cAWhC,MAAM,IAAI,IAAI;cAId,MAAM,IAAI,IAAI;CAQlC"}
|
package/dist/elements/spinner.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Component } from "./component.js";
|
|
2
|
-
import { style } from "./shared.js";
|
|
2
|
+
import { HELD, shownPaused, style } from "./shared.js";
|
|
3
3
|
// src/elements/spinner.ts
|
|
4
4
|
const STYLE = ":host{pointer-events:none;width:2.75em;height:2.75em;color:var(--mbx-text);filter:drop-shadow(0 1px 3px #00000080);margin:-1.375em 0 0 -1.375em;display:none;position:absolute;top:50%;left:50%}:host([waiting]){display:block}:host([hidden]){display:none}[part~=ring]{box-sizing:border-box;border:3px solid #ffffff38;border-top-color:currentColor;border-radius:50%;width:100%;height:100%;animation:.8s linear infinite mbx-turn}[part~=ring][hidden],slot[hidden]{display:none}::slotted(*){width:100%;height:100%}@keyframes mbx-turn{to{transform:rotate(360deg)}}@media (prefers-reduced-motion:reduce){[part~=ring]{animation:none}}";
|
|
5
5
|
/** What the video fires as it waits and as it goes on. */
|
|
@@ -7,7 +7,9 @@ const EVENTS = [
|
|
|
7
7
|
"waiting",
|
|
8
8
|
"playing",
|
|
9
9
|
"canplay",
|
|
10
|
-
"emptied"
|
|
10
|
+
"emptied",
|
|
11
|
+
"play",
|
|
12
|
+
"pause"
|
|
11
13
|
];
|
|
12
14
|
var MbxSpinner = class extends Component {
|
|
13
15
|
static get observedAttributes() {
|
|
@@ -35,6 +37,9 @@ var MbxSpinner = class extends Component {
|
|
|
35
37
|
this.listen(video, EVENTS, () => {
|
|
36
38
|
this.render();
|
|
37
39
|
});
|
|
40
|
+
this.observe(player, HELD, () => {
|
|
41
|
+
this.render();
|
|
42
|
+
});
|
|
38
43
|
this.render();
|
|
39
44
|
}
|
|
40
45
|
detach() {
|
|
@@ -44,7 +49,7 @@ var MbxSpinner = class extends Component {
|
|
|
44
49
|
const player = this.player;
|
|
45
50
|
if (player === null) return;
|
|
46
51
|
this.setAttribute("aria-label", this.word("label", "loading", "Loading"));
|
|
47
|
-
this.toggleAttribute("waiting", player.hasAttribute("waiting"));
|
|
52
|
+
this.toggleAttribute("waiting", player.hasAttribute("waiting") && !shownPaused(player));
|
|
48
53
|
}
|
|
49
54
|
};
|
|
50
55
|
export { MbxSpinner };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spinner.js","names":[],"sources":["../../src/elements/spinner.ts"],"sourcesContent":["/**\n * <mbx-spinner>: shows while the video waits for data,
|
|
1
|
+
{"version":3,"file":"spinner.js","names":[],"sources":["../../src/elements/spinner.ts"],"sourcesContent":["/**\n * <mbx-spinner>: shows while the video plays and waits for data. A wait\n * while paused, such as a seek, leaves the start button in place. A drag on\n * the seek bar and a switch to another source count as the state from\n * before, as they do for the play buttons. It sits in the player beside the\n * video, centred over the picture, so it is over the poster and inside\n * fullscreen. It reads the video's `waiting`, `playing`, `canplay`,\n * `emptied`, `play` and `pause`, and carries `waiting` on itself so its\n * stylesheet shows it. It takes the start button's place: a thin ring\n * turns there, a white head on a faint track, in the same monochrome as the\n * controls. The glyph is the `icon` slot, for a page's own; the name comes\n * from `label`.\n */\nimport type { PlayerHost } from '../host.js';\nimport { Component } from './component.js';\nimport { HELD, shownPaused, style } from './shared.js';\nimport STYLE from './spinner.css?inline';\n\n/** What the video fires as it waits and as it goes on. */\nconst EVENTS = ['waiting', 'playing', 'canplay', 'emptied', 'play', 'pause'];\n\nexport class MbxSpinner extends Component {\n static get observedAttributes(): readonly string[] {\n return ['label'];\n }\n\n declare private readonly ring: HTMLElement;\n declare private readonly slot_: HTMLSlotElement;\n\n constructor() {\n super();\n const root = this.attachShadow({ mode: 'open' });\n this.ring = document.createElement('div');\n this.ring.setAttribute('part', 'ring');\n this.slot_ = document.createElement('slot');\n this.slot_.name = 'icon';\n // A page's own glyph replaces the ring: the slot is watched for it.\n this.slot_.addEventListener('slotchange', () => {\n this.ring.hidden = this.slot_.assignedNodes().length > 0;\n });\n root.append(style(STYLE), this.ring, this.slot_);\n }\n\n /** Named before attaching: a constructor must not add attributes. */\n override connectedCallback(): void {\n if (!this.hasAttribute('role')) this.setAttribute('role', 'status');\n super.connectedCallback();\n }\n\n protected override attach(player: PlayerHost): void {\n const video = player.video;\n this.listen(video, EVENTS, () => {\n this.render();\n });\n this.observe(player, HELD, () => {\n this.render();\n });\n this.render();\n }\n\n protected override detach(): void {\n this.removeAttribute('waiting');\n }\n\n protected override render(): void {\n const player = this.player;\n if (player === null) return;\n this.setAttribute('aria-label', this.word('label', 'loading', 'Loading'));\n // The player reflects the same events, and reads them first: it listens\n // from its constructor, before any control attaches.\n this.toggleAttribute('waiting', player.hasAttribute('waiting') && !shownPaused(player));\n }\n}\n"],"mappings":";;;AAgBA,MAAA,QAAA;;AAGA,MAAA,SAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;AAAA;AAEA,IAAA,aAAA,cAAA,UAAA;CACA,WAAA,qBAAA;EACA,OAAA,CAAA,OAAA;CACA;CAKA,cAAA;EACA,MAAA;EACA,MAAA,OAAA,KAAA,aAAA,EAAA,MAAA,OAAA,CAAA;EACA,KAAA,OAAA,SAAA,cAAA,KAAA;EACA,KAAA,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AM,EAAE,UAAU,GAAG,IAAI;cAwChC,MAAM,IAAI,IAAI;IAOjC;;;;;;;;;;;;;OAaG;IACH,OAAO,CAAC,GAAG;cAqBQ,MAAM,IAAI,IAAI;
|
|
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;CAgBlC"}
|
|
@@ -114,7 +114,7 @@ var MbxStartButton = class extends Component {
|
|
|
114
114
|
show(this.slots, state);
|
|
115
115
|
this.button.setAttribute("aria-label", state === "play" ? this.word("label-play", "play", "Play") : this.word("label-replay", "replay", "Replay"));
|
|
116
116
|
const player = this.player;
|
|
117
|
-
this.hidden = this.failed || player !== null && !shownPaused(player
|
|
117
|
+
this.hidden = this.failed || player !== null && !shownPaused(player);
|
|
118
118
|
}
|
|
119
119
|
};
|
|
120
120
|
export { MbxStartButton };
|
|
@@ -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
|
|
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 and while a fatal error is on screen. A drag on the seek bar (the\n * player carries `scrubbing`) and a switch to another source keep the\n * state from before, so a seek while paused keeps it in place, and a seek\n * while playing never shows it. It sits in the player beside the video,\n * not in the bar, so it is over the poster and inside fullscreen. While the\n * video plays and waits for data, the spinner takes the centre. The glyph\n * is `icon-play` or `icon-replay`, the name `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', '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 state === 'play'\n ? this.word('label-play', 'play', 'Play')\n : this.word('label-replay', 'replay', 'Replay'),\n );\n // A wait while paused, such as a seek, keeps the button: the spinner\n // shows only while the video plays.\n const player = this.player;\n this.hidden = this.failed || (player !== null && !shownPaused(player));\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,OAAA;EACA,KAAA,OAAA,aAAA,QAAA,QAAA;EACA,KAAA,QAAA,UAAA,QAAA,IAAA;EACA,KAAA,MAAA,SAAA,QAAA,KAAA,OAAA,OAAA,KAAA,MAAA,MAAA;EACA,KAAA,OAAA,iBAAA,eAAA;GACA,KAAA,QAAA,MAAA,KAAA,CAAA,CAAA,YAAA,KAAA,CAAA;EACA,CAAA;EACA,KAAA,OAAA,MAAA,KAAA,GAAA,KAAA,MAAA;CACA;CAEA,OAAA,QAAA;EACA,MAAA,QAAA,OAAA;EACA,KAAA,OAAA,OAAA;GAAA;GAAA;GAAA;GAAA;GAAA;EAAA,SAAA;GACA,KAAA,OAAA;EACA,CAAA;EACA,KAAA,OAAA,OAAA,CAAA,WAAA,WAAA,SAAA;GACA,KAAA,SAAA;GACA,KAAA,OAAA;EACA,CAAA;EACA,KAAA,OAAA,QAAA,CAAA,cAAA,SAAA;GACA,KAAA,SAAA;GACA,KAAA,OAAA;EACA,CAAA;EACA,KAAA,QAAA,QAAA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A;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,UAAA,SACA,KAAA,KAAA,cAAA,QAAA,MAAA,IACA,KAAA,KAAA,gBAAA,UAAA,QAAA,CACA;EAGA,MAAA,SAAA,KAAA;EACA,KAAA,SAAA,KAAA,UAAA,WAAA,QAAA,CAAA,YAAA,MAAA;CACA;AACA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"title.d.ts","sourceRoot":"","sources":["../../src/elements/title.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"title.d.ts","sourceRoot":"","sources":["../../src/elements/title.ts"],"names":[],"mappings":"AA4BA,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;cAyBhC,MAAM,IAAI,IAAI;IAOjC,uEAAuE;IACvE,OAAO,CAAC,KAAK;IAKb,gHAAgH;IAChH,OAAO,CAAC,GAAG;cAUQ,MAAM,IAAI,IAAI;CAgBlC"}
|
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 { shownPaused, style } from "./shared.js";
|
|
3
|
+
import { HELD, shownPaused, style } from "./shared.js";
|
|
4
4
|
// src/elements/title.ts
|
|
5
5
|
/**
|
|
6
6
|
* <mbx-title>: the heading, the subheading and the artwork of what plays,
|
|
@@ -16,7 +16,9 @@ import { shownPaused, style } from "./shared.js";
|
|
|
16
16
|
* the element draws nothing.
|
|
17
17
|
*
|
|
18
18
|
* Shown while the video is paused, which includes before the first play,
|
|
19
|
-
* and hidden while it plays.
|
|
19
|
+
* and hidden while it plays. A drag on the seek bar and a switch to another
|
|
20
|
+
* source keep the state from before, so a seek while playing never shows
|
|
21
|
+
* it. The element carries `playing` for that rule,
|
|
20
22
|
* so a page changes it in CSS: `mattebox-player[started] mbx-title
|
|
21
23
|
* { display: none }` keeps it to the time before the first play, like the
|
|
22
24
|
* poster, and `mattebox-player:hover mbx-title { display: flex }` brings it
|
|
@@ -58,7 +60,7 @@ var MbxTitle = class extends Component {
|
|
|
58
60
|
], () => {
|
|
59
61
|
this.state(player);
|
|
60
62
|
});
|
|
61
|
-
this.observe(player,
|
|
63
|
+
this.observe(player, HELD, () => {
|
|
62
64
|
this.state(player);
|
|
63
65
|
});
|
|
64
66
|
this.listen(player, ["programmechange"], () => {
|
|
@@ -84,7 +86,7 @@ var MbxTitle = class extends Component {
|
|
|
84
86
|
}
|
|
85
87
|
/** `playing` on the element, for its own stylesheet and the page's. */
|
|
86
88
|
state(player) {
|
|
87
|
-
this.toggleAttribute("playing", !shownPaused(player
|
|
89
|
+
this.toggleAttribute("playing", !shownPaused(player));
|
|
88
90
|
}
|
|
89
91
|
/** The height of the bar's rows: its box less the padding above them, which is its fade. Zero without a bar. */
|
|
90
92
|
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 * A heading or subheading the page leaves out takes the programme's title\n * or subtitle, from what a connector resolved. The artwork comes from the\n * attribute only: the programme's image is the poster already. With none,\n * 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,
|
|
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 * A heading or subheading the page leaves out takes the programme's title\n * or subtitle, from what a connector resolved. The artwork comes from the\n * attribute only: the programme's image is the poster already. With none,\n * the element draws nothing.\n *\n * Shown while the video is paused, which includes before the first play,\n * and hidden while it plays. A drag on the seek bar and a switch to another\n * source keep the state from before, so a seek while playing never shows\n * it. 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 { HELD, 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, HELD, () => {\n this.state(player);\n });\n this.listen(player, ['programmechange'], () => {\n this.render();\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 // The pause of a drag or of a switch to another source is no pause.\n this.toggleAttribute('playing', !shownPaused(player));\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 metadata = this.player?.programme?.metadata;\n const heading = this.getAttribute('heading') ?? metadata?.title ?? '';\n const subheading = this.getAttribute('subheading') ?? metadata?.subtitle ?? '';\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,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,aA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,CAAA,SAAA,GAAA;EACA;EACA,KAAA,MAAA,YAAA,kBAAA,GAAA,KAAA,GAAA;CACA;CAEA,SAAA;EACA,MAAA,WAAA,KAAA,QAAA,WAAA;EACA,MAAA,UAAA,KAAA,aAAA,SAAA,KAAA,UAAA,SAAA;EACA,MAAA,aAAA,KAAA,aAAA,YAAA,KAAA,UAAA,YAAA;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,17 +1,28 @@
|
|
|
1
1
|
// src/controls/pip.ts
|
|
2
|
-
|
|
2
|
+
/** The attribute that turns picture in picture off for one video. */
|
|
3
|
+
const DISABLE = "disablepictureinpicture";
|
|
4
|
+
/** Watches `names` on the video, and the attribute that turns the feature off. */
|
|
5
|
+
function watching(video, names) {
|
|
3
6
|
return (fn) => {
|
|
4
|
-
for (const name of names)
|
|
7
|
+
for (const name of names) video.addEventListener(name, fn);
|
|
8
|
+
const observer = new MutationObserver(fn);
|
|
9
|
+
observer.observe(video, {
|
|
10
|
+
attributes: true,
|
|
11
|
+
attributeFilter: [DISABLE]
|
|
12
|
+
});
|
|
5
13
|
return () => {
|
|
6
|
-
for (const name of names)
|
|
14
|
+
for (const name of names) video.removeEventListener(name, fn);
|
|
15
|
+
observer.disconnect();
|
|
7
16
|
};
|
|
8
17
|
};
|
|
9
18
|
}
|
|
10
19
|
function pictureInPicture(video) {
|
|
11
20
|
var _safari$webkitSupport;
|
|
12
21
|
const safari = video;
|
|
22
|
+
const allowed = () => !video.hasAttribute(DISABLE);
|
|
13
23
|
if (typeof video.requestPictureInPicture === "function" && document.pictureInPictureEnabled) return {
|
|
14
24
|
supported: true,
|
|
25
|
+
allowed,
|
|
15
26
|
active: () => document.pictureInPictureElement === video,
|
|
16
27
|
toggle() {
|
|
17
28
|
(document.pictureInPictureElement === video ? document.exitPictureInPicture() : video.requestPictureInPicture()).catch(() => void 0);
|
|
@@ -20,6 +31,7 @@ function pictureInPicture(video) {
|
|
|
20
31
|
};
|
|
21
32
|
if (typeof safari.webkitSetPresentationMode === "function" && ((_safari$webkitSupport = safari.webkitSupportsPresentationMode) === null || _safari$webkitSupport === void 0 ? void 0 : _safari$webkitSupport.call(safari, "picture-in-picture")) === true) return {
|
|
22
33
|
supported: true,
|
|
34
|
+
allowed,
|
|
23
35
|
active: () => safari.webkitPresentationMode === "picture-in-picture",
|
|
24
36
|
toggle() {
|
|
25
37
|
var _safari$webkitSetPres;
|
|
@@ -30,6 +42,7 @@ function pictureInPicture(video) {
|
|
|
30
42
|
};
|
|
31
43
|
return {
|
|
32
44
|
supported: false,
|
|
45
|
+
allowed,
|
|
33
46
|
active: () => false,
|
|
34
47
|
toggle() {},
|
|
35
48
|
watch: () => () => {}
|
package/dist/es2015/element.js
CHANGED
|
@@ -21,12 +21,17 @@ import { createPlayer, inferType, matteboxHandler, nativeHandler, preferNativeHl
|
|
|
21
21
|
* fullscreen then work as Apple built them. Changing it reloads.
|
|
22
22
|
*/
|
|
23
23
|
const NATIVE_HLS = "native-hls";
|
|
24
|
-
/**
|
|
24
|
+
/**
|
|
25
|
+
* Attributes forwarded onto the video as attributes, never as properties.
|
|
26
|
+
* `disablepictureinpicture` also hides the browser's own picture-in-picture
|
|
27
|
+
* toggle, which Firefox draws over every video that lacks it.
|
|
28
|
+
*/
|
|
25
29
|
const FORWARDED = [
|
|
26
30
|
"autoplay",
|
|
27
31
|
"muted",
|
|
28
32
|
"poster",
|
|
29
|
-
"crossorigin"
|
|
33
|
+
"crossorigin",
|
|
34
|
+
"disablepictureinpicture"
|
|
30
35
|
];
|
|
31
36
|
const LICENSE_URL = "license-url";
|
|
32
37
|
/** The language the page chose, over the nearest `lang`. */
|
|
@@ -5,7 +5,8 @@ import { pictureInPicture } from "../controls/pip.js";
|
|
|
5
5
|
// src/elements/pip-button.ts
|
|
6
6
|
/**
|
|
7
7
|
* <mbx-pip-button>: picture in picture, through whichever API the browser
|
|
8
|
-
* has, and hidden where there is none
|
|
8
|
+
* has, and hidden where there is none or the player has
|
|
9
|
+
* `disablepictureinpicture`. The glyph is `icon-enter` or
|
|
9
10
|
* `icon-exit`, the name `label-enter` or `label-exit`, and the element
|
|
10
11
|
* sets `pip` on the player while the video is in the floating window.
|
|
11
12
|
*/
|
|
@@ -32,7 +33,6 @@ var MbxPipButton = class extends Component {
|
|
|
32
33
|
attach(player) {
|
|
33
34
|
const api = pictureInPicture(player.video);
|
|
34
35
|
this.api = api;
|
|
35
|
-
this.hidden = !api.supported;
|
|
36
36
|
this.keep(api.watch(() => {
|
|
37
37
|
this.render();
|
|
38
38
|
}));
|
|
@@ -46,6 +46,7 @@ var MbxPipButton = class extends Component {
|
|
|
46
46
|
const player = this.player;
|
|
47
47
|
if (player === null || this.api === null) return;
|
|
48
48
|
const active = this.api.active();
|
|
49
|
+
this.hidden = !this.api.supported || !this.api.allowed() && !active;
|
|
49
50
|
show(this.slots, active ? "exit" : "enter");
|
|
50
51
|
this.button.setAttribute("aria-label", active ? this.word("label-exit", "exitPip", "Leave picture in picture") : this.word("label-enter", "enterPip", "Picture in picture"));
|
|
51
52
|
player.toggleAttribute("pip", active);
|
|
@@ -35,6 +35,7 @@ var MbxQualityMenu = class extends MenuElement {
|
|
|
35
35
|
const offs = [
|
|
36
36
|
() => player.video.removeEventListener("timeupdate", clock),
|
|
37
37
|
engine.on("tracks:changed", tick),
|
|
38
|
+
engine.on("tracks:selected", tick),
|
|
38
39
|
engine.on("quality:constraints-unsatisfiable", tick),
|
|
39
40
|
engine.on("quality:pin-unsatisfiable", tick)
|
|
40
41
|
];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Component } from "./component.js";
|
|
2
|
-
import { style } from "./shared.js";
|
|
2
|
+
import { HELD, shownPaused, style } from "./shared.js";
|
|
3
3
|
// src/elements/spinner.ts
|
|
4
4
|
const STYLE = ":host{pointer-events:none;width:2.75em;height:2.75em;color:var(--mbx-text);filter:drop-shadow(0 1px 3px #00000080);margin:-1.375em 0 0 -1.375em;display:none;position:absolute;top:50%;left:50%}:host([waiting]){display:block}:host([hidden]){display:none}[part~=ring]{box-sizing:border-box;border:3px solid #ffffff38;border-top-color:currentColor;border-radius:50%;width:100%;height:100%;animation:.8s linear infinite mbx-turn}[part~=ring][hidden],slot[hidden]{display:none}::slotted(*){width:100%;height:100%}@keyframes mbx-turn{to{transform:rotate(360deg)}}@media (prefers-reduced-motion:reduce){[part~=ring]{animation:none}}";
|
|
5
5
|
/** What the video fires as it waits and as it goes on. */
|
|
@@ -7,7 +7,9 @@ const EVENTS = [
|
|
|
7
7
|
"waiting",
|
|
8
8
|
"playing",
|
|
9
9
|
"canplay",
|
|
10
|
-
"emptied"
|
|
10
|
+
"emptied",
|
|
11
|
+
"play",
|
|
12
|
+
"pause"
|
|
11
13
|
];
|
|
12
14
|
var MbxSpinner = class extends Component {
|
|
13
15
|
static get observedAttributes() {
|
|
@@ -35,6 +37,9 @@ var MbxSpinner = class extends Component {
|
|
|
35
37
|
this.listen(video, EVENTS, () => {
|
|
36
38
|
this.render();
|
|
37
39
|
});
|
|
40
|
+
this.observe(player, HELD, () => {
|
|
41
|
+
this.render();
|
|
42
|
+
});
|
|
38
43
|
this.render();
|
|
39
44
|
}
|
|
40
45
|
detach() {
|
|
@@ -44,7 +49,7 @@ var MbxSpinner = class extends Component {
|
|
|
44
49
|
const player = this.player;
|
|
45
50
|
if (player === null) return;
|
|
46
51
|
this.setAttribute("aria-label", this.word("label", "loading", "Loading"));
|
|
47
|
-
this.toggleAttribute("waiting", player.hasAttribute("waiting"));
|
|
52
|
+
this.toggleAttribute("waiting", player.hasAttribute("waiting") && !shownPaused(player));
|
|
48
53
|
}
|
|
49
54
|
};
|
|
50
55
|
export { MbxSpinner };
|
|
@@ -117,7 +117,7 @@ var MbxStartButton = class extends Component {
|
|
|
117
117
|
show(this.slots, state);
|
|
118
118
|
this.button.setAttribute("aria-label", state === "play" ? this.word("label-play", "play", "Play") : this.word("label-replay", "replay", "Replay"));
|
|
119
119
|
const player = this.player;
|
|
120
|
-
this.hidden = this.failed || player !== null && !shownPaused(player
|
|
120
|
+
this.hidden = this.failed || player !== null && !shownPaused(player);
|
|
121
121
|
}
|
|
122
122
|
};
|
|
123
123
|
export { MbxStartButton };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { el } from "../dom.js";
|
|
2
2
|
import { Component } from "./component.js";
|
|
3
|
-
import { shownPaused, style } from "./shared.js";
|
|
3
|
+
import { HELD, shownPaused, style } from "./shared.js";
|
|
4
4
|
// src/elements/title.ts
|
|
5
5
|
/**
|
|
6
6
|
* <mbx-title>: the heading, the subheading and the artwork of what plays,
|
|
@@ -16,7 +16,9 @@ import { shownPaused, style } from "./shared.js";
|
|
|
16
16
|
* the element draws nothing.
|
|
17
17
|
*
|
|
18
18
|
* Shown while the video is paused, which includes before the first play,
|
|
19
|
-
* and hidden while it plays.
|
|
19
|
+
* and hidden while it plays. A drag on the seek bar and a switch to another
|
|
20
|
+
* source keep the state from before, so a seek while playing never shows
|
|
21
|
+
* it. The element carries `playing` for that rule,
|
|
20
22
|
* so a page changes it in CSS: `mattebox-player[started] mbx-title
|
|
21
23
|
* { display: none }` keeps it to the time before the first play, like the
|
|
22
24
|
* poster, and `mattebox-player:hover mbx-title { display: flex }` brings it
|
|
@@ -58,7 +60,7 @@ var MbxTitle = class extends Component {
|
|
|
58
60
|
], () => {
|
|
59
61
|
this.state(player);
|
|
60
62
|
});
|
|
61
|
-
this.observe(player,
|
|
63
|
+
this.observe(player, HELD, () => {
|
|
62
64
|
this.state(player);
|
|
63
65
|
});
|
|
64
66
|
this.listen(player, ["programmechange"], () => {
|
|
@@ -85,7 +87,7 @@ var MbxTitle = class extends Component {
|
|
|
85
87
|
}
|
|
86
88
|
/** `playing` on the element, for its own stylesheet and the page's. */
|
|
87
89
|
state(player) {
|
|
88
|
-
this.toggleAttribute("playing", !shownPaused(player
|
|
90
|
+
this.toggleAttribute("playing", !shownPaused(player));
|
|
89
91
|
}
|
|
90
92
|
/** The height of the bar's rows: its box less the padding above them, which is its fade. Zero without a bar. */
|
|
91
93
|
fit(player) {
|
package/dist/trackers.d.ts
CHANGED
|
@@ -2,9 +2,8 @@
|
|
|
2
2
|
* The trackers of one player: what the page added, started at each
|
|
3
3
|
* programme and stopped at its end. The page decides which trackers run,
|
|
4
4
|
* and when it adds or removes them; the player only starts and stops them.
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* consent is the page's to decide.
|
|
5
|
+
* A tracker is enabled at the start of a programme and disabled at its
|
|
6
|
+
* end. The player has no tracking switch: consent is the page's to decide.
|
|
8
7
|
*/
|
|
9
8
|
import type { Programme } from '@mattebox/player-core';
|
|
10
9
|
import type { PlayerHost, Tracker, Trackers } from './host.js';
|
package/dist/trackers.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trackers.d.ts","sourceRoot":"","sources":["../src/trackers.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"trackers.d.ts","sourceRoot":"","sources":["../src/trackers.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAE/D,YAAY,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC;AAElC,8EAA8E;AAC9E,MAAM,WAAW,aAAc,SAAQ,QAAQ;IAC7C,KAAK,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI,GAAG,IAAI,CAAC;CAC1C;AAaD,2FAA2F;AAC3F,wBAAgB,cAAc,CAAC,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,IAAI,GAAG,aAAa,CA8BnF"}
|
package/dist/trackers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trackers.js","names":[],"sources":["../src/trackers.ts"],"sourcesContent":["/**\n * The trackers of one player: what the page added, started at each\n * programme and stopped at its end. The page decides which trackers run,\n * and when it adds or removes them; the player only starts and stops them.\n *
|
|
1
|
+
{"version":3,"file":"trackers.js","names":[],"sources":["../src/trackers.ts"],"sourcesContent":["/**\n * The trackers of one player: what the page added, started at each\n * programme and stopped at its end. The page decides which trackers run,\n * and when it adds or removes them; the player only starts and stops them.\n * A tracker is enabled at the start of a programme and disabled at its\n * end. The player has no tracking switch: consent is the page's to decide.\n */\nimport type { Programme } from '@mattebox/player-core';\nimport type { PlayerHost, Tracker, Trackers } from './host.js';\n\nexport type { Tracker, Trackers };\n\n/** What the element drives: the programme that starts, or null at its end. */\nexport interface TrackerRunner extends Trackers {\n begin(programme: Programme | null): void;\n}\n\n/** Runs `fn`, and throws its error on a task of its own: one tracker's bug stops neither playback nor the others. */\nfunction guard(fn: () => void): void {\n try {\n fn();\n } catch (error) {\n setTimeout(() => {\n throw error;\n });\n }\n}\n\n/** The trackers of `host`. `changed` runs after each start, stop, addition and removal. */\nexport function createTrackers(host: PlayerHost, changed: () => void): TrackerRunner {\n const set = new Set<Tracker>();\n let current: Programme | null = null;\n return {\n add(tracker) {\n if (set.has(tracker)) return;\n set.add(tracker);\n const programme = current;\n if (programme !== null) guard(() => tracker.start(programme, host));\n changed();\n },\n delete(tracker) {\n if (!set.delete(tracker)) return false;\n if (current !== null) guard(() => tracker.stop());\n changed();\n return true;\n },\n has: (tracker) => set.has(tracker),\n get list() {\n return [...set];\n },\n begin(programme) {\n if (current === null && programme === null) return;\n if (current !== null) for (const tracker of set) guard(() => tracker.stop());\n current = programme;\n if (programme !== null)\n for (const tracker of set) guard(() => tracker.start(programme, host));\n changed();\n },\n };\n}\n"],"mappings":";;AAkBA,SAAS,MAAM,IAAsB;CACnC,IAAI;EACF,GAAG;CACL,SAAS,OAAO;EACd,iBAAiB;GACf,MAAM;EACR,CAAC;CACH;AACF;;AAGA,SAAgB,eAAe,MAAkB,SAAoC;CACnF,MAAM,sBAAM,IAAI,IAAa;CAC7B,IAAI,UAA4B;CAChC,OAAO;EACL,IAAI,SAAS;GACX,IAAI,IAAI,IAAI,OAAO,GAAG;GACtB,IAAI,IAAI,OAAO;GACf,MAAM,YAAY;GAClB,IAAI,cAAc,MAAM,YAAY,QAAQ,MAAM,WAAW,IAAI,CAAC;GAClE,QAAQ;EACV;EACA,OAAO,SAAS;GACd,IAAI,CAAC,IAAI,OAAO,OAAO,GAAG,OAAO;GACjC,IAAI,YAAY,MAAM,YAAY,QAAQ,KAAK,CAAC;GAChD,QAAQ;GACR,OAAO;EACT;EACA,MAAM,YAAY,IAAI,IAAI,OAAO;EACjC,IAAI,OAAO;GACT,OAAO,CAAC,GAAG,GAAG;EAChB;EACA,MAAM,WAAW;GACf,IAAI,YAAY,QAAQ,cAAc,MAAM;GAC5C,IAAI,YAAY,MAAM,KAAK,MAAM,WAAW,KAAK,YAAY,QAAQ,KAAK,CAAC;GAC3E,UAAU;GACV,IAAI,cAAc,MAChB,KAAK,MAAM,WAAW,KAAK,YAAY,QAAQ,MAAM,WAAW,IAAI,CAAC;GACvE,QAAQ;EACV;CACF;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mattebox/player",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"description": "A <mattebox-player> custom element over @mattebox/player-core.",
|
|
5
5
|
"author": "Josep Boix Requesens",
|
|
6
6
|
"repository": {
|
|
@@ -80,6 +80,6 @@
|
|
|
80
80
|
"@mattebox/player-core": "^0.9.0"
|
|
81
81
|
},
|
|
82
82
|
"peerDependencies": {
|
|
83
|
-
"mattebox": "^0.17.
|
|
83
|
+
"mattebox": "^0.17.1"
|
|
84
84
|
}
|
|
85
85
|
}
|