@mattebox/player 0.9.1 → 0.11.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 +7 -0
- package/dist/announcer.d.ts.map +1 -0
- package/dist/announcer.js +44 -0
- package/dist/announcer.js.map +1 -0
- package/dist/cdn/mattebox-player.min.js +3 -3
- package/dist/controls/icons.d.ts +1 -1
- package/dist/controls/icons.d.ts.map +1 -1
- package/dist/controls/icons.js +1 -0
- package/dist/controls/icons.js.map +1 -1
- 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.map +1 -1
- package/dist/element.d.ts +63 -1
- package/dist/element.d.ts.map +1 -1
- package/dist/element.js +211 -12
- package/dist/element.js.map +1 -1
- package/dist/elements/audio-menu.js +1 -1
- package/dist/elements/control-bar.d.ts.map +1 -1
- package/dist/elements/control-bar.js +8 -6
- package/dist/elements/control-bar.js.map +1 -1
- package/dist/elements/drm-badge.js +2 -2
- package/dist/elements/error-screen.d.ts.map +1 -1
- package/dist/elements/error-screen.js +1 -3
- package/dist/elements/error-screen.js.map +1 -1
- package/dist/elements/menu-element.js +1 -1
- package/dist/elements/play-button.d.ts.map +1 -1
- package/dist/elements/play-button.js +7 -9
- package/dist/elements/play-button.js.map +1 -1
- package/dist/elements/seek-bar.js +1 -1
- package/dist/elements/shared.d.ts +18 -0
- package/dist/elements/shared.d.ts.map +1 -1
- package/dist/elements/shared.js +16 -9
- package/dist/elements/shared.js.map +1 -1
- package/dist/elements/skip-button.js +1 -1
- package/dist/elements/start-button.d.ts.map +1 -1
- package/dist/elements/start-button.js +3 -3
- package/dist/elements/start-button.js.map +1 -1
- package/dist/elements/subtitles-menu.js +1 -1
- package/dist/elements/title.d.ts.map +1 -1
- package/dist/elements/title.js +5 -2
- package/dist/elements/title.js.map +1 -1
- package/dist/elements/video-menu.d.ts +23 -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/entries/video-menu.d.ts +5 -0
- package/dist/entries/video-menu.d.ts.map +1 -0
- package/dist/entries/video-menu.js +9 -0
- package/dist/entries/video-menu.js.map +1 -0
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.153.0 → _@oxc-project_runtime@0.154.0}/helpers/esm/asyncToGenerator.js +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.153.0 → _@oxc-project_runtime@0.154.0}/helpers/esm/defineProperty.js +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.153.0 → _@oxc-project_runtime@0.154.0}/helpers/esm/objectSpread2.js +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.153.0 → _@oxc-project_runtime@0.154.0}/helpers/esm/toPrimitive.js +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.153.0 → _@oxc-project_runtime@0.154.0}/helpers/esm/toPropertyKey.js +1 -1
- package/dist/es2015/_virtual/{_@oxc-project_runtime@0.153.0 → _@oxc-project_runtime@0.154.0}/helpers/esm/typeof.js +1 -1
- package/dist/es2015/announcer.js +43 -0
- package/dist/es2015/controls/chapters.js +1 -1
- package/dist/es2015/controls/icons.js +1 -0
- package/dist/es2015/controls/menu.js +1 -1
- package/dist/es2015/element.js +258 -57
- package/dist/es2015/elements/audio-menu.js +1 -1
- package/dist/es2015/elements/control-bar.js +8 -6
- package/dist/es2015/elements/drm-badge.js +2 -2
- package/dist/es2015/elements/error-screen.js +2 -3
- package/dist/es2015/elements/menu-element.js +1 -1
- package/dist/es2015/elements/play-button.js +8 -10
- package/dist/es2015/elements/seek-bar.js +1 -1
- package/dist/es2015/elements/shared.js +16 -9
- package/dist/es2015/elements/skip-button.js +1 -1
- package/dist/es2015/elements/start-button.js +3 -3
- package/dist/es2015/elements/subtitles-menu.js +1 -1
- package/dist/es2015/elements/title.js +5 -2
- package/dist/es2015/elements/video-menu.js +152 -0
- package/dist/es2015/entries/video-menu.js +7 -0
- package/dist/es2015/index.js +3 -1
- package/dist/es2015/presets.js +1 -1
- package/dist/es2015/style.js +1 -1
- package/dist/es2015/tags.js +2 -1
- package/dist/es2015/video-sources.js +128 -0
- package/dist/host.d.ts +10 -1
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/style.js +1 -1
- package/dist/tags.d.ts +1 -0
- package/dist/tags.d.ts.map +1 -1
- package/dist/tags.js +2 -1
- package/dist/tags.js.map +1 -1
- package/dist/video-sources.d.ts +48 -0
- package/dist/video-sources.d.ts.map +1 -0
- package/dist/video-sources.js +134 -0
- package/dist/video-sources.js.map +1 -0
- package/package.json +4 -4
package/dist/es2015/element.js
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
|
+
import { announcer } from "./announcer.js";
|
|
1
2
|
import { createMarkers } from "./controls/markers.js";
|
|
3
|
+
import { languageName } from "./controls/track-names.js";
|
|
2
4
|
import { namespaces } from "./namespaces.js";
|
|
3
|
-
import _asyncToGenerator from "./_virtual/_@oxc-project_runtime@0.
|
|
5
|
+
import _asyncToGenerator from "./_virtual/_@oxc-project_runtime@0.154.0/helpers/esm/asyncToGenerator.js";
|
|
4
6
|
import { drmGuard, resolvePreset } from "./presets.js";
|
|
5
7
|
import { STYLE } from "./style.js";
|
|
6
8
|
import { errorSurface } from "./surface.js";
|
|
7
9
|
import { PLAYER } from "./tags.js";
|
|
8
|
-
import _objectSpread2 from "./_virtual/_@oxc-project_runtime@0.
|
|
10
|
+
import _objectSpread2 from "./_virtual/_@oxc-project_runtime@0.154.0/helpers/esm/objectSpread2.js";
|
|
11
|
+
import { chosen, holdFrame, markupVideoTracks, onNextFrame, restore, resume, versionSource } from "./video-sources.js";
|
|
9
12
|
import { createPlayer, inferType, matteboxHandler, nativeHandler, preferNativeHls } from "@mattebox/player-core";
|
|
10
13
|
//#region src/element.ts
|
|
11
14
|
/**
|
|
@@ -22,6 +25,16 @@ const FORWARDED = [
|
|
|
22
25
|
"crossorigin"
|
|
23
26
|
];
|
|
24
27
|
const LICENSE_URL = "license-url";
|
|
28
|
+
/** Carried through a switch: the play state from before it, `playing` or `paused`. */
|
|
29
|
+
const SWITCHING = "switching";
|
|
30
|
+
/** Whether the browser has EME, so a source may bring DRM. */
|
|
31
|
+
function emeAvailable() {
|
|
32
|
+
return drmGuard().without === void 0;
|
|
33
|
+
}
|
|
34
|
+
/** `source` without its DRM, for a browser without EME. */
|
|
35
|
+
function withoutDrm({ url, type, videoTracks }) {
|
|
36
|
+
return _objectSpread2(_objectSpread2({ url }, type === void 0 ? {} : { type }), videoTracks === void 0 ? {} : { videoTracks });
|
|
37
|
+
}
|
|
25
38
|
const CERTIFICATE_URL = "certificate-url";
|
|
26
39
|
/** Everything else the element watches. Changing any of them reloads. */
|
|
27
40
|
const OWN = [
|
|
@@ -93,6 +106,16 @@ const STATE_EVENTS = [
|
|
|
93
106
|
"stalled",
|
|
94
107
|
"canplay"
|
|
95
108
|
];
|
|
109
|
+
/**
|
|
110
|
+
* How long the video waits for data before the live region says so. A
|
|
111
|
+
* seek within the buffer waits for less, and saying it would only be noise.
|
|
112
|
+
*/
|
|
113
|
+
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) {
|
|
116
|
+
var _languageName;
|
|
117
|
+
return name || lang && ((_languageName = languageName(lang)) !== null && _languageName !== void 0 ? _languageName : lang) || "";
|
|
118
|
+
}
|
|
96
119
|
/** The stages that register a key system, which a native session's DRM offers. */
|
|
97
120
|
const KEY_SYSTEMS = ["eme-fairplay", "eme-cenc"];
|
|
98
121
|
/** Every stage the engine ships. A narrower preset is optimization. */
|
|
@@ -149,12 +172,27 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
|
|
|
149
172
|
this.offs = [];
|
|
150
173
|
this.queue = Promise.resolve();
|
|
151
174
|
this.pending = false;
|
|
175
|
+
this.programme = null;
|
|
176
|
+
this.version = null;
|
|
177
|
+
this.switching = false;
|
|
178
|
+
this.switched = null;
|
|
179
|
+
this.held = null;
|
|
180
|
+
this.slow = void 0;
|
|
181
|
+
this.heardAudio = void 0;
|
|
182
|
+
this.heardText = void 0;
|
|
183
|
+
this.offTracks = null;
|
|
152
184
|
this.media = document.createElement("video");
|
|
153
185
|
this.media.controls = true;
|
|
154
186
|
this.media.setAttribute(PLAYSINLINE, "");
|
|
155
187
|
for (const name of STATE_EVENTS) this.media.addEventListener(name, () => {
|
|
188
|
+
const was = this.waiting;
|
|
156
189
|
this.note(name);
|
|
157
190
|
this.reflect();
|
|
191
|
+
this.tell(name, was);
|
|
192
|
+
});
|
|
193
|
+
const lists = this.media;
|
|
194
|
+
for (const list of [lists.audioTracks, lists.textTracks]) list === null || list === void 0 || list.addEventListener("change", () => {
|
|
195
|
+
this.tracks();
|
|
158
196
|
});
|
|
159
197
|
this.media.addEventListener("playing", () => {
|
|
160
198
|
this.failure = null;
|
|
@@ -168,12 +206,13 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
|
|
|
168
206
|
});
|
|
169
207
|
this.stage.append(slot);
|
|
170
208
|
this.surface = errorSurface(() => {
|
|
171
|
-
this.
|
|
209
|
+
this.retry();
|
|
172
210
|
});
|
|
211
|
+
this.voice = announcer(this);
|
|
173
212
|
const root = this.attachShadow({ mode: "open" });
|
|
174
213
|
const style = document.createElement("style");
|
|
175
214
|
style.textContent = STYLE;
|
|
176
|
-
root.append(style, this.stage, this.surface.root);
|
|
215
|
+
root.append(style, this.stage, this.surface.root, this.voice.root);
|
|
177
216
|
}
|
|
178
217
|
/** The media element. Everything the browser already does is here. */
|
|
179
218
|
get video() {
|
|
@@ -196,14 +235,118 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
|
|
|
196
235
|
if (this.marks.list.length > 0) this.marks.set([]);
|
|
197
236
|
this.reload();
|
|
198
237
|
}
|
|
238
|
+
/**
|
|
239
|
+
* Loads the sources again, in the order a load reads them: the `src`
|
|
240
|
+
* attribute, the `sources` property, then the `<source>` children. The
|
|
241
|
+
* error screens' Retry calls it. On a version of `videoSources`, it
|
|
242
|
+
* loads that version again.
|
|
243
|
+
*/
|
|
244
|
+
retry() {
|
|
245
|
+
const again = this.version === null ? this.switched : versionSource(this.version, emeAvailable());
|
|
246
|
+
if (again === null) this.reload();
|
|
247
|
+
else this.swap(again, null, false, null, false);
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Loads `source` in place of the one that plays, from the same position
|
|
251
|
+
* and in the same play state, with the same audio and subtitle choice.
|
|
252
|
+
* Use it for the same programme at another URL, such as its HLS and
|
|
253
|
+
* DASH manifests. The last frame and the controls hold until the new
|
|
254
|
+
* load shows a frame there. The markers stay, and the versions are the
|
|
255
|
+
* ones `source` names. A new `src`, `sources` or `<source>` load
|
|
256
|
+
* replaces it.
|
|
257
|
+
*/
|
|
258
|
+
switchSource(source) {
|
|
259
|
+
var _this$current$engine, _this$current;
|
|
260
|
+
const media = this.media;
|
|
261
|
+
const at = Number.isFinite(media.duration) ? media.currentTime : null;
|
|
262
|
+
const playing = !media.paused;
|
|
263
|
+
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
|
+
const clean = emeAvailable() ? source : withoutDrm(source);
|
|
265
|
+
const was = this.version;
|
|
266
|
+
this.programme = clean;
|
|
267
|
+
this.switched = clean;
|
|
268
|
+
this.version = null;
|
|
269
|
+
if (was !== null) this.emit("videosourcechange", null);
|
|
270
|
+
this.swap(clean, at, playing, had, true);
|
|
271
|
+
}
|
|
272
|
+
/** The other versions of the picture the source names at their own URLs, for the video menu. */
|
|
273
|
+
get videoSources() {
|
|
274
|
+
var _this$programme$video, _this$programme;
|
|
275
|
+
return (_this$programme$video = (_this$programme = this.programme) === null || _this$programme === void 0 ? void 0 : _this$programme.videoTracks) !== null && _this$programme$video !== void 0 ? _this$programme$video : [];
|
|
276
|
+
}
|
|
277
|
+
/** The version of `videoSources` that plays, or null for the source itself. */
|
|
278
|
+
get videoSource() {
|
|
279
|
+
return this.version;
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Plays a version of `videoSources`, or the source itself for null, from
|
|
283
|
+
* the same position and in the same play state, with the same audio and
|
|
284
|
+
* subtitle choice. A live source joins the version at its live edge.
|
|
285
|
+
* Fires `videosourcechange`.
|
|
286
|
+
*/
|
|
287
|
+
selectVideoSource(track) {
|
|
288
|
+
var _programme$videoTrack, _this$current$engine2, _this$current2;
|
|
289
|
+
const programme = this.programme;
|
|
290
|
+
if (programme === null || track === this.version) return;
|
|
291
|
+
if (track !== null && ((_programme$videoTrack = programme.videoTracks) === null || _programme$videoTrack === void 0 ? void 0 : _programme$videoTrack.includes(track)) !== true) return;
|
|
292
|
+
const media = this.media;
|
|
293
|
+
const at = Number.isFinite(media.duration) ? media.currentTime : null;
|
|
294
|
+
const playing = !media.paused;
|
|
295
|
+
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);
|
|
296
|
+
this.version = track;
|
|
297
|
+
this.emit("videosourcechange", track);
|
|
298
|
+
this.swap(track === null ? programme : versionSource(track, emeAvailable()), at, playing, had, true);
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* Loads `source` under the programme that plays, and puts the position,
|
|
302
|
+
* play state and tracks back. With `hold`, the last frame stays as the
|
|
303
|
+
* poster and the player carries `switching`, the play state from
|
|
304
|
+
* before, so the controls show that state through the load.
|
|
305
|
+
*/
|
|
306
|
+
swap(source, at, playing, had, hold) {
|
|
307
|
+
var _this = this;
|
|
308
|
+
var _this$held;
|
|
309
|
+
const media = this.media;
|
|
310
|
+
(_this$held = this.held) === null || _this$held === void 0 || _this$held.call(this);
|
|
311
|
+
let release = null;
|
|
312
|
+
if (hold) {
|
|
313
|
+
const frame = holdFrame(media);
|
|
314
|
+
const done = () => {
|
|
315
|
+
frame === null || frame === void 0 || frame();
|
|
316
|
+
if (this.held !== done) return;
|
|
317
|
+
this.held = null;
|
|
318
|
+
this.removeAttribute(SWITCHING);
|
|
319
|
+
this.reflect();
|
|
320
|
+
};
|
|
321
|
+
this.held = done;
|
|
322
|
+
this.setAttribute(SWITCHING, playing ? "playing" : "paused");
|
|
323
|
+
release = done;
|
|
324
|
+
}
|
|
325
|
+
this.enqueue(_asyncToGenerator(function* () {
|
|
326
|
+
var _this$current$engine3, _this$current3;
|
|
327
|
+
const core = yield _this.ensure();
|
|
328
|
+
_this.switching = true;
|
|
329
|
+
try {
|
|
330
|
+
yield core.load([source]);
|
|
331
|
+
} catch (_unused) {
|
|
332
|
+
release === null || release === void 0 || release();
|
|
333
|
+
return;
|
|
334
|
+
} finally {
|
|
335
|
+
_this.switching = false;
|
|
336
|
+
}
|
|
337
|
+
resume(media, at, playing);
|
|
338
|
+
if (release !== null) onNextFrame(media, at, release);
|
|
339
|
+
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);
|
|
340
|
+
}));
|
|
341
|
+
}
|
|
199
342
|
/** The core, or null until the first source has been set up: resolving a preset is asynchronous. */
|
|
200
343
|
get player() {
|
|
201
344
|
return this.core;
|
|
202
345
|
}
|
|
203
346
|
/** The engine feeding the video, or null for a native session and before the first load. */
|
|
204
347
|
get engine() {
|
|
205
|
-
var _this$current$
|
|
206
|
-
return (_this$current$
|
|
348
|
+
var _this$current$engine4, _this$current4;
|
|
349
|
+
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;
|
|
207
350
|
}
|
|
208
351
|
/**
|
|
209
352
|
* The fatal error of the current load, or null once a load starts or
|
|
@@ -243,21 +386,69 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
|
|
|
243
386
|
/** The two states the video does not hold: whether it has played once, and whether it waits for data. */
|
|
244
387
|
note(event) {
|
|
245
388
|
if (event === "playing") {
|
|
389
|
+
if (!this.started) this.tracks();
|
|
246
390
|
this.started = true;
|
|
247
391
|
this.waiting = false;
|
|
248
392
|
} else if (event === "waiting" || event === "stalled") this.waiting = true;
|
|
249
393
|
else if (event === "canplay") this.waiting = false;
|
|
250
394
|
else if (event === "emptied") {
|
|
251
|
-
this.started = false;
|
|
395
|
+
if (this.held === null) this.started = false;
|
|
252
396
|
this.waiting = false;
|
|
397
|
+
this.heardAudio = void 0;
|
|
398
|
+
this.heardText = void 0;
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
/** Says a play or a pause, and a wait once it has lasted `LOADING_MS`. */
|
|
402
|
+
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");
|
|
405
|
+
if (this.waiting === was) return;
|
|
406
|
+
clearTimeout(this.slow);
|
|
407
|
+
if (this.waiting) this.slow = setTimeout(() => {
|
|
408
|
+
this.voice.say("loading", "Loading");
|
|
409
|
+
}, LOADING_MS);
|
|
410
|
+
}
|
|
411
|
+
/**
|
|
412
|
+
* Says a change of the audio or the subtitle track, once the video has
|
|
413
|
+
* played: the tracks a load starts with are no change. A forced track
|
|
414
|
+
* reads as off, as in the subtitles menu.
|
|
415
|
+
*/
|
|
416
|
+
tracks() {
|
|
417
|
+
var _this$current$engine5, _this$current5;
|
|
418
|
+
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;
|
|
419
|
+
let audio;
|
|
420
|
+
let text;
|
|
421
|
+
if (engine !== null) {
|
|
422
|
+
const sound = engine.tracks.active("audio");
|
|
423
|
+
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);
|
|
426
|
+
} else {
|
|
427
|
+
var _video$audioTracks;
|
|
428
|
+
const video = this.media;
|
|
429
|
+
const sound = Array.from((_video$audioTracks = video.audioTracks) !== null && _video$audioTracks !== void 0 ? _video$audioTracks : []).find((track) => track.enabled);
|
|
430
|
+
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);
|
|
433
|
+
}
|
|
434
|
+
const { heardAudio, heardText } = this;
|
|
435
|
+
this.heardAudio = audio;
|
|
436
|
+
this.heardText = text;
|
|
437
|
+
if (!this.started) return;
|
|
438
|
+
if (heardAudio !== void 0 && audio !== heardAudio) this.voice.say("audio", "Audio: {track}", audio);
|
|
439
|
+
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);
|
|
253
442
|
}
|
|
254
443
|
}
|
|
255
444
|
/** The video's state on the element, for `mattebox-player[paused]` and the like. */
|
|
256
445
|
reflect() {
|
|
257
446
|
const video = this.media;
|
|
258
447
|
this.reflecting = true;
|
|
259
|
-
this.
|
|
260
|
-
|
|
448
|
+
const held = this.getAttribute(SWITCHING);
|
|
449
|
+
const paused = held === null ? video.paused : held === "paused";
|
|
450
|
+
this.toggleAttribute("paused", paused);
|
|
451
|
+
this.toggleAttribute("playing", !paused);
|
|
261
452
|
this.toggleAttribute("ended", video.ended);
|
|
262
453
|
this.toggleAttribute("muted", video.muted);
|
|
263
454
|
this.toggleAttribute("audio", this.audio());
|
|
@@ -336,9 +527,9 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
|
|
|
336
527
|
}
|
|
337
528
|
/** Hands the `chapters` attribute to the engine, or keeps a hidden chapters track on the video for it. */
|
|
338
529
|
chapters() {
|
|
339
|
-
var _this$current$
|
|
530
|
+
var _this$current$engine6, _this$current6;
|
|
340
531
|
const url = this.getAttribute(CHAPTERS);
|
|
341
|
-
const engine = (_this$current$
|
|
532
|
+
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;
|
|
342
533
|
const api = engine === null ? void 0 : namespaces(engine).chapters;
|
|
343
534
|
if (api !== void 0) {
|
|
344
535
|
var _this$track;
|
|
@@ -398,27 +589,29 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
|
|
|
398
589
|
report(error) {
|
|
399
590
|
if (error.fatal) {
|
|
400
591
|
this.failure = error;
|
|
592
|
+
clearTimeout(this.slow);
|
|
593
|
+
if (this.querySelector("mbx-error-screen") === null) this.voice.say("error", "Playback failed");
|
|
401
594
|
if (this.getAttribute(CONTROLS) !== "custom") this.surface.show(error);
|
|
402
595
|
}
|
|
403
596
|
this.emit("error", error);
|
|
404
597
|
}
|
|
405
598
|
run() {
|
|
406
|
-
var
|
|
599
|
+
var _this2 = this;
|
|
407
600
|
return _asyncToGenerator(function* () {
|
|
408
|
-
|
|
409
|
-
if (!
|
|
410
|
-
const sources =
|
|
411
|
-
|
|
601
|
+
_this2.unmount();
|
|
602
|
+
if (!_this2.isConnected) return;
|
|
603
|
+
const sources = _this2.wanted();
|
|
604
|
+
_this2.tried = JSON.stringify(sources);
|
|
412
605
|
if (sources.length === 0) return;
|
|
413
|
-
const core = yield
|
|
414
|
-
|
|
415
|
-
|
|
606
|
+
const core = yield _this2.ensure();
|
|
607
|
+
_this2.failure = null;
|
|
608
|
+
_this2.surface.clear();
|
|
416
609
|
try {
|
|
417
610
|
yield core.load(sources);
|
|
418
|
-
} catch (
|
|
611
|
+
} catch (_unused2) {
|
|
419
612
|
return;
|
|
420
613
|
}
|
|
421
|
-
if (!
|
|
614
|
+
if (!_this2.isConnected) yield core.unload();
|
|
422
615
|
})();
|
|
423
616
|
}
|
|
424
617
|
/**
|
|
@@ -427,19 +620,15 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
|
|
|
427
620
|
* A child carries its own `license-url` and `certificate-url`.
|
|
428
621
|
*/
|
|
429
622
|
wanted() {
|
|
623
|
+
const versions = markupVideoTracks(this);
|
|
624
|
+
const withVersions = versions.length === 0 ? {} : { videoTracks: versions };
|
|
430
625
|
const url = this.getAttribute("src");
|
|
431
626
|
if (url !== null) {
|
|
432
627
|
const type = this.getAttribute("type");
|
|
433
|
-
return [type === null ? {
|
|
434
|
-
url,
|
|
435
|
-
type
|
|
436
|
-
}];
|
|
628
|
+
return [_objectSpread2(_objectSpread2({ url }, type === null ? {} : { type }), withVersions)];
|
|
437
629
|
}
|
|
438
|
-
const eme =
|
|
439
|
-
if (this.list !== null) return eme ? this.list : this.list.map(
|
|
440
|
-
url,
|
|
441
|
-
type
|
|
442
|
-
});
|
|
630
|
+
const eme = emeAvailable();
|
|
631
|
+
if (this.list !== null) return eme ? this.list : this.list.map(withoutDrm);
|
|
443
632
|
const found = [];
|
|
444
633
|
for (const child of Array.from(this.children)) {
|
|
445
634
|
const src = child.localName === "source" ? child.getAttribute("src") : null;
|
|
@@ -447,7 +636,7 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
|
|
|
447
636
|
const type = child.getAttribute("type");
|
|
448
637
|
const license = child.getAttribute(LICENSE_URL);
|
|
449
638
|
const certificate = child.getAttribute(CERTIFICATE_URL);
|
|
450
|
-
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 }) }));
|
|
639
|
+
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 }) }));
|
|
451
640
|
}
|
|
452
641
|
return found;
|
|
453
642
|
}
|
|
@@ -458,18 +647,30 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
|
|
|
458
647
|
this.chapters();
|
|
459
648
|
}
|
|
460
649
|
ensure() {
|
|
461
|
-
var
|
|
650
|
+
var _this3 = this;
|
|
462
651
|
return _asyncToGenerator(function* () {
|
|
463
|
-
if (
|
|
464
|
-
const core = createPlayer(
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
652
|
+
if (_this3.core !== null) return _this3.core;
|
|
653
|
+
const core = createPlayer(_this3.media, { handlers: yield _this3.chain() });
|
|
654
|
+
_this3.offs.push(core.on("sourcechange", (session) => {
|
|
655
|
+
var _this$offTracks, _session$engine$on, _session$engine;
|
|
656
|
+
_this3.current = session;
|
|
657
|
+
if (!_this3.switching) {
|
|
658
|
+
var _session$source, _this$held2;
|
|
659
|
+
const was = _this3.version;
|
|
660
|
+
_this3.programme = (_session$source = session === null || session === void 0 ? void 0 : session.source) !== null && _session$source !== void 0 ? _session$source : null;
|
|
661
|
+
_this3.switched = null;
|
|
662
|
+
_this3.version = null;
|
|
663
|
+
(_this$held2 = _this3.held) === null || _this$held2 === void 0 || _this$held2.call(_this3);
|
|
664
|
+
if (was !== null) _this3.emit("videosourcechange", null);
|
|
665
|
+
}
|
|
666
|
+
(_this$offTracks = _this3.offTracks) === null || _this$offTracks === void 0 || _this$offTracks.call(_this3);
|
|
667
|
+
_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;
|
|
668
|
+
if (session !== null && _this3.isConnected) _this3.adopt(session);
|
|
669
|
+
_this3.emit("sourcechange", session);
|
|
469
670
|
}), core.on("error", (error) => {
|
|
470
|
-
|
|
671
|
+
_this3.report(error);
|
|
471
672
|
}));
|
|
472
|
-
|
|
673
|
+
_this3.core = core;
|
|
473
674
|
return core;
|
|
474
675
|
})();
|
|
475
676
|
}
|
|
@@ -483,23 +684,23 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
|
|
|
483
684
|
return (_this$own = this.own) !== null && _this$own !== void 0 ? _this$own : defaults;
|
|
484
685
|
}
|
|
485
686
|
chain() {
|
|
486
|
-
var
|
|
687
|
+
var _this4 = this;
|
|
487
688
|
return _asyncToGenerator(function* () {
|
|
488
689
|
var _this$getAttribute2;
|
|
489
|
-
if (
|
|
490
|
-
const config =
|
|
690
|
+
if (_this4.options.handlers !== void 0) return _this4.options.handlers;
|
|
691
|
+
const config = _this4.options.config === void 0 ? {} : { config: _this4.options.config };
|
|
491
692
|
const native = (stages) => nativeHandler({
|
|
492
|
-
prefer: (source, env) =>
|
|
493
|
-
drm: () =>
|
|
693
|
+
prefer: (source, env) => _this4.getAttribute(NATIVE_HLS) !== "off" && preferNativeHls(source, env),
|
|
694
|
+
drm: () => _this4.drm(stages)
|
|
494
695
|
});
|
|
495
|
-
if (
|
|
696
|
+
if (_this4.options.stages !== void 0) return [matteboxHandler(_objectSpread2({ stages: _this4.options.stages }, config)), native(() => {
|
|
496
697
|
var _this$options$stages;
|
|
497
|
-
return (_this$options$stages =
|
|
698
|
+
return (_this$options$stages = _this4.options.stages) !== null && _this$options$stages !== void 0 ? _this$options$stages : [];
|
|
498
699
|
})];
|
|
499
|
-
const name = (_this$getAttribute2 =
|
|
700
|
+
const name = (_this$getAttribute2 = _this4.getAttribute("preset")) !== null && _this$getAttribute2 !== void 0 ? _this$getAttribute2 : DEFAULT_PRESET;
|
|
500
701
|
const preset = yield resolvePreset(name);
|
|
501
702
|
if (preset === null) {
|
|
502
|
-
|
|
703
|
+
_this4.report({
|
|
503
704
|
category: "config",
|
|
504
705
|
code: "CONFIG_INVALID",
|
|
505
706
|
fatal: true,
|
|
@@ -547,20 +748,20 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
|
|
|
547
748
|
this.current = null;
|
|
548
749
|
}
|
|
549
750
|
teardown() {
|
|
550
|
-
var
|
|
751
|
+
var _this5 = this;
|
|
551
752
|
return _asyncToGenerator(function* () {
|
|
552
|
-
|
|
553
|
-
if (
|
|
753
|
+
_this5.unmount();
|
|
754
|
+
if (_this5.core !== null) yield _this5.core.unload();
|
|
554
755
|
})();
|
|
555
756
|
}
|
|
556
757
|
/** Drops the player itself, so the next run builds a chain from the new preset. */
|
|
557
758
|
discard() {
|
|
558
|
-
var
|
|
759
|
+
var _this6 = this;
|
|
559
760
|
return _asyncToGenerator(function* () {
|
|
560
|
-
yield
|
|
561
|
-
for (const off of
|
|
562
|
-
|
|
563
|
-
|
|
761
|
+
yield _this6.teardown();
|
|
762
|
+
for (const off of _this6.offs) off();
|
|
763
|
+
_this6.offs = [];
|
|
764
|
+
_this6.core = null;
|
|
564
765
|
})();
|
|
565
766
|
}
|
|
566
767
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { layout, trackNames } from "../controls/track-names.js";
|
|
1
2
|
import { icon } from "../controls/icons.js";
|
|
2
3
|
import { show } from "./shared.js";
|
|
3
4
|
import { nativeTracks, onNativeTracks } from "../controls/native-tracks.js";
|
|
4
|
-
import { layout, trackNames } from "../controls/track-names.js";
|
|
5
5
|
import { MenuElement, single } from "./menu-element.js";
|
|
6
6
|
import { isAudioDescription, isOriginal } from "mattebox";
|
|
7
7
|
//#region src/elements/audio-menu.ts
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { AIRPLAY_BUTTON, AUDIO_MENU, CHAPTERS_MENU, DRM_BADGE, MUTE_BUTTON, PIP_BUTTON, QUALITY_MENU, SCAN_BUTTON, SKIP_BUTTON, SPEED_MENU, SUBTITLES_MENU, VOLUME, VOLUME_SLIDER } from "../tags.js";
|
|
1
|
+
import { AIRPLAY_BUTTON, AUDIO_MENU, CHAPTERS_MENU, DRM_BADGE, MUTE_BUTTON, PIP_BUTTON, QUALITY_MENU, SCAN_BUTTON, SKIP_BUTTON, SPEED_MENU, SUBTITLES_MENU, VIDEO_MENU, VOLUME, VOLUME_SLIDER } from "../tags.js";
|
|
2
2
|
import { Component } from "./component.js";
|
|
3
|
-
import { number, style } from "./shared.js";
|
|
3
|
+
import { number, shownPaused, style } from "./shared.js";
|
|
4
4
|
import { cueLift, cueStyle } from "../controls/cues.js";
|
|
5
5
|
import { fullscreen } from "../controls/fullscreen.js";
|
|
6
6
|
//#region src/elements/control-bar.ts
|
|
@@ -12,8 +12,9 @@ const SEEK_STEP = 5;
|
|
|
12
12
|
* suit a TV remote more than a small screen; then the slider, which takes
|
|
13
13
|
* the most room for the least; then the diagnostics, the lock and the
|
|
14
14
|
* menus a viewer rarely opens; then the menus for the picture and the
|
|
15
|
-
* sound; then the skips; then the mute
|
|
16
|
-
* menu
|
|
15
|
+
* sound; then the skips; then the mute, the subtitles and the video
|
|
16
|
+
* menu. The subtitles and video menus go last of the menus because a
|
|
17
|
+
* viewer may need them: the video menu holds the sign-language version.
|
|
17
18
|
* The diagnostics is another package's, named here as a string. A
|
|
18
19
|
* `priority` attribute on the control replaces its default.
|
|
19
20
|
*/
|
|
@@ -30,6 +31,7 @@ const PRIORITY = {
|
|
|
30
31
|
[AIRPLAY_BUTTON]: 2,
|
|
31
32
|
[SKIP_BUTTON]: 2,
|
|
32
33
|
[SUBTITLES_MENU]: 1,
|
|
34
|
+
[VIDEO_MENU]: 1,
|
|
33
35
|
[VOLUME]: 1,
|
|
34
36
|
[MUTE_BUTTON]: 1
|
|
35
37
|
};
|
|
@@ -149,7 +151,7 @@ var MbxControlBar = class extends Component {
|
|
|
149
151
|
};
|
|
150
152
|
}
|
|
151
153
|
held(player) {
|
|
152
|
-
if (player
|
|
154
|
+
if (shownPaused(player, ["switching"])) return true;
|
|
153
155
|
if (this.querySelector("[open]") !== null) return true;
|
|
154
156
|
if (!this.keyboard) return false;
|
|
155
157
|
const active = this.getRootNode().activeElement;
|
|
@@ -280,7 +282,7 @@ var MbxControlBar = class extends Component {
|
|
|
280
282
|
"pause",
|
|
281
283
|
"ended"
|
|
282
284
|
], () => {
|
|
283
|
-
this.wake(player);
|
|
285
|
+
if (!player.hasAttribute("switching")) this.wake(player);
|
|
284
286
|
});
|
|
285
287
|
this.wake(player);
|
|
286
288
|
this.cues.lifted(true);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { namespaces } from "../namespaces.js";
|
|
2
1
|
import { el } from "../dom.js";
|
|
2
|
+
import { fill } from "../labels.js";
|
|
3
|
+
import { namespaces } from "../namespaces.js";
|
|
3
4
|
import { icon } from "../controls/icons.js";
|
|
4
5
|
import { Component } from "./component.js";
|
|
5
6
|
import { style } from "./shared.js";
|
|
6
|
-
import { fill } from "../labels.js";
|
|
7
7
|
//#region src/elements/drm-badge.ts
|
|
8
8
|
const STYLE = ":host{width:2.5em;height:2.5em;color:var(--mbx-muted);border-radius:var(--mbx-radius);cursor:default;justify-content:center;align-items:center;display:inline-flex;position:relative}:host([hidden]){display:none}:host(:focus){outline:2px solid var(--mbx-accent);outline-offset:-2px}:host(:focus:not(:focus-visible)){outline:none}[part~=icon],::slotted(*){fill:currentColor;width:1.75em;height:1.75em}[part~=tooltip]{border-radius:var(--mbx-radius);color:var(--mbx-text);text-align:left;white-space:nowrap;pointer-events:none;background:#1c1c20f2;margin-bottom:.6154em;padding:.6154em .7692em;font-size:.8125em;line-height:1.4;position:absolute;bottom:100%;right:0;box-shadow:0 4px 16px #00000080}[part~=tooltip][hidden]{display:none}[part~=tooltip-title]{font-weight:600}[part~=tooltip-text]{color:var(--mbx-muted)}";
|
|
9
9
|
/** The name a viewer knows a key system by. */
|
|
@@ -19,9 +19,8 @@ var MbxErrorScreen = class extends Component {
|
|
|
19
19
|
this.retry = el("button", "retry");
|
|
20
20
|
this.retry.type = "button";
|
|
21
21
|
this.retry.addEventListener("click", () => {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
if (player !== null && player !== void 0 && src !== null && src !== void 0) player.setAttribute("src", src);
|
|
22
|
+
var _this$player;
|
|
23
|
+
(_this$player = this.player) === null || _this$player === void 0 || _this$player.retry();
|
|
25
24
|
});
|
|
26
25
|
box.append(this.title_, detail, this.retry);
|
|
27
26
|
root.append(style(STYLE), box);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { fill } from "../labels.js";
|
|
1
2
|
import { icon } from "../controls/icons.js";
|
|
2
3
|
import { Component } from "./component.js";
|
|
3
4
|
import { MENU_STYLE, iconSlots, style } from "./shared.js";
|
|
4
5
|
import { menu } from "../controls/menu.js";
|
|
5
|
-
import { fill } from "../labels.js";
|
|
6
6
|
//#region src/elements/menu-element.ts
|
|
7
7
|
var MenuElement = class extends Component {
|
|
8
8
|
constructor(states, glyphs) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { icon } from "../controls/icons.js";
|
|
2
2
|
import { Component } from "./component.js";
|
|
3
|
-
import { BUTTON_STYLE, iconSlots, show, style } from "./shared.js";
|
|
3
|
+
import { BUTTON_STYLE, HELD, iconSlots, show, shownPaused, style } from "./shared.js";
|
|
4
4
|
//#region src/elements/play-button.ts
|
|
5
5
|
/**
|
|
6
6
|
* <mbx-play-button>: play, pause, or replay once the media has ended. It
|
|
@@ -9,8 +9,8 @@ import { BUTTON_STYLE, iconSlots, show, style } from "./shared.js";
|
|
|
9
9
|
* own SVG into `icon-play`, `icon-pause` or `icon-replay`; the name is on
|
|
10
10
|
* the button, from `label-play`, `label-pause` and `label-replay`, where a
|
|
11
11
|
* screen reader reads it. While the seek bar holds the video paused for a
|
|
12
|
-
* drag,
|
|
13
|
-
* carries as `scrubbing`.
|
|
12
|
+
* drag, or a switch loads another source, the button shows the state from
|
|
13
|
+
* before, which the player carries as `scrubbing` or `switching`.
|
|
14
14
|
*/
|
|
15
15
|
const STATES = [
|
|
16
16
|
"play",
|
|
@@ -55,18 +55,16 @@ var MbxPlayButton = class extends Component {
|
|
|
55
55
|
], () => {
|
|
56
56
|
this.render();
|
|
57
57
|
});
|
|
58
|
-
this.observe(player,
|
|
58
|
+
this.observe(player, HELD, () => {
|
|
59
59
|
this.render();
|
|
60
60
|
});
|
|
61
61
|
this.render();
|
|
62
62
|
}
|
|
63
63
|
render() {
|
|
64
|
-
var _this$
|
|
65
|
-
const
|
|
66
|
-
if (
|
|
67
|
-
const
|
|
68
|
-
const paused = held === null ? video.paused : held === "paused";
|
|
69
|
-
const state = video.ended ? "replay" : paused ? "play" : "pause";
|
|
64
|
+
var _this$getAttribute;
|
|
65
|
+
const player = this.player;
|
|
66
|
+
if (player === null) return;
|
|
67
|
+
const state = player.video.ended ? "replay" : shownPaused(player) ? "play" : "pause";
|
|
70
68
|
show(this.slots, state);
|
|
71
69
|
this.button.setAttribute("aria-label", (_this$getAttribute = this.getAttribute(`label-${state}`)) !== null && _this$getAttribute !== void 0 ? _this$getAttribute : LABELS[state]);
|
|
72
70
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { el } from "../dom.js";
|
|
2
|
+
import { fill } from "../labels.js";
|
|
2
3
|
import { Component } from "./component.js";
|
|
3
4
|
import { SLIDER_STYLE, number, seekRow, style } from "./shared.js";
|
|
4
|
-
import { fill } from "../labels.js";
|
|
5
5
|
import { EMPTY, at, clip, fraction, spans } from "../controls/ranges.js";
|
|
6
6
|
import { format } from "../controls/time.js";
|
|
7
7
|
import { bufferGoal, live, optional, span, wall } from "../controls/session.js";
|
|
@@ -1,12 +1,4 @@
|
|
|
1
1
|
//#region src/elements/shared.ts
|
|
2
|
-
/**
|
|
3
|
-
* The style every button control shares. Each element carries its own
|
|
4
|
-
* copy in its shadow root, so the rules are short and the tokens come
|
|
5
|
-
* through the `--mbx-*` custom properties the player sets, which inherit
|
|
6
|
-
* through light DOM into every control.
|
|
7
|
-
*
|
|
8
|
-
* Nothing carries `!important`: a page's `::part()` rule must win.
|
|
9
|
-
*/
|
|
10
2
|
const BUTTON_STYLE_CSS = ":host{display:inline-flex}:host([hidden]){display:none}[part~=button]{width:2.5em;height:2.5em;font:inherit;color:inherit;border-radius:var(--mbx-radius);cursor:pointer;opacity:.9;background:0 0;border:0;flex:none;justify-content:center;align-items:center;padding:0;display:inline-flex;position:relative}[part~=button][aria-label]:after{content:attr(aria-label);display:var(--mbx-tooltip,block);background:var(--mbx-surface);border-radius:var(--mbx-radius);white-space:nowrap;pointer-events:none;opacity:0;margin-bottom:.4615em;padding:.3077em .6154em;font-size:.8125em;transition:opacity .1s;position:absolute;bottom:100%;left:50%;transform:translate(-50%)}[part~=button][aria-label]:focus:after{opacity:1;transition-delay:.4s}[part~=button][aria-label]:focus:not(:focus-visible):after{opacity:0;transition-delay:0s}@media (hover:hover){[part~=button][aria-label]:hover:after{opacity:1;transition-delay:.4s}}:host(:last-child) [part~=button][aria-label]:after{left:auto;right:0;transform:none}[part~=button]:hover{opacity:1}[part~=button]:focus{outline:2px solid var(--mbx-accent);outline-offset:-2px}[part~=button]:focus:not(:focus-visible){outline:none}[part~=icon],::slotted(*){fill:currentColor;width:1.75em;height:1.75em}slot[hidden]{display:none}";
|
|
11
3
|
const SLIDER_STYLE_CSS = ":host{display:block}:host([hidden]){display:none}[part~=slider]{border-radius:var(--mbx-radius);cursor:pointer;touch-action:none;height:2.5em;position:relative}[part~=slider]:focus{outline:2px solid var(--mbx-accent);outline-offset:-2px}[part~=slider]:focus:not(:focus-visible){outline:none}[part~=rail]{position:absolute;top:0;bottom:0;left:.5em;right:.5em}[part~=track]{background:#ffffff59;border-radius:2px;height:.25em;position:absolute;top:50%;left:0;right:0;overflow:hidden;transform:translateY(-50%)}[part~=fill]{background:var(--mbx-accent);position:absolute;top:0;bottom:0;left:0}[part~=thumb]{background:var(--mbx-text);pointer-events:none;border-radius:50%;width:.75em;height:.75em;margin:-.375em 0 0 -.375em;position:absolute;top:50%}";
|
|
12
4
|
const BUTTON_STYLE = BUTTON_STYLE_CSS;
|
|
@@ -50,5 +42,20 @@ function iconSlots(states, fallback) {
|
|
|
50
42
|
function show(slots, state) {
|
|
51
43
|
for (const key of Object.keys(slots)) slots[key].hidden = key !== state;
|
|
52
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* The attributes the player carries while it holds the video in another
|
|
47
|
+
* state than the one shown: `scrubbing` through a drag, `switching` through
|
|
48
|
+
* the load of `switchSource` or a version. Each holds the state from
|
|
49
|
+
* before, `playing` or `paused`.
|
|
50
|
+
*/
|
|
51
|
+
const HELD = ["scrubbing", "switching"];
|
|
52
|
+
/** Whether the controls show the video as paused: the held state, if one of `names` holds it. */
|
|
53
|
+
function shownPaused(player, names = HELD) {
|
|
54
|
+
for (const name of names) {
|
|
55
|
+
const held = player.getAttribute(name);
|
|
56
|
+
if (held !== null) return held === "paused";
|
|
57
|
+
}
|
|
58
|
+
return player.video.paused;
|
|
59
|
+
}
|
|
53
60
|
//#endregion
|
|
54
|
-
export { BUTTON_STYLE, MENU_STYLE, SLIDER_STYLE, iconSlots, number, seekRow, show, style };
|
|
61
|
+
export { BUTTON_STYLE, HELD, MENU_STYLE, SLIDER_STYLE, iconSlots, number, seekRow, show, shownPaused, style };
|