@locpd/vidstack 1.12.14
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/LICENSE +21 -0
- package/README.md +22 -0
- package/analyze.json.d.ts +8 -0
- package/bundle.d.ts +1 -0
- package/cdn/chunks/vidstack-2f5gzOW6.js +1 -0
- package/cdn/chunks/vidstack-BYgY9wmd.js +1 -0
- package/cdn/chunks/vidstack-BfBBPhXV.js +1 -0
- package/cdn/chunks/vidstack-Bjo5esRp.js +1 -0
- package/cdn/chunks/vidstack-BuL67v3q.js +1 -0
- package/cdn/chunks/vidstack-C0msPRTd.js +3 -0
- package/cdn/chunks/vidstack-CJNLoJPa.js +1 -0
- package/cdn/chunks/vidstack-CQSpZ7X8.js +16 -0
- package/cdn/chunks/vidstack-C_AxqLKV.js +1 -0
- package/cdn/chunks/vidstack-CioT3Yw2.js +1 -0
- package/cdn/chunks/vidstack-CrqkytHl.js +1 -0
- package/cdn/chunks/vidstack-D0M8R0ZU.js +1 -0
- package/cdn/chunks/vidstack-D40FSa5B.js +3 -0
- package/cdn/chunks/vidstack-DD2JwFVU.js +1 -0
- package/cdn/chunks/vidstack-DRH_1tFW.js +1 -0
- package/cdn/chunks/vidstack-DfDZuHNP.js +1 -0
- package/cdn/chunks/vidstack-DiNS2Vx5.js +1 -0
- package/cdn/chunks/vidstack-xjJ-ui_l.js +1 -0
- package/cdn/providers/vidstack-audio-2Dt_Ivbp.js +1 -0
- package/cdn/providers/vidstack-dash-CUtD4e6q.js +1 -0
- package/cdn/providers/vidstack-google-cast-BdORATUX.js +1 -0
- package/cdn/providers/vidstack-hls-R25Kb6DP.js +1 -0
- package/cdn/providers/vidstack-html-DaAUJYsD.js +1 -0
- package/cdn/providers/vidstack-video-Csvox7SO.js +1 -0
- package/cdn/providers/vidstack-vimeo-D4Z96kg2.js +1 -0
- package/cdn/providers/vidstack-youtube-DiND6h3s.js +1 -0
- package/cdn/vidstack.js +1 -0
- package/cdn/with-layouts/chunks/vidstack-2f5gzOW6.js +1 -0
- package/cdn/with-layouts/chunks/vidstack-45yH5los.js +1 -0
- package/cdn/with-layouts/chunks/vidstack-BBVMdOnf.js +1 -0
- package/cdn/with-layouts/chunks/vidstack-BB_ulI_T.js +1 -0
- package/cdn/with-layouts/chunks/vidstack-BcAewM33.js +1 -0
- package/cdn/with-layouts/chunks/vidstack-BfBBPhXV.js +1 -0
- package/cdn/with-layouts/chunks/vidstack-Bxv1Qnxe.js +1 -0
- package/cdn/with-layouts/chunks/vidstack-C2ZbG62f.js +3 -0
- package/cdn/with-layouts/chunks/vidstack-CCYIOKgL.js +1 -0
- package/cdn/with-layouts/chunks/vidstack-CL6PeIO1.js +1 -0
- package/cdn/with-layouts/chunks/vidstack-C_AxqLKV.js +1 -0
- package/cdn/with-layouts/chunks/vidstack-CifDkwDH.js +795 -0
- package/cdn/with-layouts/chunks/vidstack-Cry7aD59.js +3 -0
- package/cdn/with-layouts/chunks/vidstack-D065okCn.js +1 -0
- package/cdn/with-layouts/chunks/vidstack-DGuMoXmI.js +1 -0
- package/cdn/with-layouts/chunks/vidstack-DRH_1tFW.js +1 -0
- package/cdn/with-layouts/chunks/vidstack-DVBs1XoQ.js +1 -0
- package/cdn/with-layouts/chunks/vidstack-Dge3KT8k.js +1 -0
- package/cdn/with-layouts/chunks/vidstack-DiNS2Vx5.js +1 -0
- package/cdn/with-layouts/chunks/vidstack-HvYfJoen.js +1 -0
- package/cdn/with-layouts/providers/vidstack-audio-DE5vKIzW.js +1 -0
- package/cdn/with-layouts/providers/vidstack-dash-CA2agUuZ.js +1 -0
- package/cdn/with-layouts/providers/vidstack-google-cast-CGs-t8HM.js +1 -0
- package/cdn/with-layouts/providers/vidstack-hls-BHMbMFFR.js +1 -0
- package/cdn/with-layouts/providers/vidstack-html-Dm9gmNk6.js +1 -0
- package/cdn/with-layouts/providers/vidstack-video-C5it_Lbl.js +1 -0
- package/cdn/with-layouts/providers/vidstack-vimeo-BabLn9sy.js +1 -0
- package/cdn/with-layouts/providers/vidstack-youtube-D8UlccUL.js +1 -0
- package/cdn/with-layouts/vidstack.js +1 -0
- package/dev/chunks/vidstack-B7Zi3v_O.js +104 -0
- package/dev/chunks/vidstack-BFg1ZqiG.js +91 -0
- package/dev/chunks/vidstack-BGB2pa9s.js +58 -0
- package/dev/chunks/vidstack-BaIbHZE3.js +1519 -0
- package/dev/chunks/vidstack-Bb2rASIc.js +5188 -0
- package/dev/chunks/vidstack-Bcmx8pmK.js +224 -0
- package/dev/chunks/vidstack-Bl4b0Nen.js +29 -0
- package/dev/chunks/vidstack-Bo5OTJ06.js +58 -0
- package/dev/chunks/vidstack-BoAGnlRt.js +58 -0
- package/dev/chunks/vidstack-Bpr4fI4n.js +7 -0
- package/dev/chunks/vidstack-Bt8MP2DK.js +204 -0
- package/dev/chunks/vidstack-Bu2kfzUd.js +1637 -0
- package/dev/chunks/vidstack-C-ffXlSV.js +2995 -0
- package/dev/chunks/vidstack-C-ztJq-f.js +109 -0
- package/dev/chunks/vidstack-CFNlaVTR.js +55 -0
- package/dev/chunks/vidstack-C_l97D5j.js +254 -0
- package/dev/chunks/vidstack-CjhKISI0.js +114 -0
- package/dev/chunks/vidstack-CofXIJAy.js +57 -0
- package/dev/chunks/vidstack-CwTj4H1w.js +18 -0
- package/dev/chunks/vidstack-DDwbYVHV.js +66 -0
- package/dev/chunks/vidstack-DFImIcIL.js +11 -0
- package/dev/chunks/vidstack-DGDvUbvO.js +33 -0
- package/dev/chunks/vidstack-DO0kqA99.js +107 -0
- package/dev/chunks/vidstack-DXxIKXmd.js +50 -0
- package/dev/chunks/vidstack-DajrMUR0.js +297 -0
- package/dev/chunks/vidstack-DbBJlz7I.js +10 -0
- package/dev/chunks/vidstack-Dihypf8P.js +11 -0
- package/dev/chunks/vidstack-DlAhl87f.js +1193 -0
- package/dev/chunks/vidstack-Dm1xEU9Q.js +34 -0
- package/dev/chunks/vidstack-Dv_LIPFu.js +14 -0
- package/dev/chunks/vidstack-igYn0Apa.js +254 -0
- package/dev/chunks/vidstack-krOAtKMi.js +32 -0
- package/dev/chunks/vidstack-qh1N5_f_.js +26 -0
- package/dev/chunks/vidstack-rB-wqXw1.js +107 -0
- package/dev/chunks/vidstack-zG6PIeGg.js +66 -0
- package/dev/define/plyr-layout.js +51 -0
- package/dev/define/templates/plyr-layout.js +571 -0
- package/dev/define/templates/vidstack-audio-layout.js +167 -0
- package/dev/define/templates/vidstack-video-layout.js +390 -0
- package/dev/define/vidstack-icons.js +1 -0
- package/dev/define/vidstack-player-default-layout.js +21 -0
- package/dev/define/vidstack-player-layouts.js +25 -0
- package/dev/define/vidstack-player-ui.js +70 -0
- package/dev/define/vidstack-player.js +19 -0
- package/dev/global/plyr.js +501 -0
- package/dev/global/vidstack-player.js +129 -0
- package/dev/providers/vidstack-audio.js +35 -0
- package/dev/providers/vidstack-dash.js +516 -0
- package/dev/providers/vidstack-google-cast.js +474 -0
- package/dev/providers/vidstack-hls.js +408 -0
- package/dev/providers/vidstack-html.js +567 -0
- package/dev/providers/vidstack-video.js +207 -0
- package/dev/providers/vidstack-vimeo.js +554 -0
- package/dev/providers/vidstack-youtube.js +286 -0
- package/dev/vidstack-elements.js +36 -0
- package/dev/vidstack.js +91 -0
- package/dom.d.ts +91 -0
- package/elements.d.ts +1433 -0
- package/empty.vtt +1 -0
- package/global/player.d.ts +52 -0
- package/global/plyr.d.ts +343 -0
- package/google-cast.d.ts +1422 -0
- package/icons.d.ts +1 -0
- package/index.d.ts +402 -0
- package/package.json +199 -0
- package/player/index.d.ts +3 -0
- package/player/layouts/default.d.ts +3 -0
- package/player/layouts/index.d.ts +3 -0
- package/player/layouts/plyr.d.ts +3 -0
- package/player/styles/base.css +153 -0
- package/player/styles/default/buffering.css +55 -0
- package/player/styles/default/buttons.css +175 -0
- package/player/styles/default/captions.css +181 -0
- package/player/styles/default/chapter-title.css +26 -0
- package/player/styles/default/controls.css +56 -0
- package/player/styles/default/gestures.css +19 -0
- package/player/styles/default/icons.css +6 -0
- package/player/styles/default/keyboard.css +148 -0
- package/player/styles/default/layouts/audio.css +417 -0
- package/player/styles/default/layouts/video.css +590 -0
- package/player/styles/default/menus.css +959 -0
- package/player/styles/default/poster.css +52 -0
- package/player/styles/default/sliders.css +391 -0
- package/player/styles/default/theme.css +2461 -0
- package/player/styles/default/thumbnail.css +40 -0
- package/player/styles/default/time.css +45 -0
- package/player/styles/default/tooltips.css +141 -0
- package/player/styles/plyr/theme.css +1237 -0
- package/player/ui.d.ts +3 -0
- package/plugins.d.ts +19 -0
- package/plugins.js +13 -0
- package/prod/chunks/vidstack-B01xzxC4.js +7 -0
- package/prod/chunks/vidstack-BCeb7ryV.js +201 -0
- package/prod/chunks/vidstack-BGSTndAW.js +1590 -0
- package/prod/chunks/vidstack-BPitBBjh.js +1519 -0
- package/prod/chunks/vidstack-BQlOPwOu.js +45 -0
- package/prod/chunks/vidstack-BSDzlwxO.js +4778 -0
- package/prod/chunks/vidstack-BT0m6zEi.js +109 -0
- package/prod/chunks/vidstack-BTigPj2h.js +55 -0
- package/prod/chunks/vidstack-BiyXcJ_M.js +107 -0
- package/prod/chunks/vidstack-BoVf5n1M.js +2985 -0
- package/prod/chunks/vidstack-Bq6c3Bam.js +58 -0
- package/prod/chunks/vidstack-ByLCIBtB.js +297 -0
- package/prod/chunks/vidstack-C2US-gSO.js +248 -0
- package/prod/chunks/vidstack-C9vIqaYT.js +10 -0
- package/prod/chunks/vidstack-CF6fixCQ.js +1193 -0
- package/prod/chunks/vidstack-CTojmhKq.js +66 -0
- package/prod/chunks/vidstack-ChQTHmIQ.js +77 -0
- package/prod/chunks/vidstack-Cm6_unwd.js +246 -0
- package/prod/chunks/vidstack-CwTj4H1w.js +18 -0
- package/prod/chunks/vidstack-D3ltXc3a.js +33 -0
- package/prod/chunks/vidstack-D5EzK014.js +14 -0
- package/prod/chunks/vidstack-DDXt6fpN.js +58 -0
- package/prod/chunks/vidstack-DJDnh4xT.js +11 -0
- package/prod/chunks/vidstack-DXxIKXmd.js +50 -0
- package/prod/chunks/vidstack-D_-9AA6_.js +29 -0
- package/prod/chunks/vidstack-DbkZGjSn.js +107 -0
- package/prod/chunks/vidstack-Dihypf8P.js +11 -0
- package/prod/chunks/vidstack-Dm1xEU9Q.js +34 -0
- package/prod/chunks/vidstack-Dq5Yu0Vr.js +205 -0
- package/prod/chunks/vidstack-DqAw8m9J.js +26 -0
- package/prod/chunks/vidstack-DsPOyKtl.js +57 -0
- package/prod/chunks/vidstack-krOAtKMi.js +32 -0
- package/prod/chunks/vidstack-nLyr4NEP.js +58 -0
- package/prod/chunks/vidstack-xMS8dnYq.js +114 -0
- package/prod/chunks/vidstack-yEGTpgeA.js +104 -0
- package/prod/define/plyr-layout.js +51 -0
- package/prod/define/templates/plyr-layout.js +571 -0
- package/prod/define/templates/vidstack-audio-layout.js +167 -0
- package/prod/define/templates/vidstack-video-layout.js +390 -0
- package/prod/define/vidstack-icons.js +1 -0
- package/prod/define/vidstack-player-default-layout.js +21 -0
- package/prod/define/vidstack-player-layouts.js +25 -0
- package/prod/define/vidstack-player-ui.js +70 -0
- package/prod/define/vidstack-player.js +19 -0
- package/prod/global/plyr.js +493 -0
- package/prod/global/vidstack-player.js +129 -0
- package/prod/providers/vidstack-audio.js +35 -0
- package/prod/providers/vidstack-dash.js +501 -0
- package/prod/providers/vidstack-google-cast.js +468 -0
- package/prod/providers/vidstack-hls.js +393 -0
- package/prod/providers/vidstack-html.js +555 -0
- package/prod/providers/vidstack-video.js +204 -0
- package/prod/providers/vidstack-vimeo.js +548 -0
- package/prod/providers/vidstack-youtube.js +286 -0
- package/prod/vidstack-elements.js +36 -0
- package/prod/vidstack.js +158 -0
- package/server/chunks/vidstack-6juFdkKy.js +29 -0
- package/server/chunks/vidstack-B7iHmv7_.js +307 -0
- package/server/chunks/vidstack-BmxyML9v.js +1619 -0
- package/server/chunks/vidstack-BskfxwD3.js +566 -0
- package/server/chunks/vidstack-BvLV0SMz.js +4642 -0
- package/server/chunks/vidstack-BvWwluXZ.js +205 -0
- package/server/chunks/vidstack-C-413dj2.js +8 -0
- package/server/chunks/vidstack-C26K8z_-.js +55 -0
- package/server/chunks/vidstack-CJJiksDz.js +107 -0
- package/server/chunks/vidstack-CUNv52x1.js +141 -0
- package/server/chunks/vidstack-CqyBCODe.js +295 -0
- package/server/chunks/vidstack-CwTj4H1w.js +18 -0
- package/server/chunks/vidstack-DHAyGSOl.js +1502 -0
- package/server/chunks/vidstack-DLU3cjcp.js +381 -0
- package/server/chunks/vidstack-DXxIKXmd.js +50 -0
- package/server/chunks/vidstack-DbtDXDS2.js +104 -0
- package/server/chunks/vidstack-Dm1xEU9Q.js +34 -0
- package/server/chunks/vidstack-DzTHw_bw.js +207 -0
- package/server/chunks/vidstack-Wn3NH5Sg.js +1566 -0
- package/server/chunks/vidstack-krOAtKMi.js +32 -0
- package/server/chunks/vidstack-wNViAkr4.js +3045 -0
- package/server/define/plyr-layout.js +16 -0
- package/server/define/vidstack-icons.js +1 -0
- package/server/define/vidstack-player-default-layout.js +13 -0
- package/server/define/vidstack-player-layouts.js +16 -0
- package/server/define/vidstack-player-ui.js +11 -0
- package/server/define/vidstack-player.js +6 -0
- package/server/global/plyr.js +322 -0
- package/server/global/vidstack-player.js +58 -0
- package/server/vidstack-elements.js +46 -0
- package/server/vidstack.js +148 -0
- package/tailwind.cjs +101 -0
- package/tailwind.d.cts +15 -0
- package/types/vidstack-BOvzfZjK.d.ts +1269 -0
- package/types/vidstack-Cttpg6GU.d.ts +7474 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { defineCustomElement } from '../chunks/vidstack-Bu2kfzUd.js';
|
|
2
|
+
import { MediaPlayerElement, MediaProviderElement } from '../chunks/vidstack-B7Zi3v_O.js';
|
|
3
|
+
import '../chunks/vidstack-Bb2rASIc.js';
|
|
4
|
+
import '../chunks/vidstack-DFImIcIL.js';
|
|
5
|
+
import '../chunks/vidstack-CjhKISI0.js';
|
|
6
|
+
import '../chunks/vidstack-BFg1ZqiG.js';
|
|
7
|
+
import '../chunks/vidstack-igYn0Apa.js';
|
|
8
|
+
import '../chunks/vidstack-zG6PIeGg.js';
|
|
9
|
+
import '../chunks/vidstack-BGB2pa9s.js';
|
|
10
|
+
import '../chunks/vidstack-Dv_LIPFu.js';
|
|
11
|
+
import '../chunks/vidstack-Bpr4fI4n.js';
|
|
12
|
+
import '../chunks/vidstack-C_l97D5j.js';
|
|
13
|
+
import '@floating-ui/dom';
|
|
14
|
+
import '../chunks/vidstack-DbBJlz7I.js';
|
|
15
|
+
import '../chunks/vidstack-Dihypf8P.js';
|
|
16
|
+
import '../chunks/vidstack-CofXIJAy.js';
|
|
17
|
+
|
|
18
|
+
defineCustomElement(MediaPlayerElement);
|
|
19
|
+
defineCustomElement(MediaProviderElement);
|
|
@@ -0,0 +1,501 @@
|
|
|
1
|
+
import '../define/vidstack-player.js';
|
|
2
|
+
import '../define/plyr-layout.js';
|
|
3
|
+
import { isString, listenEvent, setAttribute, kebabToCamelCase, setStyle, createDisposalBin, isBoolean, DOMEvent } from '../chunks/vidstack-Bu2kfzUd.js';
|
|
4
|
+
import { mediaState, isHTMLAudioElement, isHTMLVideoElement, isHTMLIFrameElement } from '../chunks/vidstack-Bb2rASIc.js';
|
|
5
|
+
import { isHTMLElement } from '../chunks/vidstack-C_l97D5j.js';
|
|
6
|
+
import { canPlayVideoType } from '../chunks/vidstack-CjhKISI0.js';
|
|
7
|
+
import '../chunks/vidstack-B7Zi3v_O.js';
|
|
8
|
+
import '../chunks/vidstack-DFImIcIL.js';
|
|
9
|
+
import '../chunks/vidstack-Bt8MP2DK.js';
|
|
10
|
+
import '../chunks/vidstack-C-ffXlSV.js';
|
|
11
|
+
import '../chunks/vidstack-igYn0Apa.js';
|
|
12
|
+
import '../chunks/vidstack-zG6PIeGg.js';
|
|
13
|
+
import '../chunks/vidstack-BGB2pa9s.js';
|
|
14
|
+
import '../chunks/vidstack-CofXIJAy.js';
|
|
15
|
+
import '../chunks/vidstack-Dihypf8P.js';
|
|
16
|
+
import '../chunks/vidstack-DbBJlz7I.js';
|
|
17
|
+
import '../define/templates/plyr-layout.js';
|
|
18
|
+
import 'lit-html';
|
|
19
|
+
import '../chunks/vidstack-DO0kqA99.js';
|
|
20
|
+
import '../chunks/vidstack-Bcmx8pmK.js';
|
|
21
|
+
import 'lit-html/directives/if-defined.js';
|
|
22
|
+
import 'lit-html/directives/unsafe-svg.js';
|
|
23
|
+
import 'lit-html/async-directive.js';
|
|
24
|
+
import '../chunks/vidstack-CwTj4H1w.js';
|
|
25
|
+
import 'lit-html/directives/unsafe-html.js';
|
|
26
|
+
import '../chunks/vidstack-DGDvUbvO.js';
|
|
27
|
+
import '../chunks/vidstack-rB-wqXw1.js';
|
|
28
|
+
import '../chunks/vidstack-BFg1ZqiG.js';
|
|
29
|
+
import '../chunks/vidstack-Dv_LIPFu.js';
|
|
30
|
+
import '../chunks/vidstack-Bpr4fI4n.js';
|
|
31
|
+
import '@floating-ui/dom';
|
|
32
|
+
|
|
33
|
+
let activePlyr = null, defaults = mediaState.record, forwardedPlayerState = [
|
|
34
|
+
"playing",
|
|
35
|
+
"paused",
|
|
36
|
+
"ended",
|
|
37
|
+
"currentTime",
|
|
38
|
+
"seeking",
|
|
39
|
+
"duration",
|
|
40
|
+
"volume",
|
|
41
|
+
"muted",
|
|
42
|
+
"loop",
|
|
43
|
+
"poster"
|
|
44
|
+
], eventMap = {
|
|
45
|
+
ratechange: "rate-change",
|
|
46
|
+
ready: "can-play",
|
|
47
|
+
timeupdate: "time-update",
|
|
48
|
+
volumechange: "volume-change"
|
|
49
|
+
}, icons = [
|
|
50
|
+
"airplay",
|
|
51
|
+
"captions-off",
|
|
52
|
+
"captions-on",
|
|
53
|
+
"download",
|
|
54
|
+
"enter-fullscreen",
|
|
55
|
+
"exit-fullscreen",
|
|
56
|
+
"fast-forward",
|
|
57
|
+
"muted",
|
|
58
|
+
"pause",
|
|
59
|
+
"pip",
|
|
60
|
+
"play",
|
|
61
|
+
"restart",
|
|
62
|
+
"rewind",
|
|
63
|
+
"settings",
|
|
64
|
+
"volume"
|
|
65
|
+
];
|
|
66
|
+
class Plyr {
|
|
67
|
+
constructor(target, config = {}) {
|
|
68
|
+
this.target = target;
|
|
69
|
+
this.config = config;
|
|
70
|
+
if (isString(target)) {
|
|
71
|
+
target = document.querySelector(target);
|
|
72
|
+
} else if (!isHTMLElement(target)) {
|
|
73
|
+
target = target[0];
|
|
74
|
+
}
|
|
75
|
+
if (!isHTMLElement(target)) {
|
|
76
|
+
throw Error(`[plyr] target must be of type \`HTMLElement\`, found \`${typeof target}\``);
|
|
77
|
+
}
|
|
78
|
+
const dataConfig = target.getAttribute("data-plyr-config");
|
|
79
|
+
if (dataConfig) {
|
|
80
|
+
try {
|
|
81
|
+
config = { ...config, ...JSON.parse(dataConfig) };
|
|
82
|
+
} catch (error) {
|
|
83
|
+
{
|
|
84
|
+
console.error(`[plyr] failed to parse \`data-plyr-config\`
|
|
85
|
+
|
|
86
|
+
`, error);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
const {
|
|
91
|
+
enabled = true,
|
|
92
|
+
debug = "warn" ,
|
|
93
|
+
autoPause = true,
|
|
94
|
+
ratio = null,
|
|
95
|
+
hideControls = true,
|
|
96
|
+
resetOnEnd = false,
|
|
97
|
+
disableContextMenu = true,
|
|
98
|
+
iconUrl = null,
|
|
99
|
+
iconPrefix = "plyr",
|
|
100
|
+
keyboard = { focused: true, global: false },
|
|
101
|
+
i18n = null,
|
|
102
|
+
tracks,
|
|
103
|
+
...props
|
|
104
|
+
} = config;
|
|
105
|
+
this.player = document.createElement("media-player");
|
|
106
|
+
this.provider = document.createElement("media-provider");
|
|
107
|
+
this.layout = document.createElement("media-plyr-layout");
|
|
108
|
+
if (!enabled) return;
|
|
109
|
+
for (const prop of forwardedPlayerState) {
|
|
110
|
+
Object.defineProperty(this, prop, {
|
|
111
|
+
get: () => this.player[prop],
|
|
112
|
+
set: (value) => void (this.player[prop] = value)
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
if (isString(debug)) {
|
|
116
|
+
this.player.logLevel = debug;
|
|
117
|
+
} else if (debug) {
|
|
118
|
+
this.player.logLevel = "warn";
|
|
119
|
+
}
|
|
120
|
+
if (autoPause) {
|
|
121
|
+
this.#disposal.add(listenEvent(this.player, "play", this.#onPlay.bind(this)));
|
|
122
|
+
}
|
|
123
|
+
this.ratio = ratio;
|
|
124
|
+
this.layout.translations = i18n;
|
|
125
|
+
if (!hideControls) {
|
|
126
|
+
this.player.controls.canIdle = false;
|
|
127
|
+
}
|
|
128
|
+
if (resetOnEnd) {
|
|
129
|
+
this.#disposal.add(listenEvent(this.player, "ended", this.#onReset.bind(this)));
|
|
130
|
+
}
|
|
131
|
+
if (iconUrl) {
|
|
132
|
+
this.layout.customIcons = true;
|
|
133
|
+
const id = `sprite-${iconPrefix}`, exists = document.getElementById(id);
|
|
134
|
+
const addIcons = () => {
|
|
135
|
+
for (const icon of icons) {
|
|
136
|
+
const namepsace = "http://www.w3.org/2000/svg";
|
|
137
|
+
const svg = document.createElementNS(namepsace, "svg");
|
|
138
|
+
setAttribute(svg, "fill", "none");
|
|
139
|
+
setAttribute(svg, "slot", `${icon}-icon`);
|
|
140
|
+
setAttribute(svg, "aria-hidden", "true");
|
|
141
|
+
setAttribute(svg, "viewBox", "0 0 18 18");
|
|
142
|
+
const use = document.createElementNS(namepsace, "use");
|
|
143
|
+
use.setAttributeNS("http://www.w3.org/1999/xlink", "href", `#${iconPrefix}-${icon}`);
|
|
144
|
+
svg.append(use);
|
|
145
|
+
this.layout.append(svg);
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
if (!exists) {
|
|
149
|
+
fetch(iconUrl).then((response) => response.text()).then((data) => {
|
|
150
|
+
const container = document.createElement("div");
|
|
151
|
+
setAttribute(container, "id", id);
|
|
152
|
+
setAttribute(container, "hidden", "");
|
|
153
|
+
container.innerHTML = data;
|
|
154
|
+
document.body.insertAdjacentElement("afterbegin", container);
|
|
155
|
+
addIcons();
|
|
156
|
+
}).catch((error) => {
|
|
157
|
+
{
|
|
158
|
+
console.error("[plyr] failed tol oad sprite:\n\n", error);
|
|
159
|
+
}
|
|
160
|
+
this.layout.customIcons = false;
|
|
161
|
+
});
|
|
162
|
+
} else {
|
|
163
|
+
addIcons();
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
if (keyboard.global) {
|
|
167
|
+
this.player.keyTarget = "document";
|
|
168
|
+
} else if (keyboard.focused) {
|
|
169
|
+
this.player.keyTarget = "player";
|
|
170
|
+
} else {
|
|
171
|
+
this.player.keyDisabled = true;
|
|
172
|
+
}
|
|
173
|
+
target.removeAttribute("controls");
|
|
174
|
+
const title = target.getAttribute("title");
|
|
175
|
+
if (title) this.player.setAttribute("title", title);
|
|
176
|
+
const width = target.getAttribute("width"), height = target.getAttribute("height");
|
|
177
|
+
if (width || height) {
|
|
178
|
+
if (width) this.player.style.width = width;
|
|
179
|
+
if (height) this.player.style.height = height;
|
|
180
|
+
this.player.style.aspectRatio = "unset";
|
|
181
|
+
}
|
|
182
|
+
for (const attr of target.attributes) {
|
|
183
|
+
const name = attr.name.replace("data-", ""), propName = kebabToCamelCase(name);
|
|
184
|
+
if (propName in this.player) {
|
|
185
|
+
this.player.setAttribute(name, attr.value);
|
|
186
|
+
} else if (propName in this.layout) {
|
|
187
|
+
this.layout.setAttribute(name, attr.value);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
for (const [prop, value] of Object.entries(props)) {
|
|
191
|
+
if (prop in this.player) {
|
|
192
|
+
this.player[prop] = value;
|
|
193
|
+
} else if (prop in this.layout) {
|
|
194
|
+
this.layout[prop] = value;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
if (tracks) {
|
|
198
|
+
for (const track of tracks) this.player.textTracks.add(track);
|
|
199
|
+
}
|
|
200
|
+
this.player.append(this.provider, this.layout);
|
|
201
|
+
const isTargetContainer = !isHTMLAudioElement(target) && !isHTMLVideoElement(target) && !isHTMLIFrameElement(target);
|
|
202
|
+
if (isTargetContainer) {
|
|
203
|
+
target.append(this.player);
|
|
204
|
+
} else {
|
|
205
|
+
for (const child of [...target.children]) this.provider.append(child);
|
|
206
|
+
target.replaceWith(this.player);
|
|
207
|
+
}
|
|
208
|
+
const embedProvider = target.getAttribute("data-plyr-provider"), embedId = target.getAttribute("data-plyr-embed-id");
|
|
209
|
+
if (embedProvider && /youtube|vimeo/.test(embedProvider) && embedId) {
|
|
210
|
+
this.player.src = `${embedProvider}/${embedId}`;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
static setup(targets, config) {
|
|
214
|
+
if (isString(targets)) {
|
|
215
|
+
targets = document.querySelectorAll(targets);
|
|
216
|
+
}
|
|
217
|
+
return [...targets].map((target) => new Plyr(target, config));
|
|
218
|
+
}
|
|
219
|
+
static supported(type, provider) {
|
|
220
|
+
return true;
|
|
221
|
+
}
|
|
222
|
+
player;
|
|
223
|
+
provider;
|
|
224
|
+
layout;
|
|
225
|
+
fullscreen = new PlyrFullscreenAdapter(this);
|
|
226
|
+
// These are only included for type defs, props are defined in constructor.
|
|
227
|
+
playing = defaults.playing;
|
|
228
|
+
paused = defaults.paused;
|
|
229
|
+
ended = defaults.ended;
|
|
230
|
+
currentTime = defaults.currentTime;
|
|
231
|
+
seeking = defaults.seeking;
|
|
232
|
+
duration = defaults.duration;
|
|
233
|
+
volume = defaults.volume;
|
|
234
|
+
muted = defaults.muted;
|
|
235
|
+
loop = defaults.loop;
|
|
236
|
+
poster = defaults.poster;
|
|
237
|
+
get type() {
|
|
238
|
+
return this.player.provider?.type ?? "";
|
|
239
|
+
}
|
|
240
|
+
get isHTML5() {
|
|
241
|
+
return /audio|video|hls/.test(this.type);
|
|
242
|
+
}
|
|
243
|
+
get isEmbed() {
|
|
244
|
+
return /youtube|vimeo/.test(this.type);
|
|
245
|
+
}
|
|
246
|
+
get buffered() {
|
|
247
|
+
const { bufferedEnd, seekableEnd } = this.player.state;
|
|
248
|
+
return seekableEnd > 0 ? bufferedEnd / seekableEnd : 0;
|
|
249
|
+
}
|
|
250
|
+
get stopped() {
|
|
251
|
+
return this.paused && this.currentTime === 0;
|
|
252
|
+
}
|
|
253
|
+
get hasAudio() {
|
|
254
|
+
if (!this.isHTML5) return true;
|
|
255
|
+
const media = this.player.provider.media;
|
|
256
|
+
return Boolean(
|
|
257
|
+
media.mozHasAudio || media.webkitAudioDecodedByteCount || media.audioTracks?.length || this.player.audioTracks.length
|
|
258
|
+
);
|
|
259
|
+
}
|
|
260
|
+
get speed() {
|
|
261
|
+
return this.player.playbackRate;
|
|
262
|
+
}
|
|
263
|
+
set speed(speed) {
|
|
264
|
+
this.player.remoteControl.changePlaybackRate(speed);
|
|
265
|
+
}
|
|
266
|
+
get currentTrack() {
|
|
267
|
+
return this.player.textTracks.selectedIndex;
|
|
268
|
+
}
|
|
269
|
+
set currentTrack(index) {
|
|
270
|
+
this.player.remoteControl.changeTextTrackMode(index, "showing");
|
|
271
|
+
}
|
|
272
|
+
get pip() {
|
|
273
|
+
return this.player.state.pictureInPicture;
|
|
274
|
+
}
|
|
275
|
+
set pip(isActive) {
|
|
276
|
+
if (isActive) this.player.enterPictureInPicture();
|
|
277
|
+
else this.player.exitPictureInPicture();
|
|
278
|
+
}
|
|
279
|
+
get quality() {
|
|
280
|
+
return this.player.state.quality?.height ?? null;
|
|
281
|
+
}
|
|
282
|
+
set quality(value) {
|
|
283
|
+
let qualities = this.player.qualities, index = -1;
|
|
284
|
+
if (value !== null) {
|
|
285
|
+
let minScore = Infinity;
|
|
286
|
+
for (let i = 0; i < qualities.length; i++) {
|
|
287
|
+
const score = Math.abs(qualities[i].height - value);
|
|
288
|
+
if (score < minScore) {
|
|
289
|
+
index = i;
|
|
290
|
+
minScore = score;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
this.player.remoteControl.changeQuality(index);
|
|
295
|
+
}
|
|
296
|
+
#source = null;
|
|
297
|
+
get source() {
|
|
298
|
+
return this.#source;
|
|
299
|
+
}
|
|
300
|
+
set source(source) {
|
|
301
|
+
const {
|
|
302
|
+
type: viewType = "video",
|
|
303
|
+
sources = "",
|
|
304
|
+
title = "",
|
|
305
|
+
poster = "",
|
|
306
|
+
thumbnails = "",
|
|
307
|
+
tracks = []
|
|
308
|
+
} = source ?? {};
|
|
309
|
+
this.player.src = sources;
|
|
310
|
+
this.player.viewType = viewType;
|
|
311
|
+
this.player.title = title;
|
|
312
|
+
this.player.poster = poster;
|
|
313
|
+
this.layout.thumbnails = thumbnails;
|
|
314
|
+
this.player.textTracks.clear();
|
|
315
|
+
for (const track of tracks) this.player.textTracks.add(track);
|
|
316
|
+
this.#source = source;
|
|
317
|
+
}
|
|
318
|
+
#ratio = null;
|
|
319
|
+
get ratio() {
|
|
320
|
+
return this.#ratio;
|
|
321
|
+
}
|
|
322
|
+
set ratio(ratio) {
|
|
323
|
+
if (ratio) ratio = ratio.replace(/\s*:\s*/, " / ");
|
|
324
|
+
setStyle(this.player, "aspect-ratio", ratio ?? "unset");
|
|
325
|
+
this.#ratio = ratio;
|
|
326
|
+
}
|
|
327
|
+
get download() {
|
|
328
|
+
return this.layout.download;
|
|
329
|
+
}
|
|
330
|
+
set download(download) {
|
|
331
|
+
this.layout.download = download;
|
|
332
|
+
}
|
|
333
|
+
#disposal = createDisposalBin();
|
|
334
|
+
#onPlay() {
|
|
335
|
+
if (activePlyr !== this) activePlyr?.pause();
|
|
336
|
+
activePlyr = this;
|
|
337
|
+
}
|
|
338
|
+
#onReset() {
|
|
339
|
+
this.currentTime = 0;
|
|
340
|
+
this.paused = true;
|
|
341
|
+
}
|
|
342
|
+
play() {
|
|
343
|
+
return this.player.play();
|
|
344
|
+
}
|
|
345
|
+
pause() {
|
|
346
|
+
return this.player.pause();
|
|
347
|
+
}
|
|
348
|
+
togglePlay(toggle = this.paused) {
|
|
349
|
+
if (toggle) {
|
|
350
|
+
return this.player.play();
|
|
351
|
+
} else {
|
|
352
|
+
return this.player.pause();
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
toggleCaptions(toggle = !this.player.textTracks.selected) {
|
|
356
|
+
const controller = this.player.remoteControl;
|
|
357
|
+
if (toggle) {
|
|
358
|
+
controller.showCaptions();
|
|
359
|
+
} else {
|
|
360
|
+
controller.disableCaptions();
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
toggleControls(toggle = !this.player.controls.showing) {
|
|
364
|
+
const controls = this.player.controls;
|
|
365
|
+
if (toggle) {
|
|
366
|
+
controls.show();
|
|
367
|
+
} else {
|
|
368
|
+
controls.hide();
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
restart() {
|
|
372
|
+
this.currentTime = 0;
|
|
373
|
+
}
|
|
374
|
+
stop() {
|
|
375
|
+
this.pause();
|
|
376
|
+
this.player.currentTime = 0;
|
|
377
|
+
}
|
|
378
|
+
forward(seekTime = this.config.seekTime ?? 10) {
|
|
379
|
+
this.currentTime += seekTime;
|
|
380
|
+
}
|
|
381
|
+
rewind(seekTime = this.config.seekTime ?? 10) {
|
|
382
|
+
this.currentTime -= seekTime;
|
|
383
|
+
}
|
|
384
|
+
increaseVolume(step = 5) {
|
|
385
|
+
this.volume += step;
|
|
386
|
+
}
|
|
387
|
+
decreaseVolume(step = 5) {
|
|
388
|
+
this.volume -= step;
|
|
389
|
+
}
|
|
390
|
+
airplay() {
|
|
391
|
+
return this.player.requestAirPlay();
|
|
392
|
+
}
|
|
393
|
+
on(type, callback) {
|
|
394
|
+
this.#listen(type, callback);
|
|
395
|
+
}
|
|
396
|
+
once(type, callback) {
|
|
397
|
+
this.#listen(type, callback, { once: true });
|
|
398
|
+
}
|
|
399
|
+
off(type, callback) {
|
|
400
|
+
this.#listen(type, callback, { remove: true });
|
|
401
|
+
}
|
|
402
|
+
#listeners = [];
|
|
403
|
+
#listen(type, callback, options = {}) {
|
|
404
|
+
let eventType = type, toggle = null;
|
|
405
|
+
switch (type) {
|
|
406
|
+
case "captionsenabled":
|
|
407
|
+
case "captionsdisabled":
|
|
408
|
+
eventType = "text-track-change";
|
|
409
|
+
toggle = type === "captionsenabled";
|
|
410
|
+
break;
|
|
411
|
+
case "controlsshown":
|
|
412
|
+
case "controlshidden":
|
|
413
|
+
eventType = "controls-change";
|
|
414
|
+
toggle = type === "controlsshown";
|
|
415
|
+
break;
|
|
416
|
+
case "enterfullscreen":
|
|
417
|
+
case "exitfullscreen":
|
|
418
|
+
eventType = "fullscreen-change";
|
|
419
|
+
toggle = type === "enterfullscreen";
|
|
420
|
+
break;
|
|
421
|
+
}
|
|
422
|
+
const mappedEventType = eventMap[eventType] ?? eventType;
|
|
423
|
+
const listener = (event) => {
|
|
424
|
+
if (isBoolean(toggle) && !!event.detail !== toggle) return;
|
|
425
|
+
if (mappedEventType !== type) {
|
|
426
|
+
callback(new DOMEvent(type, { ...event, trigger: event }));
|
|
427
|
+
return;
|
|
428
|
+
}
|
|
429
|
+
callback(event);
|
|
430
|
+
};
|
|
431
|
+
if (options.remove) {
|
|
432
|
+
let index = -1;
|
|
433
|
+
do {
|
|
434
|
+
index = this.#listeners.findIndex((t) => t.type === type && t.callback === callback);
|
|
435
|
+
if (index >= 0) {
|
|
436
|
+
const { listener: listener2 } = this.#listeners[index];
|
|
437
|
+
this.player.removeEventListener(mappedEventType, listener2);
|
|
438
|
+
this.#listeners.splice(index, 1);
|
|
439
|
+
}
|
|
440
|
+
} while (index >= 0);
|
|
441
|
+
} else {
|
|
442
|
+
this.#listeners.push({ type, callback, listener });
|
|
443
|
+
this.player.addEventListener(mappedEventType, listener, { once: options.once });
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
supports(type) {
|
|
447
|
+
return !!type && canPlayVideoType(null, type);
|
|
448
|
+
}
|
|
449
|
+
destroy() {
|
|
450
|
+
for (const { type, listener } of this.#listeners) {
|
|
451
|
+
this.player.removeEventListener(eventMap[type] ?? type, listener);
|
|
452
|
+
}
|
|
453
|
+
this.#source = null;
|
|
454
|
+
this.#listeners.length = 0;
|
|
455
|
+
if (activePlyr === this) activePlyr = null;
|
|
456
|
+
this.#disposal.empty();
|
|
457
|
+
this.player.destroy();
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
class PlyrFullscreenAdapter {
|
|
461
|
+
#plyr;
|
|
462
|
+
constructor(plyr) {
|
|
463
|
+
this.#plyr = plyr;
|
|
464
|
+
}
|
|
465
|
+
get #player() {
|
|
466
|
+
return this.#plyr.player;
|
|
467
|
+
}
|
|
468
|
+
/**
|
|
469
|
+
* Returns a boolean indicating if the current player has fullscreen enabled.
|
|
470
|
+
*/
|
|
471
|
+
get enabled() {
|
|
472
|
+
return this.#player.state.canFullscreen;
|
|
473
|
+
}
|
|
474
|
+
/**
|
|
475
|
+
* Returns a boolean indicating if the current player is in fullscreen mode.
|
|
476
|
+
*/
|
|
477
|
+
get active() {
|
|
478
|
+
return this.#player.state.fullscreen;
|
|
479
|
+
}
|
|
480
|
+
/**
|
|
481
|
+
* Request to enter fullscreen.
|
|
482
|
+
*/
|
|
483
|
+
enter() {
|
|
484
|
+
return this.#player.requestFullscreen();
|
|
485
|
+
}
|
|
486
|
+
/**
|
|
487
|
+
* Request to exit fullscreen.
|
|
488
|
+
*/
|
|
489
|
+
exit() {
|
|
490
|
+
return this.#player.exitFullscreen();
|
|
491
|
+
}
|
|
492
|
+
/**
|
|
493
|
+
* Request to toggle fullscreen.
|
|
494
|
+
*/
|
|
495
|
+
toggle() {
|
|
496
|
+
if (this.active) return this.exit();
|
|
497
|
+
else return this.enter();
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
export { Plyr, PlyrFullscreenAdapter };
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import '../define/vidstack-player.js';
|
|
2
|
+
import { isString, defineCustomElement, kebabToCamelCase } from '../chunks/vidstack-Bu2kfzUd.js';
|
|
3
|
+
import { isHTMLAudioElement, isHTMLVideoElement, isHTMLIFrameElement } from '../chunks/vidstack-Bb2rASIc.js';
|
|
4
|
+
import { isHTMLElement } from '../chunks/vidstack-C_l97D5j.js';
|
|
5
|
+
import '../chunks/vidstack-B7Zi3v_O.js';
|
|
6
|
+
import '../chunks/vidstack-DFImIcIL.js';
|
|
7
|
+
import '../chunks/vidstack-CjhKISI0.js';
|
|
8
|
+
import '../chunks/vidstack-BFg1ZqiG.js';
|
|
9
|
+
import '../chunks/vidstack-igYn0Apa.js';
|
|
10
|
+
import '../chunks/vidstack-zG6PIeGg.js';
|
|
11
|
+
import '../chunks/vidstack-BGB2pa9s.js';
|
|
12
|
+
import '../chunks/vidstack-Dv_LIPFu.js';
|
|
13
|
+
import '../chunks/vidstack-Bpr4fI4n.js';
|
|
14
|
+
import '@floating-ui/dom';
|
|
15
|
+
import '../chunks/vidstack-DbBJlz7I.js';
|
|
16
|
+
import '../chunks/vidstack-Dihypf8P.js';
|
|
17
|
+
import '../chunks/vidstack-CofXIJAy.js';
|
|
18
|
+
|
|
19
|
+
class VidstackPlayerLayout {
|
|
20
|
+
constructor(props) {
|
|
21
|
+
this.props = props;
|
|
22
|
+
}
|
|
23
|
+
name = "vidstack";
|
|
24
|
+
async load() {
|
|
25
|
+
await import('../define/vidstack-player-default-layout.js');
|
|
26
|
+
await import('../define/vidstack-player-ui.js');
|
|
27
|
+
}
|
|
28
|
+
create() {
|
|
29
|
+
const layouts = [
|
|
30
|
+
document.createElement("media-audio-layout"),
|
|
31
|
+
document.createElement("media-video-layout")
|
|
32
|
+
];
|
|
33
|
+
if (this.props) {
|
|
34
|
+
for (const [prop, value] of Object.entries(this.props)) {
|
|
35
|
+
for (const el of layouts) el[prop] = value;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return layouts;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
class PlyrLayout {
|
|
43
|
+
constructor(props) {
|
|
44
|
+
this.props = props;
|
|
45
|
+
}
|
|
46
|
+
name = "plyr";
|
|
47
|
+
async load() {
|
|
48
|
+
await import('../define/plyr-layout.js');
|
|
49
|
+
}
|
|
50
|
+
create() {
|
|
51
|
+
const layout = document.createElement("media-plyr-layout");
|
|
52
|
+
if (this.props) {
|
|
53
|
+
for (const [prop, value] of Object.entries(this.props)) {
|
|
54
|
+
layout[prop] = value;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return [layout];
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const LAYOUT_LOADED = Symbol();
|
|
62
|
+
class VidstackPlayer {
|
|
63
|
+
static async create({ target, layout, tracks, ...props }) {
|
|
64
|
+
if (isString(target)) {
|
|
65
|
+
target = document.querySelector(target);
|
|
66
|
+
}
|
|
67
|
+
if (!isHTMLElement(target)) {
|
|
68
|
+
throw Error(`[vidstack] target must be of type \`HTMLElement\`, found \`${typeof target}\``);
|
|
69
|
+
}
|
|
70
|
+
let player = document.createElement("media-player"), provider = document.createElement("media-provider"), layouts, isTargetContainer = !isHTMLAudioElement(target) && !isHTMLVideoElement(target) && !isHTMLIFrameElement(target);
|
|
71
|
+
player.setAttribute("keep-alive", "");
|
|
72
|
+
if (props.poster && layout?.name !== "plyr") {
|
|
73
|
+
if (!customElements.get("media-poster")) {
|
|
74
|
+
const { MediaPosterElement } = await import('../chunks/vidstack-DGDvUbvO.js');
|
|
75
|
+
defineCustomElement(MediaPosterElement);
|
|
76
|
+
}
|
|
77
|
+
const poster = document.createElement("media-poster");
|
|
78
|
+
if (layout?.name === "vidstack") poster.classList.add("vds-poster");
|
|
79
|
+
provider.append(poster);
|
|
80
|
+
}
|
|
81
|
+
if (layout) {
|
|
82
|
+
target.removeAttribute("controls");
|
|
83
|
+
if (!layout[LAYOUT_LOADED]) {
|
|
84
|
+
await layout.load();
|
|
85
|
+
layout[LAYOUT_LOADED] = true;
|
|
86
|
+
}
|
|
87
|
+
layouts = await layout.create();
|
|
88
|
+
}
|
|
89
|
+
const title = target.getAttribute("title");
|
|
90
|
+
if (title) player.setAttribute("title", title);
|
|
91
|
+
const width = target.getAttribute("width"), height = target.getAttribute("height");
|
|
92
|
+
if (width || height) {
|
|
93
|
+
if (width) player.style.width = width;
|
|
94
|
+
if (height) player.style.height = height;
|
|
95
|
+
player.style.aspectRatio = "unset";
|
|
96
|
+
}
|
|
97
|
+
for (const attr of target.attributes) {
|
|
98
|
+
const name = attr.name.replace("data-", ""), propName = kebabToCamelCase(name);
|
|
99
|
+
if (propName in player) {
|
|
100
|
+
player.setAttribute(name, attr.value);
|
|
101
|
+
} else if (layouts?.length) {
|
|
102
|
+
for (const layout2 of layouts) {
|
|
103
|
+
if (propName in layout2) {
|
|
104
|
+
layout2.setAttribute(name, attr.value);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
for (const [prop, value] of Object.entries(props)) {
|
|
110
|
+
player[prop] = value;
|
|
111
|
+
}
|
|
112
|
+
if (tracks) {
|
|
113
|
+
for (const track of tracks) player.textTracks.add(track);
|
|
114
|
+
}
|
|
115
|
+
player.append(provider);
|
|
116
|
+
if (layouts) {
|
|
117
|
+
for (const layout2 of layouts) player.append(layout2);
|
|
118
|
+
}
|
|
119
|
+
if (isTargetContainer) {
|
|
120
|
+
target.append(player);
|
|
121
|
+
} else {
|
|
122
|
+
for (const child of [...target.children]) provider.append(child);
|
|
123
|
+
target.replaceWith(player);
|
|
124
|
+
}
|
|
125
|
+
return player;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export { PlyrLayout, VidstackPlayer, VidstackPlayerLayout };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { scoped } from '../chunks/vidstack-Bu2kfzUd.js';
|
|
2
|
+
import { HTMLMediaProvider } from './vidstack-html.js';
|
|
3
|
+
import { HTMLAirPlayAdapter } from '../chunks/vidstack-Bo5OTJ06.js';
|
|
4
|
+
import '../chunks/vidstack-CjhKISI0.js';
|
|
5
|
+
import '../chunks/vidstack-qh1N5_f_.js';
|
|
6
|
+
import '../chunks/vidstack-Dihypf8P.js';
|
|
7
|
+
import '../chunks/vidstack-Dv_LIPFu.js';
|
|
8
|
+
|
|
9
|
+
class AudioProvider extends HTMLMediaProvider {
|
|
10
|
+
$$PROVIDER_TYPE = "AUDIO";
|
|
11
|
+
get type() {
|
|
12
|
+
return "audio";
|
|
13
|
+
}
|
|
14
|
+
airPlay;
|
|
15
|
+
constructor(audio, ctx) {
|
|
16
|
+
super(audio, ctx);
|
|
17
|
+
scoped(() => {
|
|
18
|
+
this.airPlay = new HTMLAirPlayAdapter(this.media, ctx);
|
|
19
|
+
}, this.scope);
|
|
20
|
+
}
|
|
21
|
+
setup() {
|
|
22
|
+
super.setup();
|
|
23
|
+
if (this.type === "audio") this.ctx.notify("provider-setup", this);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* The native HTML `<audio>` element.
|
|
27
|
+
*
|
|
28
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLAudioElement}
|
|
29
|
+
*/
|
|
30
|
+
get audio() {
|
|
31
|
+
return this.media;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export { AudioProvider };
|