@hanifhan1f/vidstack 1.12.19 → 1.12.25
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/cdn/chunks/vidstack-BBMfnVvt.js +1 -0
- package/cdn/chunks/vidstack-BF7lZRtq.js +3 -0
- package/cdn/chunks/vidstack-BYpysj84.js +1 -0
- package/cdn/chunks/vidstack-BkxGdzTJ.js +16 -0
- package/cdn/chunks/vidstack-Bzk6lVKb.js +1 -0
- package/cdn/chunks/vidstack-C0nMUcD9.js +1 -0
- package/cdn/chunks/vidstack-C1FlyyzK.js +1 -0
- package/cdn/chunks/vidstack-C51SKMUl.js +1 -0
- package/cdn/chunks/vidstack-CL95Hezv.js +1 -0
- package/cdn/chunks/vidstack-Cj0I-Rec.js +1 -0
- package/cdn/chunks/vidstack-CkaxOIJb.js +1 -0
- package/cdn/chunks/vidstack-Cu8FqSS9.js +1 -0
- package/cdn/chunks/vidstack-D84Fzc__.js +16 -0
- package/cdn/chunks/vidstack-DIPX97sJ.js +3 -0
- package/cdn/chunks/vidstack-DQvyz7Mm.js +1 -0
- package/cdn/chunks/vidstack-Dd9fqVv6.js +1 -0
- package/cdn/chunks/vidstack-DdAmWWBJ.js +1 -0
- package/cdn/chunks/vidstack-DhXI_0ND.js +1 -0
- package/cdn/chunks/vidstack-DiXE5sG8.js +1 -0
- package/cdn/chunks/vidstack-pFwe7gvT.js +3 -0
- package/cdn/chunks/vidstack-uMxrPflF.js +1 -0
- package/cdn/chunks/vidstack-zemsqC5d.js +1 -0
- package/cdn/providers/vidstack-audio-BAfEe7CJ.js +1 -0
- package/cdn/providers/vidstack-audio-BOGYlExy.js +1 -0
- package/cdn/providers/vidstack-dash-CGZUJqdT.js +1 -0
- package/cdn/providers/vidstack-dash-D4ZARr66.js +1 -0
- package/cdn/providers/vidstack-google-cast-Drb5Ncs5.js +1 -0
- package/cdn/providers/vidstack-hls-8-552IuX.js +1 -0
- package/cdn/providers/vidstack-hls-CVpa4usG.js +1 -0
- package/cdn/providers/vidstack-html-Bag27bH6.js +1 -0
- package/cdn/providers/vidstack-html-BvVaN2VT.js +1 -0
- package/cdn/providers/vidstack-video-BnwQZKER.js +1 -0
- package/cdn/providers/vidstack-video-DXUiSn4B.js +1 -0
- package/cdn/providers/vidstack-vimeo-DD6HUOtJ.js +1 -0
- package/cdn/providers/vidstack-vimeo-gJmBqtLK.js +1 -0
- package/cdn/providers/vidstack-youtube-BVNE075s.js +1 -0
- package/cdn/providers/vidstack-youtube-Chl_dTAz.js +1 -0
- package/cdn/vidstack.js +1 -1
- package/cdn/with-layouts/chunks/vidstack-2Rlth5Cf.js +1 -0
- package/cdn/with-layouts/chunks/vidstack-4liSokT6.js +1 -0
- package/cdn/with-layouts/chunks/vidstack-B97B8XDc.js +3 -0
- package/cdn/with-layouts/chunks/vidstack-BP3ybDy9.js +912 -0
- package/cdn/with-layouts/chunks/vidstack-BaNApRCP.js +1 -0
- package/cdn/with-layouts/chunks/vidstack-BbFHhcVG.js +1 -0
- package/cdn/with-layouts/chunks/vidstack-BlWKO1g1.js +1 -0
- package/cdn/with-layouts/chunks/vidstack-BxJPOhv7.js +1 -0
- package/cdn/with-layouts/chunks/vidstack-BxdAdQ0H.js +1 -0
- package/cdn/with-layouts/chunks/vidstack-CROJF16Z.js +1 -0
- package/cdn/with-layouts/chunks/vidstack-CXEcXyBI.js +1 -0
- package/cdn/with-layouts/chunks/vidstack-CaW6KGwN.js +1 -0
- package/cdn/with-layouts/chunks/vidstack-Ciq-n5rg.js +1 -0
- package/cdn/with-layouts/chunks/vidstack-CmuGllcj.js +1 -0
- package/cdn/with-layouts/chunks/vidstack-CwzW7rJU.js +1 -0
- package/cdn/with-layouts/chunks/vidstack-CyNByJUW.js +912 -0
- package/cdn/with-layouts/chunks/vidstack-DJyGEdCH.js +1 -0
- package/cdn/with-layouts/chunks/vidstack-DeLOZ-hK.js +3 -0
- package/cdn/with-layouts/chunks/vidstack-DhNpv7SU.js +1 -0
- package/cdn/with-layouts/chunks/vidstack-Dp3Ib32P.js +1 -0
- package/cdn/with-layouts/chunks/vidstack-Dy1Hfo7P.js +3 -0
- package/cdn/with-layouts/providers/vidstack-audio-CwoQJvl2.js +1 -0
- package/cdn/with-layouts/providers/vidstack-audio-cxaZF4jF.js +1 -0
- package/cdn/with-layouts/providers/vidstack-dash-CJsKJfLI.js +1 -0
- package/cdn/with-layouts/providers/vidstack-dash-DX1VjdTW.js +1 -0
- package/cdn/with-layouts/providers/vidstack-google-cast-DYJgNlvD.js +1 -0
- package/cdn/with-layouts/providers/vidstack-hls-2d6-2JAG.js +1 -0
- package/cdn/with-layouts/providers/vidstack-hls-ji26kFdQ.js +1 -0
- package/cdn/with-layouts/providers/vidstack-html-BvHMxtoe.js +1 -0
- package/cdn/with-layouts/providers/vidstack-html-C9nnuK3r.js +1 -0
- package/cdn/with-layouts/providers/vidstack-video-1Uj5cNP2.js +1 -0
- package/cdn/with-layouts/providers/vidstack-video-EWE67g5i.js +1 -0
- package/cdn/with-layouts/providers/vidstack-vimeo-DACTbJaQ.js +1 -0
- package/cdn/with-layouts/providers/vidstack-vimeo-DqFeS0-d.js +1 -0
- package/cdn/with-layouts/providers/vidstack-youtube-RoLp-I6u.js +1 -0
- package/cdn/with-layouts/providers/vidstack-youtube-eivIFfMV.js +1 -0
- package/cdn/with-layouts/vidstack.js +1 -1
- package/dev/chunks/vidstack-0XhA3AD_.js +5181 -0
- package/dev/chunks/vidstack-44ILR0Cb.js +1521 -0
- package/dev/chunks/vidstack-5oWWZmVl.js +58 -0
- package/dev/chunks/vidstack-B4XOm7dP.js +104 -0
- package/dev/chunks/vidstack-BnBLcaA5.js +115 -0
- package/dev/chunks/vidstack-Bo8BNFJ2.js +2986 -0
- package/dev/chunks/vidstack-C3N4zIuV.js +254 -0
- package/dev/chunks/vidstack-CAL4iu_K.js +1482 -0
- package/dev/chunks/vidstack-CEjYxSqZ.js +297 -0
- package/dev/chunks/vidstack-CGyAjz8G.js +58 -0
- package/dev/chunks/vidstack-CJCnHmKE.js +104 -0
- package/dev/chunks/vidstack-CQdFhXSo.js +204 -0
- package/dev/chunks/vidstack-CzCQJ29U.js +107 -0
- package/dev/chunks/vidstack-DD_3HszA.js +1520 -0
- package/dev/chunks/vidstack-DV4g4XvL.js +33 -0
- package/dev/chunks/vidstack-DWtK42Sh.js +1483 -0
- package/dev/chunks/vidstack-D_LvMxPr.js +204 -0
- package/dev/chunks/vidstack-DdTXMZro.js +66 -0
- package/dev/chunks/vidstack-DrczgsqN.js +297 -0
- package/dev/chunks/vidstack-el2dbO0m.js +5181 -0
- package/dev/chunks/vidstack-gF_qqvCK.js +109 -0
- package/dev/chunks/vidstack-rvhuswgi.js +2986 -0
- package/dev/define/plyr-layout.js +7 -7
- package/dev/define/templates/plyr-layout.js +2 -2
- package/dev/define/templates/vidstack-audio-layout.js +3 -3
- package/dev/define/templates/vidstack-video-layout.js +7 -9
- package/dev/define/vidstack-player-default-layout.js +3 -3
- package/dev/define/vidstack-player-layouts.js +3 -3
- package/dev/define/vidstack-player-ui.js +9 -9
- package/dev/define/vidstack-player.js +5 -5
- package/dev/global/plyr.js +9 -9
- package/dev/global/vidstack-player.js +6 -6
- package/dev/providers/vidstack-audio.js +2 -2
- package/dev/providers/vidstack-dash.js +4 -4
- package/dev/providers/vidstack-hls.js +4 -4
- package/dev/providers/vidstack-html.js +1 -1
- package/dev/providers/vidstack-video.js +4 -4
- package/dev/providers/vidstack-vimeo.js +4 -4
- package/dev/providers/vidstack-youtube.js +3 -3
- package/dev/vidstack-elements.js +12 -12
- package/dev/vidstack.js +9 -9
- package/package.json +1 -1
- package/player/styles/default/layouts/video.css +113 -79
- package/prod/chunks/vidstack-BAqdCFIm.js +4771 -0
- package/prod/chunks/vidstack-BRnfTkxi.js +297 -0
- package/prod/chunks/vidstack-BexQYZop.js +2976 -0
- package/prod/chunks/vidstack-Bf1Q6kqO.js +109 -0
- package/prod/chunks/vidstack-Bn9yLryd.js +58 -0
- package/prod/chunks/vidstack-C-yd_bAJ.js +4771 -0
- package/prod/chunks/vidstack-C4PTiuot.js +107 -0
- package/prod/chunks/vidstack-Cs0fH84E.js +1521 -0
- package/prod/chunks/vidstack-DDePVDjt.js +2976 -0
- package/prod/chunks/vidstack-DMDDSV3t.js +104 -0
- package/prod/chunks/vidstack-DXfGRhxZ.js +201 -0
- package/prod/chunks/vidstack-Dg71uhRc.js +58 -0
- package/prod/chunks/vidstack-DlLwMLBL.js +33 -0
- package/prod/chunks/vidstack-DnRxQoqP.js +104 -0
- package/prod/chunks/vidstack-KShKSmYu.js +66 -0
- package/prod/chunks/vidstack-Ko2EJadT.js +1483 -0
- package/prod/chunks/vidstack-ShUhyBfI.js +201 -0
- package/prod/chunks/vidstack-V9U6gsde.js +1482 -0
- package/prod/chunks/vidstack-XA3zT5W9.js +297 -0
- package/prod/chunks/vidstack-kdaDngIm.js +1520 -0
- package/prod/chunks/vidstack-oNEzlviH.js +246 -0
- package/prod/chunks/vidstack-wTTCvdqe.js +115 -0
- package/prod/define/plyr-layout.js +7 -7
- package/prod/define/templates/plyr-layout.js +2 -2
- package/prod/define/templates/vidstack-audio-layout.js +3 -3
- package/prod/define/templates/vidstack-video-layout.js +7 -9
- package/prod/define/vidstack-player-default-layout.js +3 -3
- package/prod/define/vidstack-player-layouts.js +3 -3
- package/prod/define/vidstack-player-ui.js +9 -9
- package/prod/define/vidstack-player.js +5 -5
- package/prod/global/plyr.js +9 -9
- package/prod/global/vidstack-player.js +6 -6
- package/prod/providers/vidstack-audio.js +2 -2
- package/prod/providers/vidstack-dash.js +4 -4
- package/prod/providers/vidstack-hls.js +4 -4
- package/prod/providers/vidstack-html.js +1 -1
- package/prod/providers/vidstack-video.js +4 -4
- package/prod/providers/vidstack-vimeo.js +4 -4
- package/prod/providers/vidstack-youtube.js +3 -3
- package/prod/vidstack-elements.js +12 -12
- package/prod/vidstack.js +9 -9
- package/server/chunks/vidstack-B2Bc9g7_.js +2000 -0
- package/server/chunks/vidstack-BosyhF3p.js +207 -0
- package/server/chunks/vidstack-C8F1EUBn.js +104 -0
- package/server/chunks/vidstack-CWho6PlG.js +141 -0
- package/server/chunks/vidstack-DhF59-Up.js +4635 -0
- package/server/chunks/vidstack-DoHmOxNm.js +295 -0
- package/server/chunks/vidstack-DzWvfg1d.js +1503 -0
- package/server/chunks/vidstack-PnFpou7g.js +3035 -0
- package/server/chunks/vidstack-gEJMQpTE.js +2001 -0
- package/server/define/plyr-layout.js +2 -2
- package/server/define/vidstack-player-default-layout.js +1 -1
- package/server/define/vidstack-player-layouts.js +1 -1
- package/server/define/vidstack-player-ui.js +4 -4
- package/server/define/vidstack-player.js +2 -2
- package/server/global/plyr.js +4 -4
- package/server/global/vidstack-player.js +2 -2
- package/server/vidstack-elements.js +8 -8
- package/server/vidstack.js +4 -4
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { Host, effect, computed, setAttribute } from './vidstack-BNpgCJJ1.js';
|
|
2
|
+
import { MediaProvider, MediaPlayer } from './vidstack-BAqdCFIm.js';
|
|
3
|
+
import { useMediaContext } from './vidstack-tt3O1zL6.js';
|
|
4
|
+
|
|
5
|
+
class MediaProviderElement extends Host(HTMLElement, MediaProvider) {
|
|
6
|
+
static tagName = "media-provider";
|
|
7
|
+
#media;
|
|
8
|
+
#target = null;
|
|
9
|
+
#blocker = null;
|
|
10
|
+
onSetup() {
|
|
11
|
+
this.#media = useMediaContext();
|
|
12
|
+
this.setAttribute("keep-alive", "");
|
|
13
|
+
}
|
|
14
|
+
onDestroy() {
|
|
15
|
+
this.#blocker?.remove();
|
|
16
|
+
this.#blocker = null;
|
|
17
|
+
this.#target?.remove();
|
|
18
|
+
this.#target = null;
|
|
19
|
+
}
|
|
20
|
+
onConnect() {
|
|
21
|
+
effect(() => {
|
|
22
|
+
const loader = this.$state.loader(), isYouTubeEmbed = loader?.name === "youtube", isVimeoEmbed = loader?.name === "vimeo", isEmbed = isYouTubeEmbed || isVimeoEmbed, isGoogleCast = loader?.name === "google-cast";
|
|
23
|
+
const target = loader ? isGoogleCast ? this.#createGoogleCastContainer() : isEmbed ? this.#createIFrame() : loader.mediaType() === "audio" ? this.#createAudio() : this.#createVideo() : null;
|
|
24
|
+
if (this.#target !== target) {
|
|
25
|
+
const parent = this.#target?.parentElement ?? this;
|
|
26
|
+
this.#target?.remove();
|
|
27
|
+
this.#target = target;
|
|
28
|
+
if (target) parent.prepend(target);
|
|
29
|
+
if (isEmbed && target) {
|
|
30
|
+
effect(() => {
|
|
31
|
+
const { nativeControls, viewType } = this.#media.$state, showNativeControls = nativeControls(), isAudioView = viewType() === "audio", showBlocker = !showNativeControls && !isAudioView;
|
|
32
|
+
if (showBlocker) {
|
|
33
|
+
this.#blocker = this.querySelector(".vds-blocker");
|
|
34
|
+
if (!this.#blocker) {
|
|
35
|
+
this.#blocker = document.createElement("div");
|
|
36
|
+
this.#blocker.classList.add("vds-blocker");
|
|
37
|
+
target.after(this.#blocker);
|
|
38
|
+
}
|
|
39
|
+
} else {
|
|
40
|
+
this.#blocker?.remove();
|
|
41
|
+
this.#blocker = null;
|
|
42
|
+
}
|
|
43
|
+
setAttribute(target, "data-no-controls", !showNativeControls);
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
if (isYouTubeEmbed) target?.classList.add("vds-youtube");
|
|
48
|
+
else if (isVimeoEmbed) target?.classList.add("vds-vimeo");
|
|
49
|
+
if (!isEmbed) {
|
|
50
|
+
this.#blocker?.remove();
|
|
51
|
+
this.#blocker = null;
|
|
52
|
+
}
|
|
53
|
+
this.load(target);
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
#createAudio() {
|
|
57
|
+
const audio = this.#target instanceof HTMLAudioElement ? this.#target : document.createElement("audio");
|
|
58
|
+
const { controls, crossOrigin } = this.#media.$state;
|
|
59
|
+
effect(() => {
|
|
60
|
+
setAttribute(audio, "controls", controls());
|
|
61
|
+
setAttribute(audio, "crossorigin", crossOrigin());
|
|
62
|
+
});
|
|
63
|
+
return audio;
|
|
64
|
+
}
|
|
65
|
+
#createVideo() {
|
|
66
|
+
const video = this.#target instanceof HTMLVideoElement ? this.#target : document.createElement("video");
|
|
67
|
+
const { crossOrigin, poster, nativeControls } = this.#media.$state, $controls = computed(() => nativeControls() ? "true" : null), $poster = computed(() => poster() && nativeControls() ? poster() : null);
|
|
68
|
+
effect(() => {
|
|
69
|
+
setAttribute(video, "controls", $controls());
|
|
70
|
+
setAttribute(video, "crossorigin", crossOrigin());
|
|
71
|
+
setAttribute(video, "poster", $poster());
|
|
72
|
+
});
|
|
73
|
+
return video;
|
|
74
|
+
}
|
|
75
|
+
#createIFrame() {
|
|
76
|
+
const iframe = this.#target instanceof HTMLIFrameElement ? this.#target : document.createElement("iframe"), { nativeControls } = this.#media.$state;
|
|
77
|
+
effect(() => setAttribute(iframe, "tabindex", !nativeControls() ? -1 : null));
|
|
78
|
+
return iframe;
|
|
79
|
+
}
|
|
80
|
+
#createGoogleCastContainer() {
|
|
81
|
+
if (this.#target?.classList.contains("vds-google-cast")) {
|
|
82
|
+
return this.#target;
|
|
83
|
+
}
|
|
84
|
+
const container = document.createElement("div");
|
|
85
|
+
container.classList.add("vds-google-cast");
|
|
86
|
+
import('./vidstack-Oq65llxr.js').then(({ insertContent }) => {
|
|
87
|
+
insertContent(container, this.#media.$state);
|
|
88
|
+
});
|
|
89
|
+
return container;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
class MediaPlayerElement extends Host(HTMLElement, MediaPlayer) {
|
|
94
|
+
static tagName = "media-player";
|
|
95
|
+
static attrs = {
|
|
96
|
+
autoPlay: "autoplay",
|
|
97
|
+
crossOrigin: "crossorigin",
|
|
98
|
+
playsInline: "playsinline",
|
|
99
|
+
preferNativeHLS: "prefer-native-hls",
|
|
100
|
+
minLiveDVRWindow: "min-live-dvr-window"
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export { MediaPlayerElement, MediaProviderElement };
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { Host, effect, setAttribute, isString, useState, BOOLEAN } from './vidstack-BNpgCJJ1.js';
|
|
2
|
+
import { Thumbnail, Time, AirPlayButton, CaptionButton, FullscreenButton, LiveButton, MuteButton, PIPButton, PlayButton, SeekButton, AudioRadioGroup, CaptionsRadioGroup, Menu, MenuButton, MenuItem, MenuItems, SpeedRadioGroup, QualityRadioGroup, Radio, Slider, SliderValue, TimeSlider, SliderPreview, VolumeSlider } from './vidstack-DDePVDjt.js';
|
|
3
|
+
import { cloneTemplateContent, createTemplate, requestScopedAnimationFrame, cloneTemplate } from './vidstack-DB9WDRL5.js';
|
|
4
|
+
import { useMediaContext } from './vidstack-tt3O1zL6.js';
|
|
5
|
+
|
|
6
|
+
const imgTemplate = /* @__PURE__ */ createTemplate(
|
|
7
|
+
'<img loading="eager" decoding="async" aria-hidden="true">'
|
|
8
|
+
);
|
|
9
|
+
class MediaThumbnailElement extends Host(HTMLElement, Thumbnail) {
|
|
10
|
+
static tagName = "media-thumbnail";
|
|
11
|
+
static attrs = {
|
|
12
|
+
crossOrigin: "crossorigin"
|
|
13
|
+
};
|
|
14
|
+
#media;
|
|
15
|
+
#img = this.#createImg();
|
|
16
|
+
onSetup() {
|
|
17
|
+
this.#media = useMediaContext();
|
|
18
|
+
this.$state.img.set(this.#img);
|
|
19
|
+
}
|
|
20
|
+
onConnect() {
|
|
21
|
+
const { src, crossOrigin } = this.$state;
|
|
22
|
+
if (this.#img.parentNode !== this) {
|
|
23
|
+
this.prepend(this.#img);
|
|
24
|
+
}
|
|
25
|
+
effect(() => {
|
|
26
|
+
setAttribute(this.#img, "src", src());
|
|
27
|
+
setAttribute(this.#img, "crossorigin", crossOrigin());
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
#createImg() {
|
|
31
|
+
return cloneTemplateContent(imgTemplate);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
class MediaTimeElement extends Host(HTMLElement, Time) {
|
|
36
|
+
static tagName = "media-time";
|
|
37
|
+
onConnect() {
|
|
38
|
+
effect(() => {
|
|
39
|
+
this.textContent = this.$state.timeText();
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
class MediaAirPlayButtonElement extends Host(HTMLElement, AirPlayButton) {
|
|
45
|
+
static tagName = "media-airplay-button";
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
class MediaCaptionButtonElement extends Host(HTMLElement, CaptionButton) {
|
|
49
|
+
static tagName = "media-caption-button";
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
class MediaFullscreenButtonElement extends Host(HTMLElement, FullscreenButton) {
|
|
53
|
+
static tagName = "media-fullscreen-button";
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
class MediaLiveButtonElement extends Host(HTMLElement, LiveButton) {
|
|
57
|
+
static tagName = "media-live-button";
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
class MediaMuteButtonElement extends Host(HTMLElement, MuteButton) {
|
|
61
|
+
static tagName = "media-mute-button";
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
class MediaPIPButtonElement extends Host(HTMLElement, PIPButton) {
|
|
65
|
+
static tagName = "media-pip-button";
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
class MediaPlayButtonElement extends Host(HTMLElement, PlayButton) {
|
|
69
|
+
static tagName = "media-play-button";
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
class MediaSeekButtonElement extends Host(HTMLElement, SeekButton) {
|
|
73
|
+
static tagName = "media-seek-button";
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function renderMenuItemsTemplate(el, onCreate) {
|
|
77
|
+
requestScopedAnimationFrame(() => {
|
|
78
|
+
if (!el.connectScope) return;
|
|
79
|
+
const template = el.querySelector("template");
|
|
80
|
+
if (!template) return;
|
|
81
|
+
effect(() => {
|
|
82
|
+
const options = el.getOptions();
|
|
83
|
+
cloneTemplate(template, options.length, (radio, i) => {
|
|
84
|
+
const { label, value } = options[i], labelEl = radio.querySelector(`[data-part="label"]`);
|
|
85
|
+
radio.setAttribute("value", value);
|
|
86
|
+
if (labelEl) {
|
|
87
|
+
if (isString(label)) {
|
|
88
|
+
labelEl.textContent = label;
|
|
89
|
+
} else {
|
|
90
|
+
effect(() => {
|
|
91
|
+
labelEl.textContent = label();
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
onCreate?.(radio, options[i], i);
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
class MediaAudioRadioGroupElement extends Host(HTMLElement, AudioRadioGroup) {
|
|
102
|
+
static tagName = "media-audio-radio-group";
|
|
103
|
+
onConnect() {
|
|
104
|
+
renderMenuItemsTemplate(this);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
class MediaCaptionsRadioGroupElement extends Host(HTMLElement, CaptionsRadioGroup) {
|
|
109
|
+
static tagName = "media-captions-radio-group";
|
|
110
|
+
onConnect() {
|
|
111
|
+
renderMenuItemsTemplate(this);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
class MediaMenuElement extends Host(HTMLElement, Menu) {
|
|
116
|
+
static tagName = "media-menu";
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
class MediaMenuButtonElement extends Host(HTMLElement, MenuButton) {
|
|
120
|
+
static tagName = "media-menu-button";
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
class MediaMenuItemElement extends Host(HTMLElement, MenuItem) {
|
|
124
|
+
static tagName = "media-menu-item";
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
class MediaMenuItemsElement extends Host(HTMLElement, MenuItems) {
|
|
128
|
+
static tagName = "media-menu-items";
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
class MediaSpeedRadioGroupElement extends Host(HTMLElement, SpeedRadioGroup) {
|
|
132
|
+
static tagName = "media-speed-radio-group";
|
|
133
|
+
onConnect() {
|
|
134
|
+
renderMenuItemsTemplate(this);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
class MediaQualityRadioGroupElement extends Host(HTMLElement, QualityRadioGroup) {
|
|
139
|
+
static tagName = "media-quality-radio-group";
|
|
140
|
+
onConnect() {
|
|
141
|
+
renderMenuItemsTemplate(this, (el, option) => {
|
|
142
|
+
const bitrate = option.bitrate, bitrateEl = el.querySelector('[data-part="bitrate"]');
|
|
143
|
+
if (bitrate && bitrateEl) {
|
|
144
|
+
effect(() => {
|
|
145
|
+
bitrateEl.textContent = bitrate() || "";
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
class MediaRadioElement extends Host(HTMLElement, Radio) {
|
|
153
|
+
static tagName = "media-radio";
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
class MediaSliderThumbnailElement extends MediaThumbnailElement {
|
|
157
|
+
static tagName = "media-slider-thumbnail";
|
|
158
|
+
#media;
|
|
159
|
+
#slider;
|
|
160
|
+
onSetup() {
|
|
161
|
+
super.onSetup();
|
|
162
|
+
this.#media = useMediaContext();
|
|
163
|
+
this.#slider = useState(Slider.state);
|
|
164
|
+
}
|
|
165
|
+
onConnect() {
|
|
166
|
+
super.onConnect();
|
|
167
|
+
effect(this.#watchTime.bind(this));
|
|
168
|
+
}
|
|
169
|
+
#watchTime() {
|
|
170
|
+
const { duration, clipStartTime } = this.#media.$state;
|
|
171
|
+
this.time = clipStartTime() + this.#slider.pointerRate() * duration();
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
class MediaSliderValueElement extends Host(HTMLElement, SliderValue) {
|
|
176
|
+
static tagName = "media-slider-value";
|
|
177
|
+
static attrs = {
|
|
178
|
+
padMinutes: {
|
|
179
|
+
converter: BOOLEAN
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
onConnect() {
|
|
183
|
+
effect(() => {
|
|
184
|
+
this.textContent = this.getValueText();
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
class MediaTimeSliderElement extends Host(HTMLElement, TimeSlider) {
|
|
190
|
+
static tagName = "media-time-slider";
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
class MediaSliderPreviewElement extends Host(HTMLElement, SliderPreview) {
|
|
194
|
+
static tagName = "media-slider-preview";
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
class MediaVolumeSliderElement extends Host(HTMLElement, VolumeSlider) {
|
|
198
|
+
static tagName = "media-volume-slider";
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
export { MediaAirPlayButtonElement, MediaAudioRadioGroupElement, MediaCaptionButtonElement, MediaCaptionsRadioGroupElement, MediaFullscreenButtonElement, MediaLiveButtonElement, MediaMenuButtonElement, MediaMenuElement, MediaMenuItemElement, MediaMenuItemsElement, MediaMuteButtonElement, MediaPIPButtonElement, MediaPlayButtonElement, MediaQualityRadioGroupElement, MediaRadioElement, MediaSeekButtonElement, MediaSliderPreviewElement, MediaSliderThumbnailElement, MediaSliderValueElement, MediaSpeedRadioGroupElement, MediaThumbnailElement, MediaTimeElement, MediaTimeSliderElement, MediaVolumeSliderElement, renderMenuItemsTemplate };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { signal, listenEvent, effect, peek, isString } from './vidstack-BNpgCJJ1.js';
|
|
2
|
+
import { appendParamsToURL } from './vidstack-KShKSmYu.js';
|
|
3
|
+
|
|
4
|
+
class EmbedProvider {
|
|
5
|
+
#iframe;
|
|
6
|
+
src = signal("");
|
|
7
|
+
/**
|
|
8
|
+
* Defines which referrer is sent when fetching the resource.
|
|
9
|
+
*
|
|
10
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLIFrameElement/referrerPolicy}
|
|
11
|
+
*/
|
|
12
|
+
referrerPolicy = null;
|
|
13
|
+
get iframe() {
|
|
14
|
+
return this.#iframe;
|
|
15
|
+
}
|
|
16
|
+
constructor(iframe) {
|
|
17
|
+
this.#iframe = iframe;
|
|
18
|
+
iframe.setAttribute("frameBorder", "0");
|
|
19
|
+
iframe.setAttribute("aria-hidden", "true");
|
|
20
|
+
iframe.setAttribute(
|
|
21
|
+
"allow",
|
|
22
|
+
"autoplay; fullscreen; encrypted-media; picture-in-picture; accelerometer; gyroscope"
|
|
23
|
+
);
|
|
24
|
+
if (this.referrerPolicy !== null) {
|
|
25
|
+
iframe.setAttribute("referrerpolicy", this.referrerPolicy);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
setup() {
|
|
29
|
+
listenEvent(window, "message", this.#onWindowMessage.bind(this));
|
|
30
|
+
listenEvent(this.#iframe, "load", this.onLoad.bind(this));
|
|
31
|
+
effect(this.#watchSrc.bind(this));
|
|
32
|
+
}
|
|
33
|
+
#watchSrc() {
|
|
34
|
+
const src = this.src();
|
|
35
|
+
if (!src.length) {
|
|
36
|
+
this.#iframe.setAttribute("src", "");
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const params = peek(() => this.buildParams());
|
|
40
|
+
this.#iframe.setAttribute("src", appendParamsToURL(src, params));
|
|
41
|
+
}
|
|
42
|
+
postMessage(message, target) {
|
|
43
|
+
this.#iframe.contentWindow?.postMessage(JSON.stringify(message), target ?? "*");
|
|
44
|
+
}
|
|
45
|
+
#onWindowMessage(event) {
|
|
46
|
+
const origin = this.getOrigin(), isOriginMatch = (event.source === null || event.source === this.#iframe?.contentWindow) && (!isString(origin) || origin === event.origin);
|
|
47
|
+
if (!isOriginMatch) return;
|
|
48
|
+
try {
|
|
49
|
+
const message = JSON.parse(event.data);
|
|
50
|
+
if (message) this.onMessage(message, event);
|
|
51
|
+
return;
|
|
52
|
+
} catch (e) {
|
|
53
|
+
}
|
|
54
|
+
if (event.data) this.onMessage(event.data, event);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export { EmbedProvider };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Host, effect, setAttribute } from './vidstack-BNpgCJJ1.js';
|
|
2
|
+
import { Poster } from './vidstack-C4PTiuot.js';
|
|
3
|
+
import './vidstack-tt3O1zL6.js';
|
|
4
|
+
import './vidstack-KShKSmYu.js';
|
|
5
|
+
import './vidstack-wTTCvdqe.js';
|
|
6
|
+
|
|
7
|
+
class MediaPosterElement extends Host(HTMLElement, Poster) {
|
|
8
|
+
static tagName = "media-poster";
|
|
9
|
+
static attrs = {
|
|
10
|
+
crossOrigin: "crossorigin"
|
|
11
|
+
};
|
|
12
|
+
#img = document.createElement("img");
|
|
13
|
+
onSetup() {
|
|
14
|
+
this.$state.img.set(this.#img);
|
|
15
|
+
}
|
|
16
|
+
onConnect() {
|
|
17
|
+
const { src, alt, crossOrigin } = this.$state;
|
|
18
|
+
effect(() => {
|
|
19
|
+
const { loading, hidden } = this.$state;
|
|
20
|
+
this.#img.style.display = loading() || hidden() ? "none" : "";
|
|
21
|
+
});
|
|
22
|
+
effect(() => {
|
|
23
|
+
setAttribute(this.#img, "alt", alt());
|
|
24
|
+
setAttribute(this.#img, "crossorigin", crossOrigin());
|
|
25
|
+
setAttribute(this.#img, "src", src());
|
|
26
|
+
});
|
|
27
|
+
if (this.#img.parentNode !== this) {
|
|
28
|
+
this.prepend(this.#img);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export { MediaPosterElement };
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { Host, effect, computed, setAttribute } from './vidstack-BNpgCJJ1.js';
|
|
2
|
+
import { MediaProvider, MediaPlayer } from './vidstack-C-yd_bAJ.js';
|
|
3
|
+
import { useMediaContext } from './vidstack-tt3O1zL6.js';
|
|
4
|
+
|
|
5
|
+
class MediaProviderElement extends Host(HTMLElement, MediaProvider) {
|
|
6
|
+
static tagName = "media-provider";
|
|
7
|
+
#media;
|
|
8
|
+
#target = null;
|
|
9
|
+
#blocker = null;
|
|
10
|
+
onSetup() {
|
|
11
|
+
this.#media = useMediaContext();
|
|
12
|
+
this.setAttribute("keep-alive", "");
|
|
13
|
+
}
|
|
14
|
+
onDestroy() {
|
|
15
|
+
this.#blocker?.remove();
|
|
16
|
+
this.#blocker = null;
|
|
17
|
+
this.#target?.remove();
|
|
18
|
+
this.#target = null;
|
|
19
|
+
}
|
|
20
|
+
onConnect() {
|
|
21
|
+
effect(() => {
|
|
22
|
+
const loader = this.$state.loader(), isYouTubeEmbed = loader?.name === "youtube", isVimeoEmbed = loader?.name === "vimeo", isEmbed = isYouTubeEmbed || isVimeoEmbed, isGoogleCast = loader?.name === "google-cast";
|
|
23
|
+
const target = loader ? isGoogleCast ? this.#createGoogleCastContainer() : isEmbed ? this.#createIFrame() : loader.mediaType() === "audio" ? this.#createAudio() : this.#createVideo() : null;
|
|
24
|
+
if (this.#target !== target) {
|
|
25
|
+
const parent = this.#target?.parentElement ?? this;
|
|
26
|
+
this.#target?.remove();
|
|
27
|
+
this.#target = target;
|
|
28
|
+
if (target) parent.prepend(target);
|
|
29
|
+
if (isEmbed && target) {
|
|
30
|
+
effect(() => {
|
|
31
|
+
const { nativeControls, viewType } = this.#media.$state, showNativeControls = nativeControls(), isAudioView = viewType() === "audio", showBlocker = !showNativeControls && !isAudioView;
|
|
32
|
+
if (showBlocker) {
|
|
33
|
+
this.#blocker = this.querySelector(".vds-blocker");
|
|
34
|
+
if (!this.#blocker) {
|
|
35
|
+
this.#blocker = document.createElement("div");
|
|
36
|
+
this.#blocker.classList.add("vds-blocker");
|
|
37
|
+
target.after(this.#blocker);
|
|
38
|
+
}
|
|
39
|
+
} else {
|
|
40
|
+
this.#blocker?.remove();
|
|
41
|
+
this.#blocker = null;
|
|
42
|
+
}
|
|
43
|
+
setAttribute(target, "data-no-controls", !showNativeControls);
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
if (isYouTubeEmbed) target?.classList.add("vds-youtube");
|
|
48
|
+
else if (isVimeoEmbed) target?.classList.add("vds-vimeo");
|
|
49
|
+
if (!isEmbed) {
|
|
50
|
+
this.#blocker?.remove();
|
|
51
|
+
this.#blocker = null;
|
|
52
|
+
}
|
|
53
|
+
this.load(target);
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
#createAudio() {
|
|
57
|
+
const audio = this.#target instanceof HTMLAudioElement ? this.#target : document.createElement("audio");
|
|
58
|
+
const { controls, crossOrigin } = this.#media.$state;
|
|
59
|
+
effect(() => {
|
|
60
|
+
setAttribute(audio, "controls", controls());
|
|
61
|
+
setAttribute(audio, "crossorigin", crossOrigin());
|
|
62
|
+
});
|
|
63
|
+
return audio;
|
|
64
|
+
}
|
|
65
|
+
#createVideo() {
|
|
66
|
+
const video = this.#target instanceof HTMLVideoElement ? this.#target : document.createElement("video");
|
|
67
|
+
const { crossOrigin, poster, nativeControls } = this.#media.$state, $controls = computed(() => nativeControls() ? "true" : null), $poster = computed(() => poster() && nativeControls() ? poster() : null);
|
|
68
|
+
effect(() => {
|
|
69
|
+
setAttribute(video, "controls", $controls());
|
|
70
|
+
setAttribute(video, "crossorigin", crossOrigin());
|
|
71
|
+
setAttribute(video, "poster", $poster());
|
|
72
|
+
});
|
|
73
|
+
return video;
|
|
74
|
+
}
|
|
75
|
+
#createIFrame() {
|
|
76
|
+
const iframe = this.#target instanceof HTMLIFrameElement ? this.#target : document.createElement("iframe"), { nativeControls } = this.#media.$state;
|
|
77
|
+
effect(() => setAttribute(iframe, "tabindex", !nativeControls() ? -1 : null));
|
|
78
|
+
return iframe;
|
|
79
|
+
}
|
|
80
|
+
#createGoogleCastContainer() {
|
|
81
|
+
if (this.#target?.classList.contains("vds-google-cast")) {
|
|
82
|
+
return this.#target;
|
|
83
|
+
}
|
|
84
|
+
const container = document.createElement("div");
|
|
85
|
+
container.classList.add("vds-google-cast");
|
|
86
|
+
import('./vidstack-Oq65llxr.js').then(({ insertContent }) => {
|
|
87
|
+
insertContent(container, this.#media.$state);
|
|
88
|
+
});
|
|
89
|
+
return container;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
class MediaPlayerElement extends Host(HTMLElement, MediaPlayer) {
|
|
94
|
+
static tagName = "media-player";
|
|
95
|
+
static attrs = {
|
|
96
|
+
autoPlay: "autoplay",
|
|
97
|
+
crossOrigin: "crossorigin",
|
|
98
|
+
playsInline: "playsinline",
|
|
99
|
+
preferNativeHLS: "prefer-native-hls",
|
|
100
|
+
minLiveDVRWindow: "min-live-dvr-window"
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export { MediaPlayerElement, MediaProviderElement };
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { isNull, isString, deferredPromise, isBoolean } from './vidstack-BNpgCJJ1.js';
|
|
2
|
+
import { isAudioSrc, isVideoSrc } from './vidstack-wTTCvdqe.js';
|
|
3
|
+
|
|
4
|
+
function appendParamsToURL(baseUrl, params) {
|
|
5
|
+
const url = new URL(baseUrl);
|
|
6
|
+
for (const key of Object.keys(params)) {
|
|
7
|
+
url.searchParams.set(key, params[key] + "");
|
|
8
|
+
}
|
|
9
|
+
return url.toString();
|
|
10
|
+
}
|
|
11
|
+
function preconnect(url, rel = "preconnect") {
|
|
12
|
+
const exists = document.querySelector(`link[href="${url}"]`);
|
|
13
|
+
if (!isNull(exists)) return true;
|
|
14
|
+
const link = document.createElement("link");
|
|
15
|
+
link.rel = rel;
|
|
16
|
+
link.href = url;
|
|
17
|
+
link.crossOrigin = "true";
|
|
18
|
+
document.head.append(link);
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
const pendingRequests = {};
|
|
22
|
+
function loadScript(src) {
|
|
23
|
+
if (pendingRequests[src]) return pendingRequests[src].promise;
|
|
24
|
+
const promise = deferredPromise(), exists = document.querySelector(`script[src="${src}"]`);
|
|
25
|
+
if (!isNull(exists)) {
|
|
26
|
+
promise.resolve();
|
|
27
|
+
return promise.promise;
|
|
28
|
+
}
|
|
29
|
+
pendingRequests[src] = promise;
|
|
30
|
+
const script = document.createElement("script");
|
|
31
|
+
script.src = src;
|
|
32
|
+
script.onload = () => {
|
|
33
|
+
promise.resolve();
|
|
34
|
+
delete pendingRequests[src];
|
|
35
|
+
};
|
|
36
|
+
script.onerror = () => {
|
|
37
|
+
promise.reject();
|
|
38
|
+
delete pendingRequests[src];
|
|
39
|
+
};
|
|
40
|
+
setTimeout(() => document.head.append(script), 0);
|
|
41
|
+
return promise.promise;
|
|
42
|
+
}
|
|
43
|
+
function getRequestCredentials(crossOrigin) {
|
|
44
|
+
return crossOrigin === "use-credentials" ? "include" : isString(crossOrigin) ? "same-origin" : void 0;
|
|
45
|
+
}
|
|
46
|
+
function getDownloadFile({
|
|
47
|
+
title,
|
|
48
|
+
src,
|
|
49
|
+
download
|
|
50
|
+
}) {
|
|
51
|
+
const url = isBoolean(download) || download === "" ? src.src : isString(download) ? download : download?.url;
|
|
52
|
+
if (!isValidFileDownload({ url, src, download })) return null;
|
|
53
|
+
return {
|
|
54
|
+
url,
|
|
55
|
+
name: !isBoolean(download) && !isString(download) && download?.filename || title.toLowerCase() || "media"
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
function isValidFileDownload({
|
|
59
|
+
url,
|
|
60
|
+
src,
|
|
61
|
+
download
|
|
62
|
+
}) {
|
|
63
|
+
return isString(url) && (download && download !== true || isAudioSrc(src) || isVideoSrc(src));
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export { appendParamsToURL, getDownloadFile, getRequestCredentials, loadScript, preconnect };
|