@mattebox/player 0.11.0 → 0.13.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/breaks.d.ts +24 -0
- package/dist/controls/breaks.d.ts.map +1 -0
- package/dist/controls/breaks.js +20 -0
- package/dist/controls/breaks.js.map +1 -0
- 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.js +1 -2
- 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.js +1 -2
- 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 +135 -6
- package/dist/element.d.ts.map +1 -1
- package/dist/element.js +300 -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.js +1 -2
- 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 +54 -12
- 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 +1 -0
- package/dist/elements/marker-button.d.ts.map +1 -1
- package/dist/elements/marker-button.js +18 -13
- 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.js +2 -3
- 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 +6 -0
- package/dist/elements/seek-bar.d.ts.map +1 -1
- package/dist/elements/seek-bar.js +29 -10
- package/dist/elements/seek-bar.js.map +1 -1
- package/dist/elements/shared.js +1 -2
- 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 +2 -4
- 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 +11 -5
- package/dist/elements/title.js.map +1 -1
- package/dist/elements/video-menu.d.ts +2 -1
- package/dist/elements/video-menu.d.ts.map +1 -1
- package/dist/elements/video-menu.js +12 -12
- package/dist/elements/video-menu.js.map +1 -1
- 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.js +1 -2
- 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/breaks.js +18 -0
- 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 +1 -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 +378 -94
- 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 +1 -2
- 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 +56 -13
- 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 +19 -14
- 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 +2 -4
- 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 +36 -17
- package/dist/es2015/elements/shared.js +1 -2
- 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 +3 -5
- package/dist/es2015/elements/subtitles-menu.js +53 -31
- package/dist/es2015/elements/time-element.js +1 -2
- package/dist/es2015/elements/title.js +12 -6
- package/dist/es2015/elements/video-menu.js +12 -12
- 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 +1 -2
- 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 +2 -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 +1 -2
- package/dist/es2015/text.js +15 -0
- package/dist/es2015/trackers.js +43 -0
- package/dist/es2015/video-sources.js +2 -3
- package/dist/host.d.ts +71 -2
- 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 +9 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -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.js +1 -2
- 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.js +1 -2
- package/package.json +11 -3
package/dist/es2015/element.js
CHANGED
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
import { announcer } from "./announcer.js";
|
|
2
|
+
import { createBreakMarks } from "./controls/breaks.js";
|
|
2
3
|
import { createMarkers } from "./controls/markers.js";
|
|
3
4
|
import { languageName } from "./controls/track-names.js";
|
|
5
|
+
import _asyncToGenerator from "./_virtual/_@oxc-project_runtime@0.155.0/helpers/esm/asyncToGenerator.js";
|
|
6
|
+
import { addLocale, load, onLocales, registered, wordsNow } from "./locales.js";
|
|
4
7
|
import { namespaces } from "./namespaces.js";
|
|
5
|
-
import _asyncToGenerator from "./_virtual/_@oxc-project_runtime@0.154.0/helpers/esm/asyncToGenerator.js";
|
|
6
8
|
import { drmGuard, resolvePreset } from "./presets.js";
|
|
7
9
|
import { STYLE } from "./style.js";
|
|
8
10
|
import { errorSurface } from "./surface.js";
|
|
9
11
|
import { PLAYER } from "./tags.js";
|
|
10
|
-
import
|
|
12
|
+
import { textIn } from "./text.js";
|
|
13
|
+
import { createTrackers } from "./trackers.js";
|
|
14
|
+
import _objectSpread2 from "./_virtual/_@oxc-project_runtime@0.155.0/helpers/esm/objectSpread2.js";
|
|
11
15
|
import { chosen, holdFrame, markupVideoTracks, onNextFrame, restore, resume, versionSource } from "./video-sources.js";
|
|
12
16
|
import { createPlayer, inferType, matteboxHandler, nativeHandler, preferNativeHls } from "@mattebox/player-core";
|
|
13
|
-
|
|
17
|
+
// src/element.ts
|
|
14
18
|
/**
|
|
15
19
|
* `off` keeps HLS on the engine in Safari. Anything else lets Safari play
|
|
16
20
|
* HLS itself: FairPlay, AirPlay, Low-Latency HLS and the platform's
|
|
@@ -25,6 +29,8 @@ const FORWARDED = [
|
|
|
25
29
|
"crossorigin"
|
|
26
30
|
];
|
|
27
31
|
const LICENSE_URL = "license-url";
|
|
32
|
+
/** The language the page chose, over the nearest `lang`. */
|
|
33
|
+
const LANGUAGE = "language";
|
|
28
34
|
/** Carried through a switch: the play state from before it, `playing` or `paused`. */
|
|
29
35
|
const SWITCHING = "switching";
|
|
30
36
|
/** Whether the browser has EME, so a source may bring DRM. */
|
|
@@ -103,7 +109,6 @@ const STATE_EVENTS = [
|
|
|
103
109
|
"resize",
|
|
104
110
|
"playing",
|
|
105
111
|
"waiting",
|
|
106
|
-
"stalled",
|
|
107
112
|
"canplay"
|
|
108
113
|
];
|
|
109
114
|
/**
|
|
@@ -111,10 +116,10 @@ const STATE_EVENTS = [
|
|
|
111
116
|
* seek within the buffer waits for less, and saying it would only be noise.
|
|
112
117
|
*/
|
|
113
118
|
const LOADING_MS = 1e3;
|
|
114
|
-
/** A track's name for the live region: its name in the stream, else its language's
|
|
115
|
-
function trackName(name, lang) {
|
|
119
|
+
/** A track's name for the live region: its name in the stream, else its language's in `locale`. */
|
|
120
|
+
function trackName(name, lang, locale) {
|
|
116
121
|
var _languageName;
|
|
117
|
-
return name || lang && ((_languageName = languageName(lang)) !== null && _languageName !== void 0 ? _languageName : lang) || "";
|
|
122
|
+
return name || lang && ((_languageName = languageName(lang, locale || void 0)) !== null && _languageName !== void 0 ? _languageName : lang) || "";
|
|
118
123
|
}
|
|
119
124
|
/** The stages that register a key system, which a native session's DRM offers. */
|
|
120
125
|
const KEY_SYSTEMS = ["eme-fairplay", "eme-cenc"];
|
|
@@ -140,10 +145,22 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
|
|
|
140
145
|
CONTROLS,
|
|
141
146
|
CHAPTERS,
|
|
142
147
|
PLAYSINLINE,
|
|
143
|
-
LAYOUT
|
|
148
|
+
LAYOUT,
|
|
149
|
+
LANGUAGE,
|
|
150
|
+
"lang"
|
|
144
151
|
];
|
|
145
152
|
}
|
|
146
153
|
/**
|
|
154
|
+
* Registers the words of a language for every player on the page. Each
|
|
155
|
+
* source is a set of words or a function that loads one, which runs only
|
|
156
|
+
* when a player shows that language. Later sources go over earlier ones,
|
|
157
|
+
* so a page changes a shipped word by registering its own after it.
|
|
158
|
+
* Players that show the language take the new words at once.
|
|
159
|
+
*/
|
|
160
|
+
static addLocale(language, ...sources) {
|
|
161
|
+
addLocale(language, sources);
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
147
164
|
* Registers the element once, and records the stages markup-only pages
|
|
148
165
|
* get. The controls register through their own entries, the package's
|
|
149
166
|
* root entry importing every one; a control connected before its player
|
|
@@ -164,19 +181,26 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
|
|
|
164
181
|
this.core = null;
|
|
165
182
|
this.current = null;
|
|
166
183
|
this.failure = null;
|
|
184
|
+
this.stop = null;
|
|
167
185
|
this.reflecting = false;
|
|
168
186
|
this.sizes = null;
|
|
169
187
|
this.fixed = false;
|
|
170
188
|
this.started = false;
|
|
171
189
|
this.waiting = false;
|
|
172
190
|
this.offs = [];
|
|
191
|
+
this.attached = /* @__PURE__ */ new Map();
|
|
192
|
+
this.interruption = null;
|
|
173
193
|
this.queue = Promise.resolve();
|
|
174
194
|
this.pending = false;
|
|
175
|
-
this.
|
|
195
|
+
this.original = null;
|
|
176
196
|
this.version = null;
|
|
177
197
|
this.switching = false;
|
|
178
198
|
this.switched = null;
|
|
179
199
|
this.held = null;
|
|
200
|
+
this.words = {};
|
|
201
|
+
this.shown = "";
|
|
202
|
+
this.wordsEpoch = 0;
|
|
203
|
+
this.unwatch = null;
|
|
180
204
|
this.slow = void 0;
|
|
181
205
|
this.heardAudio = void 0;
|
|
182
206
|
this.heardText = void 0;
|
|
@@ -196,8 +220,11 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
|
|
|
196
220
|
});
|
|
197
221
|
this.media.addEventListener("playing", () => {
|
|
198
222
|
this.failure = null;
|
|
223
|
+
this.reflect();
|
|
199
224
|
});
|
|
200
225
|
this.marks = createMarkers(this.media, (name, detail) => this.emit(name, detail));
|
|
226
|
+
this.breakMarks = createBreakMarks((list) => this.emit("breakschange", list));
|
|
227
|
+
this.tracking = createTrackers(this, () => this.emit("trackerschange", this.tracking.list));
|
|
201
228
|
this.stage = document.createElement("div");
|
|
202
229
|
this.stage.setAttribute("part", "stage");
|
|
203
230
|
const slot = document.createElement("slot");
|
|
@@ -207,8 +234,11 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
|
|
|
207
234
|
this.stage.append(slot);
|
|
208
235
|
this.surface = errorSurface(() => {
|
|
209
236
|
this.retry();
|
|
237
|
+
}, () => {
|
|
238
|
+
var _this$words$retry;
|
|
239
|
+
return (_this$words$retry = this.words.retry) !== null && _this$words$retry !== void 0 ? _this$words$retry : "Retry";
|
|
210
240
|
});
|
|
211
|
-
this.voice = announcer(this);
|
|
241
|
+
this.voice = announcer(this, (id) => this.words[id]);
|
|
212
242
|
const root = this.attachShadow({ mode: "open" });
|
|
213
243
|
const style = document.createElement("style");
|
|
214
244
|
style.textContent = STYLE;
|
|
@@ -222,6 +252,10 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
|
|
|
222
252
|
get markers() {
|
|
223
253
|
return this.marks;
|
|
224
254
|
}
|
|
255
|
+
/** Where the programme's ad breaks are, which the seek bar draws: each add-on gives its own. */
|
|
256
|
+
get breaks() {
|
|
257
|
+
return this.breakMarks;
|
|
258
|
+
}
|
|
225
259
|
/**
|
|
226
260
|
* The sources to try in order, set from script. The `src` attribute wins
|
|
227
261
|
* over them, and they win over the `<source>` children. Setting them
|
|
@@ -233,9 +267,74 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
|
|
|
233
267
|
set sources(value) {
|
|
234
268
|
this.list = value;
|
|
235
269
|
if (this.marks.list.length > 0) this.marks.set([]);
|
|
270
|
+
this.interruption = null;
|
|
271
|
+
this.unblock();
|
|
236
272
|
this.reload();
|
|
237
273
|
}
|
|
238
274
|
/**
|
|
275
|
+
* The language the page chose for this player, which wins over the
|
|
276
|
+
* nearest `lang` attribute. Empty follows `lang`. Setting it changes the
|
|
277
|
+
* words of every control at once.
|
|
278
|
+
*/
|
|
279
|
+
get language() {
|
|
280
|
+
var _this$getAttribute;
|
|
281
|
+
return (_this$getAttribute = this.getAttribute(LANGUAGE)) !== null && _this$getAttribute !== void 0 ? _this$getAttribute : "";
|
|
282
|
+
}
|
|
283
|
+
set language(value) {
|
|
284
|
+
if (value === "") this.removeAttribute(LANGUAGE);
|
|
285
|
+
else this.setAttribute(LANGUAGE, value);
|
|
286
|
+
}
|
|
287
|
+
/** The language tag the words come from: `language`, else the nearest `lang`. Empty without either. */
|
|
288
|
+
get locale() {
|
|
289
|
+
return this.shown;
|
|
290
|
+
}
|
|
291
|
+
/** The word of `id` in the player's language, or undefined, where the control's English applies. */
|
|
292
|
+
message(id) {
|
|
293
|
+
return this.words[id];
|
|
294
|
+
}
|
|
295
|
+
/** Follows registrations and the document's `lang` until disconnect. */
|
|
296
|
+
watchLanguage() {
|
|
297
|
+
const off = onLocales(() => {
|
|
298
|
+
this.relocale();
|
|
299
|
+
});
|
|
300
|
+
const watch = new MutationObserver(() => {
|
|
301
|
+
this.relocale();
|
|
302
|
+
});
|
|
303
|
+
watch.observe(document.documentElement, {
|
|
304
|
+
attributes: true,
|
|
305
|
+
attributeFilter: ["lang"]
|
|
306
|
+
});
|
|
307
|
+
this.unwatch = () => {
|
|
308
|
+
off();
|
|
309
|
+
watch.disconnect();
|
|
310
|
+
};
|
|
311
|
+
this.relocale();
|
|
312
|
+
}
|
|
313
|
+
/** Resolves the language, takes its words, and tells the controls with `localechange`. */
|
|
314
|
+
relocale() {
|
|
315
|
+
var _ref, _this$getAttribute2, _this$closest;
|
|
316
|
+
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 : "";
|
|
317
|
+
const epoch = ++this.wordsEpoch;
|
|
318
|
+
const take = (words) => {
|
|
319
|
+
if (epoch !== this.wordsEpoch) return;
|
|
320
|
+
this.shown = tag;
|
|
321
|
+
this.words = words;
|
|
322
|
+
this.showBlock();
|
|
323
|
+
this.emit("localechange", tag);
|
|
324
|
+
};
|
|
325
|
+
const key = registered(tag);
|
|
326
|
+
if (key === null) {
|
|
327
|
+
take({});
|
|
328
|
+
return;
|
|
329
|
+
}
|
|
330
|
+
const now = wordsNow(key);
|
|
331
|
+
if (now !== null) {
|
|
332
|
+
take(now);
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
335
|
+
load(key).then(take, () => void 0);
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
239
338
|
* Loads the sources again, in the order a load reads them: the `src`
|
|
240
339
|
* attribute, the `sources` property, then the `<source>` children. The
|
|
241
340
|
* error screens' Retry calls it. On a version of `videoSources`, it
|
|
@@ -263,16 +362,73 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
|
|
|
263
362
|
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);
|
|
264
363
|
const clean = emeAvailable() ? source : withoutDrm(source);
|
|
265
364
|
const was = this.version;
|
|
266
|
-
this.
|
|
365
|
+
this.original = clean;
|
|
267
366
|
this.switched = clean;
|
|
268
367
|
this.version = null;
|
|
269
368
|
if (was !== null) this.emit("videosourcechange", null);
|
|
270
369
|
this.swap(clean, at, playing, had, true);
|
|
271
370
|
}
|
|
371
|
+
/**
|
|
372
|
+
* Plays `source` on the video in the programme's place, such as an ad of
|
|
373
|
+
* `@mattebox/player-ads`. The programme, its markers and its trackers
|
|
374
|
+
* stay, no `sourcechange` fires, and the controls drive the source as
|
|
375
|
+
* they drive the programme. An error of the source is not the
|
|
376
|
+
* programme's: listen to the video. `resume()` plays the programme again
|
|
377
|
+
* where it stopped. Resolves once the source is loaded; rejects when no
|
|
378
|
+
* handler plays it.
|
|
379
|
+
*/
|
|
380
|
+
interrupt(source) {
|
|
381
|
+
var _this = this;
|
|
382
|
+
var _this$interruption, _this$current$engine2, _this$current2;
|
|
383
|
+
const media = this.media;
|
|
384
|
+
(_this$interruption = this.interruption) !== null && _this$interruption !== void 0 || (this.interruption = {
|
|
385
|
+
at: Number.isFinite(media.duration) ? media.currentTime : null,
|
|
386
|
+
playing: !media.paused,
|
|
387
|
+
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)
|
|
388
|
+
});
|
|
389
|
+
return this.queued(_asyncToGenerator(function* () {
|
|
390
|
+
const core = yield _this.ensure();
|
|
391
|
+
yield core.interrupt(source);
|
|
392
|
+
_this.current = core.session;
|
|
393
|
+
media.play().catch(() => void 0);
|
|
394
|
+
}));
|
|
395
|
+
}
|
|
396
|
+
/**
|
|
397
|
+
* Plays the programme again where `interrupt` left it, in the play state
|
|
398
|
+
* it had, or as `options` says: `at` another position, such as its end
|
|
399
|
+
* after a post-roll, and `playing`.
|
|
400
|
+
*/
|
|
401
|
+
resume(options = {}) {
|
|
402
|
+
var _this2 = this;
|
|
403
|
+
var _options$playing;
|
|
404
|
+
const left = this.interruption;
|
|
405
|
+
if (left === null) return Promise.resolve();
|
|
406
|
+
this.interruption = null;
|
|
407
|
+
const at = options.at === void 0 ? left.at : options.at;
|
|
408
|
+
const playing = (_options$playing = options.playing) !== null && _options$playing !== void 0 ? _options$playing : left.playing;
|
|
409
|
+
return this.queued(_asyncToGenerator(function* () {
|
|
410
|
+
var _this$current$engine3, _this$current3;
|
|
411
|
+
const core = yield _this2.ensure();
|
|
412
|
+
yield core.resume(at !== null && at !== void 0 ? at : void 0);
|
|
413
|
+
_this2.current = core.session;
|
|
414
|
+
restore((_this$current$engine3 = (_this$current3 = _this2.current) === null || _this$current3 === void 0 ? void 0 : _this$current3.engine) !== null && _this$current$engine3 !== void 0 ? _this$current$engine3 : null, left.had);
|
|
415
|
+
if (playing) _this2.media.play().catch(() => void 0);
|
|
416
|
+
}));
|
|
417
|
+
}
|
|
418
|
+
/** `interrupt` plays in the programme's place. */
|
|
419
|
+
get interrupted() {
|
|
420
|
+
return this.interruption !== null;
|
|
421
|
+
}
|
|
422
|
+
/** Runs `task` in the element's queue, and says how it went. */
|
|
423
|
+
queued(task) {
|
|
424
|
+
return new Promise((resolve, reject) => {
|
|
425
|
+
this.enqueue(() => task().then(resolve, reject));
|
|
426
|
+
});
|
|
427
|
+
}
|
|
272
428
|
/** The other versions of the picture the source names at their own URLs, for the video menu. */
|
|
273
429
|
get videoSources() {
|
|
274
|
-
var _this$
|
|
275
|
-
return (_this$
|
|
430
|
+
var _this$original$videoT, _this$original;
|
|
431
|
+
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 : [];
|
|
276
432
|
}
|
|
277
433
|
/** The version of `videoSources` that plays, or null for the source itself. */
|
|
278
434
|
get videoSource() {
|
|
@@ -285,14 +441,14 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
|
|
|
285
441
|
* Fires `videosourcechange`.
|
|
286
442
|
*/
|
|
287
443
|
selectVideoSource(track) {
|
|
288
|
-
var _programme$videoTrack, _this$current$
|
|
289
|
-
const programme = this.
|
|
444
|
+
var _programme$videoTrack, _this$current$engine4, _this$current4;
|
|
445
|
+
const programme = this.original;
|
|
290
446
|
if (programme === null || track === this.version) return;
|
|
291
447
|
if (track !== null && ((_programme$videoTrack = programme.videoTracks) === null || _programme$videoTrack === void 0 ? void 0 : _programme$videoTrack.includes(track)) !== true) return;
|
|
292
448
|
const media = this.media;
|
|
293
449
|
const at = Number.isFinite(media.duration) ? media.currentTime : null;
|
|
294
450
|
const playing = !media.paused;
|
|
295
|
-
const had = chosen((_this$current$
|
|
451
|
+
const had = chosen((_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);
|
|
296
452
|
this.version = track;
|
|
297
453
|
this.emit("videosourcechange", track);
|
|
298
454
|
this.swap(track === null ? programme : versionSource(track, emeAvailable()), at, playing, had, true);
|
|
@@ -304,7 +460,7 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
|
|
|
304
460
|
* before, so the controls show that state through the load.
|
|
305
461
|
*/
|
|
306
462
|
swap(source, at, playing, had, hold) {
|
|
307
|
-
var
|
|
463
|
+
var _this3 = this;
|
|
308
464
|
var _this$held;
|
|
309
465
|
const media = this.media;
|
|
310
466
|
(_this$held = this.held) === null || _this$held === void 0 || _this$held.call(this);
|
|
@@ -323,20 +479,20 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
|
|
|
323
479
|
release = done;
|
|
324
480
|
}
|
|
325
481
|
this.enqueue(_asyncToGenerator(function* () {
|
|
326
|
-
var _this$current$
|
|
327
|
-
const core = yield
|
|
328
|
-
|
|
482
|
+
var _this$current$engine5, _this$current5;
|
|
483
|
+
const core = yield _this3.ensure();
|
|
484
|
+
_this3.switching = true;
|
|
329
485
|
try {
|
|
330
486
|
yield core.load([source]);
|
|
331
487
|
} catch (_unused) {
|
|
332
488
|
release === null || release === void 0 || release();
|
|
333
489
|
return;
|
|
334
490
|
} finally {
|
|
335
|
-
|
|
491
|
+
_this3.switching = false;
|
|
336
492
|
}
|
|
337
493
|
resume(media, at, playing);
|
|
338
494
|
if (release !== null) onNextFrame(media, at, release);
|
|
339
|
-
restore((_this$current$
|
|
495
|
+
restore((_this$current$engine5 = (_this$current5 = _this3.current) === null || _this$current5 === void 0 ? void 0 : _this$current5.engine) !== null && _this$current$engine5 !== void 0 ? _this$current$engine5 : null, had);
|
|
340
496
|
}));
|
|
341
497
|
}
|
|
342
498
|
/** The core, or null until the first source has been set up: resolving a preset is asynchronous. */
|
|
@@ -345,8 +501,8 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
|
|
|
345
501
|
}
|
|
346
502
|
/** The engine feeding the video, or null for a native session and before the first load. */
|
|
347
503
|
get engine() {
|
|
348
|
-
var _this$current$
|
|
349
|
-
return (_this$current$
|
|
504
|
+
var _this$current$engine6, _this$current6;
|
|
505
|
+
return (_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;
|
|
350
506
|
}
|
|
351
507
|
/**
|
|
352
508
|
* The fatal error of the current load, or null once a load starts or
|
|
@@ -357,6 +513,83 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
|
|
|
357
513
|
get error() {
|
|
358
514
|
return this.failure;
|
|
359
515
|
}
|
|
516
|
+
/**
|
|
517
|
+
* Shows why the programme does not play, in place of the video, and
|
|
518
|
+
* stops the load: the reason the page's content API gave, such as a
|
|
519
|
+
* geographic or an age restriction. The error screen shows the title,
|
|
520
|
+
* else "Not available", and the message, with no retry. Each text can
|
|
521
|
+
* be given by language tag, and follows the player's language. A new
|
|
522
|
+
* `src` or `sources` clears it. Fires `blockchange`.
|
|
523
|
+
*/
|
|
524
|
+
block(block) {
|
|
525
|
+
this.refuse(block);
|
|
526
|
+
this.enqueue(() => this.teardown());
|
|
527
|
+
}
|
|
528
|
+
/** Shows the block, for `block()` and for a programme a connector blocked, which loaded nothing. */
|
|
529
|
+
refuse(block) {
|
|
530
|
+
this.stop = block;
|
|
531
|
+
this.media.pause();
|
|
532
|
+
clearTimeout(this.slow);
|
|
533
|
+
const [title, message] = this.blockWords(block);
|
|
534
|
+
if (this.querySelector("mbx-error-screen") === null) this.voice.tell(message === "" ? title : `${title}. ${message}`);
|
|
535
|
+
this.showBlock();
|
|
536
|
+
this.reflect();
|
|
537
|
+
this.emit("blockchange", block);
|
|
538
|
+
}
|
|
539
|
+
/** Removes the block. Nothing plays until a source loads: set one, or call `retry()`. */
|
|
540
|
+
unblock() {
|
|
541
|
+
if (this.stop === null) return;
|
|
542
|
+
this.stop = null;
|
|
543
|
+
this.surface.clear();
|
|
544
|
+
this.reflect();
|
|
545
|
+
this.emit("blockchange", null);
|
|
546
|
+
}
|
|
547
|
+
/** What `block()` set, or null. */
|
|
548
|
+
get blocked() {
|
|
549
|
+
return this.stop;
|
|
550
|
+
}
|
|
551
|
+
/**
|
|
552
|
+
* What the current load resolved to: the sources, and what a connector
|
|
553
|
+
* said of the programme. Null before a load and after an unload.
|
|
554
|
+
*/
|
|
555
|
+
get programme() {
|
|
556
|
+
var _this$core$programme, _this$core;
|
|
557
|
+
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;
|
|
558
|
+
}
|
|
559
|
+
/**
|
|
560
|
+
* The page's trackers. Each starts at every programme and stops at its
|
|
561
|
+
* end; one added or removed during a programme starts or stops at once.
|
|
562
|
+
*/
|
|
563
|
+
get trackers() {
|
|
564
|
+
return this.tracking;
|
|
565
|
+
}
|
|
566
|
+
/**
|
|
567
|
+
* Applies what the load resolved, before any session: the markers, the
|
|
568
|
+
* poster, the block. The page's own `poster` and markers set after the
|
|
569
|
+
* source win. Then the trackers start on the programme.
|
|
570
|
+
*/
|
|
571
|
+
programmed(programme) {
|
|
572
|
+
const metadata = programme === null || programme === void 0 ? void 0 : programme.metadata;
|
|
573
|
+
if ((metadata === null || metadata === void 0 ? void 0 : metadata.markers) !== void 0) this.marks.set(metadata.markers);
|
|
574
|
+
if (!this.hasAttribute("poster")) {
|
|
575
|
+
if ((metadata === null || metadata === void 0 ? void 0 : metadata.poster) === void 0) this.media.removeAttribute("poster");
|
|
576
|
+
else this.media.poster = metadata.poster;
|
|
577
|
+
}
|
|
578
|
+
if ((programme === null || programme === void 0 ? void 0 : programme.block) !== void 0) this.refuse(programme.block);
|
|
579
|
+
this.emit("programmechange", programme);
|
|
580
|
+
this.tracking.begin(programme);
|
|
581
|
+
}
|
|
582
|
+
/** A block's title and message in the player's language: the title defaults to the `blocked` word. */
|
|
583
|
+
blockWords(block) {
|
|
584
|
+
var _this$words$blocked;
|
|
585
|
+
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)];
|
|
586
|
+
}
|
|
587
|
+
/** Puts the block on the row under the video, under native controls. */
|
|
588
|
+
showBlock() {
|
|
589
|
+
if (this.stop === null || this.getAttribute(CONTROLS) === "custom") return;
|
|
590
|
+
const [title, message] = this.blockWords(this.stop);
|
|
591
|
+
this.surface.inform(title, message);
|
|
592
|
+
}
|
|
360
593
|
connectedCallback() {
|
|
361
594
|
if (this.media.parentNode !== this) this.append(this.media);
|
|
362
595
|
for (const name of FORWARDED) this.forward(name);
|
|
@@ -368,8 +601,23 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
|
|
|
368
601
|
this.sizes.observe(this);
|
|
369
602
|
}
|
|
370
603
|
this.measure();
|
|
604
|
+
this.watchLanguage();
|
|
605
|
+
this.attachAddons();
|
|
371
606
|
this.reload();
|
|
372
607
|
}
|
|
608
|
+
/**
|
|
609
|
+
* Attaches each add-on of the options once. At connect, and again at each
|
|
610
|
+
* load: a page that imports the player registers it before its own
|
|
611
|
+
* `define()` gives the add-ons, and the players already on the page
|
|
612
|
+
* connected then.
|
|
613
|
+
*/
|
|
614
|
+
attachAddons() {
|
|
615
|
+
var _this$options$addons;
|
|
616
|
+
for (const addon of (_this$options$addons = this.options.addons) !== null && _this$options$addons !== void 0 ? _this$options$addons : []) {
|
|
617
|
+
var _addon$attach;
|
|
618
|
+
if (!this.attached.has(addon)) this.attached.set(addon, (_addon$attach = addon.attach) === null || _addon$attach === void 0 ? void 0 : _addon$attach.call(addon, this));
|
|
619
|
+
}
|
|
620
|
+
}
|
|
373
621
|
/** Sets `layout` from the element's box, unless the page fixed it. */
|
|
374
622
|
measure() {
|
|
375
623
|
if (this.fixed) return;
|
|
@@ -389,7 +637,7 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
|
|
|
389
637
|
if (!this.started) this.tracks();
|
|
390
638
|
this.started = true;
|
|
391
639
|
this.waiting = false;
|
|
392
|
-
} else if (event === "waiting"
|
|
640
|
+
} else if (event === "waiting") this.waiting = true;
|
|
393
641
|
else if (event === "canplay") this.waiting = false;
|
|
394
642
|
else if (event === "emptied") {
|
|
395
643
|
if (this.held === null) this.started = false;
|
|
@@ -400,12 +648,12 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
|
|
|
400
648
|
}
|
|
401
649
|
/** Says a play or a pause, and a wait once it has lasted `LOADING_MS`. */
|
|
402
650
|
tell(event, was) {
|
|
403
|
-
if (event === "play" && this.held === null) this.voice.say("playing", "Playing");
|
|
404
|
-
if (event === "pause" && !this.media.ended && this.held === null) this.voice.say("paused", "Paused");
|
|
651
|
+
if (event === "play" && this.held === null) this.voice.say("playing", "saidPlaying", "Playing");
|
|
652
|
+
if (event === "pause" && !this.media.ended && this.held === null) this.voice.say("paused", "saidPaused", "Paused");
|
|
405
653
|
if (this.waiting === was) return;
|
|
406
654
|
clearTimeout(this.slow);
|
|
407
655
|
if (this.waiting) this.slow = setTimeout(() => {
|
|
408
|
-
this.voice.say("loading", "Loading");
|
|
656
|
+
this.voice.say("loading", "loading", "Loading");
|
|
409
657
|
}, LOADING_MS);
|
|
410
658
|
}
|
|
411
659
|
/**
|
|
@@ -414,31 +662,31 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
|
|
|
414
662
|
* reads as off, as in the subtitles menu.
|
|
415
663
|
*/
|
|
416
664
|
tracks() {
|
|
417
|
-
var _this$current$
|
|
418
|
-
const engine = (_this$current$
|
|
665
|
+
var _this$current$engine7, _this$current7;
|
|
666
|
+
const engine = (_this$current$engine7 = (_this$current7 = this.current) === null || _this$current7 === void 0 ? void 0 : _this$current7.engine) !== null && _this$current$engine7 !== void 0 ? _this$current$engine7 : null;
|
|
419
667
|
let audio;
|
|
420
668
|
let text;
|
|
421
669
|
if (engine !== null) {
|
|
422
670
|
const sound = engine.tracks.active("audio");
|
|
423
671
|
const words = engine.tracks.active("text");
|
|
424
|
-
audio = sound === null ? "" : trackName(sound.name, sound.lang);
|
|
425
|
-
text = words === null || words.forced === true ? null : trackName(words.name, words.lang);
|
|
672
|
+
audio = sound === null ? "" : trackName(sound.name, sound.lang, this.locale);
|
|
673
|
+
text = words === null || words.forced === true ? null : trackName(words.name, words.lang, this.locale);
|
|
426
674
|
} else {
|
|
427
675
|
var _video$audioTracks;
|
|
428
676
|
const video = this.media;
|
|
429
677
|
const sound = Array.from((_video$audioTracks = video.audioTracks) !== null && _video$audioTracks !== void 0 ? _video$audioTracks : []).find((track) => track.enabled);
|
|
430
678
|
const words = Array.from(this.media.textTracks).find((track) => (track.kind === "subtitles" || track.kind === "captions") && track.mode === "showing");
|
|
431
|
-
audio = sound === void 0 ? "" : trackName(sound.label, sound.language);
|
|
432
|
-
text = words === void 0 ? null : trackName(words.label, words.language);
|
|
679
|
+
audio = sound === void 0 ? "" : trackName(sound.label, sound.language, this.locale);
|
|
680
|
+
text = words === void 0 ? null : trackName(words.label, words.language, this.locale);
|
|
433
681
|
}
|
|
434
682
|
const { heardAudio, heardText } = this;
|
|
435
683
|
this.heardAudio = audio;
|
|
436
684
|
this.heardText = text;
|
|
437
685
|
if (!this.started) return;
|
|
438
|
-
if (heardAudio !== void 0 && audio !== heardAudio) this.voice.say("audio", "Audio: {track}", audio);
|
|
686
|
+
if (heardAudio !== void 0 && audio !== heardAudio) this.voice.say("audio", "saidAudio", "Audio: {track}", audio);
|
|
439
687
|
if (heardText !== void 0 && text !== heardText) {
|
|
440
|
-
if (text === null) this.voice.say("subtitles-off", "Subtitles off");
|
|
441
|
-
else this.voice.say("subtitles", "Subtitles: {track}", text);
|
|
688
|
+
if (text === null) this.voice.say("subtitles-off", "saidSubtitlesOff", "Subtitles off");
|
|
689
|
+
else this.voice.say("subtitles", "saidSubtitles", "Subtitles: {track}", text);
|
|
442
690
|
}
|
|
443
691
|
}
|
|
444
692
|
/** The video's state on the element, for `mattebox-player[paused]` and the like. */
|
|
@@ -454,6 +702,8 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
|
|
|
454
702
|
this.toggleAttribute("audio", this.audio());
|
|
455
703
|
this.toggleAttribute("started", this.started);
|
|
456
704
|
this.toggleAttribute("waiting", this.waiting);
|
|
705
|
+
this.toggleAttribute("error", this.failure !== null);
|
|
706
|
+
this.toggleAttribute("blocked", this.stop !== null);
|
|
457
707
|
this.reflecting = false;
|
|
458
708
|
}
|
|
459
709
|
/**
|
|
@@ -464,20 +714,31 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
|
|
|
464
714
|
* the start rather than from its metadata.
|
|
465
715
|
*/
|
|
466
716
|
audio() {
|
|
467
|
-
var _this$
|
|
717
|
+
var _this$getAttribute3;
|
|
468
718
|
const video = this.media;
|
|
469
719
|
if (video.readyState >= HTMLMediaElement.HAVE_METADATA) return video.videoWidth === 0 && video.videoHeight === 0;
|
|
470
720
|
const src = this.getAttribute("src");
|
|
471
|
-
const type = (_this$
|
|
721
|
+
const type = (_this$getAttribute3 = this.getAttribute("type")) !== null && _this$getAttribute3 !== void 0 ? _this$getAttribute3 : src === null ? void 0 : inferType(src);
|
|
472
722
|
return (type === null || type === void 0 ? void 0 : type.startsWith("audio/")) === true;
|
|
473
723
|
}
|
|
474
724
|
disconnectedCallback() {
|
|
475
|
-
var _this$sizes;
|
|
725
|
+
var _this$sizes, _this$unwatch;
|
|
476
726
|
(_this$sizes = this.sizes) === null || _this$sizes === void 0 || _this$sizes.disconnect();
|
|
477
727
|
this.sizes = null;
|
|
478
|
-
this.
|
|
728
|
+
(_this$unwatch = this.unwatch) === null || _this$unwatch === void 0 || _this$unwatch.call(this);
|
|
729
|
+
this.unwatch = null;
|
|
730
|
+
queueMicrotask(() => {
|
|
731
|
+
if (this.isConnected) return;
|
|
732
|
+
for (const off of this.attached.values()) off === null || off === void 0 || off();
|
|
733
|
+
this.attached.clear();
|
|
734
|
+
this.enqueue(() => this.teardown());
|
|
735
|
+
});
|
|
479
736
|
}
|
|
480
737
|
attributeChangedCallback(name) {
|
|
738
|
+
if (name === LANGUAGE || name === "lang") {
|
|
739
|
+
this.relocale();
|
|
740
|
+
return;
|
|
741
|
+
}
|
|
481
742
|
if (FORWARDED.includes(name)) {
|
|
482
743
|
if (!this.reflecting) this.forward(name);
|
|
483
744
|
return;
|
|
@@ -505,6 +766,8 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
|
|
|
505
766
|
if (name === "preset") this.enqueue(() => this.discard());
|
|
506
767
|
if (name === "src" || name === "type") this.toggleAttribute("audio", this.audio());
|
|
507
768
|
if (name === "src" && this.marks.list.length > 0) this.marks.set([]);
|
|
769
|
+
if (name === "src") this.interruption = null;
|
|
770
|
+
if (name === "src") this.unblock();
|
|
508
771
|
this.reload();
|
|
509
772
|
}
|
|
510
773
|
/**
|
|
@@ -517,6 +780,7 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
|
|
|
517
780
|
const custom = value === "custom";
|
|
518
781
|
this.media.controls = !custom && value !== "none";
|
|
519
782
|
if (custom) this.surface.clear();
|
|
783
|
+
else this.showBlock();
|
|
520
784
|
if (!custom) {
|
|
521
785
|
if (this.focusable) this.removeAttribute("tabindex");
|
|
522
786
|
this.focusable = false;
|
|
@@ -527,9 +791,9 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
|
|
|
527
791
|
}
|
|
528
792
|
/** Hands the `chapters` attribute to the engine, or keeps a hidden chapters track on the video for it. */
|
|
529
793
|
chapters() {
|
|
530
|
-
var _this$current$
|
|
794
|
+
var _this$current$engine8, _this$current8;
|
|
531
795
|
const url = this.getAttribute(CHAPTERS);
|
|
532
|
-
const engine = (_this$current$
|
|
796
|
+
const engine = (_this$current$engine8 = (_this$current8 = this.current) === null || _this$current8 === void 0 ? void 0 : _this$current8.engine) !== null && _this$current$engine8 !== void 0 ? _this$current$engine8 : null;
|
|
533
797
|
const api = engine === null ? void 0 : namespaces(engine).chapters;
|
|
534
798
|
if (api !== void 0) {
|
|
535
799
|
var _this$track;
|
|
@@ -590,28 +854,30 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
|
|
|
590
854
|
if (error.fatal) {
|
|
591
855
|
this.failure = error;
|
|
592
856
|
clearTimeout(this.slow);
|
|
593
|
-
if (this.querySelector("mbx-error-screen") === null) this.voice.say("error", "Playback failed");
|
|
857
|
+
if (this.querySelector("mbx-error-screen") === null) this.voice.say("error", "playbackFailed", "Playback failed");
|
|
594
858
|
if (this.getAttribute(CONTROLS) !== "custom") this.surface.show(error);
|
|
859
|
+
this.reflect();
|
|
595
860
|
}
|
|
596
861
|
this.emit("error", error);
|
|
597
862
|
}
|
|
598
863
|
run() {
|
|
599
|
-
var
|
|
864
|
+
var _this4 = this;
|
|
600
865
|
return _asyncToGenerator(function* () {
|
|
601
|
-
|
|
602
|
-
if (!
|
|
603
|
-
const sources =
|
|
604
|
-
|
|
866
|
+
_this4.unmount();
|
|
867
|
+
if (!_this4.isConnected) return;
|
|
868
|
+
const sources = _this4.wanted();
|
|
869
|
+
_this4.tried = JSON.stringify(sources);
|
|
605
870
|
if (sources.length === 0) return;
|
|
606
|
-
const core = yield
|
|
607
|
-
|
|
608
|
-
|
|
871
|
+
const core = yield _this4.ensure();
|
|
872
|
+
_this4.failure = null;
|
|
873
|
+
_this4.surface.clear();
|
|
874
|
+
_this4.reflect();
|
|
609
875
|
try {
|
|
610
876
|
yield core.load(sources);
|
|
611
877
|
} catch (_unused2) {
|
|
612
878
|
return;
|
|
613
879
|
}
|
|
614
|
-
if (!
|
|
880
|
+
if (!_this4.isConnected) yield core.unload();
|
|
615
881
|
})();
|
|
616
882
|
}
|
|
617
883
|
/**
|
|
@@ -628,7 +894,7 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
|
|
|
628
894
|
return [_objectSpread2(_objectSpread2({ url }, type === null ? {} : { type }), withVersions)];
|
|
629
895
|
}
|
|
630
896
|
const eme = emeAvailable();
|
|
631
|
-
if (this.list !== null) return eme ? this.list : this.list.map(withoutDrm);
|
|
897
|
+
if (this.list !== null) return eme ? this.list : this.list.map((source) => "url" in source ? withoutDrm(source) : source);
|
|
632
898
|
const found = [];
|
|
633
899
|
for (const child of Array.from(this.children)) {
|
|
634
900
|
const src = child.localName === "source" ? child.getAttribute("src") : null;
|
|
@@ -642,35 +908,44 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
|
|
|
642
908
|
}
|
|
643
909
|
/** Sets a session up. It runs for every session, the one that replaces a failed source included. */
|
|
644
910
|
adopt(session) {
|
|
911
|
+
var _this$core2;
|
|
645
912
|
this.given = null;
|
|
646
913
|
this.configure(session);
|
|
914
|
+
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;
|
|
915
|
+
if (chapters !== void 0 && session.engine !== null && this.getAttribute(CHAPTERS) === null) {
|
|
916
|
+
var _namespaces$chapters;
|
|
917
|
+
(_namespaces$chapters = namespaces(session.engine).chapters) === null || _namespaces$chapters === void 0 || _namespaces$chapters.set(chapters);
|
|
918
|
+
}
|
|
647
919
|
this.chapters();
|
|
648
920
|
}
|
|
649
921
|
ensure() {
|
|
650
|
-
var
|
|
922
|
+
var _this5 = this;
|
|
651
923
|
return _asyncToGenerator(function* () {
|
|
652
|
-
if (
|
|
653
|
-
const
|
|
654
|
-
|
|
924
|
+
if (_this5.core !== null) return _this5.core;
|
|
925
|
+
const connectors = _this5.options.connectors;
|
|
926
|
+
const core = createPlayer(_this5.media, _objectSpread2({ handlers: yield _this5.chain() }, connectors === void 0 ? {} : { connectors }));
|
|
927
|
+
_this5.offs.push(core.on("programme", (programme) => {
|
|
928
|
+
_this5.programmed(programme);
|
|
929
|
+
}), core.on("sourcechange", (session) => {
|
|
655
930
|
var _this$offTracks, _session$engine$on, _session$engine;
|
|
656
|
-
|
|
657
|
-
if (!
|
|
931
|
+
_this5.current = session;
|
|
932
|
+
if (!_this5.switching) {
|
|
658
933
|
var _session$source, _this$held2;
|
|
659
|
-
const was =
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
(_this$held2 =
|
|
664
|
-
if (was !== null)
|
|
934
|
+
const was = _this5.version;
|
|
935
|
+
_this5.original = (_session$source = session === null || session === void 0 ? void 0 : session.source) !== null && _session$source !== void 0 ? _session$source : null;
|
|
936
|
+
_this5.switched = null;
|
|
937
|
+
_this5.version = null;
|
|
938
|
+
(_this$held2 = _this5.held) === null || _this$held2 === void 0 || _this$held2.call(_this5);
|
|
939
|
+
if (was !== null) _this5.emit("videosourcechange", null);
|
|
665
940
|
}
|
|
666
|
-
(_this$offTracks =
|
|
667
|
-
|
|
668
|
-
if (session !== null &&
|
|
669
|
-
|
|
941
|
+
(_this$offTracks = _this5.offTracks) === null || _this$offTracks === void 0 || _this$offTracks.call(_this5);
|
|
942
|
+
_this5.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", () => _this5.tracks())) !== null && _session$engine$on !== void 0 ? _session$engine$on : null;
|
|
943
|
+
if (session !== null && _this5.isConnected) _this5.adopt(session);
|
|
944
|
+
_this5.emit("sourcechange", session);
|
|
670
945
|
}), core.on("error", (error) => {
|
|
671
|
-
|
|
946
|
+
_this5.report(error);
|
|
672
947
|
}));
|
|
673
|
-
|
|
948
|
+
_this5.core = core;
|
|
674
949
|
return core;
|
|
675
950
|
})();
|
|
676
951
|
}
|
|
@@ -684,23 +959,32 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
|
|
|
684
959
|
return (_this$own = this.own) !== null && _this$own !== void 0 ? _this$own : defaults;
|
|
685
960
|
}
|
|
686
961
|
chain() {
|
|
687
|
-
var
|
|
962
|
+
var _this6 = this;
|
|
688
963
|
return _asyncToGenerator(function* () {
|
|
689
|
-
var _this$
|
|
690
|
-
if (
|
|
691
|
-
const config =
|
|
964
|
+
var _this$options$addons3, _this$getAttribute4;
|
|
965
|
+
if (_this6.options.handlers !== void 0) return _this6.options.handlers;
|
|
966
|
+
const config = _this6.options.config === void 0 ? {} : { config: _this6.options.config };
|
|
692
967
|
const native = (stages) => nativeHandler({
|
|
693
|
-
prefer: (source, env) =>
|
|
694
|
-
|
|
968
|
+
prefer: (source, env) => {
|
|
969
|
+
var _this$options$addons2;
|
|
970
|
+
return _this6.getAttribute(NATIVE_HLS) !== "off" && !((_this$options$addons2 = _this6.options.addons) !== null && _this$options$addons2 !== void 0 ? _this$options$addons2 : []).some((addon) => addon.engine === true) && preferNativeHls(source, env);
|
|
971
|
+
},
|
|
972
|
+
drm: () => _this6.drm(stages)
|
|
973
|
+
});
|
|
974
|
+
if (_this6.isConnected) _this6.attachAddons();
|
|
975
|
+
const added = ((_this$options$addons3 = _this6.options.addons) !== null && _this$options$addons3 !== void 0 ? _this$options$addons3 : []).flatMap((addon) => {
|
|
976
|
+
var _addon$stages, _addon$stages2;
|
|
977
|
+
return (_addon$stages = (_addon$stages2 = addon.stages) === null || _addon$stages2 === void 0 ? void 0 : _addon$stages2.call(addon)) !== null && _addon$stages !== void 0 ? _addon$stages : [];
|
|
695
978
|
});
|
|
696
|
-
if (
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
979
|
+
if (_this6.options.stages !== void 0) {
|
|
980
|
+
const own = _this6.options.stages;
|
|
981
|
+
const stages = [...own, ...added.filter((stage) => !own.some((o) => o.name === stage.name))];
|
|
982
|
+
return [matteboxHandler(_objectSpread2({ stages }, config)), native(() => stages)];
|
|
983
|
+
}
|
|
984
|
+
const name = (_this$getAttribute4 = _this6.getAttribute("preset")) !== null && _this$getAttribute4 !== void 0 ? _this$getAttribute4 : DEFAULT_PRESET;
|
|
701
985
|
const preset = yield resolvePreset(name);
|
|
702
986
|
if (preset === null) {
|
|
703
|
-
|
|
987
|
+
_this6.report({
|
|
704
988
|
category: "config",
|
|
705
989
|
code: "CONFIG_INVALID",
|
|
706
990
|
fatal: true,
|
|
@@ -710,7 +994,8 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
|
|
|
710
994
|
});
|
|
711
995
|
return [nativeHandler()];
|
|
712
996
|
}
|
|
713
|
-
|
|
997
|
+
const extra = added.length === 0 ? {} : { stages: added };
|
|
998
|
+
return [matteboxHandler(_objectSpread2(_objectSpread2(_objectSpread2({ preset }, extra), config), drmGuard())), native(() => preset.stages())];
|
|
714
999
|
})();
|
|
715
1000
|
}
|
|
716
1001
|
/**
|
|
@@ -748,22 +1033,21 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
|
|
|
748
1033
|
this.current = null;
|
|
749
1034
|
}
|
|
750
1035
|
teardown() {
|
|
751
|
-
var
|
|
1036
|
+
var _this7 = this;
|
|
752
1037
|
return _asyncToGenerator(function* () {
|
|
753
|
-
|
|
754
|
-
if (
|
|
1038
|
+
_this7.unmount();
|
|
1039
|
+
if (_this7.core !== null) yield _this7.core.unload();
|
|
755
1040
|
})();
|
|
756
1041
|
}
|
|
757
1042
|
/** Drops the player itself, so the next run builds a chain from the new preset. */
|
|
758
1043
|
discard() {
|
|
759
|
-
var
|
|
1044
|
+
var _this8 = this;
|
|
760
1045
|
return _asyncToGenerator(function* () {
|
|
761
|
-
yield
|
|
762
|
-
for (const off of
|
|
763
|
-
|
|
764
|
-
|
|
1046
|
+
yield _this8.teardown();
|
|
1047
|
+
for (const off of _this8.offs) off();
|
|
1048
|
+
_this8.offs = [];
|
|
1049
|
+
_this8.core = null;
|
|
765
1050
|
})();
|
|
766
1051
|
}
|
|
767
1052
|
};
|
|
768
|
-
//#endregion
|
|
769
1053
|
export { MatteboxPlayerElement };
|