@mattebox/player 0.10.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/announcer.d.ts +6 -3
- package/dist/announcer.d.ts.map +1 -1
- package/dist/announcer.js +17 -14
- package/dist/announcer.js.map +1 -1
- package/dist/cdn/mattebox-player.min.js +3 -3
- package/dist/controls/airplay.js +1 -2
- package/dist/controls/chapters.js +1 -2
- package/dist/controls/cues.js +1 -2
- package/dist/controls/fullscreen.js +1 -2
- package/dist/controls/icons.d.ts +1 -1
- package/dist/controls/icons.d.ts.map +1 -1
- package/dist/controls/icons.js +2 -2
- package/dist/controls/icons.js.map +1 -1
- package/dist/controls/markers.d.ts +2 -15
- package/dist/controls/markers.d.ts.map +1 -1
- package/dist/controls/markers.js +1 -2
- package/dist/controls/markers.js.map +1 -1
- package/dist/controls/menu.js +1 -2
- package/dist/controls/native-tracks.d.ts +8 -7
- package/dist/controls/native-tracks.d.ts.map +1 -1
- package/dist/controls/native-tracks.js +1 -2
- package/dist/controls/native-tracks.js.map +1 -1
- package/dist/controls/pip.js +1 -2
- package/dist/controls/quality-names.js +1 -2
- package/dist/controls/ranges.js +1 -2
- package/dist/controls/session.js +1 -2
- package/dist/controls/slider.js +1 -2
- package/dist/controls/time.js +1 -2
- package/dist/controls/track-names.d.ts +3 -2
- package/dist/controls/track-names.d.ts.map +1 -1
- package/dist/controls/track-names.js +5 -5
- package/dist/controls/track-names.js.map +1 -1
- package/dist/dom.js +1 -2
- package/dist/element-entry.d.ts +4 -1
- package/dist/element-entry.d.ts.map +1 -1
- package/dist/element-entry.js +1 -2
- package/dist/element-entry.js.map +1 -1
- package/dist/element.d.ts +134 -5
- package/dist/element.d.ts.map +1 -1
- package/dist/element.js +346 -35
- package/dist/element.js.map +1 -1
- package/dist/elements/airplay-button.js +2 -3
- package/dist/elements/airplay-button.js.map +1 -1
- package/dist/elements/audio-menu.d.ts +3 -2
- package/dist/elements/audio-menu.d.ts.map +1 -1
- package/dist/elements/audio-menu.js +18 -12
- package/dist/elements/audio-menu.js.map +1 -1
- package/dist/elements/chapters-menu.d.ts +2 -1
- package/dist/elements/chapters-menu.d.ts.map +1 -1
- package/dist/elements/chapters-menu.js +2 -3
- package/dist/elements/chapters-menu.js.map +1 -1
- package/dist/elements/component.d.ts +9 -0
- package/dist/elements/component.d.ts.map +1 -1
- package/dist/elements/component.js +16 -2
- package/dist/elements/component.js.map +1 -1
- package/dist/elements/control-bar.d.ts.map +1 -1
- package/dist/elements/control-bar.js +9 -8
- package/dist/elements/control-bar.js.map +1 -1
- package/dist/elements/current-time.js +1 -2
- package/dist/elements/drm-badge.js +4 -5
- package/dist/elements/drm-badge.js.map +1 -1
- package/dist/elements/duration.js +1 -2
- package/dist/elements/error-screen.d.ts +9 -0
- package/dist/elements/error-screen.d.ts.map +1 -1
- package/dist/elements/error-screen.js +55 -15
- package/dist/elements/error-screen.js.map +1 -1
- package/dist/elements/fullscreen-button.js +2 -3
- package/dist/elements/fullscreen-button.js.map +1 -1
- package/dist/elements/live-button.js +3 -4
- package/dist/elements/live-button.js.map +1 -1
- package/dist/elements/marker-button.d.ts.map +1 -1
- package/dist/elements/marker-button.js +7 -6
- package/dist/elements/marker-button.js.map +1 -1
- package/dist/elements/menu-element.d.ts +3 -2
- package/dist/elements/menu-element.d.ts.map +1 -1
- package/dist/elements/menu-element.js +3 -4
- package/dist/elements/menu-element.js.map +1 -1
- package/dist/elements/mute-button.js +2 -3
- package/dist/elements/mute-button.js.map +1 -1
- package/dist/elements/pip-button.js +2 -3
- 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 +9 -12
- package/dist/elements/play-button.js.map +1 -1
- package/dist/elements/quality-menu.d.ts +2 -1
- package/dist/elements/quality-menu.d.ts.map +1 -1
- package/dist/elements/quality-menu.js +3 -4
- package/dist/elements/quality-menu.js.map +1 -1
- package/dist/elements/remaining-time.js +1 -2
- package/dist/elements/scan-button.d.ts.map +1 -1
- package/dist/elements/scan-button.js +2 -3
- package/dist/elements/scan-button.js.map +1 -1
- package/dist/elements/seek-bar.d.ts +2 -0
- package/dist/elements/seek-bar.d.ts.map +1 -1
- package/dist/elements/seek-bar.js +10 -7
- package/dist/elements/seek-bar.js.map +1 -1
- package/dist/elements/shared.d.ts +18 -0
- package/dist/elements/shared.d.ts.map +1 -1
- package/dist/elements/shared.js +17 -11
- package/dist/elements/shared.js.map +1 -1
- package/dist/elements/skip-button.d.ts.map +1 -1
- package/dist/elements/skip-button.js +2 -3
- package/dist/elements/skip-button.js.map +1 -1
- package/dist/elements/spacer.js +1 -2
- package/dist/elements/speed-menu.d.ts +2 -1
- package/dist/elements/speed-menu.d.ts.map +1 -1
- package/dist/elements/speed-menu.js +3 -4
- package/dist/elements/speed-menu.js.map +1 -1
- package/dist/elements/spinner.d.ts +1 -1
- package/dist/elements/spinner.js +2 -4
- package/dist/elements/spinner.js.map +1 -1
- package/dist/elements/start-button.d.ts.map +1 -1
- package/dist/elements/start-button.js +5 -7
- package/dist/elements/start-button.js.map +1 -1
- package/dist/elements/subtitles-menu.d.ts +2 -1
- package/dist/elements/subtitles-menu.d.ts.map +1 -1
- package/dist/elements/subtitles-menu.js +51 -22
- package/dist/elements/subtitles-menu.js.map +1 -1
- package/dist/elements/time-element.js +1 -2
- package/dist/elements/title.d.ts.map +1 -1
- package/dist/elements/title.js +16 -7
- package/dist/elements/title.js.map +1 -1
- package/dist/elements/video-menu.d.ts +24 -0
- package/dist/elements/video-menu.d.ts.map +1 -0
- package/dist/elements/video-menu.js +146 -0
- package/dist/elements/video-menu.js.map +1 -0
- package/dist/elements/volume-slider.js +2 -3
- package/dist/elements/volume-slider.js.map +1 -1
- package/dist/elements/volume.js +1 -2
- package/dist/entries/airplay-button.js +1 -2
- package/dist/entries/audio-menu.js +1 -2
- package/dist/entries/chapters-menu.js +1 -2
- package/dist/entries/control-bar.js +1 -2
- package/dist/entries/current-time.js +1 -2
- package/dist/entries/drm-badge.js +1 -2
- package/dist/entries/duration.js +1 -2
- package/dist/entries/error-screen.js +1 -2
- package/dist/entries/fullscreen-button.js +1 -2
- package/dist/entries/live-button.js +1 -2
- package/dist/entries/marker-button.js +1 -2
- package/dist/entries/mute-button.js +1 -2
- package/dist/entries/pip-button.js +1 -2
- package/dist/entries/play-button.js +1 -2
- package/dist/entries/quality-menu.js +1 -2
- package/dist/entries/remaining-time.js +1 -2
- package/dist/entries/scan-button.js +1 -2
- package/dist/entries/seek-bar.js +1 -2
- package/dist/entries/skip-button.js +1 -2
- package/dist/entries/spacer.js +1 -2
- package/dist/entries/speed-menu.js +1 -2
- package/dist/entries/spinner.js +1 -2
- package/dist/entries/start-button.js +1 -2
- package/dist/entries/subtitles-menu.js +1 -2
- package/dist/entries/title.js +1 -2
- package/dist/entries/video-menu.d.ts +5 -0
- package/dist/entries/video-menu.d.ts.map +1 -0
- package/dist/entries/video-menu.js +8 -0
- package/dist/entries/video-menu.js.map +1 -0
- package/dist/entries/volume-slider.js +1 -2
- package/dist/entries/volume.js +1 -2
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.154.0 → _@oxc-project_runtime@0.155.0}/helpers/esm/asyncToGenerator.js +1 -2
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.154.0 → _@oxc-project_runtime@0.155.0}/helpers/esm/defineProperty.js +1 -2
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.154.0 → _@oxc-project_runtime@0.155.0}/helpers/esm/objectSpread2.js +1 -2
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.154.0 → _@oxc-project_runtime@0.155.0}/helpers/esm/toPrimitive.js +1 -2
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.154.0 → _@oxc-project_runtime@0.155.0}/helpers/esm/toPropertyKey.js +1 -2
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.154.0 → _@oxc-project_runtime@0.155.0}/helpers/esm/typeof.js +1 -2
- package/dist/es2015/announcer.js +18 -15
- package/dist/es2015/controls/airplay.js +1 -2
- package/dist/es2015/controls/chapters.js +2 -3
- package/dist/es2015/controls/cues.js +1 -2
- package/dist/es2015/controls/fullscreen.js +1 -2
- package/dist/es2015/controls/icons.js +2 -2
- package/dist/es2015/controls/markers.js +1 -2
- package/dist/es2015/controls/menu.js +2 -3
- package/dist/es2015/controls/native-tracks.js +1 -2
- package/dist/es2015/controls/pip.js +1 -2
- package/dist/es2015/controls/quality-names.js +1 -2
- package/dist/es2015/controls/ranges.js +1 -2
- package/dist/es2015/controls/session.js +1 -2
- package/dist/es2015/controls/slider.js +1 -2
- package/dist/es2015/controls/time.js +1 -2
- package/dist/es2015/controls/track-names.js +5 -5
- package/dist/es2015/dom.js +1 -2
- package/dist/es2015/element-entry.js +1 -2
- package/dist/es2015/element.js +402 -85
- package/dist/es2015/elements/airplay-button.js +2 -4
- package/dist/es2015/elements/audio-menu.js +18 -16
- package/dist/es2015/elements/chapters-menu.js +2 -3
- package/dist/es2015/elements/component.js +18 -2
- package/dist/es2015/elements/control-bar.js +9 -8
- package/dist/es2015/elements/current-time.js +1 -2
- package/dist/es2015/elements/drm-badge.js +5 -7
- package/dist/es2015/elements/duration.js +1 -2
- package/dist/es2015/elements/error-screen.js +58 -16
- package/dist/es2015/elements/fullscreen-button.js +2 -4
- package/dist/es2015/elements/live-button.js +3 -5
- package/dist/es2015/elements/marker-button.js +8 -7
- package/dist/es2015/elements/menu-element.js +3 -8
- package/dist/es2015/elements/mute-button.js +3 -4
- package/dist/es2015/elements/pip-button.js +2 -4
- package/dist/es2015/elements/play-button.js +9 -13
- package/dist/es2015/elements/quality-menu.js +4 -5
- package/dist/es2015/elements/remaining-time.js +1 -2
- package/dist/es2015/elements/scan-button.js +3 -4
- package/dist/es2015/elements/seek-bar.js +12 -11
- package/dist/es2015/elements/shared.js +17 -11
- package/dist/es2015/elements/skip-button.js +2 -4
- package/dist/es2015/elements/spacer.js +1 -2
- package/dist/es2015/elements/speed-menu.js +4 -5
- package/dist/es2015/elements/spinner.js +2 -5
- package/dist/es2015/elements/start-button.js +6 -8
- package/dist/es2015/elements/subtitles-menu.js +53 -31
- package/dist/es2015/elements/time-element.js +1 -2
- package/dist/es2015/elements/title.js +17 -8
- package/dist/es2015/elements/video-menu.js +152 -0
- package/dist/es2015/elements/volume-slider.js +3 -4
- package/dist/es2015/elements/volume.js +1 -2
- package/dist/es2015/entries/airplay-button.js +1 -2
- package/dist/es2015/entries/audio-menu.js +1 -2
- package/dist/es2015/entries/chapters-menu.js +1 -2
- package/dist/es2015/entries/control-bar.js +1 -2
- package/dist/es2015/entries/current-time.js +1 -2
- package/dist/es2015/entries/drm-badge.js +1 -2
- package/dist/es2015/entries/duration.js +1 -2
- package/dist/es2015/entries/error-screen.js +1 -2
- package/dist/es2015/entries/fullscreen-button.js +1 -2
- package/dist/es2015/entries/live-button.js +1 -2
- package/dist/es2015/entries/marker-button.js +1 -2
- package/dist/es2015/entries/mute-button.js +1 -2
- package/dist/es2015/entries/pip-button.js +1 -2
- package/dist/es2015/entries/play-button.js +1 -2
- package/dist/es2015/entries/quality-menu.js +1 -2
- package/dist/es2015/entries/remaining-time.js +1 -2
- package/dist/es2015/entries/scan-button.js +1 -2
- package/dist/es2015/entries/seek-bar.js +1 -2
- package/dist/es2015/entries/skip-button.js +1 -2
- package/dist/es2015/entries/spacer.js +1 -2
- package/dist/es2015/entries/speed-menu.js +1 -2
- package/dist/es2015/entries/spinner.js +1 -2
- package/dist/es2015/entries/start-button.js +1 -2
- package/dist/es2015/entries/subtitles-menu.js +1 -2
- package/dist/es2015/entries/title.js +1 -2
- package/dist/es2015/entries/video-menu.js +6 -0
- package/dist/es2015/entries/volume-slider.js +1 -2
- package/dist/es2015/entries/volume.js +1 -2
- package/dist/es2015/host.js +1 -2
- package/dist/es2015/ids.js +33 -0
- package/dist/es2015/index.js +4 -1
- package/dist/es2015/labels.js +1 -2
- package/dist/es2015/locales/ar.js +75 -0
- package/dist/es2015/locales/ca.js +75 -0
- package/dist/es2015/locales/de.js +75 -0
- package/dist/es2015/locales/es.js +75 -0
- package/dist/es2015/locales/fr.js +75 -0
- package/dist/es2015/locales/hi.js +75 -0
- package/dist/es2015/locales/it.js +75 -0
- package/dist/es2015/locales/ja.js +75 -0
- package/dist/es2015/locales/ko.js +75 -0
- package/dist/es2015/locales/pt.js +75 -0
- package/dist/es2015/locales/zh.js +75 -0
- package/dist/es2015/locales.js +61 -0
- package/dist/es2015/namespaces.js +1 -2
- package/dist/es2015/presets.js +2 -3
- package/dist/es2015/style.js +1 -2
- package/dist/es2015/surface.js +12 -4
- package/dist/es2015/tags.js +3 -3
- package/dist/es2015/text.js +15 -0
- package/dist/es2015/trackers.js +43 -0
- package/dist/es2015/video-sources.js +127 -0
- package/dist/host.d.ts +49 -1
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +1 -2
- package/dist/host.js.map +1 -1
- package/dist/ids.d.ts +19 -0
- package/dist/ids.d.ts.map +1 -0
- package/dist/ids.js +34 -0
- package/dist/ids.js.map +1 -0
- package/dist/index.d.ts +11 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/labels.js +1 -2
- package/dist/locales/ar.d.ts +75 -0
- package/dist/locales/ar.d.ts.map +1 -0
- package/dist/locales/ar.js +77 -0
- package/dist/locales/ar.js.map +1 -0
- package/dist/locales/ca.d.ts +75 -0
- package/dist/locales/ca.d.ts.map +1 -0
- package/dist/locales/ca.js +77 -0
- package/dist/locales/ca.js.map +1 -0
- package/dist/locales/de.d.ts +75 -0
- package/dist/locales/de.d.ts.map +1 -0
- package/dist/locales/de.js +77 -0
- package/dist/locales/de.js.map +1 -0
- package/dist/locales/es.d.ts +75 -0
- package/dist/locales/es.d.ts.map +1 -0
- package/dist/locales/es.js +77 -0
- package/dist/locales/es.js.map +1 -0
- package/dist/locales/fr.d.ts +75 -0
- package/dist/locales/fr.d.ts.map +1 -0
- package/dist/locales/fr.js +77 -0
- package/dist/locales/fr.js.map +1 -0
- package/dist/locales/hi.d.ts +75 -0
- package/dist/locales/hi.d.ts.map +1 -0
- package/dist/locales/hi.js +77 -0
- package/dist/locales/hi.js.map +1 -0
- package/dist/locales/it.d.ts +75 -0
- package/dist/locales/it.d.ts.map +1 -0
- package/dist/locales/it.js +77 -0
- package/dist/locales/it.js.map +1 -0
- package/dist/locales/ja.d.ts +75 -0
- package/dist/locales/ja.d.ts.map +1 -0
- package/dist/locales/ja.js +77 -0
- package/dist/locales/ja.js.map +1 -0
- package/dist/locales/ko.d.ts +75 -0
- package/dist/locales/ko.d.ts.map +1 -0
- package/dist/locales/ko.js +77 -0
- package/dist/locales/ko.js.map +1 -0
- package/dist/locales/pt.d.ts +75 -0
- package/dist/locales/pt.d.ts.map +1 -0
- package/dist/locales/pt.js +77 -0
- package/dist/locales/pt.js.map +1 -0
- package/dist/locales/zh.d.ts +75 -0
- package/dist/locales/zh.d.ts.map +1 -0
- package/dist/locales/zh.js +77 -0
- package/dist/locales/zh.js.map +1 -0
- package/dist/locales.d.ts +27 -0
- package/dist/locales.d.ts.map +1 -0
- package/dist/locales.js +48 -0
- package/dist/locales.js.map +1 -0
- package/dist/messages.d.ts +167 -0
- package/dist/messages.d.ts.map +1 -0
- package/dist/namespaces.js +1 -2
- package/dist/presets.js +1 -2
- package/dist/style.js +1 -2
- package/dist/surface.d.ts +4 -1
- package/dist/surface.d.ts.map +1 -1
- package/dist/surface.js +12 -4
- package/dist/surface.js.map +1 -1
- package/dist/tags.d.ts +1 -0
- package/dist/tags.d.ts.map +1 -1
- package/dist/tags.js +3 -3
- package/dist/tags.js.map +1 -1
- package/dist/text.d.ts +14 -0
- package/dist/text.d.ts.map +1 -0
- package/dist/text.js +16 -0
- package/dist/text.js.map +1 -0
- package/dist/trackers.d.ts +18 -0
- package/dist/trackers.d.ts.map +1 -0
- package/dist/trackers.js +45 -0
- package/dist/trackers.js.map +1 -0
- package/dist/video-sources.d.ts +48 -0
- package/dist/video-sources.d.ts.map +1 -0
- package/dist/video-sources.js +133 -0
- package/dist/video-sources.js.map +1 -0
- package/package.json +11 -3
package/dist/es2015/element.js
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
import { announcer } from "./announcer.js";
|
|
2
2
|
import { createMarkers } from "./controls/markers.js";
|
|
3
3
|
import { languageName } from "./controls/track-names.js";
|
|
4
|
+
import _asyncToGenerator from "./_virtual/_@oxc-project_runtime@0.155.0/helpers/esm/asyncToGenerator.js";
|
|
5
|
+
import { addLocale, load, onLocales, registered, wordsNow } from "./locales.js";
|
|
4
6
|
import { namespaces } from "./namespaces.js";
|
|
5
|
-
import _asyncToGenerator from "./_virtual/_@oxc-project_runtime@0.154.0/helpers/esm/asyncToGenerator.js";
|
|
6
7
|
import { drmGuard, resolvePreset } from "./presets.js";
|
|
7
8
|
import { STYLE } from "./style.js";
|
|
8
9
|
import { errorSurface } from "./surface.js";
|
|
9
10
|
import { PLAYER } from "./tags.js";
|
|
10
|
-
import
|
|
11
|
+
import { textIn } from "./text.js";
|
|
12
|
+
import { createTrackers } from "./trackers.js";
|
|
13
|
+
import _objectSpread2 from "./_virtual/_@oxc-project_runtime@0.155.0/helpers/esm/objectSpread2.js";
|
|
14
|
+
import { chosen, holdFrame, markupVideoTracks, onNextFrame, restore, resume, versionSource } from "./video-sources.js";
|
|
11
15
|
import { createPlayer, inferType, matteboxHandler, nativeHandler, preferNativeHls } from "@mattebox/player-core";
|
|
12
|
-
|
|
16
|
+
// src/element.ts
|
|
13
17
|
/**
|
|
14
18
|
* `off` keeps HLS on the engine in Safari. Anything else lets Safari play
|
|
15
19
|
* HLS itself: FairPlay, AirPlay, Low-Latency HLS and the platform's
|
|
@@ -24,6 +28,18 @@ const FORWARDED = [
|
|
|
24
28
|
"crossorigin"
|
|
25
29
|
];
|
|
26
30
|
const LICENSE_URL = "license-url";
|
|
31
|
+
/** The language the page chose, over the nearest `lang`. */
|
|
32
|
+
const LANGUAGE = "language";
|
|
33
|
+
/** Carried through a switch: the play state from before it, `playing` or `paused`. */
|
|
34
|
+
const SWITCHING = "switching";
|
|
35
|
+
/** Whether the browser has EME, so a source may bring DRM. */
|
|
36
|
+
function emeAvailable() {
|
|
37
|
+
return drmGuard().without === void 0;
|
|
38
|
+
}
|
|
39
|
+
/** `source` without its DRM, for a browser without EME. */
|
|
40
|
+
function withoutDrm({ url, type, videoTracks }) {
|
|
41
|
+
return _objectSpread2(_objectSpread2({ url }, type === void 0 ? {} : { type }), videoTracks === void 0 ? {} : { videoTracks });
|
|
42
|
+
}
|
|
27
43
|
const CERTIFICATE_URL = "certificate-url";
|
|
28
44
|
/** Everything else the element watches. Changing any of them reloads. */
|
|
29
45
|
const OWN = [
|
|
@@ -92,7 +108,6 @@ const STATE_EVENTS = [
|
|
|
92
108
|
"resize",
|
|
93
109
|
"playing",
|
|
94
110
|
"waiting",
|
|
95
|
-
"stalled",
|
|
96
111
|
"canplay"
|
|
97
112
|
];
|
|
98
113
|
/**
|
|
@@ -100,10 +115,10 @@ const STATE_EVENTS = [
|
|
|
100
115
|
* seek within the buffer waits for less, and saying it would only be noise.
|
|
101
116
|
*/
|
|
102
117
|
const LOADING_MS = 1e3;
|
|
103
|
-
/** A track's name for the live region: its name in the stream, else its language's
|
|
104
|
-
function trackName(name, lang) {
|
|
118
|
+
/** A track's name for the live region: its name in the stream, else its language's in `locale`. */
|
|
119
|
+
function trackName(name, lang, locale) {
|
|
105
120
|
var _languageName;
|
|
106
|
-
return name || lang && ((_languageName = languageName(lang)) !== null && _languageName !== void 0 ? _languageName : lang) || "";
|
|
121
|
+
return name || lang && ((_languageName = languageName(lang, locale || void 0)) !== null && _languageName !== void 0 ? _languageName : lang) || "";
|
|
107
122
|
}
|
|
108
123
|
/** The stages that register a key system, which a native session's DRM offers. */
|
|
109
124
|
const KEY_SYSTEMS = ["eme-fairplay", "eme-cenc"];
|
|
@@ -129,10 +144,22 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
|
|
|
129
144
|
CONTROLS,
|
|
130
145
|
CHAPTERS,
|
|
131
146
|
PLAYSINLINE,
|
|
132
|
-
LAYOUT
|
|
147
|
+
LAYOUT,
|
|
148
|
+
LANGUAGE,
|
|
149
|
+
"lang"
|
|
133
150
|
];
|
|
134
151
|
}
|
|
135
152
|
/**
|
|
153
|
+
* Registers the words of a language for every player on the page. Each
|
|
154
|
+
* source is a set of words or a function that loads one, which runs only
|
|
155
|
+
* when a player shows that language. Later sources go over earlier ones,
|
|
156
|
+
* so a page changes a shipped word by registering its own after it.
|
|
157
|
+
* Players that show the language take the new words at once.
|
|
158
|
+
*/
|
|
159
|
+
static addLocale(language, ...sources) {
|
|
160
|
+
addLocale(language, sources);
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
136
163
|
* Registers the element once, and records the stages markup-only pages
|
|
137
164
|
* get. The controls register through their own entries, the package's
|
|
138
165
|
* root entry importing every one; a control connected before its player
|
|
@@ -153,6 +180,7 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
|
|
|
153
180
|
this.core = null;
|
|
154
181
|
this.current = null;
|
|
155
182
|
this.failure = null;
|
|
183
|
+
this.stop = null;
|
|
156
184
|
this.reflecting = false;
|
|
157
185
|
this.sizes = null;
|
|
158
186
|
this.fixed = false;
|
|
@@ -161,6 +189,15 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
|
|
|
161
189
|
this.offs = [];
|
|
162
190
|
this.queue = Promise.resolve();
|
|
163
191
|
this.pending = false;
|
|
192
|
+
this.original = null;
|
|
193
|
+
this.version = null;
|
|
194
|
+
this.switching = false;
|
|
195
|
+
this.switched = null;
|
|
196
|
+
this.held = null;
|
|
197
|
+
this.words = {};
|
|
198
|
+
this.shown = "";
|
|
199
|
+
this.wordsEpoch = 0;
|
|
200
|
+
this.unwatch = null;
|
|
164
201
|
this.slow = void 0;
|
|
165
202
|
this.heardAudio = void 0;
|
|
166
203
|
this.heardText = void 0;
|
|
@@ -180,8 +217,10 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
|
|
|
180
217
|
});
|
|
181
218
|
this.media.addEventListener("playing", () => {
|
|
182
219
|
this.failure = null;
|
|
220
|
+
this.reflect();
|
|
183
221
|
});
|
|
184
222
|
this.marks = createMarkers(this.media, (name, detail) => this.emit(name, detail));
|
|
223
|
+
this.tracking = createTrackers(this, () => this.emit("trackerschange", this.tracking.list));
|
|
185
224
|
this.stage = document.createElement("div");
|
|
186
225
|
this.stage.setAttribute("part", "stage");
|
|
187
226
|
const slot = document.createElement("slot");
|
|
@@ -190,9 +229,12 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
|
|
|
190
229
|
});
|
|
191
230
|
this.stage.append(slot);
|
|
192
231
|
this.surface = errorSurface(() => {
|
|
193
|
-
this.
|
|
232
|
+
this.retry();
|
|
233
|
+
}, () => {
|
|
234
|
+
var _this$words$retry;
|
|
235
|
+
return (_this$words$retry = this.words.retry) !== null && _this$words$retry !== void 0 ? _this$words$retry : "Retry";
|
|
194
236
|
});
|
|
195
|
-
this.voice = announcer(this);
|
|
237
|
+
this.voice = announcer(this, (id) => this.words[id]);
|
|
196
238
|
const root = this.attachShadow({ mode: "open" });
|
|
197
239
|
const style = document.createElement("style");
|
|
198
240
|
style.textContent = STYLE;
|
|
@@ -217,16 +259,184 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
|
|
|
217
259
|
set sources(value) {
|
|
218
260
|
this.list = value;
|
|
219
261
|
if (this.marks.list.length > 0) this.marks.set([]);
|
|
262
|
+
this.unblock();
|
|
220
263
|
this.reload();
|
|
221
264
|
}
|
|
265
|
+
/**
|
|
266
|
+
* The language the page chose for this player, which wins over the
|
|
267
|
+
* nearest `lang` attribute. Empty follows `lang`. Setting it changes the
|
|
268
|
+
* words of every control at once.
|
|
269
|
+
*/
|
|
270
|
+
get language() {
|
|
271
|
+
var _this$getAttribute;
|
|
272
|
+
return (_this$getAttribute = this.getAttribute(LANGUAGE)) !== null && _this$getAttribute !== void 0 ? _this$getAttribute : "";
|
|
273
|
+
}
|
|
274
|
+
set language(value) {
|
|
275
|
+
if (value === "") this.removeAttribute(LANGUAGE);
|
|
276
|
+
else this.setAttribute(LANGUAGE, value);
|
|
277
|
+
}
|
|
278
|
+
/** The language tag the words come from: `language`, else the nearest `lang`. Empty without either. */
|
|
279
|
+
get locale() {
|
|
280
|
+
return this.shown;
|
|
281
|
+
}
|
|
282
|
+
/** The word of `id` in the player's language, or undefined, where the control's English applies. */
|
|
283
|
+
message(id) {
|
|
284
|
+
return this.words[id];
|
|
285
|
+
}
|
|
286
|
+
/** Follows registrations and the document's `lang` until disconnect. */
|
|
287
|
+
watchLanguage() {
|
|
288
|
+
const off = onLocales(() => {
|
|
289
|
+
this.relocale();
|
|
290
|
+
});
|
|
291
|
+
const watch = new MutationObserver(() => {
|
|
292
|
+
this.relocale();
|
|
293
|
+
});
|
|
294
|
+
watch.observe(document.documentElement, {
|
|
295
|
+
attributes: true,
|
|
296
|
+
attributeFilter: ["lang"]
|
|
297
|
+
});
|
|
298
|
+
this.unwatch = () => {
|
|
299
|
+
off();
|
|
300
|
+
watch.disconnect();
|
|
301
|
+
};
|
|
302
|
+
this.relocale();
|
|
303
|
+
}
|
|
304
|
+
/** Resolves the language, takes its words, and tells the controls with `localechange`. */
|
|
305
|
+
relocale() {
|
|
306
|
+
var _ref, _this$getAttribute2, _this$closest;
|
|
307
|
+
const tag = (_ref = (_this$getAttribute2 = this.getAttribute(LANGUAGE)) !== null && _this$getAttribute2 !== void 0 ? _this$getAttribute2 : (_this$closest = this.closest("[lang]")) === null || _this$closest === void 0 ? void 0 : _this$closest.getAttribute("lang")) !== null && _ref !== void 0 ? _ref : "";
|
|
308
|
+
const epoch = ++this.wordsEpoch;
|
|
309
|
+
const take = (words) => {
|
|
310
|
+
if (epoch !== this.wordsEpoch) return;
|
|
311
|
+
this.shown = tag;
|
|
312
|
+
this.words = words;
|
|
313
|
+
this.showBlock();
|
|
314
|
+
this.emit("localechange", tag);
|
|
315
|
+
};
|
|
316
|
+
const key = registered(tag);
|
|
317
|
+
if (key === null) {
|
|
318
|
+
take({});
|
|
319
|
+
return;
|
|
320
|
+
}
|
|
321
|
+
const now = wordsNow(key);
|
|
322
|
+
if (now !== null) {
|
|
323
|
+
take(now);
|
|
324
|
+
return;
|
|
325
|
+
}
|
|
326
|
+
load(key).then(take, () => void 0);
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Loads the sources again, in the order a load reads them: the `src`
|
|
330
|
+
* attribute, the `sources` property, then the `<source>` children. The
|
|
331
|
+
* error screens' Retry calls it. On a version of `videoSources`, it
|
|
332
|
+
* loads that version again.
|
|
333
|
+
*/
|
|
334
|
+
retry() {
|
|
335
|
+
const again = this.version === null ? this.switched : versionSource(this.version, emeAvailable());
|
|
336
|
+
if (again === null) this.reload();
|
|
337
|
+
else this.swap(again, null, false, null, false);
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* Loads `source` in place of the one that plays, from the same position
|
|
341
|
+
* and in the same play state, with the same audio and subtitle choice.
|
|
342
|
+
* Use it for the same programme at another URL, such as its HLS and
|
|
343
|
+
* DASH manifests. The last frame and the controls hold until the new
|
|
344
|
+
* load shows a frame there. The markers stay, and the versions are the
|
|
345
|
+
* ones `source` names. A new `src`, `sources` or `<source>` load
|
|
346
|
+
* replaces it.
|
|
347
|
+
*/
|
|
348
|
+
switchSource(source) {
|
|
349
|
+
var _this$current$engine, _this$current;
|
|
350
|
+
const media = this.media;
|
|
351
|
+
const at = Number.isFinite(media.duration) ? media.currentTime : null;
|
|
352
|
+
const playing = !media.paused;
|
|
353
|
+
const had = chosen((_this$current$engine = (_this$current = this.current) === null || _this$current === void 0 ? void 0 : _this$current.engine) !== null && _this$current$engine !== void 0 ? _this$current$engine : null);
|
|
354
|
+
const clean = emeAvailable() ? source : withoutDrm(source);
|
|
355
|
+
const was = this.version;
|
|
356
|
+
this.original = clean;
|
|
357
|
+
this.switched = clean;
|
|
358
|
+
this.version = null;
|
|
359
|
+
if (was !== null) this.emit("videosourcechange", null);
|
|
360
|
+
this.swap(clean, at, playing, had, true);
|
|
361
|
+
}
|
|
362
|
+
/** The other versions of the picture the source names at their own URLs, for the video menu. */
|
|
363
|
+
get videoSources() {
|
|
364
|
+
var _this$original$videoT, _this$original;
|
|
365
|
+
return (_this$original$videoT = (_this$original = this.original) === null || _this$original === void 0 ? void 0 : _this$original.videoTracks) !== null && _this$original$videoT !== void 0 ? _this$original$videoT : [];
|
|
366
|
+
}
|
|
367
|
+
/** The version of `videoSources` that plays, or null for the source itself. */
|
|
368
|
+
get videoSource() {
|
|
369
|
+
return this.version;
|
|
370
|
+
}
|
|
371
|
+
/**
|
|
372
|
+
* Plays a version of `videoSources`, or the source itself for null, from
|
|
373
|
+
* the same position and in the same play state, with the same audio and
|
|
374
|
+
* subtitle choice. A live source joins the version at its live edge.
|
|
375
|
+
* Fires `videosourcechange`.
|
|
376
|
+
*/
|
|
377
|
+
selectVideoSource(track) {
|
|
378
|
+
var _programme$videoTrack, _this$current$engine2, _this$current2;
|
|
379
|
+
const programme = this.original;
|
|
380
|
+
if (programme === null || track === this.version) return;
|
|
381
|
+
if (track !== null && ((_programme$videoTrack = programme.videoTracks) === null || _programme$videoTrack === void 0 ? void 0 : _programme$videoTrack.includes(track)) !== true) return;
|
|
382
|
+
const media = this.media;
|
|
383
|
+
const at = Number.isFinite(media.duration) ? media.currentTime : null;
|
|
384
|
+
const playing = !media.paused;
|
|
385
|
+
const had = chosen((_this$current$engine2 = (_this$current2 = this.current) === null || _this$current2 === void 0 ? void 0 : _this$current2.engine) !== null && _this$current$engine2 !== void 0 ? _this$current$engine2 : null);
|
|
386
|
+
this.version = track;
|
|
387
|
+
this.emit("videosourcechange", track);
|
|
388
|
+
this.swap(track === null ? programme : versionSource(track, emeAvailable()), at, playing, had, true);
|
|
389
|
+
}
|
|
390
|
+
/**
|
|
391
|
+
* Loads `source` under the programme that plays, and puts the position,
|
|
392
|
+
* play state and tracks back. With `hold`, the last frame stays as the
|
|
393
|
+
* poster and the player carries `switching`, the play state from
|
|
394
|
+
* before, so the controls show that state through the load.
|
|
395
|
+
*/
|
|
396
|
+
swap(source, at, playing, had, hold) {
|
|
397
|
+
var _this = this;
|
|
398
|
+
var _this$held;
|
|
399
|
+
const media = this.media;
|
|
400
|
+
(_this$held = this.held) === null || _this$held === void 0 || _this$held.call(this);
|
|
401
|
+
let release = null;
|
|
402
|
+
if (hold) {
|
|
403
|
+
const frame = holdFrame(media);
|
|
404
|
+
const done = () => {
|
|
405
|
+
frame === null || frame === void 0 || frame();
|
|
406
|
+
if (this.held !== done) return;
|
|
407
|
+
this.held = null;
|
|
408
|
+
this.removeAttribute(SWITCHING);
|
|
409
|
+
this.reflect();
|
|
410
|
+
};
|
|
411
|
+
this.held = done;
|
|
412
|
+
this.setAttribute(SWITCHING, playing ? "playing" : "paused");
|
|
413
|
+
release = done;
|
|
414
|
+
}
|
|
415
|
+
this.enqueue(_asyncToGenerator(function* () {
|
|
416
|
+
var _this$current$engine3, _this$current3;
|
|
417
|
+
const core = yield _this.ensure();
|
|
418
|
+
_this.switching = true;
|
|
419
|
+
try {
|
|
420
|
+
yield core.load([source]);
|
|
421
|
+
} catch (_unused) {
|
|
422
|
+
release === null || release === void 0 || release();
|
|
423
|
+
return;
|
|
424
|
+
} finally {
|
|
425
|
+
_this.switching = false;
|
|
426
|
+
}
|
|
427
|
+
resume(media, at, playing);
|
|
428
|
+
if (release !== null) onNextFrame(media, at, release);
|
|
429
|
+
restore((_this$current$engine3 = (_this$current3 = _this.current) === null || _this$current3 === void 0 ? void 0 : _this$current3.engine) !== null && _this$current$engine3 !== void 0 ? _this$current$engine3 : null, had);
|
|
430
|
+
}));
|
|
431
|
+
}
|
|
222
432
|
/** The core, or null until the first source has been set up: resolving a preset is asynchronous. */
|
|
223
433
|
get player() {
|
|
224
434
|
return this.core;
|
|
225
435
|
}
|
|
226
436
|
/** The engine feeding the video, or null for a native session and before the first load. */
|
|
227
437
|
get engine() {
|
|
228
|
-
var _this$current$
|
|
229
|
-
return (_this$current$
|
|
438
|
+
var _this$current$engine4, _this$current4;
|
|
439
|
+
return (_this$current$engine4 = (_this$current4 = this.current) === null || _this$current4 === void 0 ? void 0 : _this$current4.engine) !== null && _this$current$engine4 !== void 0 ? _this$current$engine4 : null;
|
|
230
440
|
}
|
|
231
441
|
/**
|
|
232
442
|
* The fatal error of the current load, or null once a load starts or
|
|
@@ -237,6 +447,83 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
|
|
|
237
447
|
get error() {
|
|
238
448
|
return this.failure;
|
|
239
449
|
}
|
|
450
|
+
/**
|
|
451
|
+
* Shows why the programme does not play, in place of the video, and
|
|
452
|
+
* stops the load: the reason the page's content API gave, such as a
|
|
453
|
+
* geographic or an age restriction. The error screen shows the title,
|
|
454
|
+
* else "Not available", and the message, with no retry. Each text can
|
|
455
|
+
* be given by language tag, and follows the player's language. A new
|
|
456
|
+
* `src` or `sources` clears it. Fires `blockchange`.
|
|
457
|
+
*/
|
|
458
|
+
block(block) {
|
|
459
|
+
this.refuse(block);
|
|
460
|
+
this.enqueue(() => this.teardown());
|
|
461
|
+
}
|
|
462
|
+
/** Shows the block, for `block()` and for a programme a connector blocked, which loaded nothing. */
|
|
463
|
+
refuse(block) {
|
|
464
|
+
this.stop = block;
|
|
465
|
+
this.media.pause();
|
|
466
|
+
clearTimeout(this.slow);
|
|
467
|
+
const [title, message] = this.blockWords(block);
|
|
468
|
+
if (this.querySelector("mbx-error-screen") === null) this.voice.tell(message === "" ? title : `${title}. ${message}`);
|
|
469
|
+
this.showBlock();
|
|
470
|
+
this.reflect();
|
|
471
|
+
this.emit("blockchange", block);
|
|
472
|
+
}
|
|
473
|
+
/** Removes the block. Nothing plays until a source loads: set one, or call `retry()`. */
|
|
474
|
+
unblock() {
|
|
475
|
+
if (this.stop === null) return;
|
|
476
|
+
this.stop = null;
|
|
477
|
+
this.surface.clear();
|
|
478
|
+
this.reflect();
|
|
479
|
+
this.emit("blockchange", null);
|
|
480
|
+
}
|
|
481
|
+
/** What `block()` set, or null. */
|
|
482
|
+
get blocked() {
|
|
483
|
+
return this.stop;
|
|
484
|
+
}
|
|
485
|
+
/**
|
|
486
|
+
* What the current load resolved to: the sources, and what a connector
|
|
487
|
+
* said of the programme. Null before a load and after an unload.
|
|
488
|
+
*/
|
|
489
|
+
get programme() {
|
|
490
|
+
var _this$core$programme, _this$core;
|
|
491
|
+
return (_this$core$programme = (_this$core = this.core) === null || _this$core === void 0 ? void 0 : _this$core.programme) !== null && _this$core$programme !== void 0 ? _this$core$programme : null;
|
|
492
|
+
}
|
|
493
|
+
/**
|
|
494
|
+
* The page's trackers. Each starts at every programme and stops at its
|
|
495
|
+
* end; one added or removed during a programme starts or stops at once.
|
|
496
|
+
*/
|
|
497
|
+
get trackers() {
|
|
498
|
+
return this.tracking;
|
|
499
|
+
}
|
|
500
|
+
/**
|
|
501
|
+
* Applies what the load resolved, before any session: the markers, the
|
|
502
|
+
* poster, the block. The page's own `poster` and markers set after the
|
|
503
|
+
* source win. Then the trackers start on the programme.
|
|
504
|
+
*/
|
|
505
|
+
programmed(programme) {
|
|
506
|
+
const metadata = programme === null || programme === void 0 ? void 0 : programme.metadata;
|
|
507
|
+
if ((metadata === null || metadata === void 0 ? void 0 : metadata.markers) !== void 0) this.marks.set(metadata.markers);
|
|
508
|
+
if (!this.hasAttribute("poster")) {
|
|
509
|
+
if ((metadata === null || metadata === void 0 ? void 0 : metadata.poster) === void 0) this.media.removeAttribute("poster");
|
|
510
|
+
else this.media.poster = metadata.poster;
|
|
511
|
+
}
|
|
512
|
+
if ((programme === null || programme === void 0 ? void 0 : programme.block) !== void 0) this.refuse(programme.block);
|
|
513
|
+
this.emit("programmechange", programme);
|
|
514
|
+
this.tracking.begin(programme);
|
|
515
|
+
}
|
|
516
|
+
/** A block's title and message in the player's language: the title defaults to the `blocked` word. */
|
|
517
|
+
blockWords(block) {
|
|
518
|
+
var _this$words$blocked;
|
|
519
|
+
return [block.title === void 0 ? (_this$words$blocked = this.words.blocked) !== null && _this$words$blocked !== void 0 ? _this$words$blocked : "Not available" : textIn(block.title, this.shown), block.message === void 0 ? "" : textIn(block.message, this.shown)];
|
|
520
|
+
}
|
|
521
|
+
/** Puts the block on the row under the video, under native controls. */
|
|
522
|
+
showBlock() {
|
|
523
|
+
if (this.stop === null || this.getAttribute(CONTROLS) === "custom") return;
|
|
524
|
+
const [title, message] = this.blockWords(this.stop);
|
|
525
|
+
this.surface.inform(title, message);
|
|
526
|
+
}
|
|
240
527
|
connectedCallback() {
|
|
241
528
|
if (this.media.parentNode !== this) this.append(this.media);
|
|
242
529
|
for (const name of FORWARDED) this.forward(name);
|
|
@@ -248,6 +535,7 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
|
|
|
248
535
|
this.sizes.observe(this);
|
|
249
536
|
}
|
|
250
537
|
this.measure();
|
|
538
|
+
this.watchLanguage();
|
|
251
539
|
this.reload();
|
|
252
540
|
}
|
|
253
541
|
/** Sets `layout` from the element's box, unless the page fixed it. */
|
|
@@ -269,10 +557,10 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
|
|
|
269
557
|
if (!this.started) this.tracks();
|
|
270
558
|
this.started = true;
|
|
271
559
|
this.waiting = false;
|
|
272
|
-
} else if (event === "waiting"
|
|
560
|
+
} else if (event === "waiting") this.waiting = true;
|
|
273
561
|
else if (event === "canplay") this.waiting = false;
|
|
274
562
|
else if (event === "emptied") {
|
|
275
|
-
this.started = false;
|
|
563
|
+
if (this.held === null) this.started = false;
|
|
276
564
|
this.waiting = false;
|
|
277
565
|
this.heardAudio = void 0;
|
|
278
566
|
this.heardText = void 0;
|
|
@@ -280,12 +568,12 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
|
|
|
280
568
|
}
|
|
281
569
|
/** Says a play or a pause, and a wait once it has lasted `LOADING_MS`. */
|
|
282
570
|
tell(event, was) {
|
|
283
|
-
if (event === "play") this.voice.say("playing", "Playing");
|
|
284
|
-
if (event === "pause" && !this.media.ended) this.voice.say("paused", "Paused");
|
|
571
|
+
if (event === "play" && this.held === null) this.voice.say("playing", "saidPlaying", "Playing");
|
|
572
|
+
if (event === "pause" && !this.media.ended && this.held === null) this.voice.say("paused", "saidPaused", "Paused");
|
|
285
573
|
if (this.waiting === was) return;
|
|
286
574
|
clearTimeout(this.slow);
|
|
287
575
|
if (this.waiting) this.slow = setTimeout(() => {
|
|
288
|
-
this.voice.say("loading", "Loading");
|
|
576
|
+
this.voice.say("loading", "loading", "Loading");
|
|
289
577
|
}, LOADING_MS);
|
|
290
578
|
}
|
|
291
579
|
/**
|
|
@@ -294,44 +582,48 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
|
|
|
294
582
|
* reads as off, as in the subtitles menu.
|
|
295
583
|
*/
|
|
296
584
|
tracks() {
|
|
297
|
-
var _this$current$
|
|
298
|
-
const engine = (_this$current$
|
|
585
|
+
var _this$current$engine5, _this$current5;
|
|
586
|
+
const engine = (_this$current$engine5 = (_this$current5 = this.current) === null || _this$current5 === void 0 ? void 0 : _this$current5.engine) !== null && _this$current$engine5 !== void 0 ? _this$current$engine5 : null;
|
|
299
587
|
let audio;
|
|
300
588
|
let text;
|
|
301
589
|
if (engine !== null) {
|
|
302
590
|
const sound = engine.tracks.active("audio");
|
|
303
591
|
const words = engine.tracks.active("text");
|
|
304
|
-
audio = sound === null ? "" : trackName(sound.name, sound.lang);
|
|
305
|
-
text = words === null || words.forced === true ? null : trackName(words.name, words.lang);
|
|
592
|
+
audio = sound === null ? "" : trackName(sound.name, sound.lang, this.locale);
|
|
593
|
+
text = words === null || words.forced === true ? null : trackName(words.name, words.lang, this.locale);
|
|
306
594
|
} else {
|
|
307
595
|
var _video$audioTracks;
|
|
308
596
|
const video = this.media;
|
|
309
597
|
const sound = Array.from((_video$audioTracks = video.audioTracks) !== null && _video$audioTracks !== void 0 ? _video$audioTracks : []).find((track) => track.enabled);
|
|
310
598
|
const words = Array.from(this.media.textTracks).find((track) => (track.kind === "subtitles" || track.kind === "captions") && track.mode === "showing");
|
|
311
|
-
audio = sound === void 0 ? "" : trackName(sound.label, sound.language);
|
|
312
|
-
text = words === void 0 ? null : trackName(words.label, words.language);
|
|
599
|
+
audio = sound === void 0 ? "" : trackName(sound.label, sound.language, this.locale);
|
|
600
|
+
text = words === void 0 ? null : trackName(words.label, words.language, this.locale);
|
|
313
601
|
}
|
|
314
602
|
const { heardAudio, heardText } = this;
|
|
315
603
|
this.heardAudio = audio;
|
|
316
604
|
this.heardText = text;
|
|
317
605
|
if (!this.started) return;
|
|
318
|
-
if (heardAudio !== void 0 && audio !== heardAudio) this.voice.say("audio", "Audio: {track}", audio);
|
|
606
|
+
if (heardAudio !== void 0 && audio !== heardAudio) this.voice.say("audio", "saidAudio", "Audio: {track}", audio);
|
|
319
607
|
if (heardText !== void 0 && text !== heardText) {
|
|
320
|
-
if (text === null) this.voice.say("subtitles-off", "Subtitles off");
|
|
321
|
-
else this.voice.say("subtitles", "Subtitles: {track}", text);
|
|
608
|
+
if (text === null) this.voice.say("subtitles-off", "saidSubtitlesOff", "Subtitles off");
|
|
609
|
+
else this.voice.say("subtitles", "saidSubtitles", "Subtitles: {track}", text);
|
|
322
610
|
}
|
|
323
611
|
}
|
|
324
612
|
/** The video's state on the element, for `mattebox-player[paused]` and the like. */
|
|
325
613
|
reflect() {
|
|
326
614
|
const video = this.media;
|
|
327
615
|
this.reflecting = true;
|
|
328
|
-
this.
|
|
329
|
-
|
|
616
|
+
const held = this.getAttribute(SWITCHING);
|
|
617
|
+
const paused = held === null ? video.paused : held === "paused";
|
|
618
|
+
this.toggleAttribute("paused", paused);
|
|
619
|
+
this.toggleAttribute("playing", !paused);
|
|
330
620
|
this.toggleAttribute("ended", video.ended);
|
|
331
621
|
this.toggleAttribute("muted", video.muted);
|
|
332
622
|
this.toggleAttribute("audio", this.audio());
|
|
333
623
|
this.toggleAttribute("started", this.started);
|
|
334
624
|
this.toggleAttribute("waiting", this.waiting);
|
|
625
|
+
this.toggleAttribute("error", this.failure !== null);
|
|
626
|
+
this.toggleAttribute("blocked", this.stop !== null);
|
|
335
627
|
this.reflecting = false;
|
|
336
628
|
}
|
|
337
629
|
/**
|
|
@@ -342,20 +634,28 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
|
|
|
342
634
|
* the start rather than from its metadata.
|
|
343
635
|
*/
|
|
344
636
|
audio() {
|
|
345
|
-
var _this$
|
|
637
|
+
var _this$getAttribute3;
|
|
346
638
|
const video = this.media;
|
|
347
639
|
if (video.readyState >= HTMLMediaElement.HAVE_METADATA) return video.videoWidth === 0 && video.videoHeight === 0;
|
|
348
640
|
const src = this.getAttribute("src");
|
|
349
|
-
const type = (_this$
|
|
641
|
+
const type = (_this$getAttribute3 = this.getAttribute("type")) !== null && _this$getAttribute3 !== void 0 ? _this$getAttribute3 : src === null ? void 0 : inferType(src);
|
|
350
642
|
return (type === null || type === void 0 ? void 0 : type.startsWith("audio/")) === true;
|
|
351
643
|
}
|
|
352
644
|
disconnectedCallback() {
|
|
353
|
-
var _this$sizes;
|
|
645
|
+
var _this$sizes, _this$unwatch;
|
|
354
646
|
(_this$sizes = this.sizes) === null || _this$sizes === void 0 || _this$sizes.disconnect();
|
|
355
647
|
this.sizes = null;
|
|
356
|
-
this.
|
|
648
|
+
(_this$unwatch = this.unwatch) === null || _this$unwatch === void 0 || _this$unwatch.call(this);
|
|
649
|
+
this.unwatch = null;
|
|
650
|
+
queueMicrotask(() => {
|
|
651
|
+
if (!this.isConnected) this.enqueue(() => this.teardown());
|
|
652
|
+
});
|
|
357
653
|
}
|
|
358
654
|
attributeChangedCallback(name) {
|
|
655
|
+
if (name === LANGUAGE || name === "lang") {
|
|
656
|
+
this.relocale();
|
|
657
|
+
return;
|
|
658
|
+
}
|
|
359
659
|
if (FORWARDED.includes(name)) {
|
|
360
660
|
if (!this.reflecting) this.forward(name);
|
|
361
661
|
return;
|
|
@@ -383,6 +683,7 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
|
|
|
383
683
|
if (name === "preset") this.enqueue(() => this.discard());
|
|
384
684
|
if (name === "src" || name === "type") this.toggleAttribute("audio", this.audio());
|
|
385
685
|
if (name === "src" && this.marks.list.length > 0) this.marks.set([]);
|
|
686
|
+
if (name === "src") this.unblock();
|
|
386
687
|
this.reload();
|
|
387
688
|
}
|
|
388
689
|
/**
|
|
@@ -395,6 +696,7 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
|
|
|
395
696
|
const custom = value === "custom";
|
|
396
697
|
this.media.controls = !custom && value !== "none";
|
|
397
698
|
if (custom) this.surface.clear();
|
|
699
|
+
else this.showBlock();
|
|
398
700
|
if (!custom) {
|
|
399
701
|
if (this.focusable) this.removeAttribute("tabindex");
|
|
400
702
|
this.focusable = false;
|
|
@@ -405,9 +707,9 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
|
|
|
405
707
|
}
|
|
406
708
|
/** Hands the `chapters` attribute to the engine, or keeps a hidden chapters track on the video for it. */
|
|
407
709
|
chapters() {
|
|
408
|
-
var _this$current$
|
|
710
|
+
var _this$current$engine6, _this$current6;
|
|
409
711
|
const url = this.getAttribute(CHAPTERS);
|
|
410
|
-
const engine = (_this$current$
|
|
712
|
+
const engine = (_this$current$engine6 = (_this$current6 = this.current) === null || _this$current6 === void 0 ? void 0 : _this$current6.engine) !== null && _this$current$engine6 !== void 0 ? _this$current$engine6 : null;
|
|
411
713
|
const api = engine === null ? void 0 : namespaces(engine).chapters;
|
|
412
714
|
if (api !== void 0) {
|
|
413
715
|
var _this$track;
|
|
@@ -468,28 +770,30 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
|
|
|
468
770
|
if (error.fatal) {
|
|
469
771
|
this.failure = error;
|
|
470
772
|
clearTimeout(this.slow);
|
|
471
|
-
if (this.querySelector("mbx-error-screen") === null) this.voice.say("error", "Playback failed");
|
|
773
|
+
if (this.querySelector("mbx-error-screen") === null) this.voice.say("error", "playbackFailed", "Playback failed");
|
|
472
774
|
if (this.getAttribute(CONTROLS) !== "custom") this.surface.show(error);
|
|
775
|
+
this.reflect();
|
|
473
776
|
}
|
|
474
777
|
this.emit("error", error);
|
|
475
778
|
}
|
|
476
779
|
run() {
|
|
477
|
-
var
|
|
780
|
+
var _this2 = this;
|
|
478
781
|
return _asyncToGenerator(function* () {
|
|
479
|
-
|
|
480
|
-
if (!
|
|
481
|
-
const sources =
|
|
482
|
-
|
|
782
|
+
_this2.unmount();
|
|
783
|
+
if (!_this2.isConnected) return;
|
|
784
|
+
const sources = _this2.wanted();
|
|
785
|
+
_this2.tried = JSON.stringify(sources);
|
|
483
786
|
if (sources.length === 0) return;
|
|
484
|
-
const core = yield
|
|
485
|
-
|
|
486
|
-
|
|
787
|
+
const core = yield _this2.ensure();
|
|
788
|
+
_this2.failure = null;
|
|
789
|
+
_this2.surface.clear();
|
|
790
|
+
_this2.reflect();
|
|
487
791
|
try {
|
|
488
792
|
yield core.load(sources);
|
|
489
|
-
} catch (
|
|
793
|
+
} catch (_unused2) {
|
|
490
794
|
return;
|
|
491
795
|
}
|
|
492
|
-
if (!
|
|
796
|
+
if (!_this2.isConnected) yield core.unload();
|
|
493
797
|
})();
|
|
494
798
|
}
|
|
495
799
|
/**
|
|
@@ -498,19 +802,15 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
|
|
|
498
802
|
* A child carries its own `license-url` and `certificate-url`.
|
|
499
803
|
*/
|
|
500
804
|
wanted() {
|
|
805
|
+
const versions = markupVideoTracks(this);
|
|
806
|
+
const withVersions = versions.length === 0 ? {} : { videoTracks: versions };
|
|
501
807
|
const url = this.getAttribute("src");
|
|
502
808
|
if (url !== null) {
|
|
503
809
|
const type = this.getAttribute("type");
|
|
504
|
-
return [type === null ? {
|
|
505
|
-
url,
|
|
506
|
-
type
|
|
507
|
-
}];
|
|
810
|
+
return [_objectSpread2(_objectSpread2({ url }, type === null ? {} : { type }), withVersions)];
|
|
508
811
|
}
|
|
509
|
-
const eme =
|
|
510
|
-
if (this.list !== null) return eme ? this.list : this.list.map((
|
|
511
|
-
url,
|
|
512
|
-
type
|
|
513
|
-
});
|
|
812
|
+
const eme = emeAvailable();
|
|
813
|
+
if (this.list !== null) return eme ? this.list : this.list.map((source) => "url" in source ? withoutDrm(source) : source);
|
|
514
814
|
const found = [];
|
|
515
815
|
for (const child of Array.from(this.children)) {
|
|
516
816
|
const src = child.localName === "source" ? child.getAttribute("src") : null;
|
|
@@ -518,32 +818,50 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
|
|
|
518
818
|
const type = child.getAttribute("type");
|
|
519
819
|
const license = child.getAttribute(LICENSE_URL);
|
|
520
820
|
const certificate = child.getAttribute(CERTIFICATE_URL);
|
|
521
|
-
found.push(_objectSpread2(_objectSpread2({ url: src }, type === null ? {} : { type }), !eme || license === null && certificate === null ? {} : { drm: _objectSpread2(_objectSpread2({}, license === null ? {} : { licenseUrl: license }), certificate === null ? {} : { certificateUrl: certificate }) }));
|
|
821
|
+
found.push(_objectSpread2(_objectSpread2(_objectSpread2({ url: src }, type === null ? {} : { type }), withVersions), !eme || license === null && certificate === null ? {} : { drm: _objectSpread2(_objectSpread2({}, license === null ? {} : { licenseUrl: license }), certificate === null ? {} : { certificateUrl: certificate }) }));
|
|
522
822
|
}
|
|
523
823
|
return found;
|
|
524
824
|
}
|
|
525
825
|
/** Sets a session up. It runs for every session, the one that replaces a failed source included. */
|
|
526
826
|
adopt(session) {
|
|
827
|
+
var _this$core2;
|
|
527
828
|
this.given = null;
|
|
528
829
|
this.configure(session);
|
|
830
|
+
const chapters = (_this$core2 = this.core) === null || _this$core2 === void 0 || (_this$core2 = _this$core2.programme) === null || _this$core2 === void 0 || (_this$core2 = _this$core2.metadata) === null || _this$core2 === void 0 ? void 0 : _this$core2.chapters;
|
|
831
|
+
if (chapters !== void 0 && session.engine !== null && this.getAttribute(CHAPTERS) === null) {
|
|
832
|
+
var _namespaces$chapters;
|
|
833
|
+
(_namespaces$chapters = namespaces(session.engine).chapters) === null || _namespaces$chapters === void 0 || _namespaces$chapters.set(chapters);
|
|
834
|
+
}
|
|
529
835
|
this.chapters();
|
|
530
836
|
}
|
|
531
837
|
ensure() {
|
|
532
|
-
var
|
|
838
|
+
var _this3 = this;
|
|
533
839
|
return _asyncToGenerator(function* () {
|
|
534
|
-
if (
|
|
535
|
-
const
|
|
536
|
-
|
|
840
|
+
if (_this3.core !== null) return _this3.core;
|
|
841
|
+
const connectors = _this3.options.connectors;
|
|
842
|
+
const core = createPlayer(_this3.media, _objectSpread2({ handlers: yield _this3.chain() }, connectors === void 0 ? {} : { connectors }));
|
|
843
|
+
_this3.offs.push(core.on("programme", (programme) => {
|
|
844
|
+
_this3.programmed(programme);
|
|
845
|
+
}), core.on("sourcechange", (session) => {
|
|
537
846
|
var _this$offTracks, _session$engine$on, _session$engine;
|
|
538
|
-
|
|
539
|
-
(
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
847
|
+
_this3.current = session;
|
|
848
|
+
if (!_this3.switching) {
|
|
849
|
+
var _session$source, _this$held2;
|
|
850
|
+
const was = _this3.version;
|
|
851
|
+
_this3.original = (_session$source = session === null || session === void 0 ? void 0 : session.source) !== null && _session$source !== void 0 ? _session$source : null;
|
|
852
|
+
_this3.switched = null;
|
|
853
|
+
_this3.version = null;
|
|
854
|
+
(_this$held2 = _this3.held) === null || _this$held2 === void 0 || _this$held2.call(_this3);
|
|
855
|
+
if (was !== null) _this3.emit("videosourcechange", null);
|
|
856
|
+
}
|
|
857
|
+
(_this$offTracks = _this3.offTracks) === null || _this$offTracks === void 0 || _this$offTracks.call(_this3);
|
|
858
|
+
_this3.offTracks = (_session$engine$on = session === null || session === void 0 || (_session$engine = session.engine) === null || _session$engine === void 0 ? void 0 : _session$engine.on("tracks:selected", () => _this3.tracks())) !== null && _session$engine$on !== void 0 ? _session$engine$on : null;
|
|
859
|
+
if (session !== null && _this3.isConnected) _this3.adopt(session);
|
|
860
|
+
_this3.emit("sourcechange", session);
|
|
543
861
|
}), core.on("error", (error) => {
|
|
544
|
-
|
|
862
|
+
_this3.report(error);
|
|
545
863
|
}));
|
|
546
|
-
|
|
864
|
+
_this3.core = core;
|
|
547
865
|
return core;
|
|
548
866
|
})();
|
|
549
867
|
}
|
|
@@ -557,23 +875,23 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
|
|
|
557
875
|
return (_this$own = this.own) !== null && _this$own !== void 0 ? _this$own : defaults;
|
|
558
876
|
}
|
|
559
877
|
chain() {
|
|
560
|
-
var
|
|
878
|
+
var _this4 = this;
|
|
561
879
|
return _asyncToGenerator(function* () {
|
|
562
|
-
var _this$
|
|
563
|
-
if (
|
|
564
|
-
const config =
|
|
880
|
+
var _this$getAttribute4;
|
|
881
|
+
if (_this4.options.handlers !== void 0) return _this4.options.handlers;
|
|
882
|
+
const config = _this4.options.config === void 0 ? {} : { config: _this4.options.config };
|
|
565
883
|
const native = (stages) => nativeHandler({
|
|
566
|
-
prefer: (source, env) =>
|
|
567
|
-
drm: () =>
|
|
884
|
+
prefer: (source, env) => _this4.getAttribute(NATIVE_HLS) !== "off" && preferNativeHls(source, env),
|
|
885
|
+
drm: () => _this4.drm(stages)
|
|
568
886
|
});
|
|
569
|
-
if (
|
|
887
|
+
if (_this4.options.stages !== void 0) return [matteboxHandler(_objectSpread2({ stages: _this4.options.stages }, config)), native(() => {
|
|
570
888
|
var _this$options$stages;
|
|
571
|
-
return (_this$options$stages =
|
|
889
|
+
return (_this$options$stages = _this4.options.stages) !== null && _this$options$stages !== void 0 ? _this$options$stages : [];
|
|
572
890
|
})];
|
|
573
|
-
const name = (_this$
|
|
891
|
+
const name = (_this$getAttribute4 = _this4.getAttribute("preset")) !== null && _this$getAttribute4 !== void 0 ? _this$getAttribute4 : DEFAULT_PRESET;
|
|
574
892
|
const preset = yield resolvePreset(name);
|
|
575
893
|
if (preset === null) {
|
|
576
|
-
|
|
894
|
+
_this4.report({
|
|
577
895
|
category: "config",
|
|
578
896
|
code: "CONFIG_INVALID",
|
|
579
897
|
fatal: true,
|
|
@@ -621,22 +939,21 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
|
|
|
621
939
|
this.current = null;
|
|
622
940
|
}
|
|
623
941
|
teardown() {
|
|
624
|
-
var
|
|
942
|
+
var _this5 = this;
|
|
625
943
|
return _asyncToGenerator(function* () {
|
|
626
|
-
|
|
627
|
-
if (
|
|
944
|
+
_this5.unmount();
|
|
945
|
+
if (_this5.core !== null) yield _this5.core.unload();
|
|
628
946
|
})();
|
|
629
947
|
}
|
|
630
948
|
/** Drops the player itself, so the next run builds a chain from the new preset. */
|
|
631
949
|
discard() {
|
|
632
|
-
var
|
|
950
|
+
var _this6 = this;
|
|
633
951
|
return _asyncToGenerator(function* () {
|
|
634
|
-
yield
|
|
635
|
-
for (const off of
|
|
636
|
-
|
|
637
|
-
|
|
952
|
+
yield _this6.teardown();
|
|
953
|
+
for (const off of _this6.offs) off();
|
|
954
|
+
_this6.offs = [];
|
|
955
|
+
_this6.core = null;
|
|
638
956
|
})();
|
|
639
957
|
}
|
|
640
958
|
};
|
|
641
|
-
//#endregion
|
|
642
959
|
export { MatteboxPlayerElement };
|