@mattebox/player 0.6.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cdn/mattebox-player.min.js +3 -435
- package/dist/controls/airplay.js +28 -44
- package/dist/controls/airplay.js.map +1 -1
- package/dist/controls/chapters.d.ts +22 -11
- package/dist/controls/chapters.d.ts.map +1 -1
- package/dist/controls/chapters.js +87 -73
- package/dist/controls/chapters.js.map +1 -1
- package/dist/controls/cues.d.ts +0 -22
- package/dist/controls/cues.d.ts.map +1 -1
- package/dist/controls/cues.js +161 -191
- package/dist/controls/cues.js.map +1 -1
- package/dist/controls/fullscreen.js +52 -70
- package/dist/controls/fullscreen.js.map +1 -1
- package/dist/controls/icons.d.ts +4 -2
- package/dist/controls/icons.d.ts.map +1 -1
- package/dist/controls/icons.js +46 -70
- package/dist/controls/icons.js.map +1 -1
- package/dist/controls/markers.d.ts +39 -0
- package/dist/controls/markers.d.ts.map +1 -0
- package/dist/controls/markers.js +38 -0
- package/dist/controls/markers.js.map +1 -0
- package/dist/controls/menu.d.ts +8 -4
- package/dist/controls/menu.d.ts.map +1 -1
- package/dist/controls/menu.js +261 -223
- package/dist/controls/menu.js.map +1 -1
- package/dist/controls/native-tracks.d.ts +28 -0
- package/dist/controls/native-tracks.d.ts.map +1 -0
- package/dist/controls/native-tracks.js +30 -0
- package/dist/controls/native-tracks.js.map +1 -0
- package/dist/controls/pip.js +35 -49
- package/dist/controls/pip.js.map +1 -1
- package/dist/controls/quality-names.d.ts +15 -0
- package/dist/controls/quality-names.d.ts.map +1 -0
- package/dist/controls/quality-names.js +62 -0
- package/dist/controls/quality-names.js.map +1 -0
- package/dist/controls/ranges.js +42 -37
- package/dist/controls/ranges.js.map +1 -1
- package/dist/controls/session.d.ts +6 -1
- package/dist/controls/session.d.ts.map +1 -1
- package/dist/controls/session.js +41 -26
- package/dist/controls/session.js.map +1 -1
- package/dist/controls/slider.d.ts +2 -2
- package/dist/controls/slider.d.ts.map +1 -1
- package/dist/controls/slider.js +151 -159
- package/dist/controls/slider.js.map +1 -1
- package/dist/controls/time.js +17 -17
- package/dist/controls/time.js.map +1 -1
- package/dist/controls/track-names.d.ts +40 -0
- package/dist/controls/track-names.d.ts.map +1 -0
- package/dist/controls/track-names.js +59 -0
- package/dist/controls/track-names.js.map +1 -0
- package/dist/dom.d.ts +6 -0
- package/dist/dom.d.ts.map +1 -1
- package/dist/dom.js +28 -19
- package/dist/dom.js.map +1 -1
- package/dist/element-entry.js +9 -6
- package/dist/element-entry.js.map +1 -1
- package/dist/element.d.ts +28 -2
- package/dist/element.d.ts.map +1 -1
- package/dist/element.js +426 -442
- package/dist/element.js.map +1 -1
- package/dist/elements/airplay-button.js +51 -53
- package/dist/elements/airplay-button.js.map +1 -1
- package/dist/elements/audio-menu.d.ts +19 -8
- package/dist/elements/audio-menu.d.ts.map +1 -1
- package/dist/elements/audio-menu.js +103 -65
- package/dist/elements/audio-menu.js.map +1 -1
- package/dist/elements/chapters-menu.d.ts.map +1 -1
- package/dist/elements/chapters-menu.js +75 -65
- package/dist/elements/chapters-menu.js.map +1 -1
- package/dist/elements/component.d.ts +1 -1
- package/dist/elements/component.d.ts.map +1 -1
- package/dist/elements/component.js +86 -89
- package/dist/elements/component.js.map +1 -1
- package/dist/elements/control-bar.d.ts +18 -5
- package/dist/elements/control-bar.d.ts.map +1 -1
- package/dist/elements/control-bar.js +282 -319
- package/dist/elements/control-bar.js.map +1 -1
- package/dist/elements/current-time.js +26 -25
- package/dist/elements/current-time.js.map +1 -1
- package/dist/elements/drm-badge.d.ts +3 -2
- package/dist/elements/drm-badge.d.ts.map +1 -1
- package/dist/elements/drm-badge.js +109 -141
- package/dist/elements/drm-badge.js.map +1 -1
- package/dist/elements/duration.d.ts.map +1 -1
- package/dist/elements/duration.js +24 -21
- package/dist/elements/duration.js.map +1 -1
- package/dist/elements/error-screen.d.ts.map +1 -1
- package/dist/elements/error-screen.js +68 -102
- package/dist/elements/error-screen.js.map +1 -1
- package/dist/elements/fullscreen-button.js +48 -54
- package/dist/elements/fullscreen-button.js.map +1 -1
- package/dist/elements/live-button.d.ts.map +1 -1
- package/dist/elements/live-button.js +67 -94
- package/dist/elements/live-button.js.map +1 -1
- package/dist/elements/marker-button.d.ts +22 -0
- package/dist/elements/marker-button.d.ts.map +1 -0
- package/dist/elements/marker-button.js +99 -0
- package/dist/elements/marker-button.js.map +1 -0
- package/dist/elements/menu-element.js +31 -28
- package/dist/elements/menu-element.js.map +1 -1
- package/dist/elements/mute-button.js +58 -59
- package/dist/elements/mute-button.js.map +1 -1
- package/dist/elements/pip-button.js +54 -54
- package/dist/elements/pip-button.js.map +1 -1
- package/dist/elements/play-button.d.ts.map +1 -1
- package/dist/elements/play-button.js +73 -58
- package/dist/elements/play-button.js.map +1 -1
- package/dist/elements/quality-menu.d.ts +4 -0
- package/dist/elements/quality-menu.d.ts.map +1 -1
- package/dist/elements/quality-menu.js +82 -71
- package/dist/elements/quality-menu.js.map +1 -1
- package/dist/elements/remaining-time.d.ts.map +1 -1
- package/dist/elements/remaining-time.js +27 -24
- package/dist/elements/remaining-time.js.map +1 -1
- package/dist/elements/scan-button.d.ts +17 -0
- package/dist/elements/scan-button.d.ts.map +1 -0
- package/dist/elements/scan-button.js +117 -0
- package/dist/elements/scan-button.js.map +1 -0
- package/dist/elements/seek-bar.d.ts +99 -15
- package/dist/elements/seek-bar.d.ts.map +1 -1
- package/dist/elements/seek-bar.js +487 -336
- package/dist/elements/seek-bar.js.map +1 -1
- package/dist/elements/shared.d.ts +3 -11
- package/dist/elements/shared.d.ts.map +1 -1
- package/dist/elements/shared.js +44 -144
- package/dist/elements/shared.js.map +1 -1
- package/dist/elements/skip-button.d.ts.map +1 -1
- package/dist/elements/skip-button.js +54 -55
- package/dist/elements/skip-button.js.map +1 -1
- package/dist/elements/spacer.d.ts.map +1 -1
- package/dist/elements/spacer.js +12 -7
- package/dist/elements/spacer.js.map +1 -1
- package/dist/elements/speed-menu.js +60 -55
- package/dist/elements/speed-menu.js.map +1 -1
- package/dist/elements/spinner.d.ts.map +1 -1
- package/dist/elements/spinner.js +52 -78
- package/dist/elements/spinner.js.map +1 -1
- package/dist/elements/start-button.d.ts.map +1 -1
- package/dist/elements/start-button.js +107 -120
- package/dist/elements/start-button.js.map +1 -1
- package/dist/elements/subtitles-menu.d.ts +2 -0
- package/dist/elements/subtitles-menu.d.ts.map +1 -1
- package/dist/elements/subtitles-menu.js +119 -103
- package/dist/elements/subtitles-menu.js.map +1 -1
- package/dist/elements/time-element.d.ts.map +1 -1
- package/dist/elements/time-element.js +36 -28
- package/dist/elements/time-element.js.map +1 -1
- package/dist/elements/title.d.ts.map +1 -1
- package/dist/elements/title.js +105 -137
- package/dist/elements/title.js.map +1 -1
- package/dist/elements/volume-slider.d.ts.map +1 -1
- package/dist/elements/volume-slider.js +47 -45
- package/dist/elements/volume-slider.js.map +1 -1
- package/dist/elements/volume.d.ts.map +1 -1
- package/dist/elements/volume.js +42 -50
- package/dist/elements/volume.js.map +1 -1
- package/dist/entries/airplay-button.js +7 -7
- package/dist/entries/airplay-button.js.map +1 -1
- package/dist/entries/audio-menu.js +7 -6
- package/dist/entries/audio-menu.js.map +1 -1
- package/dist/entries/chapters-menu.js +7 -7
- package/dist/entries/chapters-menu.js.map +1 -1
- package/dist/entries/control-bar.js +7 -6
- package/dist/entries/control-bar.js.map +1 -1
- package/dist/entries/current-time.js +7 -6
- package/dist/entries/current-time.js.map +1 -1
- package/dist/entries/drm-badge.js +7 -6
- package/dist/entries/drm-badge.js.map +1 -1
- package/dist/entries/duration.js +7 -6
- package/dist/entries/duration.js.map +1 -1
- package/dist/entries/error-screen.js +7 -6
- package/dist/entries/error-screen.js.map +1 -1
- package/dist/entries/fullscreen-button.js +7 -6
- package/dist/entries/fullscreen-button.js.map +1 -1
- package/dist/entries/live-button.js +7 -6
- package/dist/entries/live-button.js.map +1 -1
- package/dist/entries/marker-button.d.ts +5 -0
- package/dist/entries/marker-button.d.ts.map +1 -0
- package/dist/entries/marker-button.js +9 -0
- package/dist/entries/marker-button.js.map +1 -0
- package/dist/entries/mute-button.js +7 -6
- package/dist/entries/mute-button.js.map +1 -1
- package/dist/entries/pip-button.js +7 -6
- package/dist/entries/pip-button.js.map +1 -1
- package/dist/entries/play-button.js +7 -6
- package/dist/entries/play-button.js.map +1 -1
- package/dist/entries/quality-menu.js +7 -6
- package/dist/entries/quality-menu.js.map +1 -1
- package/dist/entries/remaining-time.js +7 -7
- package/dist/entries/remaining-time.js.map +1 -1
- package/dist/entries/scan-button.d.ts +5 -0
- package/dist/entries/scan-button.d.ts.map +1 -0
- package/dist/entries/scan-button.js +9 -0
- package/dist/entries/scan-button.js.map +1 -0
- package/dist/entries/seek-bar.js +7 -6
- package/dist/entries/seek-bar.js.map +1 -1
- package/dist/entries/skip-button.js +7 -6
- package/dist/entries/skip-button.js.map +1 -1
- package/dist/entries/spacer.js +7 -6
- package/dist/entries/spacer.js.map +1 -1
- package/dist/entries/speed-menu.js +7 -6
- package/dist/entries/speed-menu.js.map +1 -1
- package/dist/entries/spinner.js +7 -7
- package/dist/entries/spinner.js.map +1 -1
- package/dist/entries/start-button.js +7 -6
- package/dist/entries/start-button.js.map +1 -1
- package/dist/entries/subtitles-menu.js +7 -6
- package/dist/entries/subtitles-menu.js.map +1 -1
- package/dist/entries/title.js +7 -7
- package/dist/entries/title.js.map +1 -1
- package/dist/entries/volume-slider.js +7 -6
- package/dist/entries/volume-slider.js.map +1 -1
- package/dist/entries/volume.js +9 -8
- package/dist/entries/volume.js.map +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.150.0 → _@oxc-project_runtime@0.152.0}/helpers/esm/asyncToGenerator.js +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.150.0 → _@oxc-project_runtime@0.152.0}/helpers/esm/defineProperty.js +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.150.0 → _@oxc-project_runtime@0.152.0}/helpers/esm/objectSpread2.js +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.150.0 → _@oxc-project_runtime@0.152.0}/helpers/esm/toPrimitive.js +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.150.0 → _@oxc-project_runtime@0.152.0}/helpers/esm/toPropertyKey.js +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.150.0 → _@oxc-project_runtime@0.152.0}/helpers/esm/typeof.js +1 -1
- package/dist/es2015/controls/chapters.js +40 -7
- package/dist/es2015/controls/cues.js +1 -8
- package/dist/es2015/controls/icons.js +27 -25
- package/dist/es2015/controls/markers.js +36 -0
- package/dist/es2015/controls/menu.js +49 -10
- package/dist/es2015/controls/native-tracks.js +29 -0
- package/dist/es2015/controls/quality-names.js +67 -0
- package/dist/es2015/controls/session.js +16 -4
- package/dist/es2015/controls/slider.js +5 -4
- package/dist/es2015/controls/track-names.js +57 -0
- package/dist/es2015/dom.js +10 -1
- package/dist/es2015/element.js +71 -13
- package/dist/es2015/elements/audio-menu.js +62 -19
- package/dist/es2015/elements/chapters-menu.js +18 -10
- package/dist/es2015/elements/control-bar.js +41 -35
- package/dist/es2015/elements/drm-badge.js +12 -33
- package/dist/es2015/elements/duration.js +2 -1
- package/dist/es2015/elements/error-screen.js +1 -30
- package/dist/es2015/elements/live-button.js +1 -29
- package/dist/es2015/elements/marker-button.js +100 -0
- package/dist/es2015/elements/menu-element.js +2 -2
- package/dist/es2015/elements/play-button.js +10 -3
- package/dist/es2015/elements/quality-menu.js +22 -7
- package/dist/es2015/elements/remaining-time.js +2 -1
- package/dist/es2015/elements/scan-button.js +118 -0
- package/dist/es2015/elements/seek-bar.js +295 -90
- package/dist/es2015/elements/shared.js +5 -106
- package/dist/es2015/elements/skip-button.js +2 -1
- package/dist/es2015/elements/spacer.js +2 -1
- package/dist/es2015/elements/spinner.js +1 -32
- package/dist/es2015/elements/start-button.js +8 -26
- package/dist/es2015/elements/subtitles-menu.js +39 -11
- package/dist/es2015/elements/time-element.js +1 -4
- package/dist/es2015/elements/title.js +1 -45
- package/dist/es2015/elements/volume-slider.js +2 -1
- package/dist/es2015/elements/volume.js +1 -11
- package/dist/es2015/entries/marker-button.js +7 -0
- package/dist/es2015/entries/scan-button.js +7 -0
- package/dist/es2015/index.js +5 -1
- package/dist/es2015/presets.js +1 -1
- package/dist/es2015/style.js +1 -101
- package/dist/es2015/tags.js +3 -1
- package/dist/host.d.ts +3 -0
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +19 -17
- package/dist/host.js.map +1 -1
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +57 -27
- package/dist/labels.js +13 -9
- package/dist/labels.js.map +1 -1
- package/dist/namespaces.d.ts +9 -26
- package/dist/namespaces.d.ts.map +1 -1
- package/dist/namespaces.js +6 -2
- package/dist/namespaces.js.map +1 -1
- package/dist/presets.js +33 -28
- package/dist/presets.js.map +1 -1
- package/dist/style.d.ts +1 -20
- package/dist/style.d.ts.map +1 -1
- package/dist/style.js +4 -100
- package/dist/style.js.map +1 -1
- package/dist/surface.js +25 -21
- package/dist/surface.js.map +1 -1
- package/dist/tags.d.ts +2 -0
- package/dist/tags.d.ts.map +1 -1
- package/dist/tags.js +32 -26
- package/dist/tags.js.map +1 -1
- package/package.json +4 -4
- package/dist/index.js.map +0 -1
package/dist/element.js
CHANGED
|
@@ -1,456 +1,440 @@
|
|
|
1
|
+
import { createMarkers } from "./controls/markers.js";
|
|
2
|
+
import { namespaces } from "./namespaces.js";
|
|
3
|
+
import { drmGuard, resolvePreset } from "./presets.js";
|
|
4
|
+
import { STYLE } from "./style.js";
|
|
5
|
+
import { errorSurface } from "./surface.js";
|
|
6
|
+
import { PLAYER } from "./tags.js";
|
|
7
|
+
import { createPlayer, inferType, matteboxHandler, nativeHandler, preferNativeHls } from "@mattebox/player-core";
|
|
8
|
+
//#region src/element.ts
|
|
1
9
|
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
*
|
|
8
|
-
* The controls are elements the page places inside, beside the video, and
|
|
9
|
-
* the stage slots them over the picture. The element appends none of its
|
|
10
|
-
* own: the composition is the page's in every mode, and `none` hides every
|
|
11
|
-
* child but the video. The element reflects the video's state as
|
|
12
|
-
* attributes on itself, `paused`, `playing`, `ended`, `muted`, `audio`,
|
|
13
|
-
* `started` and `waiting`, for the page's stylesheet and the controls
|
|
14
|
-
* alike.
|
|
15
|
-
*
|
|
16
|
-
* No class fields, `#private` or otherwise: the ES2015 build would lower
|
|
17
|
-
* them into runtime helpers, and the emit check bans helpers. Statics are
|
|
18
|
-
* getters and instance state is declared, then assigned in the constructor.
|
|
19
|
-
*/
|
|
20
|
-
import { createPlayer, inferType, matteboxHandler, nativeHandler } from '@mattebox/player-core';
|
|
21
|
-
import { namespaces } from './namespaces.js';
|
|
22
|
-
import { drmGuard, resolvePreset } from './presets.js';
|
|
23
|
-
import { STYLE } from './style.js';
|
|
24
|
-
import { errorSurface } from './surface.js';
|
|
25
|
-
import { PLAYER } from './tags.js';
|
|
10
|
+
* `off` keeps HLS on the engine in Safari. Anything else lets Safari play
|
|
11
|
+
* HLS itself: FairPlay, AirPlay, Low-Latency HLS and the platform's
|
|
12
|
+
* fullscreen then work as Apple built them. Changing it reloads.
|
|
13
|
+
*/
|
|
14
|
+
const NATIVE_HLS = "native-hls";
|
|
26
15
|
/** Attributes forwarded onto the video as attributes, never as properties. */
|
|
27
|
-
const FORWARDED = [
|
|
16
|
+
const FORWARDED = [
|
|
17
|
+
"autoplay",
|
|
18
|
+
"muted",
|
|
19
|
+
"poster",
|
|
20
|
+
"crossorigin"
|
|
21
|
+
];
|
|
28
22
|
/** Everything else the element watches. Changing any of them reloads. */
|
|
29
|
-
const OWN = [
|
|
23
|
+
const OWN = [
|
|
24
|
+
"src",
|
|
25
|
+
"type",
|
|
26
|
+
"preset",
|
|
27
|
+
"license-url",
|
|
28
|
+
"certificate-url",
|
|
29
|
+
"thumbnails",
|
|
30
|
+
NATIVE_HLS
|
|
31
|
+
];
|
|
30
32
|
/**
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
* The chapters file URL. A session with the engine's `chapters` namespace
|
|
34
|
+
* loads it there: through the engine's transport, so request hooks apply,
|
|
35
|
+
* and in every format the engine reads. Any other session gets a
|
|
36
|
+
* `<track kind="chapters">` on the video, hidden so its cues load and
|
|
37
|
+
* nothing is drawn. The seek bar and the chapters menu read either.
|
|
38
|
+
* Changing it never reloads the source.
|
|
39
|
+
*/
|
|
40
|
+
const CHAPTERS = "chapters";
|
|
38
41
|
/**
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
const CONTROLS =
|
|
42
|
+
* The one attribute whose meaning the element owns: `native` keeps the
|
|
43
|
+
* browser's controls on the video, `custom` swaps them for the controls the
|
|
44
|
+
* page placed inside, `none` takes the browser's off and hides every child
|
|
45
|
+
* but the video. Anything else is `native`. Changing it never touches the
|
|
46
|
+
* session.
|
|
47
|
+
*/
|
|
48
|
+
const CONTROLS = "controls";
|
|
46
49
|
/**
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
const PLAYSINLINE =
|
|
50
|
+
* Inline playback, on until the page writes `playsinline="false"`, the way
|
|
51
|
+
* `spellcheck` and `draggable` are on until told otherwise. An iPhone takes
|
|
52
|
+
* a video without `playsinline` to its own fullscreen on play, where no
|
|
53
|
+
* control the page placed shows. Changing it never reloads.
|
|
54
|
+
*/
|
|
55
|
+
const PLAYSINLINE = "playsinline";
|
|
53
56
|
/** The video's state, as attributes on the element, read on the events the video fires for it. */
|
|
54
57
|
const STATE_EVENTS = [
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
58
|
+
"play",
|
|
59
|
+
"pause",
|
|
60
|
+
"ended",
|
|
61
|
+
"seeked",
|
|
62
|
+
"emptied",
|
|
63
|
+
"volumechange",
|
|
64
|
+
"loadedmetadata",
|
|
65
|
+
"resize",
|
|
66
|
+
"playing",
|
|
67
|
+
"waiting",
|
|
68
|
+
"stalled",
|
|
69
|
+
"canplay"
|
|
66
70
|
];
|
|
71
|
+
/** The stages that register a key system, which a native session's DRM offers. */
|
|
72
|
+
const KEY_SYSTEMS = ["eme-fairplay", "eme-cenc"];
|
|
67
73
|
/** Every stage the engine ships. A narrower preset is optimization. */
|
|
68
|
-
const DEFAULT_PRESET =
|
|
74
|
+
const DEFAULT_PRESET = "full";
|
|
69
75
|
/**
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
76
|
+
* What `define()` recorded, for the elements the parser creates. It is the
|
|
77
|
+
* one value shared across elements, because a page that writes only markup
|
|
78
|
+
* still has to be able to say what the engine carries.
|
|
79
|
+
*/
|
|
74
80
|
let defaults = {};
|
|
75
81
|
/**
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
// under `native` the track only answers `engine.thumbnails.at(time)` for
|
|
435
|
-
// the app. See docs/guide/03-the-element.md.
|
|
436
|
-
void optional.thumbnails.load(track).catch(() => undefined);
|
|
437
|
-
}
|
|
438
|
-
}
|
|
439
|
-
unmount() {
|
|
440
|
-
this.current = null;
|
|
441
|
-
}
|
|
442
|
-
async teardown() {
|
|
443
|
-
this.unmount();
|
|
444
|
-
if (this.core !== null)
|
|
445
|
-
await this.core.unload();
|
|
446
|
-
}
|
|
447
|
-
/** Drops the player itself, so the next run builds a chain from the new preset. */
|
|
448
|
-
async discard() {
|
|
449
|
-
await this.teardown();
|
|
450
|
-
for (const off of this.offs)
|
|
451
|
-
off();
|
|
452
|
-
this.offs = [];
|
|
453
|
-
this.core = null;
|
|
454
|
-
}
|
|
455
|
-
}
|
|
82
|
+
* The interface above merges only `addEventListener` and `removeEventListener`
|
|
83
|
+
* overloads, which the class inherits from HTMLElement. The rule it suppresses
|
|
84
|
+
* guards against properties an interface declares and a constructor never
|
|
85
|
+
* assigns, and there are none.
|
|
86
|
+
*/
|
|
87
|
+
var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
|
|
88
|
+
static get observedAttributes() {
|
|
89
|
+
return [
|
|
90
|
+
...FORWARDED,
|
|
91
|
+
...OWN,
|
|
92
|
+
CONTROLS,
|
|
93
|
+
CHAPTERS,
|
|
94
|
+
PLAYSINLINE
|
|
95
|
+
];
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Registers the element once, and records the stages markup-only pages
|
|
99
|
+
* get. The controls register through their own entries, the package's
|
|
100
|
+
* root entry importing every one; a control connected before its player
|
|
101
|
+
* is defined waits for the definition.
|
|
102
|
+
*/
|
|
103
|
+
static define(options) {
|
|
104
|
+
if (options !== void 0) defaults = options;
|
|
105
|
+
if (customElements.get("mattebox-player") === void 0) customElements.define(PLAYER, MatteboxPlayerElement);
|
|
106
|
+
}
|
|
107
|
+
constructor(options) {
|
|
108
|
+
super();
|
|
109
|
+
this.options = options ?? defaults;
|
|
110
|
+
this.focusable = false;
|
|
111
|
+
this.track = null;
|
|
112
|
+
this.given = null;
|
|
113
|
+
this.core = null;
|
|
114
|
+
this.current = null;
|
|
115
|
+
this.failure = null;
|
|
116
|
+
this.reflecting = false;
|
|
117
|
+
this.started = false;
|
|
118
|
+
this.waiting = false;
|
|
119
|
+
this.offs = [];
|
|
120
|
+
this.queue = Promise.resolve();
|
|
121
|
+
this.pending = false;
|
|
122
|
+
this.media = document.createElement("video");
|
|
123
|
+
this.media.controls = true;
|
|
124
|
+
this.media.setAttribute(PLAYSINLINE, "");
|
|
125
|
+
for (const name of STATE_EVENTS) this.media.addEventListener(name, () => {
|
|
126
|
+
this.note(name);
|
|
127
|
+
this.reflect();
|
|
128
|
+
});
|
|
129
|
+
this.media.addEventListener("playing", () => {
|
|
130
|
+
this.failure = null;
|
|
131
|
+
});
|
|
132
|
+
this.marks = createMarkers(this.media, (name, detail) => this.emit(name, detail));
|
|
133
|
+
this.stage = document.createElement("div");
|
|
134
|
+
this.stage.setAttribute("part", "stage");
|
|
135
|
+
this.stage.append(document.createElement("slot"));
|
|
136
|
+
this.surface = errorSurface(() => {
|
|
137
|
+
this.reload();
|
|
138
|
+
});
|
|
139
|
+
const root = this.attachShadow({ mode: "open" });
|
|
140
|
+
const style = document.createElement("style");
|
|
141
|
+
style.textContent = STYLE;
|
|
142
|
+
root.append(style, this.stage, this.surface.root);
|
|
143
|
+
}
|
|
144
|
+
/** The media element. Everything the browser already does is here. */
|
|
145
|
+
get video() {
|
|
146
|
+
return this.media;
|
|
147
|
+
}
|
|
148
|
+
/** The ranges the page named in this source: credits to skip, parts that must not play. */
|
|
149
|
+
get markers() {
|
|
150
|
+
return this.marks;
|
|
151
|
+
}
|
|
152
|
+
/** The core, or null until the first source has been set up: resolving a preset is asynchronous. */
|
|
153
|
+
get player() {
|
|
154
|
+
return this.core;
|
|
155
|
+
}
|
|
156
|
+
/** The engine feeding the video, or null for a native session and before the first load. */
|
|
157
|
+
get engine() {
|
|
158
|
+
return this.current?.engine ?? null;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* The fatal error of the current load, or null once a load starts or
|
|
162
|
+
* playback resumes. The `error` event says when; this says what, for a
|
|
163
|
+
* control that attaches after the event, such as an error screen parsed
|
|
164
|
+
* after a source that failed while the page was still loading.
|
|
165
|
+
*/
|
|
166
|
+
get error() {
|
|
167
|
+
return this.failure;
|
|
168
|
+
}
|
|
169
|
+
connectedCallback() {
|
|
170
|
+
if (this.media.parentNode !== this) this.append(this.media);
|
|
171
|
+
for (const name of FORWARDED) this.forward(name);
|
|
172
|
+
this.reflect();
|
|
173
|
+
this.reload();
|
|
174
|
+
}
|
|
175
|
+
/** The two states the video does not hold: whether it has played once, and whether it waits for data. */
|
|
176
|
+
note(event) {
|
|
177
|
+
if (event === "playing") {
|
|
178
|
+
this.started = true;
|
|
179
|
+
this.waiting = false;
|
|
180
|
+
} else if (event === "waiting" || event === "stalled") this.waiting = true;
|
|
181
|
+
else if (event === "canplay") this.waiting = false;
|
|
182
|
+
else if (event === "emptied") {
|
|
183
|
+
this.started = false;
|
|
184
|
+
this.waiting = false;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
/** The video's state on the element, for `mattebox-player[paused]` and the like. */
|
|
188
|
+
reflect() {
|
|
189
|
+
const video = this.media;
|
|
190
|
+
this.reflecting = true;
|
|
191
|
+
this.toggleAttribute("paused", video.paused);
|
|
192
|
+
this.toggleAttribute("playing", !video.paused);
|
|
193
|
+
this.toggleAttribute("ended", video.ended);
|
|
194
|
+
this.toggleAttribute("muted", video.muted);
|
|
195
|
+
this.toggleAttribute("audio", this.audio());
|
|
196
|
+
this.toggleAttribute("started", this.started);
|
|
197
|
+
this.toggleAttribute("waiting", this.waiting);
|
|
198
|
+
this.reflecting = false;
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Whether the source has no picture. Once the metadata is in, the video's
|
|
202
|
+
* size decides: zero by zero is sound alone, and `resize` catches a stream
|
|
203
|
+
* that moves to or from an audio-only rendition. Before that, the type the
|
|
204
|
+
* page wrote or the URL implies is the hint, so an mp3 is `audio` from
|
|
205
|
+
* the start rather than from its metadata.
|
|
206
|
+
*/
|
|
207
|
+
audio() {
|
|
208
|
+
const video = this.media;
|
|
209
|
+
if (video.readyState >= HTMLMediaElement.HAVE_METADATA) return video.videoWidth === 0 && video.videoHeight === 0;
|
|
210
|
+
const src = this.getAttribute("src");
|
|
211
|
+
return (this.getAttribute("type") ?? (src === null ? void 0 : inferType(src)))?.startsWith("audio/") === true;
|
|
212
|
+
}
|
|
213
|
+
disconnectedCallback() {
|
|
214
|
+
this.enqueue(() => this.teardown());
|
|
215
|
+
}
|
|
216
|
+
attributeChangedCallback(name) {
|
|
217
|
+
if (FORWARDED.includes(name)) {
|
|
218
|
+
if (!this.reflecting) this.forward(name);
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
if (name === CONTROLS) {
|
|
222
|
+
this.mode();
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
if (name === CHAPTERS) {
|
|
226
|
+
this.chapters();
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
if (name === PLAYSINLINE) {
|
|
230
|
+
this.media.toggleAttribute(PLAYSINLINE, this.getAttribute(PLAYSINLINE) !== "false");
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
if (name === "preset") this.enqueue(() => this.discard());
|
|
234
|
+
if (name === "src" || name === "type") this.toggleAttribute("audio", this.audio());
|
|
235
|
+
if (name === "src" && this.marks.list.length > 0) this.marks.set([]);
|
|
236
|
+
this.reload();
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Applies the `controls` attribute: the video's own controls and the
|
|
240
|
+
* tabindex. The controls themselves are elements the page placed, and
|
|
241
|
+
* they attach on their own; the element appends none.
|
|
242
|
+
*/
|
|
243
|
+
mode() {
|
|
244
|
+
const value = this.getAttribute(CONTROLS);
|
|
245
|
+
const custom = value === "custom";
|
|
246
|
+
this.media.controls = !custom && value !== "none";
|
|
247
|
+
if (custom) this.surface.clear();
|
|
248
|
+
if (!custom) {
|
|
249
|
+
if (this.focusable) this.removeAttribute("tabindex");
|
|
250
|
+
this.focusable = false;
|
|
251
|
+
} else if (!this.hasAttribute("tabindex")) {
|
|
252
|
+
this.tabIndex = 0;
|
|
253
|
+
this.focusable = true;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
/** Hands the `chapters` attribute to the engine, or keeps a hidden chapters track on the video for it. */
|
|
257
|
+
chapters() {
|
|
258
|
+
const url = this.getAttribute(CHAPTERS);
|
|
259
|
+
const engine = this.current?.engine ?? null;
|
|
260
|
+
const api = engine === null ? void 0 : namespaces(engine).chapters;
|
|
261
|
+
if (api !== void 0) {
|
|
262
|
+
this.track?.remove();
|
|
263
|
+
this.track = null;
|
|
264
|
+
if (url === this.given) return;
|
|
265
|
+
this.given = url;
|
|
266
|
+
if (url === null) api.set([]);
|
|
267
|
+
else api.load(url).catch(() => void 0);
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
if (url === null) {
|
|
271
|
+
this.track?.remove();
|
|
272
|
+
this.track = null;
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
const held = this.track;
|
|
276
|
+
if (held !== null && held.parentNode === this.media && held.getAttribute("src") === url) return;
|
|
277
|
+
held?.remove();
|
|
278
|
+
const track = document.createElement("track");
|
|
279
|
+
track.kind = "chapters";
|
|
280
|
+
track.src = url;
|
|
281
|
+
this.track = track;
|
|
282
|
+
this.media.append(track);
|
|
283
|
+
track.track.mode = "hidden";
|
|
284
|
+
}
|
|
285
|
+
forward(name) {
|
|
286
|
+
const value = this.getAttribute(name);
|
|
287
|
+
if (value === null) this.media.removeAttribute(name);
|
|
288
|
+
else this.media.setAttribute(name, value);
|
|
289
|
+
if (name === "muted") this.media.muted = value !== null;
|
|
290
|
+
}
|
|
291
|
+
enqueue(task) {
|
|
292
|
+
this.queue = this.queue.then(task, task).catch(() => void 0);
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* One run per burst. The parser sets every attribute and then connects the
|
|
296
|
+
* element before any queued task starts, and each of those would load on
|
|
297
|
+
* its own; the flag folds them into the one run that sees the final state.
|
|
298
|
+
*/
|
|
299
|
+
reload() {
|
|
300
|
+
if (this.pending) return;
|
|
301
|
+
this.pending = true;
|
|
302
|
+
this.enqueue(() => {
|
|
303
|
+
this.pending = false;
|
|
304
|
+
return this.run();
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
emit(name, detail) {
|
|
308
|
+
this.dispatchEvent(new CustomEvent(name, {
|
|
309
|
+
detail,
|
|
310
|
+
bubbles: true,
|
|
311
|
+
composed: true
|
|
312
|
+
}));
|
|
313
|
+
}
|
|
314
|
+
report(error) {
|
|
315
|
+
if (error.fatal) {
|
|
316
|
+
this.failure = error;
|
|
317
|
+
if (this.getAttribute(CONTROLS) !== "custom") this.surface.show(error);
|
|
318
|
+
}
|
|
319
|
+
this.emit("error", error);
|
|
320
|
+
}
|
|
321
|
+
async run() {
|
|
322
|
+
this.unmount();
|
|
323
|
+
if (!this.isConnected) return;
|
|
324
|
+
const url = this.getAttribute("src");
|
|
325
|
+
if (url === null) return;
|
|
326
|
+
const core = await this.ensure();
|
|
327
|
+
const type = this.getAttribute("type");
|
|
328
|
+
const source = type === null ? { url } : {
|
|
329
|
+
url,
|
|
330
|
+
type
|
|
331
|
+
};
|
|
332
|
+
this.failure = null;
|
|
333
|
+
this.surface.clear();
|
|
334
|
+
let session;
|
|
335
|
+
try {
|
|
336
|
+
session = await core.load(source);
|
|
337
|
+
} catch {
|
|
338
|
+
return;
|
|
339
|
+
}
|
|
340
|
+
if (!this.isConnected) {
|
|
341
|
+
await core.unload();
|
|
342
|
+
return;
|
|
343
|
+
}
|
|
344
|
+
this.current = session;
|
|
345
|
+
this.given = null;
|
|
346
|
+
this.configure(session);
|
|
347
|
+
this.chapters();
|
|
348
|
+
}
|
|
349
|
+
async ensure() {
|
|
350
|
+
if (this.core !== null) return this.core;
|
|
351
|
+
const core = createPlayer(this.media, { handlers: await this.chain() });
|
|
352
|
+
this.offs.push(core.on("sourcechange", (session) => {
|
|
353
|
+
this.current = session;
|
|
354
|
+
this.emit("sourcechange", session);
|
|
355
|
+
}), core.on("error", (error) => {
|
|
356
|
+
this.report(error);
|
|
357
|
+
}));
|
|
358
|
+
this.core = core;
|
|
359
|
+
return core;
|
|
360
|
+
}
|
|
361
|
+
async chain() {
|
|
362
|
+
if (this.options.handlers !== void 0) return this.options.handlers;
|
|
363
|
+
const config = this.options.config === void 0 ? {} : { config: this.options.config };
|
|
364
|
+
const native = (stages) => nativeHandler({
|
|
365
|
+
prefer: (source, env) => this.getAttribute(NATIVE_HLS) !== "off" && preferNativeHls(source, env),
|
|
366
|
+
drm: () => this.drm(stages)
|
|
367
|
+
});
|
|
368
|
+
if (this.options.stages !== void 0) return [matteboxHandler({
|
|
369
|
+
stages: this.options.stages,
|
|
370
|
+
...config
|
|
371
|
+
}), native(() => this.options.stages ?? [])];
|
|
372
|
+
const name = this.getAttribute("preset") ?? DEFAULT_PRESET;
|
|
373
|
+
const preset = await resolvePreset(name);
|
|
374
|
+
if (preset === null) {
|
|
375
|
+
this.report({
|
|
376
|
+
category: "config",
|
|
377
|
+
code: "CONFIG_INVALID",
|
|
378
|
+
fatal: true,
|
|
379
|
+
recoverable: false,
|
|
380
|
+
handler: null,
|
|
381
|
+
context: { preset: name }
|
|
382
|
+
});
|
|
383
|
+
return [nativeHandler()];
|
|
384
|
+
}
|
|
385
|
+
return [matteboxHandler({
|
|
386
|
+
preset,
|
|
387
|
+
...config,
|
|
388
|
+
...drmGuard()
|
|
389
|
+
}), native(() => preset.stages())];
|
|
390
|
+
}
|
|
391
|
+
/**
|
|
392
|
+
* The DRM a native session attaches: the page's `drm` option, the
|
|
393
|
+
* key-system stages of the engine's stack, and the `license-url`
|
|
394
|
+
* attribute. None on a browser without EME, as for the engine.
|
|
395
|
+
*/
|
|
396
|
+
drm(stages) {
|
|
397
|
+
if (drmGuard().without !== void 0) return void 0;
|
|
398
|
+
const keySystems = stages().filter((stage) => KEY_SYSTEMS.includes(stage.name));
|
|
399
|
+
const license = this.getAttribute("license-url");
|
|
400
|
+
const certificate = this.getAttribute("certificate-url");
|
|
401
|
+
const page = this.options.drm;
|
|
402
|
+
if (keySystems.length === 0 && license === null && page === void 0) return void 0;
|
|
403
|
+
return {
|
|
404
|
+
keySystems,
|
|
405
|
+
...page,
|
|
406
|
+
...license === null ? {} : { licenseUrl: license },
|
|
407
|
+
...certificate === null ? {} : { certificateUrl: certificate }
|
|
408
|
+
};
|
|
409
|
+
}
|
|
410
|
+
/** What the attributes ask of the session's namespaces, once there is one. */
|
|
411
|
+
configure(session) {
|
|
412
|
+
const engine = session.engine;
|
|
413
|
+
if (engine === null) return;
|
|
414
|
+
const optional = namespaces(engine);
|
|
415
|
+
const license = this.getAttribute("license-url");
|
|
416
|
+
if (license !== null && optional.drm !== void 0) optional.drm.setLicenseUrl(license);
|
|
417
|
+
const certificate = this.getAttribute("certificate-url");
|
|
418
|
+
if (certificate !== null) optional.drm?.setCertificateUrl(certificate);
|
|
419
|
+
const track = this.getAttribute("thumbnails");
|
|
420
|
+
if (track !== null && optional.thumbnails !== void 0) optional.thumbnails.load(track).catch(() => void 0);
|
|
421
|
+
}
|
|
422
|
+
unmount() {
|
|
423
|
+
this.current = null;
|
|
424
|
+
}
|
|
425
|
+
async teardown() {
|
|
426
|
+
this.unmount();
|
|
427
|
+
if (this.core !== null) await this.core.unload();
|
|
428
|
+
}
|
|
429
|
+
/** Drops the player itself, so the next run builds a chain from the new preset. */
|
|
430
|
+
async discard() {
|
|
431
|
+
await this.teardown();
|
|
432
|
+
for (const off of this.offs) off();
|
|
433
|
+
this.offs = [];
|
|
434
|
+
this.core = null;
|
|
435
|
+
}
|
|
436
|
+
};
|
|
437
|
+
//#endregion
|
|
438
|
+
export { MatteboxPlayerElement };
|
|
439
|
+
|
|
456
440
|
//# sourceMappingURL=element.js.map
|