@mattebox/player 0.13.1 → 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 +2 -2
- 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/es2015/controls/pip.js +16 -3
- package/dist/es2015/element.js +7 -2
- package/dist/es2015/elements/pip-button.js +3 -2
- 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 +1 -1
package/dist/controls/pip.d.ts
CHANGED
|
@@ -7,6 +7,12 @@
|
|
|
7
7
|
export interface PictureInPicture {
|
|
8
8
|
/** Whether any API exists. Without one the button is hidden. */
|
|
9
9
|
readonly supported: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Whether the page allows it: false while the video has
|
|
12
|
+
* `disablepictureinpicture`, which makes the browser refuse the request.
|
|
13
|
+
* Read from the attribute, since Firefox has no such property.
|
|
14
|
+
*/
|
|
15
|
+
allowed(): boolean;
|
|
10
16
|
active(): boolean;
|
|
11
17
|
toggle(): void;
|
|
12
18
|
/** Runs `fn` on every change. Returns the unsubscribe. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pip.d.ts","sourceRoot":"","sources":["../../src/controls/pip.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAQH,MAAM,WAAW,gBAAgB;IAC/B,gEAAgE;IAChE,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,MAAM,IAAI,OAAO,CAAC;IAClB,MAAM,IAAI,IAAI,CAAC;IACf,0DAA0D;IAC1D,KAAK,CAAC,EAAE,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC;CACnC;
|
|
1
|
+
{"version":3,"file":"pip.d.ts","sourceRoot":"","sources":["../../src/controls/pip.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAQH,MAAM,WAAW,gBAAgB;IAC/B,gEAAgE;IAChE,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B;;;;OAIG;IACH,OAAO,IAAI,OAAO,CAAC;IACnB,MAAM,IAAI,OAAO,CAAC;IAClB,MAAM,IAAI,IAAI,CAAC;IACf,0DAA0D;IAC1D,KAAK,CAAC,EAAE,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC;CACnC;AAkBD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,gBAAgB,GAAG,gBAAgB,CA8C1E"}
|
package/dist/controls/pip.js
CHANGED
|
@@ -1,16 +1,27 @@
|
|
|
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
|
const safari = video;
|
|
21
|
+
const allowed = () => !video.hasAttribute(DISABLE);
|
|
12
22
|
if (typeof video.requestPictureInPicture === "function" && document.pictureInPictureEnabled) return {
|
|
13
23
|
supported: true,
|
|
24
|
+
allowed,
|
|
14
25
|
active: () => document.pictureInPictureElement === video,
|
|
15
26
|
toggle() {
|
|
16
27
|
(document.pictureInPictureElement === video ? document.exitPictureInPicture() : video.requestPictureInPicture()).catch(() => void 0);
|
|
@@ -19,6 +30,7 @@ function pictureInPicture(video) {
|
|
|
19
30
|
};
|
|
20
31
|
if (typeof safari.webkitSetPresentationMode === "function" && safari.webkitSupportsPresentationMode?.("picture-in-picture") === true) return {
|
|
21
32
|
supported: true,
|
|
33
|
+
allowed,
|
|
22
34
|
active: () => safari.webkitPresentationMode === "picture-in-picture",
|
|
23
35
|
toggle() {
|
|
24
36
|
const next = safari.webkitPresentationMode === "picture-in-picture" ? "inline" : "picture-in-picture";
|
|
@@ -28,6 +40,7 @@ function pictureInPicture(video) {
|
|
|
28
40
|
};
|
|
29
41
|
return {
|
|
30
42
|
supported: false,
|
|
43
|
+
allowed,
|
|
31
44
|
active: () => false,
|
|
32
45
|
toggle() {},
|
|
33
46
|
watch: () => () => {}
|
package/dist/controls/pip.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pip.js","names":[],"sources":["../../src/controls/pip.ts"],"sourcesContent":["/**\n * Picture-in-Picture on the video, through whichever API the browser has:\n * the standard one, or Safari's presentation mode. Neither means no\n * button. Both live on the video itself, which is where the browser draws\n * the floating window from.\n */\n\ninterface PresentationVideo {\n webkitSupportsPresentationMode?: (mode: string) => boolean;\n webkitSetPresentationMode?: (mode: string) => void;\n readonly webkitPresentationMode?: string;\n}\n\nexport interface PictureInPicture {\n /** Whether any API exists. Without one the button is hidden. */\n readonly supported: boolean;\n active(): boolean;\n toggle(): void;\n /** Runs `fn` on every change. Returns the unsubscribe. */\n watch(fn: () => void): () => void;\n}\n\nfunction watching(
|
|
1
|
+
{"version":3,"file":"pip.js","names":[],"sources":["../../src/controls/pip.ts"],"sourcesContent":["/**\n * Picture-in-Picture on the video, through whichever API the browser has:\n * the standard one, or Safari's presentation mode. Neither means no\n * button. Both live on the video itself, which is where the browser draws\n * the floating window from.\n */\n\ninterface PresentationVideo {\n webkitSupportsPresentationMode?: (mode: string) => boolean;\n webkitSetPresentationMode?: (mode: string) => void;\n readonly webkitPresentationMode?: string;\n}\n\nexport interface PictureInPicture {\n /** Whether any API exists. Without one the button is hidden. */\n readonly supported: boolean;\n /**\n * Whether the page allows it: false while the video has\n * `disablepictureinpicture`, which makes the browser refuse the request.\n * Read from the attribute, since Firefox has no such property.\n */\n allowed(): boolean;\n active(): boolean;\n toggle(): void;\n /** Runs `fn` on every change. Returns the unsubscribe. */\n watch(fn: () => void): () => void;\n}\n\n/** The attribute that turns picture in picture off for one video. */\nconst DISABLE = 'disablepictureinpicture';\n\n/** Watches `names` on the video, and the attribute that turns the feature off. */\nfunction watching(video: HTMLVideoElement, names: readonly string[]) {\n return (fn: () => void): (() => void) => {\n for (const name of names) video.addEventListener(name, fn);\n const observer = new MutationObserver(fn);\n observer.observe(video, { attributes: true, attributeFilter: [DISABLE] });\n return () => {\n for (const name of names) video.removeEventListener(name, fn);\n observer.disconnect();\n };\n };\n}\n\nexport function pictureInPicture(video: HTMLVideoElement): PictureInPicture {\n const safari = video as HTMLVideoElement & PresentationVideo;\n const allowed = (): boolean => !video.hasAttribute(DISABLE);\n\n if (typeof video.requestPictureInPicture === 'function' && document.pictureInPictureEnabled) {\n return {\n supported: true,\n allowed,\n active: () => document.pictureInPictureElement === video,\n toggle(): void {\n // Rejected outside a user gesture, or before the video has metadata;\n // nothing to do with that but drop it.\n const request =\n document.pictureInPictureElement === video\n ? document.exitPictureInPicture()\n : video.requestPictureInPicture();\n request.catch(() => undefined);\n },\n watch: watching(video, ['enterpictureinpicture', 'leavepictureinpicture']),\n };\n }\n\n if (\n typeof safari.webkitSetPresentationMode === 'function' &&\n safari.webkitSupportsPresentationMode?.('picture-in-picture') === true\n ) {\n return {\n supported: true,\n allowed,\n active: () => safari.webkitPresentationMode === 'picture-in-picture',\n toggle(): void {\n const next =\n safari.webkitPresentationMode === 'picture-in-picture' ? 'inline' : 'picture-in-picture';\n safari.webkitSetPresentationMode?.(next);\n },\n watch: watching(video, ['webkitpresentationmodechanged']),\n };\n }\n\n return {\n supported: false,\n allowed,\n active: () => false,\n toggle(): void {},\n watch: () => () => {},\n };\n}\n"],"mappings":";;AA6BA,MAAM,UAAU;;AAGhB,SAAS,SAAS,OAAyB,OAA0B;CACnE,QAAQ,OAAiC;EACvC,KAAK,MAAM,QAAQ,OAAO,MAAM,iBAAiB,MAAM,EAAE;EACzD,MAAM,WAAW,IAAI,iBAAiB,EAAE;EACxC,SAAS,QAAQ,OAAO;GAAE,YAAY;GAAM,iBAAiB,CAAC,OAAO;EAAE,CAAC;EACxE,aAAa;GACX,KAAK,MAAM,QAAQ,OAAO,MAAM,oBAAoB,MAAM,EAAE;GAC5D,SAAS,WAAW;EACtB;CACF;AACF;AAEA,SAAgB,iBAAiB,OAA2C;CAC1E,MAAM,SAAS;CACf,MAAM,gBAAyB,CAAC,MAAM,aAAa,OAAO;CAE1D,IAAI,OAAO,MAAM,4BAA4B,cAAc,SAAS,yBAClE,OAAO;EACL,WAAW;EACX;EACA,cAAc,SAAS,4BAA4B;EACnD,SAAe;GAOb,CAHE,SAAS,4BAA4B,QACjC,SAAS,qBAAqB,IAC9B,MAAM,wBAAwB,EAAA,CAC5B,YAAY,KAAA,CAAS;EAC/B;EACA,OAAO,SAAS,OAAO,CAAC,yBAAyB,uBAAuB,CAAC;CAC3E;CAGF,IACE,OAAO,OAAO,8BAA8B,cAC5C,OAAO,iCAAiC,oBAAoB,MAAM,MAElE,OAAO;EACL,WAAW;EACX;EACA,cAAc,OAAO,2BAA2B;EAChD,SAAe;GACb,MAAM,OACJ,OAAO,2BAA2B,uBAAuB,WAAW;GACtE,OAAO,4BAA4B,IAAI;EACzC;EACA,OAAO,SAAS,OAAO,CAAC,+BAA+B,CAAC;CAC1D;CAGF,OAAO;EACL,WAAW;EACX;EACA,cAAc;EACd,SAAe,CAAC;EAChB,mBAAmB,CAAC;CACtB;AACF"}
|
package/dist/element.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"element.d.ts","sourceRoot":"","sources":["../src/element.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EACV,SAAS,EACT,OAAO,EACP,MAAM,EACN,WAAW,EACX,SAAS,EACT,eAAe,EACf,OAAO,EACP,MAAM,EACN,gBAAgB,EACjB,MAAM,uBAAuB,CAAC;AAQ/B,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAC9D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAGrD,OAAO,EAAE,KAAK,UAAU,EAAoB,MAAM,sBAAsB,CAAC;AACzE,OAAO,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAG7D,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAChE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEjD,OAAO,KAAK,EAAE,QAAQ,EAAS,MAAM,eAAe,CAAC;AAQrD,OAAO,KAAK,EAAE,OAAO,EAAiB,QAAQ,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"element.d.ts","sourceRoot":"","sources":["../src/element.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EACV,SAAS,EACT,OAAO,EACP,MAAM,EACN,WAAW,EACX,SAAS,EACT,eAAe,EACf,OAAO,EACP,MAAM,EACN,gBAAgB,EACjB,MAAM,uBAAuB,CAAC;AAQ/B,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAC9D,OAAO,KAAK,EAA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KG;IACH,OAAO,CAAC,YAAY;IAMpB,sEAAsE;IACtE,OAAO,CAAC,OAAO;IAmBf,yGAAyG;IACzG,OAAO,CAAC,IAAI;IAsBZ,0EAA0E;IAC1E,OAAO,CAAC,IAAI;IAgBZ;;;;OAIG;IACH,OAAO,CAAC,MAAM;IAqCd,oFAAoF;IACpF,OAAO,CAAC,OAAO;IAqBf;;;;;;OAMG;IACH,OAAO,CAAC,KAAK;IAUb,oBAAoB,IAAI,IAAI;IAkB5B,wBAAwB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IA6C5C;;;;OAIG;IACH,OAAO,CAAC,IAAI;IAmBZ,0GAA0G;IAC1G,OAAO,CAAC,QAAQ;IAmChB,OAAO,CAAC,OAAO;IAUf,OAAO,CAAC,OAAO;IAIf;;;;OAIG;IACH,OAAO,CAAC,MAAM;IASd,OAAO,CAAC,IAAI;IAIZ,OAAO,CAAC,MAAM;YAgBA,GAAG;IAsBjB;;;;OAIG;IACH,OAAO,CAAC,MAAM;IAwCd,oGAAoG;IACpG,OAAO,CAAC,KAAK;YAiBC,MAAM;IAqCpB;;;;OAIG;IACH,OAAO,KAAK,OAAO,GAElB;YAEa,KAAK;IA0CnB;;;;OAIG;IACH,OAAO,CAAC,GAAG;IAeX,8EAA8E;IAC9E,OAAO,CAAC,SAAS;IA6BjB,OAAO,CAAC,OAAO;YAID,QAAQ;IAKtB,mFAAmF;YACrE,OAAO;CAMtB"}
|
package/dist/element.js
CHANGED
|
@@ -19,12 +19,17 @@ import { createPlayer, inferType, matteboxHandler, nativeHandler, preferNativeHl
|
|
|
19
19
|
* fullscreen then work as Apple built them. Changing it reloads.
|
|
20
20
|
*/
|
|
21
21
|
const NATIVE_HLS = "native-hls";
|
|
22
|
-
/**
|
|
22
|
+
/**
|
|
23
|
+
* Attributes forwarded onto the video as attributes, never as properties.
|
|
24
|
+
* `disablepictureinpicture` also hides the browser's own picture-in-picture
|
|
25
|
+
* toggle, which Firefox draws over every video that lacks it.
|
|
26
|
+
*/
|
|
23
27
|
const FORWARDED = [
|
|
24
28
|
"autoplay",
|
|
25
29
|
"muted",
|
|
26
30
|
"poster",
|
|
27
|
-
"crossorigin"
|
|
31
|
+
"crossorigin",
|
|
32
|
+
"disablepictureinpicture"
|
|
28
33
|
];
|
|
29
34
|
const LICENSE_URL = "license-url";
|
|
30
35
|
/** The language the page chose, over the nearest `lang`. */
|
package/dist/element.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"element.js","names":[],"sources":["../src/element.ts"],"sourcesContent":["/**\n * <mattebox-player>: a real <video> as a light-DOM child, so the integrator\n * can reach it, and the error surface in shadow DOM. The element never\n * forwards or wraps a media element member: play, pause, seek, volume and\n * the rest live on the video, where the browser, Picture-in-Picture and the\n * OS media session already find them.\n *\n * The controls are elements the page places inside, beside the video, and\n * the stage slots them over the picture. The element appends none of its\n * own: the composition is the page's in every mode, and `none` hides every\n * child but the video. The element reflects the video's state as\n * attributes on itself, `paused`, `playing`, `ended`, `muted`, `audio`,\n * `started` and `waiting`, for the page's stylesheet and the controls\n * alike.\n *\n * No class fields, `#private` or otherwise: the ES2015 build would lower\n * them into runtime helpers, and the emit check bans helpers. Statics are\n * getters and instance state is declared, then assigned in the constructor.\n */\n\nimport type {\n Connector,\n Handler,\n Player,\n PlayerError,\n Programme,\n ProgrammeSource,\n Session,\n Source,\n SourceVideoTrack,\n} from '@mattebox/player-core';\nimport {\n createPlayer,\n inferType,\n matteboxHandler,\n nativeHandler,\n preferNativeHls,\n} from '@mattebox/player-core';\nimport type { KernelConfig, Mattebox, Stage } from 'mattebox';\nimport type { AttachEmeOptions } from 'mattebox/eme';\nimport type { Announcer } from './announcer.js';\nimport { announcer } from './announcer.js';\nimport { type BreakMarks, createBreakMarks } from './controls/breaks.js';\nimport type { Marker, Markers } from './controls/markers.js';\nimport { createMarkers } from './controls/markers.js';\nimport { languageName } from './controls/track-names.js';\nimport type { Block, PlayerAddon, PlayerHost } from './host.js';\nimport type { LocaleSource } from './locales.js';\nimport { addLocale, load, onLocales, registered, wordsNow } from './locales.js';\nimport type { Messages, Words } from './messages.js';\nimport { namespaces } from './namespaces.js';\nimport { drmGuard, resolvePreset } from './presets.js';\nimport { STYLE } from './style.js';\nimport type { ErrorSurface } from './surface.js';\nimport { errorSurface } from './surface.js';\nimport { ERROR_SCREEN, PLAYER } from './tags.js';\nimport { textIn } from './text.js';\nimport type { Tracker, TrackerRunner, Trackers } from './trackers.js';\nimport { createTrackers } from './trackers.js';\nimport type { Chosen } from './video-sources.js';\nimport {\n chosen,\n holdFrame,\n markupVideoTracks,\n onNextFrame,\n restore,\n resume,\n versionSource,\n} from './video-sources.js';\n\n/**\n * `off` keeps HLS on the engine in Safari. Anything else lets Safari play\n * HLS itself: FairPlay, AirPlay, Low-Latency HLS and the platform's\n * fullscreen then work as Apple built them. Changing it reloads.\n */\nconst NATIVE_HLS = 'native-hls';\n\n/** Attributes forwarded onto the video as attributes, never as properties. */\nconst FORWARDED = ['autoplay', 'muted', 'poster', 'crossorigin'];\n\nconst LICENSE_URL = 'license-url';\n\n/** The language the page chose, over the nearest `lang`. */\nconst LANGUAGE = 'language';\n\n/** Carried through a switch: the play state from before it, `playing` or `paused`. */\nconst SWITCHING = 'switching';\n\n/** Whether the browser has EME, so a source may bring DRM. */\nfunction emeAvailable(): boolean {\n return drmGuard().without === undefined;\n}\n\n/** `source` without its DRM, for a browser without EME. */\nfunction withoutDrm({ url, type, videoTracks }: Source): Source {\n return {\n url,\n ...(type === undefined ? {} : { type }),\n ...(videoTracks === undefined ? {} : { videoTracks }),\n };\n}\nconst CERTIFICATE_URL = 'certificate-url';\n\n/** Everything else the element watches. Changing any of them reloads. */\nconst OWN = ['src', 'type', 'preset', LICENSE_URL, CERTIFICATE_URL, 'thumbnails', NATIVE_HLS];\n\n/**\n * The chapters file URL. A session with the engine's `chapters` namespace\n * loads it there: through the engine's transport, so request hooks apply,\n * and in every format the engine reads. Any other session gets a\n * `<track kind=\"chapters\">` on the video, hidden so its cues load and\n * nothing is drawn. The seek bar and the chapters menu read either.\n * Changing it never reloads the source.\n */\nconst CHAPTERS = 'chapters';\n\n/**\n * The one attribute whose meaning the element owns: `native` keeps the\n * browser's controls on the video, `custom` swaps them for the controls the\n * page placed inside, `none` takes the browser's off and hides every child\n * but the video. Anything else is `native`. Changing it never touches the\n * session.\n */\nconst CONTROLS = 'controls';\n\n/**\n * Inline playback, on until the page writes `playsinline=\"false\"`, the way\n * `spellcheck` and `draggable` are on until told otherwise. An iPhone takes\n * a video without `playsinline` to its own fullscreen on play, where no\n * control the page placed shows. Changing it never reloads.\n */\nconst PLAYSINLINE = 'playsinline';\n\n/**\n * The size tier the controls draw for: `compact` on a small player, such\n * as a phone held upright, `wide` on a large one, such as a TV or\n * fullscreen, and `regular` between. The element measures itself and sets\n * the attribute, so a stylesheet matches `mattebox-player[layout=\"compact\"]`.\n * A page that writes one of the three values fixes it, and removing the\n * attribute hands it back. The player's own box decides, not the screen:\n * a small embed on a desktop is compact, and a phone in fullscreen is not.\n */\nconst LAYOUT = 'layout';\nconst LAYOUTS = ['compact', 'regular', 'wide'];\n/** Under either, the player is compact. */\nconst COMPACT_WIDTH = 480;\nconst COMPACT_HEIGHT = 320;\n/** From both, the player is wide. */\nconst WIDE_WIDTH = 1280;\nconst WIDE_HEIGHT = 700;\n\n/** The video's state, as attributes on the element, read on the events the video fires for it. */\nconst STATE_EVENTS = [\n 'play',\n 'pause',\n 'ended',\n // A seek back from the end leaves `ended` with no play, pause or ended event.\n 'seeked',\n 'emptied',\n 'volumechange',\n 'loadedmetadata',\n 'resize',\n 'playing',\n 'waiting',\n 'canplay',\n];\n\n/**\n * How long the video waits for data before the live region says so. A\n * seek within the buffer waits for less, and saying it would only be noise.\n */\nconst LOADING_MS = 1000;\n\n/** A track's name for the live region: its name in the stream, else its language's in `locale`. */\nfunction trackName(name: string | undefined, lang: string | undefined, locale: string): string {\n return name || (lang && (languageName(lang, locale || undefined) ?? lang)) || '';\n}\n\n/** The stages that register a key system, which a native session's DRM offers. */\nconst KEY_SYSTEMS = ['eme-fairplay', 'eme-cenc'];\n\n/** Every stage the engine ships. A narrower preset is optimization. */\nconst DEFAULT_PRESET = 'full';\n\n/**\n * What the element dispatches. `error` is also a standard DOM event name, so\n * without these overloads a listener on it is typed as `ErrorEvent` and the\n * payload needs a double cast. They are declarations only: no runtime bytes.\n */\nexport interface MatteboxPlayerEventMap {\n sourcechange: CustomEvent<Session | null>;\n /** The size tier changed: `compact`, `regular` or `wide`. */\n layoutchange: CustomEvent<string>;\n error: CustomEvent<PlayerError>;\n /** The markers changed: set by the page, or cleared by a new source. */\n markerschange: CustomEvent<readonly Marker[]>;\n /** Playback reached a blocked range and moved past it. */\n blocked: CustomEvent<Marker>;\n /** The page called `block()` or `unblock()`, or a new source cleared the block: the block, or null. */\n blockchange: CustomEvent<Block | null>;\n /** A load resolved what it plays, before the session: the programme, or null at unload. */\n programmechange: CustomEvent<Programme | null>;\n /** A tracker was added, removed, started or stopped: the trackers. */\n trackerschange: CustomEvent<readonly Tracker[]>;\n}\n\nexport interface MatteboxPlayerElement {\n addEventListener<K extends keyof MatteboxPlayerEventMap>(\n type: K,\n listener: (this: MatteboxPlayerElement, event: MatteboxPlayerEventMap[K]) => void,\n options?: boolean | AddEventListenerOptions,\n ): void;\n addEventListener(\n type: string,\n listener: EventListenerOrEventListenerObject,\n options?: boolean | AddEventListenerOptions,\n ): void;\n removeEventListener<K extends keyof MatteboxPlayerEventMap>(\n type: K,\n listener: (this: MatteboxPlayerElement, event: MatteboxPlayerEventMap[K]) => void,\n options?: boolean | EventListenerOptions,\n ): void;\n removeEventListener(\n type: string,\n listener: EventListenerOrEventListenerObject,\n options?: boolean | EventListenerOptions,\n ): void;\n}\n\nexport interface MatteboxPlayerOptions {\n /** The whole chain, in order. Takes precedence over `stages` and the `preset` attribute. */\n readonly handlers?: readonly Handler[];\n /** Stages for the mattebox handler. Takes precedence over the `preset` attribute. */\n readonly stages?: readonly Stage[];\n /**\n * Kernel tuning for the engines the elements build, `traceCapacity` among\n * it. A page decision, like the stages, so not an attribute. Ignored with\n * `handlers`, which carry their own.\n */\n readonly config?: Partial<KernelConfig>;\n /**\n * DRM for a native session, as `attachEme` from `mattebox/eme` takes it:\n * `keySystems`, `licenseUrl`, `licenseUrls`, `requestHook`. Without\n * `keySystems` the session offers the key-system stages of the engine's\n * stack. The `license-url` attribute overrides `licenseUrl`, and\n * `certificate-url` gives the FairPlay certificate. Ignored\n * with `handlers`, which carry their own.\n */\n readonly drm?: AttachEmeOptions;\n /**\n * One per source type, such as `srgssr/urn`: a source of that type is a\n * programme id, or data you give, which the connector resolves to what\n * plays. Kept with `handlers`.\n */\n readonly connectors?: readonly Connector[];\n /**\n * Packages that add to every player, such as `ads()` from\n * `@mattebox/player-ads`: their stages join the stack, and each runs on\n * every player that connects. Ignored with `handlers`, apart from what\n * they run on the player.\n */\n readonly addons?: readonly PlayerAddon[];\n}\n\n/**\n * What `define()` recorded, for the elements the parser creates. It is the\n * one value shared across elements, because a page that writes only markup\n * still has to be able to say what the engine carries.\n */\nlet defaults: MatteboxPlayerOptions = {};\n\n/**\n * The interface above merges only `addEventListener` and `removeEventListener`\n * overloads, which the class inherits from HTMLElement. The rule it suppresses\n * guards against properties an interface declares and a constructor never\n * assigns, and there are none.\n */\n// biome-ignore lint/suspicious/noUnsafeDeclarationMerging: method overloads only, no properties\nexport class MatteboxPlayerElement extends HTMLElement implements PlayerHost {\n static get observedAttributes(): readonly string[] {\n return [...FORWARDED, ...OWN, CONTROLS, CHAPTERS, PLAYSINLINE, LAYOUT, LANGUAGE, 'lang'];\n }\n\n /**\n * Registers the words of a language for every player on the page. Each\n * source is a set of words or a function that loads one, which runs only\n * when a player shows that language. Later sources go over earlier ones,\n * so a page changes a shipped word by registering its own after it.\n * Players that show the language take the new words at once.\n */\n static addLocale(language: string, ...sources: readonly LocaleSource[]): void {\n addLocale(language, sources);\n }\n\n /**\n * Registers the element once, and records the stages markup-only pages\n * get. The controls register through their own entries, the package's\n * root entry importing every one; a control connected before its player\n * is defined waits for the definition.\n */\n static define(options?: MatteboxPlayerOptions): void {\n if (options !== undefined) defaults = options;\n if (customElements.get(PLAYER) === undefined) {\n customElements.define(PLAYER, MatteboxPlayerElement);\n }\n }\n\n declare private readonly media: HTMLVideoElement;\n /** Wraps the slot: the picture, and the controls over it or under it. */\n declare private readonly stage: HTMLDivElement;\n /** Whether the element gave itself a tabindex for the bar, to take back with it. */\n declare private focusable: boolean;\n declare private readonly surface: ErrorSurface;\n declare private readonly voice: Announcer;\n /** The words of the language shown, empty for English. */\n declare private words: Words;\n /** The language tag the player resolved, or empty without one. */\n declare private shown: string;\n /** Bumped on every resolution, so a slow loader does not win over a later choice. */\n declare private wordsEpoch: number;\n /** Ends the watch on registrations and on the page's `lang`. */\n declare private unwatch: (() => void) | null;\n /** Runs out when the video has waited `LOADING_MS`. */\n declare private slow: ReturnType<typeof setTimeout> | undefined;\n /** The audio track the live region last saw, so it says only a change. Undefined before the first play. */\n declare private heardAudio: string | undefined;\n /** The subtitle track it last saw: null for off, undefined before the first play. */\n declare private heardText: string | null | undefined;\n /** Stops listening to the current engine's track selection. */\n declare private offTracks: (() => void) | null;\n declare private readonly marks: Markers;\n declare private readonly breakMarks: BreakMarks;\n /** The chapters track element, while the `chapters` attribute names one and the engine takes none. */\n declare private track: HTMLTrackElement | null;\n /** The chapters URL the current session's engine was given, or null. */\n declare private given: string | null;\n /** The sources the page set from script, or null. */\n declare private list: readonly ProgrammeSource[] | null;\n declare private readonly tracking: TrackerRunner;\n /** The sources of the last run, as text: what tells a new `<source>` child from the ones already tried. */\n declare private tried: string;\n /** The options this element was constructed with, or null for the ones `define()` recorded. */\n declare private readonly own: MatteboxPlayerOptions | null;\n declare private core: Player | null;\n declare private current: Session | null;\n declare private failure: PlayerError | null;\n /** What `block()` set, or null. */\n declare private stop: Block | null;\n /** Whether an attribute change is the element's own reflection, which must not write back to the video. */\n declare private reflecting: boolean;\n /** Watches the element's box for `layout`, while connected. */\n declare private sizes: ResizeObserver | null;\n /** Whether the page wrote `layout`, so the element leaves it alone. */\n declare private fixed: boolean;\n /** The video has played once since its source was set: `started`, which tells a first play from a pause. */\n declare private started: boolean;\n /** The video waits for data: `waiting`, set on `waiting`, cleared once it can play. */\n declare private waiting: boolean;\n declare private offs: Array<() => void>;\n /** Where `interrupt` left the programme: its time, whether it played, its tracks. */\n declare private interruption: { at: number | null; playing: boolean; had: Chosen | null } | null;\n /** The add-ons attached to this player, with what each returned, run when it leaves the page. */\n declare private attached: Map<PlayerAddon, (() => void) | undefined>;\n /** Everything the element does to the player runs here, so it runs in order. */\n declare private queue: Promise<void>;\n /** Whether a run is queued and not yet started, so a burst of changes loads once. */\n declare private pending: boolean;\n /** The source the versions of `videoSources` belong to: the one that played before a switch. */\n declare private original: Source | null;\n /** The version that plays, or null for the programme itself. */\n declare private version: SourceVideoTrack | null;\n /** True while a version loads, so its `sourcechange` keeps the programme. */\n declare private switching: boolean;\n /** The source `switchSource` loaded, which a retry loads again, or null. */\n declare private switched: Source | null;\n /** Ends the hold of a switch: the poster and `switching` go back. Null without one. */\n declare private held: (() => void) | null;\n\n constructor(options?: MatteboxPlayerOptions) {\n super();\n this.own = options ?? null;\n this.focusable = false;\n this.track = null;\n this.given = null;\n this.list = null;\n this.tried = '';\n this.core = null;\n this.current = null;\n this.failure = null;\n this.stop = null;\n this.reflecting = false;\n this.sizes = null;\n this.fixed = false;\n this.started = false;\n this.waiting = false;\n this.offs = [];\n this.attached = new Map();\n this.interruption = null;\n this.queue = Promise.resolve();\n this.pending = false;\n this.original = null;\n this.version = null;\n this.switching = false;\n this.switched = null;\n this.held = null;\n this.words = {};\n this.shown = '';\n this.wordsEpoch = 0;\n this.unwatch = null;\n this.slow = undefined;\n this.heardAudio = undefined;\n this.heardText = undefined;\n this.offTracks = null;\n\n this.media = document.createElement('video');\n // Native until the `controls` attribute says otherwise, which arrives\n // through attributeChangedCallback: a constructor must not read attributes.\n this.media.controls = true;\n // Inline is the default, and the player's own attribute has not arrived\n // yet. Set as an attribute: not every browser has the `playsInline`\n // property. The fullscreen button still reaches the iPhone's fullscreen,\n // through `webkitEnterFullscreen`.\n this.media.setAttribute(PLAYSINLINE, '');\n for (const name of STATE_EVENTS) {\n this.media.addEventListener(name, () => {\n const was = this.waiting;\n this.note(name);\n this.reflect();\n this.tell(name, was);\n });\n }\n // A native session's tracks; an engine session's are on `tracks:selected`.\n const lists = this.media as { audioTracks?: EventTarget; textTracks: EventTarget };\n for (const list of [lists.audioTracks, lists.textTracks]) {\n list?.addEventListener('change', () => {\n this.tracks();\n });\n }\n // An error over a picture that then plays is wrong by definition.\n this.media.addEventListener('playing', () => {\n this.failure = null;\n this.reflect();\n });\n this.marks = createMarkers(this.media, (name, detail) => this.emit(name, detail));\n this.breakMarks = createBreakMarks((list) => this.emit('breakschange', list));\n this.tracking = createTrackers(this, () => this.emit('trackerschange', this.tracking.list));\n this.stage = document.createElement('div');\n this.stage.setAttribute('part', 'stage');\n const slot = document.createElement('slot');\n // The parser connects the element before its children exist, so the\n // first run finds no `<source>`. A video starts its selection when a\n // `<source>` arrives and nothing is loaded, and so does this.\n slot.addEventListener('slotchange', () => {\n if (this.current === null && JSON.stringify(this.wanted()) !== this.tried) this.reload();\n });\n this.stage.append(slot);\n this.surface = errorSurface(\n () => {\n this.retry();\n },\n () => this.words.retry ?? 'Retry',\n );\n\n this.voice = announcer(this, (id) => this.words[id]);\n\n const root = this.attachShadow({ mode: 'open' });\n const style = document.createElement('style');\n style.textContent = STYLE;\n root.append(style, this.stage, this.surface.root, this.voice.root);\n }\n\n /** The media element. Everything the browser already does is here. */\n get video(): HTMLVideoElement {\n return this.media;\n }\n\n /** The ranges the page named in this source: credits to skip, parts that must not play. */\n get markers(): Markers {\n return this.marks;\n }\n\n /** Where the programme's ad breaks are, which the seek bar draws: each add-on gives its own. */\n get breaks(): BreakMarks {\n return this.breakMarks;\n }\n\n /**\n * The sources to try in order, set from script. The `src` attribute wins\n * over them, and they win over the `<source>` children. Setting them\n * loads, and null returns to the children.\n */\n get sources(): readonly ProgrammeSource[] | null {\n return this.list;\n }\n\n set sources(value: readonly ProgrammeSource[] | null) {\n this.list = value;\n // Markers, a block and an interruption belong to a source, as for `src`.\n if (this.marks.list.length > 0) this.marks.set([]);\n this.interruption = null;\n this.unblock();\n this.reload();\n }\n\n /**\n * The language the page chose for this player, which wins over the\n * nearest `lang` attribute. Empty follows `lang`. Setting it changes the\n * words of every control at once.\n */\n get language(): string {\n return this.getAttribute(LANGUAGE) ?? '';\n }\n\n set language(value: string) {\n if (value === '') this.removeAttribute(LANGUAGE);\n else this.setAttribute(LANGUAGE, value);\n }\n\n /** The language tag the words come from: `language`, else the nearest `lang`. Empty without either. */\n get locale(): string {\n return this.shown;\n }\n\n /** The word of `id` in the player's language, or undefined, where the control's English applies. */\n message(id: keyof Messages): string | undefined {\n return this.words[id];\n }\n\n /** Follows registrations and the document's `lang` until disconnect. */\n private watchLanguage(): void {\n const off = onLocales(() => {\n this.relocale();\n });\n // The page's language usually sits on <html>; a lang on another\n // ancestor is read at connect, and `language` covers a change there.\n const watch = new MutationObserver(() => {\n this.relocale();\n });\n watch.observe(document.documentElement, { attributes: true, attributeFilter: ['lang'] });\n this.unwatch = () => {\n off();\n watch.disconnect();\n };\n this.relocale();\n }\n\n /** Resolves the language, takes its words, and tells the controls with `localechange`. */\n private relocale(): void {\n const tag = this.getAttribute(LANGUAGE) ?? this.closest('[lang]')?.getAttribute('lang') ?? '';\n const epoch = ++this.wordsEpoch;\n const take = (words: Words): void => {\n if (epoch !== this.wordsEpoch) return;\n this.shown = tag;\n this.words = words;\n this.showBlock();\n this.emit('localechange', tag);\n };\n const key = registered(tag);\n if (key === null) {\n take({});\n return;\n }\n const now = wordsNow(key);\n if (now !== null) {\n take(now);\n return;\n }\n // The words on screen stay until the language arrives; a loader that\n // fails leaves them.\n load(key).then(take, () => undefined);\n }\n\n /**\n * Loads the sources again, in the order a load reads them: the `src`\n * attribute, the `sources` property, then the `<source>` children. The\n * error screens' Retry calls it. On a version of `videoSources`, it\n * loads that version again.\n */\n retry(): void {\n const again =\n this.version === null ? this.switched : versionSource(this.version, emeAvailable());\n if (again === null) this.reload();\n else this.swap(again, null, false, null, false);\n }\n\n /**\n * Loads `source` in place of the one that plays, from the same position\n * and in the same play state, with the same audio and subtitle choice.\n * Use it for the same programme at another URL, such as its HLS and\n * DASH manifests. The last frame and the controls hold until the new\n * load shows a frame there. The markers stay, and the versions are the\n * ones `source` names. A new `src`, `sources` or `<source>` load\n * replaces it.\n */\n switchSource(source: Source): void {\n const media = this.media;\n const at = Number.isFinite(media.duration) ? media.currentTime : null;\n const playing = !media.paused;\n const had = chosen(this.current?.engine ?? null);\n const clean = emeAvailable() ? source : withoutDrm(source);\n const was = this.version;\n this.original = clean;\n this.switched = clean;\n this.version = null;\n if (was !== null) this.emit('videosourcechange', null);\n this.swap(clean, at, playing, had, true);\n }\n\n /**\n * Plays `source` on the video in the programme's place, such as an ad of\n * `@mattebox/player-ads`. The programme, its markers and its trackers\n * stay, no `sourcechange` fires, and the controls drive the source as\n * they drive the programme. An error of the source is not the\n * programme's: listen to the video. `resume()` plays the programme again\n * where it stopped. Resolves once the source is loaded; rejects when no\n * handler plays it.\n */\n interrupt(source: Source): Promise<void> {\n const media = this.media;\n this.interruption ??= {\n at: Number.isFinite(media.duration) ? media.currentTime : null,\n playing: !media.paused,\n had: chosen(this.current?.engine ?? null),\n };\n return this.queued(async () => {\n const core = await this.ensure();\n await core.interrupt(source);\n this.current = core.session;\n media.play().catch(() => undefined);\n });\n }\n\n /**\n * Plays the programme again where `interrupt` left it, in the play state\n * it had, or as `options` says: `at` another position, such as its end\n * after a post-roll, and `playing`.\n */\n resume(options: { readonly at?: number | null; readonly playing?: boolean } = {}): Promise<void> {\n const left = this.interruption;\n if (left === null) return Promise.resolve();\n this.interruption = null;\n const at = options.at === undefined ? left.at : options.at;\n const playing = options.playing ?? left.playing;\n return this.queued(async () => {\n const core = await this.ensure();\n await core.resume(at ?? undefined);\n this.current = core.session;\n restore(this.current?.engine ?? null, left.had);\n if (playing) this.media.play().catch(() => undefined);\n });\n }\n\n /** `interrupt` plays in the programme's place. */\n get interrupted(): boolean {\n return this.interruption !== null;\n }\n\n /** Runs `task` in the element's queue, and says how it went. */\n private queued(task: () => Promise<void>): Promise<void> {\n return new Promise((resolve, reject) => {\n this.enqueue(() => task().then(resolve, reject));\n });\n }\n\n /** The other versions of the picture the source names at their own URLs, for the video menu. */\n get videoSources(): readonly SourceVideoTrack[] {\n return this.original?.videoTracks ?? [];\n }\n\n /** The version of `videoSources` that plays, or null for the source itself. */\n get videoSource(): SourceVideoTrack | null {\n return this.version;\n }\n\n /**\n * Plays a version of `videoSources`, or the source itself for null, from\n * the same position and in the same play state, with the same audio and\n * subtitle choice. A live source joins the version at its live edge.\n * Fires `videosourcechange`.\n */\n selectVideoSource(track: SourceVideoTrack | null): void {\n const programme = this.original;\n if (programme === null || track === this.version) return;\n if (track !== null && programme.videoTracks?.includes(track) !== true) return;\n const media = this.media;\n const at = Number.isFinite(media.duration) ? media.currentTime : null;\n const playing = !media.paused;\n const had = chosen(this.current?.engine ?? null);\n this.version = track;\n this.emit('videosourcechange', track);\n this.swap(\n track === null ? programme : versionSource(track, emeAvailable()),\n at,\n playing,\n had,\n true,\n );\n }\n\n /**\n * Loads `source` under the programme that plays, and puts the position,\n * play state and tracks back. With `hold`, the last frame stays as the\n * poster and the player carries `switching`, the play state from\n * before, so the controls show that state through the load.\n */\n private swap(\n source: Source,\n at: number | null,\n playing: boolean,\n had: Chosen | null,\n hold: boolean,\n ): void {\n const media = this.media;\n this.held?.();\n let release: (() => void) | null = null;\n if (hold) {\n // Taken now, while the frame of the source that played is still on screen.\n const frame = holdFrame(media);\n const done = (): void => {\n frame?.();\n if (this.held !== done) return;\n this.held = null;\n this.removeAttribute(SWITCHING);\n this.reflect();\n };\n this.held = done;\n this.setAttribute(SWITCHING, playing ? 'playing' : 'paused');\n release = done;\n }\n this.enqueue(async () => {\n const core = await this.ensure();\n this.switching = true;\n try {\n await core.load([source]);\n } catch {\n // Reported on the error event, as for any load.\n release?.();\n return;\n } finally {\n this.switching = false;\n }\n resume(media, at, playing);\n if (release !== null) onNextFrame(media, at, release);\n restore(this.current?.engine ?? null, had);\n });\n }\n\n /** The core, or null until the first source has been set up: resolving a preset is asynchronous. */\n get player(): Player | null {\n return this.core;\n }\n\n /** The engine feeding the video, or null for a native session and before the first load. */\n get engine(): Mattebox | null {\n return this.current?.engine ?? null;\n }\n\n /**\n * The fatal error of the current load, or null once a load starts or\n * playback resumes. The `error` event says when; this says what, for a\n * control that attaches after the event, such as an error screen parsed\n * after a source that failed while the page was still loading.\n */\n get error(): PlayerError | null {\n return this.failure;\n }\n\n /**\n * Shows why the programme does not play, in place of the video, and\n * stops the load: the reason the page's content API gave, such as a\n * geographic or an age restriction. The error screen shows the title,\n * else \"Not available\", and the message, with no retry. Each text can\n * be given by language tag, and follows the player's language. A new\n * `src` or `sources` clears it. Fires `blockchange`.\n */\n block(block: Block): void {\n this.refuse(block);\n this.enqueue(() => this.teardown());\n }\n\n /** Shows the block, for `block()` and for a programme a connector blocked, which loaded nothing. */\n private refuse(block: Block): void {\n this.stop = block;\n this.media.pause();\n clearTimeout(this.slow);\n const [title, message] = this.blockWords(block);\n // An error screen in the player is an alert of its own, read already.\n if (this.querySelector(ERROR_SCREEN) === null) {\n this.voice.tell(message === '' ? title : `${title}. ${message}`);\n }\n this.showBlock();\n this.reflect();\n this.emit('blockchange', block);\n }\n\n /** Removes the block. Nothing plays until a source loads: set one, or call `retry()`. */\n unblock(): void {\n if (this.stop === null) return;\n this.stop = null;\n this.surface.clear();\n this.reflect();\n this.emit('blockchange', null);\n }\n\n /** What `block()` set, or null. */\n get blocked(): Block | null {\n return this.stop;\n }\n\n /**\n * What the current load resolved to: the sources, and what a connector\n * said of the programme. Null before a load and after an unload.\n */\n get programme(): Programme | null {\n return this.core?.programme ?? null;\n }\n\n /**\n * The page's trackers. Each starts at every programme and stops at its\n * end; one added or removed during a programme starts or stops at once.\n */\n get trackers(): Trackers {\n return this.tracking;\n }\n\n /**\n * Applies what the load resolved, before any session: the markers, the\n * poster, the block. The page's own `poster` and markers set after the\n * source win. Then the trackers start on the programme.\n */\n private programmed(programme: Programme | null): void {\n const metadata = programme?.metadata;\n if (metadata?.markers !== undefined) this.marks.set(metadata.markers);\n if (!this.hasAttribute('poster')) {\n if (metadata?.poster === undefined) this.media.removeAttribute('poster');\n else this.media.poster = metadata.poster;\n }\n if (programme?.block !== undefined) this.refuse(programme.block);\n this.emit('programmechange', programme);\n this.tracking.begin(programme);\n }\n\n /** A block's title and message in the player's language: the title defaults to the `blocked` word. */\n private blockWords(block: Block): [string, string] {\n return [\n block.title === undefined\n ? (this.words.blocked ?? 'Not available')\n : textIn(block.title, this.shown),\n block.message === undefined ? '' : textIn(block.message, this.shown),\n ];\n }\n\n /** Puts the block on the row under the video, under native controls. */\n private showBlock(): void {\n if (this.stop === null || this.getAttribute(CONTROLS) === 'custom') return;\n const [title, message] = this.blockWords(this.stop);\n this.surface.inform(title, message);\n }\n\n connectedCallback(): void {\n if (this.media.parentNode !== this) this.append(this.media);\n for (const name of FORWARDED) this.forward(name);\n this.reflect();\n if (typeof ResizeObserver !== 'undefined') {\n this.sizes = new ResizeObserver(() => {\n this.measure();\n });\n this.sizes.observe(this);\n }\n this.measure();\n this.watchLanguage();\n this.attachAddons();\n this.reload();\n }\n\n /**\n * Attaches each add-on of the options once. At connect, and again at each\n * load: a page that imports the player registers it before its own\n * `define()` gives the add-ons, and the players already on the page\n * connected then.\n */\n private attachAddons(): void {\n for (const addon of this.options.addons ?? []) {\n if (!this.attached.has(addon)) this.attached.set(addon, addon.attach?.(this));\n }\n }\n\n /** Sets `layout` from the element's box, unless the page fixed it. */\n private measure(): void {\n if (this.fixed) return;\n const width = this.clientWidth;\n const height = this.clientHeight;\n // Not laid out yet: no tier until there is a box to judge.\n if (width === 0 || height === 0) return;\n const layout =\n width < COMPACT_WIDTH || height < COMPACT_HEIGHT\n ? 'compact'\n : width >= WIDE_WIDTH && height >= WIDE_HEIGHT\n ? 'wide'\n : 'regular';\n if (this.getAttribute(LAYOUT) === layout) return;\n this.reflecting = true;\n this.setAttribute(LAYOUT, layout);\n this.reflecting = false;\n this.emit('layoutchange', layout);\n }\n\n /** The two states the video does not hold: whether it has played once, and whether it waits for data. */\n private note(event: string): void {\n if (event === 'playing') {\n // The tracks the video starts playing with are what a change is from.\n if (!this.started) this.tracks();\n this.started = true;\n this.waiting = false;\n } else if (event === 'waiting') {\n // Not `stalled`: a paused video with a full buffer fires it too, when\n // nothing more is appended for three seconds. video.js reads `waiting` alone.\n this.waiting = true;\n } else if (event === 'canplay') {\n this.waiting = false;\n } else if (event === 'emptied') {\n // A new source starts over: the title shows again before its first play.\n // A switch is the same programme, so it keeps its start.\n if (this.held === null) this.started = false;\n this.waiting = false;\n this.heardAudio = undefined;\n this.heardText = undefined;\n }\n }\n\n /** Says a play or a pause, and a wait once it has lasted `LOADING_MS`. */\n private tell(event: string, was: boolean): void {\n // The load of a switch pauses and plays the video, and the viewer did neither.\n if (event === 'play' && this.held === null) this.voice.say('playing', 'saidPlaying', 'Playing');\n // The end of the video pauses it too, and that is no pause to say.\n if (event === 'pause' && !this.media.ended && this.held === null) {\n this.voice.say('paused', 'saidPaused', 'Paused');\n }\n if (this.waiting === was) return;\n clearTimeout(this.slow);\n if (this.waiting) {\n this.slow = setTimeout(() => {\n this.voice.say('loading', 'loading', 'Loading');\n }, LOADING_MS);\n }\n }\n\n /**\n * Says a change of the audio or the subtitle track, once the video has\n * played: the tracks a load starts with are no change. A forced track\n * reads as off, as in the subtitles menu.\n */\n private tracks(): void {\n const engine = this.current?.engine ?? null;\n let audio: string;\n let text: string | null;\n if (engine !== null) {\n const sound = engine.tracks.active('audio');\n const words = engine.tracks.active('text');\n audio = sound === null ? '' : trackName(sound.name, sound.lang, this.locale);\n text =\n words === null || words.forced === true\n ? null\n : trackName(words.name, words.lang, this.locale);\n } else {\n const video = this.media as {\n audioTracks?: ArrayLike<{ enabled: boolean; label: string; language: string }>;\n };\n const sound = Array.from(video.audioTracks ?? []).find((track) => track.enabled);\n const words = Array.from(this.media.textTracks).find(\n (track) =>\n (track.kind === 'subtitles' || track.kind === 'captions') && track.mode === 'showing',\n );\n audio = sound === undefined ? '' : trackName(sound.label, sound.language, this.locale);\n text = words === undefined ? null : trackName(words.label, words.language, this.locale);\n }\n const { heardAudio, heardText } = this;\n this.heardAudio = audio;\n this.heardText = text;\n if (!this.started) return;\n if (heardAudio !== undefined && audio !== heardAudio) {\n this.voice.say('audio', 'saidAudio', 'Audio: {track}', audio);\n }\n if (heardText !== undefined && text !== heardText) {\n if (text === null) this.voice.say('subtitles-off', 'saidSubtitlesOff', 'Subtitles off');\n else this.voice.say('subtitles', 'saidSubtitles', 'Subtitles: {track}', text);\n }\n }\n\n /** The video's state on the element, for `mattebox-player[paused]` and the like. */\n private reflect(): void {\n const video = this.media;\n this.reflecting = true;\n // Through a switch, the play state from before it.\n const held = this.getAttribute(SWITCHING);\n const paused = held === null ? video.paused : held === 'paused';\n this.toggleAttribute('paused', paused);\n this.toggleAttribute('playing', !paused);\n this.toggleAttribute('ended', video.ended);\n // `muted` is also forwarded: the page's attribute sets the video, and\n // the video's state sets the attribute. Reflection never forwards, so\n // a read can only ever change the attribute, never the video.\n this.toggleAttribute('muted', video.muted);\n this.toggleAttribute('audio', this.audio());\n this.toggleAttribute('started', this.started);\n this.toggleAttribute('waiting', this.waiting);\n this.toggleAttribute('error', this.failure !== null);\n this.toggleAttribute('blocked', this.stop !== null);\n this.reflecting = false;\n }\n\n /**\n * Whether the source has no picture. Once the metadata is in, the video's\n * size decides: zero by zero is sound alone, and `resize` catches a stream\n * that moves to or from an audio-only rendition. Before that, the type the\n * page wrote or the URL implies is the hint, so an mp3 is `audio` from\n * the start rather than from its metadata.\n */\n private audio(): boolean {\n const video = this.media;\n if (video.readyState >= HTMLMediaElement.HAVE_METADATA) {\n return video.videoWidth === 0 && video.videoHeight === 0;\n }\n const src = this.getAttribute('src');\n const type = this.getAttribute('type') ?? (src === null ? undefined : inferType(src));\n return type?.startsWith('audio/') === true;\n }\n\n disconnectedCallback(): void {\n this.sizes?.disconnect();\n this.sizes = null;\n this.unwatch?.();\n this.unwatch = null;\n // A single-page app must not leave a pipeline attached to a video it\n // navigated away from. Reconnecting loads the `src` again. A move is no\n // removal: as HTML's media element waits for a stable state before it\n // pauses, the teardown waits a microtask and runs only if the element is\n // still out of the document.\n queueMicrotask(() => {\n if (this.isConnected) return;\n for (const off of this.attached.values()) off?.();\n this.attached.clear();\n this.enqueue(() => this.teardown());\n });\n }\n\n attributeChangedCallback(name: string): void {\n if (name === LANGUAGE || name === 'lang') {\n this.relocale();\n return;\n }\n if (FORWARDED.includes(name)) {\n if (!this.reflecting) this.forward(name);\n return;\n }\n if (name === CONTROLS) {\n this.mode();\n return;\n }\n if (name === CHAPTERS) {\n this.chapters();\n return;\n }\n if (name === LAYOUT) {\n // The element's own write is not the page's.\n if (this.reflecting) return;\n const value = this.getAttribute(LAYOUT);\n this.fixed = value !== null && LAYOUTS.includes(value);\n if (this.fixed) this.emit('layoutchange', value);\n else this.measure();\n return;\n }\n if (name === PLAYSINLINE) {\n // On the video it is a boolean attribute, so off is absent.\n this.media.toggleAttribute(PLAYSINLINE, this.getAttribute(PLAYSINLINE) !== 'false');\n return;\n }\n // The preset decides the chain, so it is the one attribute that rebuilds it.\n if (name === 'preset') this.enqueue(() => this.discard());\n // The source's type is the hint for `audio` until its metadata arrives.\n // Only `audio`: a full reflection here would drop a `muted` the page\n // wrote before its own callback forwards it.\n if (name === 'src' || name === 'type') this.toggleAttribute('audio', this.audio());\n // Markers belong to a source. Cleared here, not on `emptied`, which\n // arrives later and would clear the ones the page sets right after.\n if (name === 'src' && this.marks.list.length > 0) this.marks.set([]);\n if (name === 'src') this.interruption = null;\n if (name === 'src') this.unblock();\n this.reload();\n }\n\n /**\n * Applies the `controls` attribute: the video's own controls and the\n * tabindex. The controls themselves are elements the page placed, and\n * they attach on their own; the element appends none.\n */\n private mode(): void {\n const value = this.getAttribute(CONTROLS);\n const custom = value === 'custom';\n this.media.controls = !custom && value !== 'none';\n // Under custom controls the error screen element carries a fatal error.\n if (custom) this.surface.clear();\n else this.showBlock();\n if (!custom) {\n if (this.focusable) this.removeAttribute('tabindex');\n this.focusable = false;\n } else if (!this.hasAttribute('tabindex')) {\n // A bare video is not focusable, so without this a click on it would\n // leave the shortcuts nowhere to listen. A page that set its own\n // tabindex keeps it.\n this.tabIndex = 0;\n this.focusable = true;\n }\n }\n\n /** Hands the `chapters` attribute to the engine, or keeps a hidden chapters track on the video for it. */\n private chapters(): void {\n const url = this.getAttribute(CHAPTERS);\n const engine = this.current?.engine ?? null;\n const api = engine === null ? undefined : namespaces(engine).chapters;\n if (api !== undefined) {\n this.track?.remove();\n this.track = null;\n if (url === this.given) return;\n this.given = url;\n // An empty list removes the chapters the attribute loaded.\n if (url === null) api.set([]);\n else void api.load(url).catch(() => undefined);\n return;\n }\n if (url === null) {\n this.track?.remove();\n this.track = null;\n return;\n }\n const held = this.track;\n if (held !== null && held.parentNode === this.media && held.getAttribute('src') === url) return;\n // A new element each time: one removed mid-load, as the engine's attach\n // does, stays in its error state, and neither a new `src` nor a second\n // insertion starts it loading again.\n held?.remove();\n const track = document.createElement('track');\n track.kind = 'chapters';\n track.src = url;\n this.track = track;\n this.media.append(track);\n // Set after the insertion: a track element's mode exists once it is in\n // a media element, and `hidden` is what makes its cues load unseen.\n track.track.mode = 'hidden';\n }\n\n private forward(name: string): void {\n const value = this.getAttribute(name);\n if (value === null) this.media.removeAttribute(name);\n else this.media.setAttribute(name, value);\n // A video reads `muted` into its state only when it is created, and this\n // one was created before any attribute reached it. Muted autoplay and\n // the autoplay policy read the state, so the attribute alone would not do.\n if (name === 'muted') this.media.muted = value !== null;\n }\n\n private enqueue(task: () => Promise<void>): void {\n this.queue = this.queue.then(task, task).catch(() => undefined);\n }\n\n /**\n * One run per burst. The parser sets every attribute and then connects the\n * element before any queued task starts, and each of those would load on\n * its own; the flag folds them into the one run that sees the final state.\n */\n private reload(): void {\n if (this.pending) return;\n this.pending = true;\n this.enqueue(() => {\n this.pending = false;\n return this.run();\n });\n }\n\n private emit(name: string, detail: unknown): void {\n this.dispatchEvent(new CustomEvent(name, { detail, bubbles: true, composed: true }));\n }\n\n private report(error: PlayerError): void {\n if (error.fatal) {\n this.failure = error;\n clearTimeout(this.slow);\n // An error screen in the player is an alert of its own, read already.\n if (this.querySelector(ERROR_SCREEN) === null) {\n this.voice.say('error', 'playbackFailed', 'Playback failed');\n }\n // Under custom controls the error screen element is the surface, and\n // the element's own row under the video stays quiet.\n if (this.getAttribute(CONTROLS) !== 'custom') this.surface.show(error);\n this.reflect();\n }\n this.emit('error', error);\n }\n\n private async run(): Promise<void> {\n this.unmount();\n if (!this.isConnected) return;\n const sources = this.wanted();\n this.tried = JSON.stringify(sources);\n if (sources.length === 0) return;\n\n const core = await this.ensure();\n this.failure = null;\n this.surface.clear();\n this.reflect();\n\n try {\n await core.load(sources);\n } catch {\n // The core already reported it on the error event, which the surface\n // and the element's own event both carry. Nothing to add here.\n return;\n }\n if (!this.isConnected) await core.unload();\n }\n\n /**\n * What to load, ranked as a video ranks them: the `src` attribute, then\n * the `sources` property, then the `<source>` children in their order.\n * A child carries its own `license-url` and `certificate-url`.\n */\n private wanted(): readonly ProgrammeSource[] {\n // The `<mbx-video-track>` children are versions of the `src` or `<source>` picture.\n const versions = markupVideoTracks(this);\n const withVersions = versions.length === 0 ? {} : { videoTracks: versions };\n const url = this.getAttribute('src');\n if (url !== null) {\n const type = this.getAttribute('type');\n return [{ url, ...(type === null ? {} : { type }), ...withVersions }];\n }\n // A browser without EME gets no DRM stage, and a source must not bring DRM back.\n const eme = emeAvailable();\n if (this.list !== null) {\n return eme\n ? this.list\n : this.list.map((source) => ('url' in source ? withoutDrm(source) : source));\n }\n const found: Source[] = [];\n for (const child of Array.from(this.children)) {\n const src = child.localName === 'source' ? child.getAttribute('src') : null;\n if (src === null) continue;\n const type = child.getAttribute('type');\n const license = child.getAttribute(LICENSE_URL);\n const certificate = child.getAttribute(CERTIFICATE_URL);\n found.push({\n url: src,\n ...(type === null ? {} : { type }),\n ...withVersions,\n ...(!eme || (license === null && certificate === null)\n ? {}\n : {\n drm: {\n ...(license === null ? {} : { licenseUrl: license }),\n ...(certificate === null ? {} : { certificateUrl: certificate }),\n },\n }),\n });\n }\n return found;\n }\n\n /** Sets a session up. It runs for every session, the one that replaces a failed source included. */\n private adopt(session: Session): void {\n this.given = null;\n this.configure(session);\n // A content API's chapters, unless the `chapters` attribute names a file.\n const chapters = this.core?.programme?.metadata?.chapters;\n if (chapters !== undefined && session.engine !== null && this.getAttribute(CHAPTERS) === null) {\n namespaces(session.engine).chapters?.set(chapters);\n }\n // The engine's attach empties the media element to reset its resource\n // selection (`kernel/mse.ts`), and the chapters track goes with the\n // `<source>` children it means. Wanted: the track to survive attach.\n // Had to: put it back once the session is in. The surface that would\n // make it one call: an attach that removes `<source>` children alone.\n // A session with the engine's chapters takes the URL there instead.\n this.chapters();\n }\n\n private async ensure(): Promise<Player> {\n if (this.core !== null) return this.core;\n const connectors = this.options.connectors;\n const core = createPlayer(this.media, {\n handlers: await this.chain(),\n ...(connectors === undefined ? {} : { connectors }),\n });\n this.offs.push(\n core.on('programme', (programme) => {\n this.programmed(programme);\n }),\n core.on('sourcechange', (session) => {\n // Before the event goes out, so a control that reads `engine` on\n // `sourcechange` sees the session the event is about.\n this.current = session;\n // A version loads under the programme it belongs to; any other load is a programme of its own.\n if (!this.switching) {\n const was = this.version;\n this.original = session?.source ?? null;\n this.switched = null;\n this.version = null;\n this.held?.();\n if (was !== null) this.emit('videosourcechange', null);\n }\n this.offTracks?.();\n this.offTracks = session?.engine?.on('tracks:selected', () => this.tracks()) ?? null;\n if (session !== null && this.isConnected) this.adopt(session);\n this.emit('sourcechange', session);\n }),\n core.on('error', (error) => {\n this.report(error);\n }),\n );\n this.core = core;\n return core;\n }\n\n /**\n * Read at each use, not once in the constructor. Importing the package\n * registers the element, and the parser's elements are constructed then,\n * before the page's own `define()` call can run.\n */\n private get options(): MatteboxPlayerOptions {\n return this.own ?? defaults;\n }\n\n private async chain(): Promise<readonly Handler[]> {\n if (this.options.handlers !== undefined) return this.options.handlers;\n const config = this.options.config === undefined ? {} : { config: this.options.config };\n // The stack is read at load time: a preset builds its stages only when asked.\n const native = (stages: () => readonly Stage[]): Handler =>\n nativeHandler({\n // Read on every load, so the attribute applies without a new chain.\n prefer: (source, env) =>\n this.getAttribute(NATIVE_HLS) !== 'off' &&\n !(this.options.addons ?? []).some((addon) => addon.engine === true) &&\n preferNativeHls(source, env),\n drm: () => this.drm(stages),\n });\n if (this.isConnected) this.attachAddons();\n // The add-ons' stages, fresh for this chain, join whatever stack it builds.\n const added = (this.options.addons ?? []).flatMap((addon) => addon.stages?.() ?? []);\n if (this.options.stages !== undefined) {\n const own = this.options.stages;\n const stages = [...own, ...added.filter((stage) => !own.some((o) => o.name === stage.name))];\n return [matteboxHandler({ stages, ...config }), native(() => stages)];\n }\n const name = this.getAttribute('preset') ?? DEFAULT_PRESET;\n const preset = await resolvePreset(name);\n if (preset === null) {\n this.report({\n category: 'config',\n code: 'CONFIG_INVALID',\n fatal: true,\n recoverable: false,\n handler: null,\n context: { preset: name },\n });\n return [nativeHandler()];\n }\n // With a preset, the handler merges these stages into its own by name.\n const extra = added.length === 0 ? {} : { stages: added };\n return [\n matteboxHandler({ preset, ...extra, ...config, ...drmGuard() }),\n native(() => preset.stages()),\n ];\n }\n\n /**\n * The DRM a native session attaches: the page's `drm` option, the\n * key-system stages of the engine's stack, and the `license-url`\n * attribute. None on a browser without EME, as for the engine.\n */\n private drm(stages: () => readonly Stage[]): AttachEmeOptions | undefined {\n if (drmGuard().without !== undefined) return undefined;\n const keySystems = stages().filter((stage) => KEY_SYSTEMS.includes(stage.name));\n const license = this.getAttribute(LICENSE_URL);\n const certificate = this.getAttribute(CERTIFICATE_URL);\n const page = this.options.drm;\n if (keySystems.length === 0 && license === null && page === undefined) return undefined;\n return {\n keySystems,\n ...page,\n ...(license === null ? {} : { licenseUrl: license }),\n ...(certificate === null ? {} : { certificateUrl: certificate }),\n };\n }\n\n /** What the attributes ask of the session's namespaces, once there is one. */\n private configure(session: Session): void {\n const engine = session.engine;\n if (engine === null) return;\n\n const optional = namespaces(engine);\n\n // The attributes are the default. A source's own URL is already on the\n // engine: the handler set it from `source.drm` before the load.\n const own = session.source.drm;\n const license = this.getAttribute(LICENSE_URL);\n // After the session exists, not before: passing a license URL up front\n // means constructing eme-core, and importing a stage to configure it\n // would bundle it.\n if (license !== null && own?.licenseUrl === undefined) optional.drm?.setLicenseUrl(license);\n const certificate = this.getAttribute(CERTIFICATE_URL);\n if (certificate !== null && own?.certificateUrl === undefined) {\n optional.drm?.setCertificateUrl(certificate);\n }\n\n const track = this.getAttribute('thumbnails');\n if (track !== null && optional.thumbnails !== undefined) {\n // Loaded here; drawn by the seek bar's preview under `controls=\"custom\"`.\n // Native controls expose no scrub position to anchor a preview to, so\n // under `native` the track only answers `engine.thumbnails.at(time)` for\n // the app. See docs/guide/03-the-element.md.\n void optional.thumbnails.load(track).catch(() => undefined);\n }\n }\n\n private unmount(): void {\n this.current = null;\n }\n\n private async teardown(): Promise<void> {\n this.unmount();\n if (this.core !== null) await this.core.unload();\n }\n\n /** Drops the player itself, so the next run builds a chain from the new preset. */\n private async discard(): Promise<void> {\n await this.teardown();\n for (const off of this.offs) off();\n this.offs = [];\n this.core = null;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA2EA,MAAM,aAAa;;AAGnB,MAAM,YAAY;CAAC;CAAY;CAAS;CAAU;AAAa;AAE/D,MAAM,cAAc;;AAGpB,MAAM,WAAW;;AAGjB,MAAM,YAAY;;AAGlB,SAAS,eAAwB;CAC/B,OAAO,SAAS,CAAC,CAAC,YAAY,KAAA;AAChC;;AAGA,SAAS,WAAW,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AAc,UAAyB;EACrC,MAAM,KAAK,SAAS;EACpB,KAAK,MAAM,OAAO,KAAK,MAAM,IAAI;EACjC,KAAK,OAAO,CAAC;EACb,KAAK,OAAO;CACd;AACF"}
|
|
1
|
+
{"version":3,"file":"element.js","names":[],"sources":["../src/element.ts"],"sourcesContent":["/**\n * <mattebox-player>: a real <video> as a light-DOM child, so the integrator\n * can reach it, and the error surface in shadow DOM. The element never\n * forwards or wraps a media element member: play, pause, seek, volume and\n * the rest live on the video, where the browser, Picture-in-Picture and the\n * OS media session already find them.\n *\n * The controls are elements the page places inside, beside the video, and\n * the stage slots them over the picture. The element appends none of its\n * own: the composition is the page's in every mode, and `none` hides every\n * child but the video. The element reflects the video's state as\n * attributes on itself, `paused`, `playing`, `ended`, `muted`, `audio`,\n * `started` and `waiting`, for the page's stylesheet and the controls\n * alike.\n *\n * No class fields, `#private` or otherwise: the ES2015 build would lower\n * them into runtime helpers, and the emit check bans helpers. Statics are\n * getters and instance state is declared, then assigned in the constructor.\n */\n\nimport type {\n Connector,\n Handler,\n Player,\n PlayerError,\n Programme,\n ProgrammeSource,\n Session,\n Source,\n SourceVideoTrack,\n} from '@mattebox/player-core';\nimport {\n createPlayer,\n inferType,\n matteboxHandler,\n nativeHandler,\n preferNativeHls,\n} from '@mattebox/player-core';\nimport type { KernelConfig, Mattebox, Stage } from 'mattebox';\nimport type { AttachEmeOptions } from 'mattebox/eme';\nimport type { Announcer } from './announcer.js';\nimport { announcer } from './announcer.js';\nimport { type BreakMarks, createBreakMarks } from './controls/breaks.js';\nimport type { Marker, Markers } from './controls/markers.js';\nimport { createMarkers } from './controls/markers.js';\nimport { languageName } from './controls/track-names.js';\nimport type { Block, PlayerAddon, PlayerHost } from './host.js';\nimport type { LocaleSource } from './locales.js';\nimport { addLocale, load, onLocales, registered, wordsNow } from './locales.js';\nimport type { Messages, Words } from './messages.js';\nimport { namespaces } from './namespaces.js';\nimport { drmGuard, resolvePreset } from './presets.js';\nimport { STYLE } from './style.js';\nimport type { ErrorSurface } from './surface.js';\nimport { errorSurface } from './surface.js';\nimport { ERROR_SCREEN, PLAYER } from './tags.js';\nimport { textIn } from './text.js';\nimport type { Tracker, TrackerRunner, Trackers } from './trackers.js';\nimport { createTrackers } from './trackers.js';\nimport type { Chosen } from './video-sources.js';\nimport {\n chosen,\n holdFrame,\n markupVideoTracks,\n onNextFrame,\n restore,\n resume,\n versionSource,\n} from './video-sources.js';\n\n/**\n * `off` keeps HLS on the engine in Safari. Anything else lets Safari play\n * HLS itself: FairPlay, AirPlay, Low-Latency HLS and the platform's\n * fullscreen then work as Apple built them. Changing it reloads.\n */\nconst NATIVE_HLS = 'native-hls';\n\n/**\n * Attributes forwarded onto the video as attributes, never as properties.\n * `disablepictureinpicture` also hides the browser's own picture-in-picture\n * toggle, which Firefox draws over every video that lacks it.\n */\nconst FORWARDED = ['autoplay', 'muted', 'poster', 'crossorigin', 'disablepictureinpicture'];\n\nconst LICENSE_URL = 'license-url';\n\n/** The language the page chose, over the nearest `lang`. */\nconst LANGUAGE = 'language';\n\n/** Carried through a switch: the play state from before it, `playing` or `paused`. */\nconst SWITCHING = 'switching';\n\n/** Whether the browser has EME, so a source may bring DRM. */\nfunction emeAvailable(): boolean {\n return drmGuard().without === undefined;\n}\n\n/** `source` without its DRM, for a browser without EME. */\nfunction withoutDrm({ url, type, videoTracks }: Source): Source {\n return {\n url,\n ...(type === undefined ? {} : { type }),\n ...(videoTracks === undefined ? {} : { videoTracks }),\n };\n}\nconst CERTIFICATE_URL = 'certificate-url';\n\n/** Everything else the element watches. Changing any of them reloads. */\nconst OWN = ['src', 'type', 'preset', LICENSE_URL, CERTIFICATE_URL, 'thumbnails', NATIVE_HLS];\n\n/**\n * The chapters file URL. A session with the engine's `chapters` namespace\n * loads it there: through the engine's transport, so request hooks apply,\n * and in every format the engine reads. Any other session gets a\n * `<track kind=\"chapters\">` on the video, hidden so its cues load and\n * nothing is drawn. The seek bar and the chapters menu read either.\n * Changing it never reloads the source.\n */\nconst CHAPTERS = 'chapters';\n\n/**\n * The one attribute whose meaning the element owns: `native` keeps the\n * browser's controls on the video, `custom` swaps them for the controls the\n * page placed inside, `none` takes the browser's off and hides every child\n * but the video. Anything else is `native`. Changing it never touches the\n * session.\n */\nconst CONTROLS = 'controls';\n\n/**\n * Inline playback, on until the page writes `playsinline=\"false\"`, the way\n * `spellcheck` and `draggable` are on until told otherwise. An iPhone takes\n * a video without `playsinline` to its own fullscreen on play, where no\n * control the page placed shows. Changing it never reloads.\n */\nconst PLAYSINLINE = 'playsinline';\n\n/**\n * The size tier the controls draw for: `compact` on a small player, such\n * as a phone held upright, `wide` on a large one, such as a TV or\n * fullscreen, and `regular` between. The element measures itself and sets\n * the attribute, so a stylesheet matches `mattebox-player[layout=\"compact\"]`.\n * A page that writes one of the three values fixes it, and removing the\n * attribute hands it back. The player's own box decides, not the screen:\n * a small embed on a desktop is compact, and a phone in fullscreen is not.\n */\nconst LAYOUT = 'layout';\nconst LAYOUTS = ['compact', 'regular', 'wide'];\n/** Under either, the player is compact. */\nconst COMPACT_WIDTH = 480;\nconst COMPACT_HEIGHT = 320;\n/** From both, the player is wide. */\nconst WIDE_WIDTH = 1280;\nconst WIDE_HEIGHT = 700;\n\n/** The video's state, as attributes on the element, read on the events the video fires for it. */\nconst STATE_EVENTS = [\n 'play',\n 'pause',\n 'ended',\n // A seek back from the end leaves `ended` with no play, pause or ended event.\n 'seeked',\n 'emptied',\n 'volumechange',\n 'loadedmetadata',\n 'resize',\n 'playing',\n 'waiting',\n 'canplay',\n];\n\n/**\n * How long the video waits for data before the live region says so. A\n * seek within the buffer waits for less, and saying it would only be noise.\n */\nconst LOADING_MS = 1000;\n\n/** A track's name for the live region: its name in the stream, else its language's in `locale`. */\nfunction trackName(name: string | undefined, lang: string | undefined, locale: string): string {\n return name || (lang && (languageName(lang, locale || undefined) ?? lang)) || '';\n}\n\n/** The stages that register a key system, which a native session's DRM offers. */\nconst KEY_SYSTEMS = ['eme-fairplay', 'eme-cenc'];\n\n/** Every stage the engine ships. A narrower preset is optimization. */\nconst DEFAULT_PRESET = 'full';\n\n/**\n * What the element dispatches. `error` is also a standard DOM event name, so\n * without these overloads a listener on it is typed as `ErrorEvent` and the\n * payload needs a double cast. They are declarations only: no runtime bytes.\n */\nexport interface MatteboxPlayerEventMap {\n sourcechange: CustomEvent<Session | null>;\n /** The size tier changed: `compact`, `regular` or `wide`. */\n layoutchange: CustomEvent<string>;\n error: CustomEvent<PlayerError>;\n /** The markers changed: set by the page, or cleared by a new source. */\n markerschange: CustomEvent<readonly Marker[]>;\n /** Playback reached a blocked range and moved past it. */\n blocked: CustomEvent<Marker>;\n /** The page called `block()` or `unblock()`, or a new source cleared the block: the block, or null. */\n blockchange: CustomEvent<Block | null>;\n /** A load resolved what it plays, before the session: the programme, or null at unload. */\n programmechange: CustomEvent<Programme | null>;\n /** A tracker was added, removed, started or stopped: the trackers. */\n trackerschange: CustomEvent<readonly Tracker[]>;\n}\n\nexport interface MatteboxPlayerElement {\n addEventListener<K extends keyof MatteboxPlayerEventMap>(\n type: K,\n listener: (this: MatteboxPlayerElement, event: MatteboxPlayerEventMap[K]) => void,\n options?: boolean | AddEventListenerOptions,\n ): void;\n addEventListener(\n type: string,\n listener: EventListenerOrEventListenerObject,\n options?: boolean | AddEventListenerOptions,\n ): void;\n removeEventListener<K extends keyof MatteboxPlayerEventMap>(\n type: K,\n listener: (this: MatteboxPlayerElement, event: MatteboxPlayerEventMap[K]) => void,\n options?: boolean | EventListenerOptions,\n ): void;\n removeEventListener(\n type: string,\n listener: EventListenerOrEventListenerObject,\n options?: boolean | EventListenerOptions,\n ): void;\n}\n\nexport interface MatteboxPlayerOptions {\n /** The whole chain, in order. Takes precedence over `stages` and the `preset` attribute. */\n readonly handlers?: readonly Handler[];\n /** Stages for the mattebox handler. Takes precedence over the `preset` attribute. */\n readonly stages?: readonly Stage[];\n /**\n * Kernel tuning for the engines the elements build, `traceCapacity` among\n * it. A page decision, like the stages, so not an attribute. Ignored with\n * `handlers`, which carry their own.\n */\n readonly config?: Partial<KernelConfig>;\n /**\n * DRM for a native session, as `attachEme` from `mattebox/eme` takes it:\n * `keySystems`, `licenseUrl`, `licenseUrls`, `requestHook`. Without\n * `keySystems` the session offers the key-system stages of the engine's\n * stack. The `license-url` attribute overrides `licenseUrl`, and\n * `certificate-url` gives the FairPlay certificate. Ignored\n * with `handlers`, which carry their own.\n */\n readonly drm?: AttachEmeOptions;\n /**\n * One per source type, such as `srgssr/urn`: a source of that type is a\n * programme id, or data you give, which the connector resolves to what\n * plays. Kept with `handlers`.\n */\n readonly connectors?: readonly Connector[];\n /**\n * Packages that add to every player, such as `ads()` from\n * `@mattebox/player-ads`: their stages join the stack, and each runs on\n * every player that connects. Ignored with `handlers`, apart from what\n * they run on the player.\n */\n readonly addons?: readonly PlayerAddon[];\n}\n\n/**\n * What `define()` recorded, for the elements the parser creates. It is the\n * one value shared across elements, because a page that writes only markup\n * still has to be able to say what the engine carries.\n */\nlet defaults: MatteboxPlayerOptions = {};\n\n/**\n * The interface above merges only `addEventListener` and `removeEventListener`\n * overloads, which the class inherits from HTMLElement. The rule it suppresses\n * guards against properties an interface declares and a constructor never\n * assigns, and there are none.\n */\n// biome-ignore lint/suspicious/noUnsafeDeclarationMerging: method overloads only, no properties\nexport class MatteboxPlayerElement extends HTMLElement implements PlayerHost {\n static get observedAttributes(): readonly string[] {\n return [...FORWARDED, ...OWN, CONTROLS, CHAPTERS, PLAYSINLINE, LAYOUT, LANGUAGE, 'lang'];\n }\n\n /**\n * Registers the words of a language for every player on the page. Each\n * source is a set of words or a function that loads one, which runs only\n * when a player shows that language. Later sources go over earlier ones,\n * so a page changes a shipped word by registering its own after it.\n * Players that show the language take the new words at once.\n */\n static addLocale(language: string, ...sources: readonly LocaleSource[]): void {\n addLocale(language, sources);\n }\n\n /**\n * Registers the element once, and records the stages markup-only pages\n * get. The controls register through their own entries, the package's\n * root entry importing every one; a control connected before its player\n * is defined waits for the definition.\n */\n static define(options?: MatteboxPlayerOptions): void {\n if (options !== undefined) defaults = options;\n if (customElements.get(PLAYER) === undefined) {\n customElements.define(PLAYER, MatteboxPlayerElement);\n }\n }\n\n declare private readonly media: HTMLVideoElement;\n /** Wraps the slot: the picture, and the controls over it or under it. */\n declare private readonly stage: HTMLDivElement;\n /** Whether the element gave itself a tabindex for the bar, to take back with it. */\n declare private focusable: boolean;\n declare private readonly surface: ErrorSurface;\n declare private readonly voice: Announcer;\n /** The words of the language shown, empty for English. */\n declare private words: Words;\n /** The language tag the player resolved, or empty without one. */\n declare private shown: string;\n /** Bumped on every resolution, so a slow loader does not win over a later choice. */\n declare private wordsEpoch: number;\n /** Ends the watch on registrations and on the page's `lang`. */\n declare private unwatch: (() => void) | null;\n /** Runs out when the video has waited `LOADING_MS`. */\n declare private slow: ReturnType<typeof setTimeout> | undefined;\n /** The audio track the live region last saw, so it says only a change. Undefined before the first play. */\n declare private heardAudio: string | undefined;\n /** The subtitle track it last saw: null for off, undefined before the first play. */\n declare private heardText: string | null | undefined;\n /** Stops listening to the current engine's track selection. */\n declare private offTracks: (() => void) | null;\n declare private readonly marks: Markers;\n declare private readonly breakMarks: BreakMarks;\n /** The chapters track element, while the `chapters` attribute names one and the engine takes none. */\n declare private track: HTMLTrackElement | null;\n /** The chapters URL the current session's engine was given, or null. */\n declare private given: string | null;\n /** The sources the page set from script, or null. */\n declare private list: readonly ProgrammeSource[] | null;\n declare private readonly tracking: TrackerRunner;\n /** The sources of the last run, as text: what tells a new `<source>` child from the ones already tried. */\n declare private tried: string;\n /** The options this element was constructed with, or null for the ones `define()` recorded. */\n declare private readonly own: MatteboxPlayerOptions | null;\n declare private core: Player | null;\n declare private current: Session | null;\n declare private failure: PlayerError | null;\n /** What `block()` set, or null. */\n declare private stop: Block | null;\n /** Whether an attribute change is the element's own reflection, which must not write back to the video. */\n declare private reflecting: boolean;\n /** Watches the element's box for `layout`, while connected. */\n declare private sizes: ResizeObserver | null;\n /** Whether the page wrote `layout`, so the element leaves it alone. */\n declare private fixed: boolean;\n /** The video has played once since its source was set: `started`, which tells a first play from a pause. */\n declare private started: boolean;\n /** The video waits for data: `waiting`, set on `waiting`, cleared once it can play. */\n declare private waiting: boolean;\n declare private offs: Array<() => void>;\n /** Where `interrupt` left the programme: its time, whether it played, its tracks. */\n declare private interruption: { at: number | null; playing: boolean; had: Chosen | null } | null;\n /** The add-ons attached to this player, with what each returned, run when it leaves the page. */\n declare private attached: Map<PlayerAddon, (() => void) | undefined>;\n /** Everything the element does to the player runs here, so it runs in order. */\n declare private queue: Promise<void>;\n /** Whether a run is queued and not yet started, so a burst of changes loads once. */\n declare private pending: boolean;\n /** The source the versions of `videoSources` belong to: the one that played before a switch. */\n declare private original: Source | null;\n /** The version that plays, or null for the programme itself. */\n declare private version: SourceVideoTrack | null;\n /** True while a version loads, so its `sourcechange` keeps the programme. */\n declare private switching: boolean;\n /** The source `switchSource` loaded, which a retry loads again, or null. */\n declare private switched: Source | null;\n /** Ends the hold of a switch: the poster and `switching` go back. Null without one. */\n declare private held: (() => void) | null;\n\n constructor(options?: MatteboxPlayerOptions) {\n super();\n this.own = options ?? null;\n this.focusable = false;\n this.track = null;\n this.given = null;\n this.list = null;\n this.tried = '';\n this.core = null;\n this.current = null;\n this.failure = null;\n this.stop = null;\n this.reflecting = false;\n this.sizes = null;\n this.fixed = false;\n this.started = false;\n this.waiting = false;\n this.offs = [];\n this.attached = new Map();\n this.interruption = null;\n this.queue = Promise.resolve();\n this.pending = false;\n this.original = null;\n this.version = null;\n this.switching = false;\n this.switched = null;\n this.held = null;\n this.words = {};\n this.shown = '';\n this.wordsEpoch = 0;\n this.unwatch = null;\n this.slow = undefined;\n this.heardAudio = undefined;\n this.heardText = undefined;\n this.offTracks = null;\n\n this.media = document.createElement('video');\n // Native until the `controls` attribute says otherwise, which arrives\n // through attributeChangedCallback: a constructor must not read attributes.\n this.media.controls = true;\n // Inline is the default, and the player's own attribute has not arrived\n // yet. Set as an attribute: not every browser has the `playsInline`\n // property. The fullscreen button still reaches the iPhone's fullscreen,\n // through `webkitEnterFullscreen`.\n this.media.setAttribute(PLAYSINLINE, '');\n for (const name of STATE_EVENTS) {\n this.media.addEventListener(name, () => {\n const was = this.waiting;\n this.note(name);\n this.reflect();\n this.tell(name, was);\n });\n }\n // A native session's tracks; an engine session's are on `tracks:selected`.\n const lists = this.media as { audioTracks?: EventTarget; textTracks: EventTarget };\n for (const list of [lists.audioTracks, lists.textTracks]) {\n list?.addEventListener('change', () => {\n this.tracks();\n });\n }\n // An error over a picture that then plays is wrong by definition.\n this.media.addEventListener('playing', () => {\n this.failure = null;\n this.reflect();\n });\n this.marks = createMarkers(this.media, (name, detail) => this.emit(name, detail));\n this.breakMarks = createBreakMarks((list) => this.emit('breakschange', list));\n this.tracking = createTrackers(this, () => this.emit('trackerschange', this.tracking.list));\n this.stage = document.createElement('div');\n this.stage.setAttribute('part', 'stage');\n const slot = document.createElement('slot');\n // The parser connects the element before its children exist, so the\n // first run finds no `<source>`. A video starts its selection when a\n // `<source>` arrives and nothing is loaded, and so does this.\n slot.addEventListener('slotchange', () => {\n if (this.current === null && JSON.stringify(this.wanted()) !== this.tried) this.reload();\n });\n this.stage.append(slot);\n this.surface = errorSurface(\n () => {\n this.retry();\n },\n () => this.words.retry ?? 'Retry',\n );\n\n this.voice = announcer(this, (id) => this.words[id]);\n\n const root = this.attachShadow({ mode: 'open' });\n const style = document.createElement('style');\n style.textContent = STYLE;\n root.append(style, this.stage, this.surface.root, this.voice.root);\n }\n\n /** The media element. Everything the browser already does is here. */\n get video(): HTMLVideoElement {\n return this.media;\n }\n\n /** The ranges the page named in this source: credits to skip, parts that must not play. */\n get markers(): Markers {\n return this.marks;\n }\n\n /** Where the programme's ad breaks are, which the seek bar draws: each add-on gives its own. */\n get breaks(): BreakMarks {\n return this.breakMarks;\n }\n\n /**\n * The sources to try in order, set from script. The `src` attribute wins\n * over them, and they win over the `<source>` children. Setting them\n * loads, and null returns to the children.\n */\n get sources(): readonly ProgrammeSource[] | null {\n return this.list;\n }\n\n set sources(value: readonly ProgrammeSource[] | null) {\n this.list = value;\n // Markers, a block and an interruption belong to a source, as for `src`.\n if (this.marks.list.length > 0) this.marks.set([]);\n this.interruption = null;\n this.unblock();\n this.reload();\n }\n\n /**\n * The language the page chose for this player, which wins over the\n * nearest `lang` attribute. Empty follows `lang`. Setting it changes the\n * words of every control at once.\n */\n get language(): string {\n return this.getAttribute(LANGUAGE) ?? '';\n }\n\n set language(value: string) {\n if (value === '') this.removeAttribute(LANGUAGE);\n else this.setAttribute(LANGUAGE, value);\n }\n\n /** The language tag the words come from: `language`, else the nearest `lang`. Empty without either. */\n get locale(): string {\n return this.shown;\n }\n\n /** The word of `id` in the player's language, or undefined, where the control's English applies. */\n message(id: keyof Messages): string | undefined {\n return this.words[id];\n }\n\n /** Follows registrations and the document's `lang` until disconnect. */\n private watchLanguage(): void {\n const off = onLocales(() => {\n this.relocale();\n });\n // The page's language usually sits on <html>; a lang on another\n // ancestor is read at connect, and `language` covers a change there.\n const watch = new MutationObserver(() => {\n this.relocale();\n });\n watch.observe(document.documentElement, { attributes: true, attributeFilter: ['lang'] });\n this.unwatch = () => {\n off();\n watch.disconnect();\n };\n this.relocale();\n }\n\n /** Resolves the language, takes its words, and tells the controls with `localechange`. */\n private relocale(): void {\n const tag = this.getAttribute(LANGUAGE) ?? this.closest('[lang]')?.getAttribute('lang') ?? '';\n const epoch = ++this.wordsEpoch;\n const take = (words: Words): void => {\n if (epoch !== this.wordsEpoch) return;\n this.shown = tag;\n this.words = words;\n this.showBlock();\n this.emit('localechange', tag);\n };\n const key = registered(tag);\n if (key === null) {\n take({});\n return;\n }\n const now = wordsNow(key);\n if (now !== null) {\n take(now);\n return;\n }\n // The words on screen stay until the language arrives; a loader that\n // fails leaves them.\n load(key).then(take, () => undefined);\n }\n\n /**\n * Loads the sources again, in the order a load reads them: the `src`\n * attribute, the `sources` property, then the `<source>` children. The\n * error screens' Retry calls it. On a version of `videoSources`, it\n * loads that version again.\n */\n retry(): void {\n const again =\n this.version === null ? this.switched : versionSource(this.version, emeAvailable());\n if (again === null) this.reload();\n else this.swap(again, null, false, null, false);\n }\n\n /**\n * Loads `source` in place of the one that plays, from the same position\n * and in the same play state, with the same audio and subtitle choice.\n * Use it for the same programme at another URL, such as its HLS and\n * DASH manifests. The last frame and the controls hold until the new\n * load shows a frame there. The markers stay, and the versions are the\n * ones `source` names. A new `src`, `sources` or `<source>` load\n * replaces it.\n */\n switchSource(source: Source): void {\n const media = this.media;\n const at = Number.isFinite(media.duration) ? media.currentTime : null;\n const playing = !media.paused;\n const had = chosen(this.current?.engine ?? null);\n const clean = emeAvailable() ? source : withoutDrm(source);\n const was = this.version;\n this.original = clean;\n this.switched = clean;\n this.version = null;\n if (was !== null) this.emit('videosourcechange', null);\n this.swap(clean, at, playing, had, true);\n }\n\n /**\n * Plays `source` on the video in the programme's place, such as an ad of\n * `@mattebox/player-ads`. The programme, its markers and its trackers\n * stay, no `sourcechange` fires, and the controls drive the source as\n * they drive the programme. An error of the source is not the\n * programme's: listen to the video. `resume()` plays the programme again\n * where it stopped. Resolves once the source is loaded; rejects when no\n * handler plays it.\n */\n interrupt(source: Source): Promise<void> {\n const media = this.media;\n this.interruption ??= {\n at: Number.isFinite(media.duration) ? media.currentTime : null,\n playing: !media.paused,\n had: chosen(this.current?.engine ?? null),\n };\n return this.queued(async () => {\n const core = await this.ensure();\n await core.interrupt(source);\n this.current = core.session;\n media.play().catch(() => undefined);\n });\n }\n\n /**\n * Plays the programme again where `interrupt` left it, in the play state\n * it had, or as `options` says: `at` another position, such as its end\n * after a post-roll, and `playing`.\n */\n resume(options: { readonly at?: number | null; readonly playing?: boolean } = {}): Promise<void> {\n const left = this.interruption;\n if (left === null) return Promise.resolve();\n this.interruption = null;\n const at = options.at === undefined ? left.at : options.at;\n const playing = options.playing ?? left.playing;\n return this.queued(async () => {\n const core = await this.ensure();\n await core.resume(at ?? undefined);\n this.current = core.session;\n restore(this.current?.engine ?? null, left.had);\n if (playing) this.media.play().catch(() => undefined);\n });\n }\n\n /** `interrupt` plays in the programme's place. */\n get interrupted(): boolean {\n return this.interruption !== null;\n }\n\n /** Runs `task` in the element's queue, and says how it went. */\n private queued(task: () => Promise<void>): Promise<void> {\n return new Promise((resolve, reject) => {\n this.enqueue(() => task().then(resolve, reject));\n });\n }\n\n /** The other versions of the picture the source names at their own URLs, for the video menu. */\n get videoSources(): readonly SourceVideoTrack[] {\n return this.original?.videoTracks ?? [];\n }\n\n /** The version of `videoSources` that plays, or null for the source itself. */\n get videoSource(): SourceVideoTrack | null {\n return this.version;\n }\n\n /**\n * Plays a version of `videoSources`, or the source itself for null, from\n * the same position and in the same play state, with the same audio and\n * subtitle choice. A live source joins the version at its live edge.\n * Fires `videosourcechange`.\n */\n selectVideoSource(track: SourceVideoTrack | null): void {\n const programme = this.original;\n if (programme === null || track === this.version) return;\n if (track !== null && programme.videoTracks?.includes(track) !== true) return;\n const media = this.media;\n const at = Number.isFinite(media.duration) ? media.currentTime : null;\n const playing = !media.paused;\n const had = chosen(this.current?.engine ?? null);\n this.version = track;\n this.emit('videosourcechange', track);\n this.swap(\n track === null ? programme : versionSource(track, emeAvailable()),\n at,\n playing,\n had,\n true,\n );\n }\n\n /**\n * Loads `source` under the programme that plays, and puts the position,\n * play state and tracks back. With `hold`, the last frame stays as the\n * poster and the player carries `switching`, the play state from\n * before, so the controls show that state through the load.\n */\n private swap(\n source: Source,\n at: number | null,\n playing: boolean,\n had: Chosen | null,\n hold: boolean,\n ): void {\n const media = this.media;\n this.held?.();\n let release: (() => void) | null = null;\n if (hold) {\n // Taken now, while the frame of the source that played is still on screen.\n const frame = holdFrame(media);\n const done = (): void => {\n frame?.();\n if (this.held !== done) return;\n this.held = null;\n this.removeAttribute(SWITCHING);\n this.reflect();\n };\n this.held = done;\n this.setAttribute(SWITCHING, playing ? 'playing' : 'paused');\n release = done;\n }\n this.enqueue(async () => {\n const core = await this.ensure();\n this.switching = true;\n try {\n await core.load([source]);\n } catch {\n // Reported on the error event, as for any load.\n release?.();\n return;\n } finally {\n this.switching = false;\n }\n resume(media, at, playing);\n if (release !== null) onNextFrame(media, at, release);\n restore(this.current?.engine ?? null, had);\n });\n }\n\n /** The core, or null until the first source has been set up: resolving a preset is asynchronous. */\n get player(): Player | null {\n return this.core;\n }\n\n /** The engine feeding the video, or null for a native session and before the first load. */\n get engine(): Mattebox | null {\n return this.current?.engine ?? null;\n }\n\n /**\n * The fatal error of the current load, or null once a load starts or\n * playback resumes. The `error` event says when; this says what, for a\n * control that attaches after the event, such as an error screen parsed\n * after a source that failed while the page was still loading.\n */\n get error(): PlayerError | null {\n return this.failure;\n }\n\n /**\n * Shows why the programme does not play, in place of the video, and\n * stops the load: the reason the page's content API gave, such as a\n * geographic or an age restriction. The error screen shows the title,\n * else \"Not available\", and the message, with no retry. Each text can\n * be given by language tag, and follows the player's language. A new\n * `src` or `sources` clears it. Fires `blockchange`.\n */\n block(block: Block): void {\n this.refuse(block);\n this.enqueue(() => this.teardown());\n }\n\n /** Shows the block, for `block()` and for a programme a connector blocked, which loaded nothing. */\n private refuse(block: Block): void {\n this.stop = block;\n this.media.pause();\n clearTimeout(this.slow);\n const [title, message] = this.blockWords(block);\n // An error screen in the player is an alert of its own, read already.\n if (this.querySelector(ERROR_SCREEN) === null) {\n this.voice.tell(message === '' ? title : `${title}. ${message}`);\n }\n this.showBlock();\n this.reflect();\n this.emit('blockchange', block);\n }\n\n /** Removes the block. Nothing plays until a source loads: set one, or call `retry()`. */\n unblock(): void {\n if (this.stop === null) return;\n this.stop = null;\n this.surface.clear();\n this.reflect();\n this.emit('blockchange', null);\n }\n\n /** What `block()` set, or null. */\n get blocked(): Block | null {\n return this.stop;\n }\n\n /**\n * What the current load resolved to: the sources, and what a connector\n * said of the programme. Null before a load and after an unload.\n */\n get programme(): Programme | null {\n return this.core?.programme ?? null;\n }\n\n /**\n * The page's trackers. Each starts at every programme and stops at its\n * end; one added or removed during a programme starts or stops at once.\n */\n get trackers(): Trackers {\n return this.tracking;\n }\n\n /**\n * Applies what the load resolved, before any session: the markers, the\n * poster, the block. The page's own `poster` and markers set after the\n * source win. Then the trackers start on the programme.\n */\n private programmed(programme: Programme | null): void {\n const metadata = programme?.metadata;\n if (metadata?.markers !== undefined) this.marks.set(metadata.markers);\n if (!this.hasAttribute('poster')) {\n if (metadata?.poster === undefined) this.media.removeAttribute('poster');\n else this.media.poster = metadata.poster;\n }\n if (programme?.block !== undefined) this.refuse(programme.block);\n this.emit('programmechange', programme);\n this.tracking.begin(programme);\n }\n\n /** A block's title and message in the player's language: the title defaults to the `blocked` word. */\n private blockWords(block: Block): [string, string] {\n return [\n block.title === undefined\n ? (this.words.blocked ?? 'Not available')\n : textIn(block.title, this.shown),\n block.message === undefined ? '' : textIn(block.message, this.shown),\n ];\n }\n\n /** Puts the block on the row under the video, under native controls. */\n private showBlock(): void {\n if (this.stop === null || this.getAttribute(CONTROLS) === 'custom') return;\n const [title, message] = this.blockWords(this.stop);\n this.surface.inform(title, message);\n }\n\n connectedCallback(): void {\n if (this.media.parentNode !== this) this.append(this.media);\n for (const name of FORWARDED) this.forward(name);\n this.reflect();\n if (typeof ResizeObserver !== 'undefined') {\n this.sizes = new ResizeObserver(() => {\n this.measure();\n });\n this.sizes.observe(this);\n }\n this.measure();\n this.watchLanguage();\n this.attachAddons();\n this.reload();\n }\n\n /**\n * Attaches each add-on of the options once. At connect, and again at each\n * load: a page that imports the player registers it before its own\n * `define()` gives the add-ons, and the players already on the page\n * connected then.\n */\n private attachAddons(): void {\n for (const addon of this.options.addons ?? []) {\n if (!this.attached.has(addon)) this.attached.set(addon, addon.attach?.(this));\n }\n }\n\n /** Sets `layout` from the element's box, unless the page fixed it. */\n private measure(): void {\n if (this.fixed) return;\n const width = this.clientWidth;\n const height = this.clientHeight;\n // Not laid out yet: no tier until there is a box to judge.\n if (width === 0 || height === 0) return;\n const layout =\n width < COMPACT_WIDTH || height < COMPACT_HEIGHT\n ? 'compact'\n : width >= WIDE_WIDTH && height >= WIDE_HEIGHT\n ? 'wide'\n : 'regular';\n if (this.getAttribute(LAYOUT) === layout) return;\n this.reflecting = true;\n this.setAttribute(LAYOUT, layout);\n this.reflecting = false;\n this.emit('layoutchange', layout);\n }\n\n /** The two states the video does not hold: whether it has played once, and whether it waits for data. */\n private note(event: string): void {\n if (event === 'playing') {\n // The tracks the video starts playing with are what a change is from.\n if (!this.started) this.tracks();\n this.started = true;\n this.waiting = false;\n } else if (event === 'waiting') {\n // Not `stalled`: a paused video with a full buffer fires it too, when\n // nothing more is appended for three seconds. video.js reads `waiting` alone.\n this.waiting = true;\n } else if (event === 'canplay') {\n this.waiting = false;\n } else if (event === 'emptied') {\n // A new source starts over: the title shows again before its first play.\n // A switch is the same programme, so it keeps its start.\n if (this.held === null) this.started = false;\n this.waiting = false;\n this.heardAudio = undefined;\n this.heardText = undefined;\n }\n }\n\n /** Says a play or a pause, and a wait once it has lasted `LOADING_MS`. */\n private tell(event: string, was: boolean): void {\n // The load of a switch pauses and plays the video, and the viewer did neither.\n if (event === 'play' && this.held === null) this.voice.say('playing', 'saidPlaying', 'Playing');\n // The end of the video pauses it too, and that is no pause to say.\n if (event === 'pause' && !this.media.ended && this.held === null) {\n this.voice.say('paused', 'saidPaused', 'Paused');\n }\n if (this.waiting === was) return;\n clearTimeout(this.slow);\n if (this.waiting) {\n this.slow = setTimeout(() => {\n this.voice.say('loading', 'loading', 'Loading');\n }, LOADING_MS);\n }\n }\n\n /**\n * Says a change of the audio or the subtitle track, once the video has\n * played: the tracks a load starts with are no change. A forced track\n * reads as off, as in the subtitles menu.\n */\n private tracks(): void {\n const engine = this.current?.engine ?? null;\n let audio: string;\n let text: string | null;\n if (engine !== null) {\n const sound = engine.tracks.active('audio');\n const words = engine.tracks.active('text');\n audio = sound === null ? '' : trackName(sound.name, sound.lang, this.locale);\n text =\n words === null || words.forced === true\n ? null\n : trackName(words.name, words.lang, this.locale);\n } else {\n const video = this.media as {\n audioTracks?: ArrayLike<{ enabled: boolean; label: string; language: string }>;\n };\n const sound = Array.from(video.audioTracks ?? []).find((track) => track.enabled);\n const words = Array.from(this.media.textTracks).find(\n (track) =>\n (track.kind === 'subtitles' || track.kind === 'captions') && track.mode === 'showing',\n );\n audio = sound === undefined ? '' : trackName(sound.label, sound.language, this.locale);\n text = words === undefined ? null : trackName(words.label, words.language, this.locale);\n }\n const { heardAudio, heardText } = this;\n this.heardAudio = audio;\n this.heardText = text;\n if (!this.started) return;\n if (heardAudio !== undefined && audio !== heardAudio) {\n this.voice.say('audio', 'saidAudio', 'Audio: {track}', audio);\n }\n if (heardText !== undefined && text !== heardText) {\n if (text === null) this.voice.say('subtitles-off', 'saidSubtitlesOff', 'Subtitles off');\n else this.voice.say('subtitles', 'saidSubtitles', 'Subtitles: {track}', text);\n }\n }\n\n /** The video's state on the element, for `mattebox-player[paused]` and the like. */\n private reflect(): void {\n const video = this.media;\n this.reflecting = true;\n // Through a switch, the play state from before it.\n const held = this.getAttribute(SWITCHING);\n const paused = held === null ? video.paused : held === 'paused';\n this.toggleAttribute('paused', paused);\n this.toggleAttribute('playing', !paused);\n this.toggleAttribute('ended', video.ended);\n // `muted` is also forwarded: the page's attribute sets the video, and\n // the video's state sets the attribute. Reflection never forwards, so\n // a read can only ever change the attribute, never the video.\n this.toggleAttribute('muted', video.muted);\n this.toggleAttribute('audio', this.audio());\n this.toggleAttribute('started', this.started);\n this.toggleAttribute('waiting', this.waiting);\n this.toggleAttribute('error', this.failure !== null);\n this.toggleAttribute('blocked', this.stop !== null);\n this.reflecting = false;\n }\n\n /**\n * Whether the source has no picture. Once the metadata is in, the video's\n * size decides: zero by zero is sound alone, and `resize` catches a stream\n * that moves to or from an audio-only rendition. Before that, the type the\n * page wrote or the URL implies is the hint, so an mp3 is `audio` from\n * the start rather than from its metadata.\n */\n private audio(): boolean {\n const video = this.media;\n if (video.readyState >= HTMLMediaElement.HAVE_METADATA) {\n return video.videoWidth === 0 && video.videoHeight === 0;\n }\n const src = this.getAttribute('src');\n const type = this.getAttribute('type') ?? (src === null ? undefined : inferType(src));\n return type?.startsWith('audio/') === true;\n }\n\n disconnectedCallback(): void {\n this.sizes?.disconnect();\n this.sizes = null;\n this.unwatch?.();\n this.unwatch = null;\n // A single-page app must not leave a pipeline attached to a video it\n // navigated away from. Reconnecting loads the `src` again. A move is no\n // removal: as HTML's media element waits for a stable state before it\n // pauses, the teardown waits a microtask and runs only if the element is\n // still out of the document.\n queueMicrotask(() => {\n if (this.isConnected) return;\n for (const off of this.attached.values()) off?.();\n this.attached.clear();\n this.enqueue(() => this.teardown());\n });\n }\n\n attributeChangedCallback(name: string): void {\n if (name === LANGUAGE || name === 'lang') {\n this.relocale();\n return;\n }\n if (FORWARDED.includes(name)) {\n if (!this.reflecting) this.forward(name);\n return;\n }\n if (name === CONTROLS) {\n this.mode();\n return;\n }\n if (name === CHAPTERS) {\n this.chapters();\n return;\n }\n if (name === LAYOUT) {\n // The element's own write is not the page's.\n if (this.reflecting) return;\n const value = this.getAttribute(LAYOUT);\n this.fixed = value !== null && LAYOUTS.includes(value);\n if (this.fixed) this.emit('layoutchange', value);\n else this.measure();\n return;\n }\n if (name === PLAYSINLINE) {\n // On the video it is a boolean attribute, so off is absent.\n this.media.toggleAttribute(PLAYSINLINE, this.getAttribute(PLAYSINLINE) !== 'false');\n return;\n }\n // The preset decides the chain, so it is the one attribute that rebuilds it.\n if (name === 'preset') this.enqueue(() => this.discard());\n // The source's type is the hint for `audio` until its metadata arrives.\n // Only `audio`: a full reflection here would drop a `muted` the page\n // wrote before its own callback forwards it.\n if (name === 'src' || name === 'type') this.toggleAttribute('audio', this.audio());\n // Markers belong to a source. Cleared here, not on `emptied`, which\n // arrives later and would clear the ones the page sets right after.\n if (name === 'src' && this.marks.list.length > 0) this.marks.set([]);\n if (name === 'src') this.interruption = null;\n if (name === 'src') this.unblock();\n this.reload();\n }\n\n /**\n * Applies the `controls` attribute: the video's own controls and the\n * tabindex. The controls themselves are elements the page placed, and\n * they attach on their own; the element appends none.\n */\n private mode(): void {\n const value = this.getAttribute(CONTROLS);\n const custom = value === 'custom';\n this.media.controls = !custom && value !== 'none';\n // Under custom controls the error screen element carries a fatal error.\n if (custom) this.surface.clear();\n else this.showBlock();\n if (!custom) {\n if (this.focusable) this.removeAttribute('tabindex');\n this.focusable = false;\n } else if (!this.hasAttribute('tabindex')) {\n // A bare video is not focusable, so without this a click on it would\n // leave the shortcuts nowhere to listen. A page that set its own\n // tabindex keeps it.\n this.tabIndex = 0;\n this.focusable = true;\n }\n }\n\n /** Hands the `chapters` attribute to the engine, or keeps a hidden chapters track on the video for it. */\n private chapters(): void {\n const url = this.getAttribute(CHAPTERS);\n const engine = this.current?.engine ?? null;\n const api = engine === null ? undefined : namespaces(engine).chapters;\n if (api !== undefined) {\n this.track?.remove();\n this.track = null;\n if (url === this.given) return;\n this.given = url;\n // An empty list removes the chapters the attribute loaded.\n if (url === null) api.set([]);\n else void api.load(url).catch(() => undefined);\n return;\n }\n if (url === null) {\n this.track?.remove();\n this.track = null;\n return;\n }\n const held = this.track;\n if (held !== null && held.parentNode === this.media && held.getAttribute('src') === url) return;\n // A new element each time: one removed mid-load, as the engine's attach\n // does, stays in its error state, and neither a new `src` nor a second\n // insertion starts it loading again.\n held?.remove();\n const track = document.createElement('track');\n track.kind = 'chapters';\n track.src = url;\n this.track = track;\n this.media.append(track);\n // Set after the insertion: a track element's mode exists once it is in\n // a media element, and `hidden` is what makes its cues load unseen.\n track.track.mode = 'hidden';\n }\n\n private forward(name: string): void {\n const value = this.getAttribute(name);\n if (value === null) this.media.removeAttribute(name);\n else this.media.setAttribute(name, value);\n // A video reads `muted` into its state only when it is created, and this\n // one was created before any attribute reached it. Muted autoplay and\n // the autoplay policy read the state, so the attribute alone would not do.\n if (name === 'muted') this.media.muted = value !== null;\n }\n\n private enqueue(task: () => Promise<void>): void {\n this.queue = this.queue.then(task, task).catch(() => undefined);\n }\n\n /**\n * One run per burst. The parser sets every attribute and then connects the\n * element before any queued task starts, and each of those would load on\n * its own; the flag folds them into the one run that sees the final state.\n */\n private reload(): void {\n if (this.pending) return;\n this.pending = true;\n this.enqueue(() => {\n this.pending = false;\n return this.run();\n });\n }\n\n private emit(name: string, detail: unknown): void {\n this.dispatchEvent(new CustomEvent(name, { detail, bubbles: true, composed: true }));\n }\n\n private report(error: PlayerError): void {\n if (error.fatal) {\n this.failure = error;\n clearTimeout(this.slow);\n // An error screen in the player is an alert of its own, read already.\n if (this.querySelector(ERROR_SCREEN) === null) {\n this.voice.say('error', 'playbackFailed', 'Playback failed');\n }\n // Under custom controls the error screen element is the surface, and\n // the element's own row under the video stays quiet.\n if (this.getAttribute(CONTROLS) !== 'custom') this.surface.show(error);\n this.reflect();\n }\n this.emit('error', error);\n }\n\n private async run(): Promise<void> {\n this.unmount();\n if (!this.isConnected) return;\n const sources = this.wanted();\n this.tried = JSON.stringify(sources);\n if (sources.length === 0) return;\n\n const core = await this.ensure();\n this.failure = null;\n this.surface.clear();\n this.reflect();\n\n try {\n await core.load(sources);\n } catch {\n // The core already reported it on the error event, which the surface\n // and the element's own event both carry. Nothing to add here.\n return;\n }\n if (!this.isConnected) await core.unload();\n }\n\n /**\n * What to load, ranked as a video ranks them: the `src` attribute, then\n * the `sources` property, then the `<source>` children in their order.\n * A child carries its own `license-url` and `certificate-url`.\n */\n private wanted(): readonly ProgrammeSource[] {\n // The `<mbx-video-track>` children are versions of the `src` or `<source>` picture.\n const versions = markupVideoTracks(this);\n const withVersions = versions.length === 0 ? {} : { videoTracks: versions };\n const url = this.getAttribute('src');\n if (url !== null) {\n const type = this.getAttribute('type');\n return [{ url, ...(type === null ? {} : { type }), ...withVersions }];\n }\n // A browser without EME gets no DRM stage, and a source must not bring DRM back.\n const eme = emeAvailable();\n if (this.list !== null) {\n return eme\n ? this.list\n : this.list.map((source) => ('url' in source ? withoutDrm(source) : source));\n }\n const found: Source[] = [];\n for (const child of Array.from(this.children)) {\n const src = child.localName === 'source' ? child.getAttribute('src') : null;\n if (src === null) continue;\n const type = child.getAttribute('type');\n const license = child.getAttribute(LICENSE_URL);\n const certificate = child.getAttribute(CERTIFICATE_URL);\n found.push({\n url: src,\n ...(type === null ? {} : { type }),\n ...withVersions,\n ...(!eme || (license === null && certificate === null)\n ? {}\n : {\n drm: {\n ...(license === null ? {} : { licenseUrl: license }),\n ...(certificate === null ? {} : { certificateUrl: certificate }),\n },\n }),\n });\n }\n return found;\n }\n\n /** Sets a session up. It runs for every session, the one that replaces a failed source included. */\n private adopt(session: Session): void {\n this.given = null;\n this.configure(session);\n // A content API's chapters, unless the `chapters` attribute names a file.\n const chapters = this.core?.programme?.metadata?.chapters;\n if (chapters !== undefined && session.engine !== null && this.getAttribute(CHAPTERS) === null) {\n namespaces(session.engine).chapters?.set(chapters);\n }\n // The engine's attach empties the media element to reset its resource\n // selection (`kernel/mse.ts`), and the chapters track goes with the\n // `<source>` children it means. Wanted: the track to survive attach.\n // Had to: put it back once the session is in. The surface that would\n // make it one call: an attach that removes `<source>` children alone.\n // A session with the engine's chapters takes the URL there instead.\n this.chapters();\n }\n\n private async ensure(): Promise<Player> {\n if (this.core !== null) return this.core;\n const connectors = this.options.connectors;\n const core = createPlayer(this.media, {\n handlers: await this.chain(),\n ...(connectors === undefined ? {} : { connectors }),\n });\n this.offs.push(\n core.on('programme', (programme) => {\n this.programmed(programme);\n }),\n core.on('sourcechange', (session) => {\n // Before the event goes out, so a control that reads `engine` on\n // `sourcechange` sees the session the event is about.\n this.current = session;\n // A version loads under the programme it belongs to; any other load is a programme of its own.\n if (!this.switching) {\n const was = this.version;\n this.original = session?.source ?? null;\n this.switched = null;\n this.version = null;\n this.held?.();\n if (was !== null) this.emit('videosourcechange', null);\n }\n this.offTracks?.();\n this.offTracks = session?.engine?.on('tracks:selected', () => this.tracks()) ?? null;\n if (session !== null && this.isConnected) this.adopt(session);\n this.emit('sourcechange', session);\n }),\n core.on('error', (error) => {\n this.report(error);\n }),\n );\n this.core = core;\n return core;\n }\n\n /**\n * Read at each use, not once in the constructor. Importing the package\n * registers the element, and the parser's elements are constructed then,\n * before the page's own `define()` call can run.\n */\n private get options(): MatteboxPlayerOptions {\n return this.own ?? defaults;\n }\n\n private async chain(): Promise<readonly Handler[]> {\n if (this.options.handlers !== undefined) return this.options.handlers;\n const config = this.options.config === undefined ? {} : { config: this.options.config };\n // The stack is read at load time: a preset builds its stages only when asked.\n const native = (stages: () => readonly Stage[]): Handler =>\n nativeHandler({\n // Read on every load, so the attribute applies without a new chain.\n prefer: (source, env) =>\n this.getAttribute(NATIVE_HLS) !== 'off' &&\n !(this.options.addons ?? []).some((addon) => addon.engine === true) &&\n preferNativeHls(source, env),\n drm: () => this.drm(stages),\n });\n if (this.isConnected) this.attachAddons();\n // The add-ons' stages, fresh for this chain, join whatever stack it builds.\n const added = (this.options.addons ?? []).flatMap((addon) => addon.stages?.() ?? []);\n if (this.options.stages !== undefined) {\n const own = this.options.stages;\n const stages = [...own, ...added.filter((stage) => !own.some((o) => o.name === stage.name))];\n return [matteboxHandler({ stages, ...config }), native(() => stages)];\n }\n const name = this.getAttribute('preset') ?? DEFAULT_PRESET;\n const preset = await resolvePreset(name);\n if (preset === null) {\n this.report({\n category: 'config',\n code: 'CONFIG_INVALID',\n fatal: true,\n recoverable: false,\n handler: null,\n context: { preset: name },\n });\n return [nativeHandler()];\n }\n // With a preset, the handler merges these stages into its own by name.\n const extra = added.length === 0 ? {} : { stages: added };\n return [\n matteboxHandler({ preset, ...extra, ...config, ...drmGuard() }),\n native(() => preset.stages()),\n ];\n }\n\n /**\n * The DRM a native session attaches: the page's `drm` option, the\n * key-system stages of the engine's stack, and the `license-url`\n * attribute. None on a browser without EME, as for the engine.\n */\n private drm(stages: () => readonly Stage[]): AttachEmeOptions | undefined {\n if (drmGuard().without !== undefined) return undefined;\n const keySystems = stages().filter((stage) => KEY_SYSTEMS.includes(stage.name));\n const license = this.getAttribute(LICENSE_URL);\n const certificate = this.getAttribute(CERTIFICATE_URL);\n const page = this.options.drm;\n if (keySystems.length === 0 && license === null && page === undefined) return undefined;\n return {\n keySystems,\n ...page,\n ...(license === null ? {} : { licenseUrl: license }),\n ...(certificate === null ? {} : { certificateUrl: certificate }),\n };\n }\n\n /** What the attributes ask of the session's namespaces, once there is one. */\n private configure(session: Session): void {\n const engine = session.engine;\n if (engine === null) return;\n\n const optional = namespaces(engine);\n\n // The attributes are the default. A source's own URL is already on the\n // engine: the handler set it from `source.drm` before the load.\n const own = session.source.drm;\n const license = this.getAttribute(LICENSE_URL);\n // After the session exists, not before: passing a license URL up front\n // means constructing eme-core, and importing a stage to configure it\n // would bundle it.\n if (license !== null && own?.licenseUrl === undefined) optional.drm?.setLicenseUrl(license);\n const certificate = this.getAttribute(CERTIFICATE_URL);\n if (certificate !== null && own?.certificateUrl === undefined) {\n optional.drm?.setCertificateUrl(certificate);\n }\n\n const track = this.getAttribute('thumbnails');\n if (track !== null && optional.thumbnails !== undefined) {\n // Loaded here; drawn by the seek bar's preview under `controls=\"custom\"`.\n // Native controls expose no scrub position to anchor a preview to, so\n // under `native` the track only answers `engine.thumbnails.at(time)` for\n // the app. See docs/guide/03-the-element.md.\n void optional.thumbnails.load(track).catch(() => undefined);\n }\n }\n\n private unmount(): void {\n this.current = null;\n }\n\n private async teardown(): Promise<void> {\n this.unmount();\n if (this.core !== null) await this.core.unload();\n }\n\n /** Drops the player itself, so the next run builds a chain from the new preset. */\n private async discard(): Promise<void> {\n await this.teardown();\n for (const off of this.offs) off();\n this.offs = [];\n this.core = null;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA2EA,MAAM,aAAa;;;;;;AAOnB,MAAM,YAAY;CAAC;CAAY;CAAS;CAAU;CAAe;AAAyB;AAE1F,MAAM,cAAc;;AAGpB,MAAM,WAAW;;AAGjB,MAAM,YAAY;;AAGlB,SAAS,eAAwB;CAC/B,OAAO,SAAS,CAAC,CAAC,YAAY,KAAA;AAChC;;AAGA,SAAS,WAAW,EAAE,KAAK,MAAM,eAA+B;CAC9D,OAAO;EACL;EACA,GAAI,SAAS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,KAAK,MAAM,IAAI;EACjC,KAAK,OAAO,CAAC;EACb,KAAK,OAAO;CACd;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pip-button.d.ts","sourceRoot":"","sources":["../../src/elements/pip-button.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pip-button.d.ts","sourceRoot":"","sources":["../../src/elements/pip-button.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAM3C,qBAAa,YAAa,SAAQ,SAAS;IACzC,MAAM,KAAK,kBAAkB,IAAI,SAAS,MAAM,EAAE,CAEjD;IAED,iBAAyB,MAAM,CAAoB;IACnD,iBAAyB,KAAK,CAAiC;IAC/D,QAAgB,GAAG,CAA0B;;cAmB1B,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;cAWhC,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;cAKhC,MAAM,IAAI,IAAI;CAelC"}
|
|
@@ -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
|
*/
|
|
@@ -31,7 +32,6 @@ var MbxPipButton = class extends Component {
|
|
|
31
32
|
attach(player) {
|
|
32
33
|
const api = pictureInPicture(player.video);
|
|
33
34
|
this.api = api;
|
|
34
|
-
this.hidden = !api.supported;
|
|
35
35
|
this.keep(api.watch(() => {
|
|
36
36
|
this.render();
|
|
37
37
|
}));
|
|
@@ -45,6 +45,7 @@ var MbxPipButton = class extends Component {
|
|
|
45
45
|
const player = this.player;
|
|
46
46
|
if (player === null || this.api === null) return;
|
|
47
47
|
const active = this.api.active();
|
|
48
|
+
this.hidden = !this.api.supported || !this.api.allowed() && !active;
|
|
48
49
|
show(this.slots, active ? "exit" : "enter");
|
|
49
50
|
this.button.setAttribute("aria-label", active ? this.word("label-exit", "exitPip", "Leave picture in picture") : this.word("label-enter", "enterPip", "Picture in picture"));
|
|
50
51
|
player.toggleAttribute("pip", active);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pip-button.js","names":[],"sources":["../../src/elements/pip-button.ts"],"sourcesContent":["/**\n * <mbx-pip-button>: picture in picture, through whichever API the browser\n * has, and hidden where there is none
|
|
1
|
+
{"version":3,"file":"pip-button.js","names":[],"sources":["../../src/elements/pip-button.ts"],"sourcesContent":["/**\n * <mbx-pip-button>: picture in picture, through whichever API the browser\n * has, and hidden where there is none or the player has\n * `disablepictureinpicture`. The glyph is `icon-enter` or\n * `icon-exit`, the name `label-enter` or `label-exit`, and the element\n * sets `pip` on the player while the video is in the floating window.\n */\nimport { icon } from '../controls/icons.js';\nimport type { PictureInPicture } from '../controls/pip.js';\nimport { pictureInPicture } from '../controls/pip.js';\nimport type { PlayerHost } from '../host.js';\nimport { Component } from './component.js';\nimport { BUTTON_STYLE, iconSlots, show, style } from './shared.js';\n\ntype State = 'enter' | 'exit';\nconst STATES: readonly State[] = ['enter', 'exit'];\n\nexport class MbxPipButton extends Component {\n static get observedAttributes(): readonly string[] {\n return ['label-enter', 'label-exit'];\n }\n\n declare private readonly button: HTMLButtonElement;\n declare private readonly slots: Record<State, HTMLSlotElement>;\n declare private api: PictureInPicture | null;\n\n constructor() {\n super();\n this.api = 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, (state) =>\n icon(state === 'enter' ? 'picture-in-picture' : 'picture-in-picture-exit'),\n );\n for (const state of STATES) this.button.append(this.slots[state]);\n this.button.addEventListener('click', () => {\n this.api?.toggle();\n });\n root.append(style(BUTTON_STYLE), this.button);\n }\n\n protected override attach(player: PlayerHost): void {\n const api = pictureInPicture(player.video);\n this.api = api;\n this.keep(\n api.watch(() => {\n this.render();\n }),\n );\n this.render();\n }\n\n protected override detach(player: PlayerHost): void {\n this.api = null;\n player.removeAttribute('pip');\n }\n\n protected override render(): void {\n const player = this.player;\n if (player === null || this.api === null) return;\n const active = this.api.active();\n // While the video floats the button stays, so the viewer can bring it back.\n this.hidden = !this.api.supported || (!this.api.allowed() && !active);\n show(this.slots, active ? 'exit' : 'enter');\n this.button.setAttribute(\n 'aria-label',\n active\n ? this.word('label-exit', 'exitPip', 'Leave picture in picture')\n : this.word('label-enter', 'enterPip', 'Picture in picture'),\n );\n player.toggleAttribute('pip', active);\n }\n}\n"],"mappings":";;;;;;;;;;;;AAeA,MAAM,SAA2B,CAAC,SAAS,MAAM;AAEjD,IAAa,eAAb,cAAkC,UAAU;CAC1C,WAAW,qBAAwC;EACjD,OAAO,CAAC,eAAe,YAAY;CACrC;CAMA,cAAc;EACZ,MAAM;EACN,KAAK,MAAM;EACX,MAAM,OAAO,KAAK,aAAa,EAAE,MAAM,OAAO,CAAC;EAC/C,KAAK,SAAS,SAAS,cAAc,QAAQ;EAC7C,KAAK,OAAO,OAAO;EACnB,KAAK,OAAO,aAAa,QAAQ,QAAQ;EACzC,KAAK,QAAQ,UAAU,SAAS,UAC9B,KAAK,UAAU,UAAU,uBAAuB,yBAAyB,CAC3E;EACA,KAAK,MAAM,SAAS,QAAQ,KAAK,OAAO,OAAO,KAAK,MAAM,MAAM;EAChE,KAAK,OAAO,iBAAiB,eAAe;GAC1C,KAAK,KAAK,OAAO;EACnB,CAAC;EACD,KAAK,OAAO,MAAM,YAAY,GAAG,KAAK,MAAM;CAC9C;CAEA,OAA0B,QAA0B;EAClD,MAAM,MAAM,iBAAiB,OAAO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