@hanifhan1f/vidstack 1.12.25 → 1.12.27
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-8JHLDxl5.js +1 -0
- package/cdn/chunks/vidstack-Bpnl-N6k.js +1 -0
- package/cdn/chunks/vidstack-CnWKPIKT.js +16 -0
- package/cdn/chunks/vidstack-CqzAnF2W.js +16 -0
- package/cdn/vidstack.js +1 -1
- package/cdn/with-layouts/chunks/vidstack-BD5YoTt5.js +937 -0
- package/cdn/with-layouts/chunks/vidstack-DCaNJN4T.js +1 -0
- package/cdn/with-layouts/chunks/vidstack-Dd3L-eQj.js +1 -0
- package/cdn/with-layouts/chunks/vidstack-T2rZVigk.js +912 -0
- package/cdn/with-layouts/vidstack.js +1 -1
- package/dev/chunks/vidstack--aukHYxl.js +1520 -0
- package/dev/chunks/vidstack-B__DfQsT.js +1621 -0
- package/dev/chunks/vidstack-BoLIUOyq.js +204 -0
- package/dev/chunks/vidstack-CSryZFvY.js +1521 -0
- package/dev/chunks/vidstack-Cky9ors4.js +297 -0
- package/dev/chunks/vidstack-Crz0ROkT.js +3009 -0
- package/dev/chunks/vidstack-D-sqb6YI.js +308 -0
- package/dev/chunks/vidstack-DLXCqdYV.js +3010 -0
- package/dev/chunks/vidstack-DS7nRfge.js +204 -0
- package/dev/chunks/vidstack-Dco6kA4h.js +104 -0
- package/dev/chunks/vidstack-DpS0Kt4b.js +297 -0
- package/dev/chunks/vidstack-zJT-7ncH.js +5182 -0
- package/dev/define/plyr-layout.js +3 -4
- package/dev/define/templates/vidstack-audio-layout.js +4 -4
- package/dev/define/templates/vidstack-video-layout.js +4 -4
- package/dev/define/vidstack-player-default-layout.js +4 -4
- package/dev/define/vidstack-player-layouts.js +4 -4
- package/dev/define/vidstack-player-ui.js +5 -6
- package/dev/define/vidstack-player.js +3 -4
- package/dev/global/plyr.js +5 -6
- package/dev/global/vidstack-player.js +3 -4
- package/dev/providers/vidstack-dash.js +1 -2
- package/dev/providers/vidstack-hls.js +1 -2
- package/dev/providers/vidstack-video.js +1 -2
- package/dev/providers/vidstack-vimeo.js +1 -2
- package/dev/vidstack-elements.js +8 -9
- package/dev/vidstack.js +6 -7
- package/package.json +2 -1
- package/prod/chunks/vidstack-BVSJtdRd.js +297 -0
- package/prod/chunks/vidstack-BnEo_Sla.js +1621 -0
- package/prod/chunks/vidstack-CFXAYpuh.js +1521 -0
- package/prod/chunks/vidstack-CIvL96_j.js +297 -0
- package/prod/chunks/vidstack-CLTPjjXX.js +4772 -0
- package/prod/chunks/vidstack-CSHHV2zO.js +201 -0
- package/prod/chunks/vidstack-CYVCrFjx.js +201 -0
- package/prod/chunks/vidstack-D_atbNqH.js +3000 -0
- package/prod/chunks/vidstack-Eo46ZHu7.js +2999 -0
- package/prod/chunks/vidstack-sP7TQMB1.js +300 -0
- package/prod/chunks/vidstack-uVm3xX8H.js +104 -0
- package/prod/chunks/vidstack-zknLxihl.js +1520 -0
- package/prod/define/plyr-layout.js +3 -4
- package/prod/define/templates/vidstack-audio-layout.js +4 -4
- package/prod/define/templates/vidstack-video-layout.js +4 -4
- package/prod/define/vidstack-player-default-layout.js +4 -4
- package/prod/define/vidstack-player-layouts.js +4 -4
- package/prod/define/vidstack-player-ui.js +5 -6
- package/prod/define/vidstack-player.js +3 -4
- package/prod/global/plyr.js +5 -6
- package/prod/global/vidstack-player.js +3 -4
- package/prod/providers/vidstack-dash.js +1 -2
- package/prod/providers/vidstack-hls.js +1 -2
- package/prod/providers/vidstack-video.js +1 -2
- package/prod/providers/vidstack-vimeo.js +1 -2
- package/prod/vidstack-elements.js +8 -9
- package/prod/vidstack.js +6 -7
- package/server/chunks/vidstack-B3eA67nX.js +205 -0
- package/server/chunks/vidstack-B8P1aUCK.js +1503 -0
- package/server/chunks/vidstack-B8_v1VQn.js +3059 -0
- package/server/chunks/vidstack-BK4xGWUK.js +207 -0
- package/server/chunks/vidstack-BO8FLks6.js +295 -0
- package/server/chunks/vidstack-BaXvZgx2.js +141 -0
- package/server/chunks/vidstack-BlvJg_5A.js +4636 -0
- package/server/chunks/vidstack-CBhikwSz.js +67 -0
- package/server/chunks/vidstack-COczNXom.js +3059 -0
- package/server/chunks/vidstack-CyZPtpwO.js +1503 -0
- package/server/chunks/vidstack-Db22EuE_.js +207 -0
- package/server/chunks/vidstack-Dh1ZDEI-.js +29 -0
- package/server/chunks/vidstack-Dm-ETAZh.js +295 -0
- package/server/chunks/vidstack-NpAD9hfP.js +620 -0
- package/server/chunks/vidstack-O4BgIcQI.js +104 -0
- package/server/chunks/vidstack-n4zAyLEV.js +2139 -0
- package/server/chunks/vidstack-za5Yh5DQ.js +566 -0
- package/server/chunks/vidstack-zoXyfYxa.js +107 -0
- package/server/define/plyr-layout.js +7 -7
- package/server/define/vidstack-player-default-layout.js +3 -3
- package/server/define/vidstack-player-layouts.js +5 -5
- package/server/define/vidstack-player-ui.js +6 -6
- package/server/define/vidstack-player.js +4 -4
- package/server/global/plyr.js +9 -9
- package/server/global/vidstack-player.js +4 -4
- package/server/vidstack-elements.js +13 -13
- package/server/vidstack.js +8 -8
|
@@ -0,0 +1,2139 @@
|
|
|
1
|
+
import { createContext, useContext, prop, Component, computed, provideContext, signal, isBoolean, effect, setAttribute, uppercaseFirstChar, isNil, isString, noop, isFunction, unwrap, isArray, camelToKebabCase, tick, peek, isKeyboardClick, toggleClass, Host, listenEvent } from './vidstack-B8LynzY5.js';
|
|
2
|
+
import { useMediaContext, watchColorScheme, useMediaState, getDownloadFile, appendParamsToURL, watchActiveTextTrack, isTrackCaptionKind, useResizeObserver, useActive, useTransitionActive, isHTMLElement, createSlot } from './vidstack-NpAD9hfP.js';
|
|
3
|
+
import { $signal, LayoutIconsLoader, Icon, SlotManager } from './vidstack-B3eA67nX.js';
|
|
4
|
+
import { LitElement } from './vidstack-CwTj4H1w.js';
|
|
5
|
+
import { html } from 'lit-html';
|
|
6
|
+
import { ref } from 'lit-html/directives/ref.js';
|
|
7
|
+
import { keyed } from 'lit-html/directives/keyed.js';
|
|
8
|
+
import { $ariaBool, sortVideoQualities } from './vidstack-BOTZD4tC.js';
|
|
9
|
+
import { ifDefined } from 'lit-html/directives/if-defined.js';
|
|
10
|
+
|
|
11
|
+
const defaultLayoutContext = createContext();
|
|
12
|
+
function useDefaultLayoutContext() {
|
|
13
|
+
return useContext(defaultLayoutContext);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const defaultLayoutProps = {
|
|
17
|
+
colorScheme: "system",
|
|
18
|
+
download: null,
|
|
19
|
+
customIcons: false,
|
|
20
|
+
disableTimeSlider: false,
|
|
21
|
+
menuContainer: null,
|
|
22
|
+
menuGroup: "bottom",
|
|
23
|
+
noAudioGain: false,
|
|
24
|
+
noGestures: false,
|
|
25
|
+
noKeyboardAnimations: false,
|
|
26
|
+
noModal: false,
|
|
27
|
+
noScrubGesture: false,
|
|
28
|
+
playbackRates: { min: 0, max: 2, step: 0.25 },
|
|
29
|
+
audioGains: { min: 0, max: 300, step: 25 },
|
|
30
|
+
seekStep: 5,
|
|
31
|
+
sliderChaptersMinWidth: 325,
|
|
32
|
+
hideQualityBitrate: false,
|
|
33
|
+
episodes: null,
|
|
34
|
+
episodesTitle: "Episodes",
|
|
35
|
+
smallWhen: false,
|
|
36
|
+
thumbnails: null,
|
|
37
|
+
translations: null,
|
|
38
|
+
when: false
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
class DefaultLayout extends Component {
|
|
42
|
+
static props = defaultLayoutProps;
|
|
43
|
+
#media;
|
|
44
|
+
#when = computed(() => {
|
|
45
|
+
const when = this.$props.when();
|
|
46
|
+
return this.#matches(when);
|
|
47
|
+
});
|
|
48
|
+
#smallWhen = computed(() => {
|
|
49
|
+
const when = this.$props.smallWhen();
|
|
50
|
+
return this.#matches(when);
|
|
51
|
+
});
|
|
52
|
+
get isMatch() {
|
|
53
|
+
return this.#when();
|
|
54
|
+
}
|
|
55
|
+
get isSmallLayout() {
|
|
56
|
+
return this.#smallWhen();
|
|
57
|
+
}
|
|
58
|
+
onSetup() {
|
|
59
|
+
this.#media = useMediaContext();
|
|
60
|
+
this.setAttributes({
|
|
61
|
+
"data-match": this.#when,
|
|
62
|
+
"data-sm": () => this.#smallWhen() ? "" : null,
|
|
63
|
+
"data-lg": () => !this.#smallWhen() ? "" : null,
|
|
64
|
+
"data-size": () => this.#smallWhen() ? "sm" : "lg",
|
|
65
|
+
"data-no-scrub-gesture": this.$props.noScrubGesture
|
|
66
|
+
});
|
|
67
|
+
provideContext(defaultLayoutContext, {
|
|
68
|
+
...this.$props,
|
|
69
|
+
when: this.#when,
|
|
70
|
+
smallWhen: this.#smallWhen,
|
|
71
|
+
userPrefersAnnouncements: signal(true),
|
|
72
|
+
userPrefersKeyboardAnimations: signal(true),
|
|
73
|
+
menuPortal: signal(null)
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
onAttach(el) {
|
|
77
|
+
watchColorScheme(el, this.$props.colorScheme);
|
|
78
|
+
}
|
|
79
|
+
#matches(query) {
|
|
80
|
+
return query !== "never" && (isBoolean(query) ? query : computed(() => query(this.#media.player.state))());
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
const defaultlayout__proto = DefaultLayout.prototype;
|
|
84
|
+
prop(defaultlayout__proto, "isMatch");
|
|
85
|
+
prop(defaultlayout__proto, "isSmallLayout");
|
|
86
|
+
|
|
87
|
+
let DefaultAudioLayout$1 = class DefaultAudioLayout extends DefaultLayout {
|
|
88
|
+
static props = {
|
|
89
|
+
...super.props,
|
|
90
|
+
when: ({ viewType }) => viewType === "audio",
|
|
91
|
+
smallWhen: ({ width }) => width < 576
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
function setLayoutName(name, isMatch) {
|
|
96
|
+
effect(() => {
|
|
97
|
+
const { player } = useMediaContext(), el = player.el;
|
|
98
|
+
el && setAttribute(el, "data-layout", isMatch() && name);
|
|
99
|
+
return () => el?.removeAttribute("data-layout");
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function i18n(translations, word) {
|
|
104
|
+
return translations()?.[word] ?? word;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function DefaultAnnouncer() {
|
|
108
|
+
return $signal(() => {
|
|
109
|
+
const { translations, userPrefersAnnouncements } = useDefaultLayoutContext();
|
|
110
|
+
if (!userPrefersAnnouncements()) return null;
|
|
111
|
+
return html`<media-announcer .translations=${$signal(translations)}></media-announcer>`;
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function IconSlot(name, classes = "") {
|
|
116
|
+
return html`<slot
|
|
117
|
+
name=${`${name}-icon`}
|
|
118
|
+
data-class=${`vds-icon vds-${name}-icon${classes ? ` ${classes}` : ""}`}
|
|
119
|
+
></slot>`;
|
|
120
|
+
}
|
|
121
|
+
function IconSlots(names) {
|
|
122
|
+
return names.map((name) => IconSlot(name));
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function $i18n(translations, word) {
|
|
126
|
+
return $signal(() => i18n(translations, word));
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function DefaultAirPlayButton({ tooltip }) {
|
|
130
|
+
const { translations } = useDefaultLayoutContext(), { remotePlaybackState } = useMediaState(), $label = $signal(() => {
|
|
131
|
+
const airPlayText = i18n(translations, "AirPlay"), stateText = uppercaseFirstChar(remotePlaybackState());
|
|
132
|
+
return `${airPlayText} ${stateText}`;
|
|
133
|
+
}), $airPlayText = $i18n(translations, "AirPlay");
|
|
134
|
+
return html`
|
|
135
|
+
<media-tooltip class="vds-airplay-tooltip vds-tooltip">
|
|
136
|
+
<media-tooltip-trigger>
|
|
137
|
+
<media-airplay-button class="vds-airplay-button vds-button" aria-label=${$label}>
|
|
138
|
+
${IconSlot("airplay")}
|
|
139
|
+
</media-airplay-button>
|
|
140
|
+
</media-tooltip-trigger>
|
|
141
|
+
<media-tooltip-content class="vds-tooltip-content" placement=${tooltip}>
|
|
142
|
+
<span class="vds-airplay-tooltip-text">${$airPlayText}</span>
|
|
143
|
+
</media-tooltip-content>
|
|
144
|
+
</media-tooltip>
|
|
145
|
+
`;
|
|
146
|
+
}
|
|
147
|
+
function DefaultPlayButton({ tooltip }) {
|
|
148
|
+
const { translations } = useDefaultLayoutContext(), $playText = $i18n(translations, "Play"), $pauseText = $i18n(translations, "Pause");
|
|
149
|
+
return html`
|
|
150
|
+
<media-tooltip class="vds-play-tooltip vds-tooltip">
|
|
151
|
+
<media-tooltip-trigger>
|
|
152
|
+
<media-play-button
|
|
153
|
+
class="vds-play-button vds-button"
|
|
154
|
+
aria-label=${$i18n(translations, "Play")}
|
|
155
|
+
>
|
|
156
|
+
${IconSlots(["play", "pause", "replay"])}
|
|
157
|
+
</media-play-button>
|
|
158
|
+
</media-tooltip-trigger>
|
|
159
|
+
<media-tooltip-content class="vds-tooltip-content" placement=${tooltip}>
|
|
160
|
+
<span class="vds-play-tooltip-text">${$playText}</span>
|
|
161
|
+
<span class="vds-pause-tooltip-text">${$pauseText}</span>
|
|
162
|
+
</media-tooltip-content>
|
|
163
|
+
</media-tooltip>
|
|
164
|
+
`;
|
|
165
|
+
}
|
|
166
|
+
function DefaultMuteButton({
|
|
167
|
+
tooltip,
|
|
168
|
+
ref: ref$1 = noop
|
|
169
|
+
}) {
|
|
170
|
+
const { translations } = useDefaultLayoutContext(), $muteText = $i18n(translations, "Mute"), $unmuteText = $i18n(translations, "Unmute");
|
|
171
|
+
return html`
|
|
172
|
+
<media-tooltip class="vds-mute-tooltip vds-tooltip">
|
|
173
|
+
<media-tooltip-trigger>
|
|
174
|
+
<media-mute-button
|
|
175
|
+
class="vds-mute-button vds-button"
|
|
176
|
+
aria-label=${$i18n(translations, "Mute")}
|
|
177
|
+
${ref(ref$1)}
|
|
178
|
+
>
|
|
179
|
+
${IconSlots(["mute", "volume-low", "volume-high"])}
|
|
180
|
+
</media-mute-button>
|
|
181
|
+
</media-tooltip-trigger>
|
|
182
|
+
<media-tooltip-content class="vds-tooltip-content" placement=${tooltip}>
|
|
183
|
+
<span class="vds-mute-tooltip-text">${$unmuteText}</span>
|
|
184
|
+
<span class="vds-unmute-tooltip-text">${$muteText}</span>
|
|
185
|
+
</media-tooltip-content>
|
|
186
|
+
</media-tooltip>
|
|
187
|
+
`;
|
|
188
|
+
}
|
|
189
|
+
function DefaultCaptionButton({ tooltip }) {
|
|
190
|
+
const { translations } = useDefaultLayoutContext(), $ccOnText = $i18n(translations, "Closed-Captions On"), $ccOffText = $i18n(translations, "Closed-Captions Off");
|
|
191
|
+
return html`
|
|
192
|
+
<media-tooltip class="vds-caption-tooltip vds-tooltip">
|
|
193
|
+
<media-tooltip-trigger>
|
|
194
|
+
<media-caption-button
|
|
195
|
+
class="vds-caption-button vds-button"
|
|
196
|
+
aria-label=${$i18n(translations, "Captions")}
|
|
197
|
+
>
|
|
198
|
+
${IconSlots(["cc-on", "cc-off"])}
|
|
199
|
+
</media-caption-button>
|
|
200
|
+
</media-tooltip-trigger>
|
|
201
|
+
<media-tooltip-content class="vds-tooltip-content" placement=${tooltip}>
|
|
202
|
+
<span class="vds-cc-on-tooltip-text">${$ccOffText}</span>
|
|
203
|
+
<span class="vds-cc-off-tooltip-text">${$ccOnText}</span>
|
|
204
|
+
</media-tooltip-content>
|
|
205
|
+
</media-tooltip>
|
|
206
|
+
`;
|
|
207
|
+
}
|
|
208
|
+
function DefaultPIPButton() {
|
|
209
|
+
const { translations } = useDefaultLayoutContext(), $enterText = $i18n(translations, "Enter PiP"), $exitText = $i18n(translations, "Exit PiP");
|
|
210
|
+
return html`
|
|
211
|
+
<media-tooltip class="vds-pip-tooltip vds-tooltip">
|
|
212
|
+
<media-tooltip-trigger>
|
|
213
|
+
<media-pip-button
|
|
214
|
+
class="vds-pip-button vds-button"
|
|
215
|
+
aria-label=${$i18n(translations, "PiP")}
|
|
216
|
+
>
|
|
217
|
+
${IconSlots(["pip-enter", "pip-exit"])}
|
|
218
|
+
</media-pip-button>
|
|
219
|
+
</media-tooltip-trigger>
|
|
220
|
+
<media-tooltip-content class="vds-tooltip-content">
|
|
221
|
+
<span class="vds-pip-enter-tooltip-text">${$enterText}</span>
|
|
222
|
+
<span class="vds-pip-exit-tooltip-text">${$exitText}</span>
|
|
223
|
+
</media-tooltip-content>
|
|
224
|
+
</media-tooltip>
|
|
225
|
+
`;
|
|
226
|
+
}
|
|
227
|
+
function DefaultFullscreenButton({ tooltip }) {
|
|
228
|
+
const { translations } = useDefaultLayoutContext(), $enterText = $i18n(translations, "Enter Fullscreen"), $exitText = $i18n(translations, "Exit Fullscreen");
|
|
229
|
+
return html`
|
|
230
|
+
<media-tooltip class="vds-fullscreen-tooltip vds-tooltip">
|
|
231
|
+
<media-tooltip-trigger>
|
|
232
|
+
<media-fullscreen-button
|
|
233
|
+
class="vds-fullscreen-button vds-button"
|
|
234
|
+
aria-label=${$i18n(translations, "Fullscreen")}
|
|
235
|
+
>
|
|
236
|
+
${IconSlots(["fs-enter", "fs-exit"])}
|
|
237
|
+
</media-fullscreen-button>
|
|
238
|
+
</media-tooltip-trigger>
|
|
239
|
+
<media-tooltip-content class="vds-tooltip-content" placement=${tooltip}>
|
|
240
|
+
<span class="vds-fs-enter-tooltip-text">${$enterText}</span>
|
|
241
|
+
<span class="vds-fs-exit-tooltip-text">${$exitText}</span>
|
|
242
|
+
</media-tooltip-content>
|
|
243
|
+
</media-tooltip>
|
|
244
|
+
`;
|
|
245
|
+
}
|
|
246
|
+
function DefaultSeekButton({
|
|
247
|
+
backward,
|
|
248
|
+
tooltip
|
|
249
|
+
}) {
|
|
250
|
+
const { translations, seekStep } = useDefaultLayoutContext(), seekText = !backward ? "Seek Forward" : "Seek Backward", $label = $i18n(translations, seekText), $seconds = () => (backward ? -1 : 1) * seekStep();
|
|
251
|
+
return html`
|
|
252
|
+
<media-tooltip class="vds-seek-tooltip vds-tooltip">
|
|
253
|
+
<media-tooltip-trigger>
|
|
254
|
+
<media-seek-button
|
|
255
|
+
class="vds-seek-button vds-button"
|
|
256
|
+
seconds=${$signal($seconds)}
|
|
257
|
+
aria-label=${$label}
|
|
258
|
+
>
|
|
259
|
+
${!backward ? IconSlot("seek-forward") : IconSlot("seek-backward")}
|
|
260
|
+
</media-seek-button>
|
|
261
|
+
</media-tooltip-trigger>
|
|
262
|
+
<media-tooltip-content class="vds-tooltip-content" placement=${tooltip}>
|
|
263
|
+
${$i18n(translations, seekText)}
|
|
264
|
+
</media-tooltip-content>
|
|
265
|
+
</media-tooltip>
|
|
266
|
+
`;
|
|
267
|
+
}
|
|
268
|
+
function DefaultLiveButton() {
|
|
269
|
+
const { translations } = useDefaultLayoutContext(), { live } = useMediaState(), $label = $i18n(translations, "Skip To Live"), $liveText = $i18n(translations, "LIVE");
|
|
270
|
+
return live() ? html`
|
|
271
|
+
<media-live-button class="vds-live-button" aria-label=${$label}>
|
|
272
|
+
<span class="vds-live-button-text">${$liveText}</span>
|
|
273
|
+
</media-live-button>
|
|
274
|
+
` : null;
|
|
275
|
+
}
|
|
276
|
+
function DefaultDownloadButton() {
|
|
277
|
+
return $signal(() => {
|
|
278
|
+
const { download, translations } = useDefaultLayoutContext(), $download = download();
|
|
279
|
+
if (isNil($download)) return null;
|
|
280
|
+
const { source, title } = useMediaState(), $src = source(), file = getDownloadFile({
|
|
281
|
+
title: title(),
|
|
282
|
+
src: $src,
|
|
283
|
+
download: $download
|
|
284
|
+
});
|
|
285
|
+
return isString(file?.url) ? html`
|
|
286
|
+
<media-tooltip class="vds-download-tooltip vds-tooltip">
|
|
287
|
+
<media-tooltip-trigger>
|
|
288
|
+
<a
|
|
289
|
+
role="button"
|
|
290
|
+
class="vds-download-button vds-button"
|
|
291
|
+
aria-label=${$i18n(translations, "Download")}
|
|
292
|
+
href=${appendParamsToURL(file.url, { download: file.name })}
|
|
293
|
+
download=${file.name}
|
|
294
|
+
target="_blank"
|
|
295
|
+
>
|
|
296
|
+
<slot name="download-icon" data-class="vds-icon" />
|
|
297
|
+
</a>
|
|
298
|
+
</media-tooltip-trigger>
|
|
299
|
+
<media-tooltip-content class="vds-tooltip-content" placement="top">
|
|
300
|
+
${$i18n(translations, "Download")}
|
|
301
|
+
</media-tooltip-content>
|
|
302
|
+
</media-tooltip>
|
|
303
|
+
` : null;
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
function DefaultEpisodeButton({ tooltip } = {}) {
|
|
307
|
+
const $label = "Episodes", $episodesText = "Episodes";
|
|
308
|
+
function openEpisodes(e) {
|
|
309
|
+
e.stopPropagation();
|
|
310
|
+
e.currentTarget?.dispatchEvent(
|
|
311
|
+
new CustomEvent("vds-episodes-open", { bubbles: true, composed: true })
|
|
312
|
+
);
|
|
313
|
+
}
|
|
314
|
+
const content = html`
|
|
315
|
+
<button
|
|
316
|
+
type="button"
|
|
317
|
+
class="vds-episode-button vds-button"
|
|
318
|
+
aria-label=${$label}
|
|
319
|
+
@pointerup=${openEpisodes}
|
|
320
|
+
>
|
|
321
|
+
${IconSlot("menu-episodes")}
|
|
322
|
+
</button>
|
|
323
|
+
`;
|
|
324
|
+
if (!tooltip) return content;
|
|
325
|
+
return html`
|
|
326
|
+
<media-tooltip class="vds-episode-tooltip vds-tooltip">
|
|
327
|
+
<media-tooltip-trigger> ${content} </media-tooltip-trigger>
|
|
328
|
+
<media-tooltip-content class="vds-tooltip-content" placement=${tooltip}>
|
|
329
|
+
<span class="vds-episode-tooltip-text">${$episodesText}</span>
|
|
330
|
+
</media-tooltip-content>
|
|
331
|
+
</media-tooltip>
|
|
332
|
+
`;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
function DefaultCaptions() {
|
|
336
|
+
const { translations } = useDefaultLayoutContext();
|
|
337
|
+
return html`
|
|
338
|
+
<media-captions
|
|
339
|
+
class="vds-captions"
|
|
340
|
+
.exampleText=${$i18n(translations, "Captions look like this")}
|
|
341
|
+
></media-captions>
|
|
342
|
+
`;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
function DefaultControlsSpacer() {
|
|
346
|
+
return html`<div class="vds-controls-spacer"></div>`;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
function MenuPortal(container, template) {
|
|
350
|
+
return html`
|
|
351
|
+
<media-menu-portal .container=${$signal(container)} disabled="fullscreen">
|
|
352
|
+
${template}
|
|
353
|
+
</media-menu-portal>
|
|
354
|
+
`;
|
|
355
|
+
}
|
|
356
|
+
function createMenuContainer(layoutEl, rootSelector, className, isSmallLayout) {
|
|
357
|
+
let root = isString(rootSelector) ? document.querySelector(rootSelector) : rootSelector;
|
|
358
|
+
if (!root) root = layoutEl?.closest("dialog");
|
|
359
|
+
if (!root) root = document.body;
|
|
360
|
+
const container = document.createElement("div");
|
|
361
|
+
container.style.display = "contents";
|
|
362
|
+
container.classList.add(className);
|
|
363
|
+
root.append(container);
|
|
364
|
+
effect(() => {
|
|
365
|
+
if (!container) return;
|
|
366
|
+
const { viewType } = useMediaState(), isSmall = isSmallLayout();
|
|
367
|
+
setAttribute(container, "data-view-type", viewType());
|
|
368
|
+
setAttribute(container, "data-sm", isSmall);
|
|
369
|
+
setAttribute(container, "data-lg", !isSmall);
|
|
370
|
+
setAttribute(container, "data-size", isSmall ? "sm" : "lg");
|
|
371
|
+
});
|
|
372
|
+
const { colorScheme } = useDefaultLayoutContext();
|
|
373
|
+
watchColorScheme(container, colorScheme);
|
|
374
|
+
return container;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
function DefaultChaptersMenu({
|
|
378
|
+
placement,
|
|
379
|
+
tooltip,
|
|
380
|
+
portal
|
|
381
|
+
}) {
|
|
382
|
+
const { textTracks } = useMediaContext(), { viewType, seekableStart, seekableEnd } = useMediaState(), {
|
|
383
|
+
translations,
|
|
384
|
+
thumbnails,
|
|
385
|
+
menuPortal,
|
|
386
|
+
noModal,
|
|
387
|
+
menuGroup,
|
|
388
|
+
smallWhen: smWhen
|
|
389
|
+
} = useDefaultLayoutContext(), $disabled = computed(() => {
|
|
390
|
+
const $startTime = seekableStart(), $endTime = seekableEnd(), $track = signal(null);
|
|
391
|
+
watchActiveTextTrack(textTracks, "chapters", $track.set);
|
|
392
|
+
const cues = $track()?.cues.filter(
|
|
393
|
+
(cue) => cue.startTime <= $endTime && cue.endTime >= $startTime
|
|
394
|
+
);
|
|
395
|
+
return !cues?.length;
|
|
396
|
+
});
|
|
397
|
+
if ($disabled()) return null;
|
|
398
|
+
const $placement = computed(
|
|
399
|
+
() => noModal() ? unwrap(placement) : !smWhen() ? unwrap(placement) : null
|
|
400
|
+
), $offset = computed(
|
|
401
|
+
() => !smWhen() && menuGroup() === "bottom" && viewType() === "video" ? 26 : 0
|
|
402
|
+
), $isOpen = signal(false);
|
|
403
|
+
function onOpen() {
|
|
404
|
+
$isOpen.set(true);
|
|
405
|
+
}
|
|
406
|
+
function onClose() {
|
|
407
|
+
$isOpen.set(false);
|
|
408
|
+
}
|
|
409
|
+
const items = html`
|
|
410
|
+
<media-menu-items
|
|
411
|
+
class="vds-chapters-menu-items vds-menu-items"
|
|
412
|
+
placement=${$signal($placement)}
|
|
413
|
+
offset=${$signal($offset)}
|
|
414
|
+
>
|
|
415
|
+
${$signal(() => {
|
|
416
|
+
if (!$isOpen()) return null;
|
|
417
|
+
return html`
|
|
418
|
+
<media-chapters-radio-group
|
|
419
|
+
class="vds-chapters-radio-group vds-radio-group"
|
|
420
|
+
.thumbnails=${$signal(thumbnails)}
|
|
421
|
+
>
|
|
422
|
+
<template>
|
|
423
|
+
<media-radio class="vds-chapter-radio vds-radio">
|
|
424
|
+
<media-thumbnail class="vds-thumbnail"></media-thumbnail>
|
|
425
|
+
<div class="vds-chapter-radio-content">
|
|
426
|
+
<span class="vds-chapter-radio-label" data-part="label"></span>
|
|
427
|
+
<span class="vds-chapter-radio-start-time" data-part="start-time"></span>
|
|
428
|
+
<span class="vds-chapter-radio-duration" data-part="duration"></span>
|
|
429
|
+
</div>
|
|
430
|
+
</media-radio>
|
|
431
|
+
</template>
|
|
432
|
+
</media-chapters-radio-group>
|
|
433
|
+
`;
|
|
434
|
+
})}
|
|
435
|
+
</media-menu-items>
|
|
436
|
+
`;
|
|
437
|
+
return html`
|
|
438
|
+
<media-menu class="vds-chapters-menu vds-menu" @open=${onOpen} @close=${onClose}>
|
|
439
|
+
<media-tooltip class="vds-tooltip">
|
|
440
|
+
<media-tooltip-trigger>
|
|
441
|
+
<media-menu-button
|
|
442
|
+
class="vds-menu-button vds-button"
|
|
443
|
+
aria-label=${$i18n(translations, "Chapters")}
|
|
444
|
+
>
|
|
445
|
+
${IconSlot("menu-chapters")}
|
|
446
|
+
</media-menu-button>
|
|
447
|
+
</media-tooltip-trigger>
|
|
448
|
+
<media-tooltip-content
|
|
449
|
+
class="vds-tooltip-content"
|
|
450
|
+
placement=${isFunction(tooltip) ? $signal(tooltip) : tooltip}
|
|
451
|
+
>
|
|
452
|
+
${$i18n(translations, "Chapters")}
|
|
453
|
+
</media-tooltip-content>
|
|
454
|
+
</media-tooltip>
|
|
455
|
+
${MenuPortal(menuPortal, items) }
|
|
456
|
+
</media-menu>
|
|
457
|
+
`;
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
const FONT_COLOR_OPTION = {
|
|
461
|
+
type: "color"
|
|
462
|
+
};
|
|
463
|
+
const FONT_FAMILY_OPTION = {
|
|
464
|
+
type: "radio",
|
|
465
|
+
values: {
|
|
466
|
+
"Monospaced Serif": "mono-serif",
|
|
467
|
+
"Proportional Serif": "pro-serif",
|
|
468
|
+
"Monospaced Sans-Serif": "mono-sans",
|
|
469
|
+
"Proportional Sans-Serif": "pro-sans",
|
|
470
|
+
Casual: "casual",
|
|
471
|
+
Cursive: "cursive",
|
|
472
|
+
"Small Capitals": "capitals"
|
|
473
|
+
}
|
|
474
|
+
};
|
|
475
|
+
const FONT_SIZE_OPTION = {
|
|
476
|
+
type: "slider",
|
|
477
|
+
min: 0,
|
|
478
|
+
max: 400,
|
|
479
|
+
step: 25,
|
|
480
|
+
upIcon: null,
|
|
481
|
+
downIcon: null
|
|
482
|
+
};
|
|
483
|
+
const FONT_OPACITY_OPTION = {
|
|
484
|
+
type: "slider",
|
|
485
|
+
min: 0,
|
|
486
|
+
max: 100,
|
|
487
|
+
step: 5,
|
|
488
|
+
upIcon: null,
|
|
489
|
+
downIcon: null
|
|
490
|
+
};
|
|
491
|
+
const FONT_TEXT_SHADOW_OPTION = {
|
|
492
|
+
type: "radio",
|
|
493
|
+
values: ["None", "Drop Shadow", "Raised", "Depressed", "Outline"]
|
|
494
|
+
};
|
|
495
|
+
const FONT_DEFAULTS = {
|
|
496
|
+
fontFamily: "pro-sans",
|
|
497
|
+
fontSize: "100%",
|
|
498
|
+
textColor: "#ffffff",
|
|
499
|
+
textOpacity: "100%",
|
|
500
|
+
textShadow: "none",
|
|
501
|
+
textBg: "#000000",
|
|
502
|
+
textBgOpacity: "100%",
|
|
503
|
+
displayBg: "#000000",
|
|
504
|
+
displayBgOpacity: "0%"
|
|
505
|
+
};
|
|
506
|
+
const FONT_SIGNALS = Object.keys(FONT_DEFAULTS).reduce(
|
|
507
|
+
(prev, type) => ({
|
|
508
|
+
...prev,
|
|
509
|
+
[type]: signal(FONT_DEFAULTS[type])
|
|
510
|
+
}),
|
|
511
|
+
{}
|
|
512
|
+
);
|
|
513
|
+
function onFontReset() {
|
|
514
|
+
for (const type of Object.keys(FONT_SIGNALS)) {
|
|
515
|
+
const defaultValue = FONT_DEFAULTS[type];
|
|
516
|
+
FONT_SIGNALS[type].set(defaultValue);
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
let sectionId = 0;
|
|
521
|
+
function DefaultMenuSection({ label = "", value = "", children }) {
|
|
522
|
+
if (!label) {
|
|
523
|
+
return html`
|
|
524
|
+
<div class="vds-menu-section">
|
|
525
|
+
<div class="vds-menu-section-body">${children}</div>
|
|
526
|
+
</div>
|
|
527
|
+
`;
|
|
528
|
+
}
|
|
529
|
+
const id = `vds-menu-section-${++sectionId}`;
|
|
530
|
+
return html`
|
|
531
|
+
<section class="vds-menu-section" role="group" aria-labelledby=${id}>
|
|
532
|
+
<div class="vds-menu-section-title">
|
|
533
|
+
<header id=${id}>${label}</header>
|
|
534
|
+
${value ? html`<div class="vds-menu-section-value">${value}</div>` : null}
|
|
535
|
+
</div>
|
|
536
|
+
<div class="vds-menu-section-body">${children}</div>
|
|
537
|
+
</section>
|
|
538
|
+
`;
|
|
539
|
+
}
|
|
540
|
+
function DefaultMenuItem({ label, children }) {
|
|
541
|
+
return html`
|
|
542
|
+
<div class="vds-menu-item">
|
|
543
|
+
<div class="vds-menu-item-label">${label}</div>
|
|
544
|
+
${children}
|
|
545
|
+
</div>
|
|
546
|
+
`;
|
|
547
|
+
}
|
|
548
|
+
function DefaultMenuButton({
|
|
549
|
+
label,
|
|
550
|
+
icon,
|
|
551
|
+
hint
|
|
552
|
+
}) {
|
|
553
|
+
return html`
|
|
554
|
+
<media-menu-button class="vds-menu-item">
|
|
555
|
+
${IconSlot("menu-arrow-left", "vds-menu-close-icon")}
|
|
556
|
+
${icon ? IconSlot(icon, "vds-menu-item-icon") : null}
|
|
557
|
+
<span class="vds-menu-item-label">${$signal(label)}</span>
|
|
558
|
+
<span class="vds-menu-item-hint" data-part="hint">${hint ? $signal(hint) : null} </span>
|
|
559
|
+
${IconSlot("menu-arrow-right", "vds-menu-open-icon")}
|
|
560
|
+
</media-menu-button>
|
|
561
|
+
`;
|
|
562
|
+
}
|
|
563
|
+
function DefaultRadioGroup({
|
|
564
|
+
value = null,
|
|
565
|
+
options,
|
|
566
|
+
hideLabel = false,
|
|
567
|
+
children = null,
|
|
568
|
+
onChange = null
|
|
569
|
+
}) {
|
|
570
|
+
function renderRadio(option) {
|
|
571
|
+
const { value: value2, label: content } = option;
|
|
572
|
+
return html`
|
|
573
|
+
<media-radio class="vds-radio" value=${value2}>
|
|
574
|
+
${IconSlot("menu-radio-check")}
|
|
575
|
+
${!hideLabel ? html`
|
|
576
|
+
<span class="vds-radio-label" data-part="label">
|
|
577
|
+
${isString(content) ? content : $signal(content)}
|
|
578
|
+
</span>
|
|
579
|
+
` : null}
|
|
580
|
+
${isFunction(children) ? children(option) : children}
|
|
581
|
+
</media-radio>
|
|
582
|
+
`;
|
|
583
|
+
}
|
|
584
|
+
return html`
|
|
585
|
+
<media-radio-group
|
|
586
|
+
class="vds-radio-group"
|
|
587
|
+
value=${isString(value) ? value : value ? $signal(value) : ""}
|
|
588
|
+
@change=${onChange}
|
|
589
|
+
>
|
|
590
|
+
${isArray(options) ? options.map(renderRadio) : $signal(() => options().map(renderRadio))}
|
|
591
|
+
</media-radio-group>
|
|
592
|
+
`;
|
|
593
|
+
}
|
|
594
|
+
function createRadioOptions(entries) {
|
|
595
|
+
return isArray(entries) ? entries.map((entry) => ({ label: entry, value: entry.toLowerCase() })) : Object.keys(entries).map((label) => ({ label, value: entries[label] }));
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
function DefaultSliderParts() {
|
|
599
|
+
return html`
|
|
600
|
+
<div class="vds-slider-track"></div>
|
|
601
|
+
<div class="vds-slider-track-fill vds-slider-track"></div>
|
|
602
|
+
<div class="vds-slider-thumb"></div>
|
|
603
|
+
`;
|
|
604
|
+
}
|
|
605
|
+
function DefaultSliderSteps() {
|
|
606
|
+
return html`
|
|
607
|
+
<media-slider-steps class="vds-slider-steps">
|
|
608
|
+
<template>
|
|
609
|
+
<div class="vds-slider-step"></div>
|
|
610
|
+
</template>
|
|
611
|
+
</media-slider-steps>
|
|
612
|
+
`;
|
|
613
|
+
}
|
|
614
|
+
function DefaultMenuSliderItem({
|
|
615
|
+
label = null,
|
|
616
|
+
value = null,
|
|
617
|
+
upIcon = "",
|
|
618
|
+
downIcon = "",
|
|
619
|
+
children,
|
|
620
|
+
isMin,
|
|
621
|
+
isMax
|
|
622
|
+
}) {
|
|
623
|
+
const hasTitle = label || value, content = [
|
|
624
|
+
downIcon ? IconSlot(downIcon, "down") : null,
|
|
625
|
+
children,
|
|
626
|
+
upIcon ? IconSlot(upIcon, "up") : null
|
|
627
|
+
];
|
|
628
|
+
return html`
|
|
629
|
+
<div
|
|
630
|
+
class=${`vds-menu-item vds-menu-slider-item${hasTitle ? " group" : ""}`}
|
|
631
|
+
data-min=${$signal(() => isMin() ? "" : null)}
|
|
632
|
+
data-max=${$signal(() => isMax() ? "" : null)}
|
|
633
|
+
>
|
|
634
|
+
${hasTitle ? html`
|
|
635
|
+
<div class="vds-menu-slider-title">
|
|
636
|
+
${[
|
|
637
|
+
label ? html`<div>${label}</div>` : null,
|
|
638
|
+
value ? html`<div>${value}</div>` : null
|
|
639
|
+
]}
|
|
640
|
+
</div>
|
|
641
|
+
<div class="vds-menu-slider-body">${content}</div>
|
|
642
|
+
` : content}
|
|
643
|
+
</div>
|
|
644
|
+
`;
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
const FONT_SIZE_OPTION_WITH_ICONS = {
|
|
648
|
+
...FONT_SIZE_OPTION,
|
|
649
|
+
upIcon: "menu-opacity-up",
|
|
650
|
+
downIcon: "menu-opacity-down"
|
|
651
|
+
};
|
|
652
|
+
const FONT_OPACITY_OPTION_WITH_ICONS = {
|
|
653
|
+
...FONT_OPACITY_OPTION,
|
|
654
|
+
upIcon: "menu-opacity-up",
|
|
655
|
+
downIcon: "menu-opacity-down"
|
|
656
|
+
};
|
|
657
|
+
function DefaultFontMenu() {
|
|
658
|
+
return $signal(() => {
|
|
659
|
+
const { hasCaptions } = useMediaState(), { translations } = useDefaultLayoutContext();
|
|
660
|
+
if (!hasCaptions()) return null;
|
|
661
|
+
return html`
|
|
662
|
+
<media-menu class="vds-font-menu vds-menu">
|
|
663
|
+
${DefaultMenuButton({
|
|
664
|
+
label: () => i18n(translations, "Caption Styles")
|
|
665
|
+
})}
|
|
666
|
+
<media-menu-items class="vds-menu-items">
|
|
667
|
+
${[
|
|
668
|
+
DefaultMenuSection({
|
|
669
|
+
label: $i18n(translations, "Font"),
|
|
670
|
+
children: [DefaultFontFamilyMenu(), DefaultFontSizeSlider()]
|
|
671
|
+
}),
|
|
672
|
+
DefaultMenuSection({
|
|
673
|
+
label: $i18n(translations, "Text"),
|
|
674
|
+
children: [
|
|
675
|
+
DefaultTextColorInput(),
|
|
676
|
+
DefaultTextShadowMenu(),
|
|
677
|
+
DefaultTextOpacitySlider()
|
|
678
|
+
]
|
|
679
|
+
}),
|
|
680
|
+
DefaultMenuSection({
|
|
681
|
+
label: $i18n(translations, "Text Background"),
|
|
682
|
+
children: [DefaultTextBgInput(), DefaultTextBgOpacitySlider()]
|
|
683
|
+
}),
|
|
684
|
+
DefaultMenuSection({
|
|
685
|
+
label: $i18n(translations, "Display Background"),
|
|
686
|
+
children: [DefaultDisplayBgInput(), DefaultDisplayOpacitySlider()]
|
|
687
|
+
}),
|
|
688
|
+
DefaultMenuSection({
|
|
689
|
+
children: [DefaultResetMenuItem()]
|
|
690
|
+
})
|
|
691
|
+
]}
|
|
692
|
+
</media-menu-items>
|
|
693
|
+
</media-menu>
|
|
694
|
+
`;
|
|
695
|
+
});
|
|
696
|
+
}
|
|
697
|
+
function DefaultFontFamilyMenu() {
|
|
698
|
+
return DefaultFontSetting({
|
|
699
|
+
label: "Family",
|
|
700
|
+
option: FONT_FAMILY_OPTION,
|
|
701
|
+
type: "fontFamily"
|
|
702
|
+
});
|
|
703
|
+
}
|
|
704
|
+
function DefaultFontSizeSlider() {
|
|
705
|
+
return DefaultFontSetting({
|
|
706
|
+
label: "Size",
|
|
707
|
+
option: FONT_SIZE_OPTION_WITH_ICONS,
|
|
708
|
+
type: "fontSize"
|
|
709
|
+
});
|
|
710
|
+
}
|
|
711
|
+
function DefaultTextColorInput() {
|
|
712
|
+
return DefaultFontSetting({
|
|
713
|
+
label: "Color",
|
|
714
|
+
option: FONT_COLOR_OPTION,
|
|
715
|
+
type: "textColor"
|
|
716
|
+
});
|
|
717
|
+
}
|
|
718
|
+
function DefaultTextOpacitySlider() {
|
|
719
|
+
return DefaultFontSetting({
|
|
720
|
+
label: "Opacity",
|
|
721
|
+
option: FONT_OPACITY_OPTION_WITH_ICONS,
|
|
722
|
+
type: "textOpacity"
|
|
723
|
+
});
|
|
724
|
+
}
|
|
725
|
+
function DefaultTextShadowMenu() {
|
|
726
|
+
return DefaultFontSetting({
|
|
727
|
+
label: "Shadow",
|
|
728
|
+
option: FONT_TEXT_SHADOW_OPTION,
|
|
729
|
+
type: "textShadow"
|
|
730
|
+
});
|
|
731
|
+
}
|
|
732
|
+
function DefaultTextBgInput() {
|
|
733
|
+
return DefaultFontSetting({
|
|
734
|
+
label: "Color",
|
|
735
|
+
option: FONT_COLOR_OPTION,
|
|
736
|
+
type: "textBg"
|
|
737
|
+
});
|
|
738
|
+
}
|
|
739
|
+
function DefaultTextBgOpacitySlider() {
|
|
740
|
+
return DefaultFontSetting({
|
|
741
|
+
label: "Opacity",
|
|
742
|
+
option: FONT_OPACITY_OPTION_WITH_ICONS,
|
|
743
|
+
type: "textBgOpacity"
|
|
744
|
+
});
|
|
745
|
+
}
|
|
746
|
+
function DefaultDisplayBgInput() {
|
|
747
|
+
return DefaultFontSetting({
|
|
748
|
+
label: "Color",
|
|
749
|
+
option: FONT_COLOR_OPTION,
|
|
750
|
+
type: "displayBg"
|
|
751
|
+
});
|
|
752
|
+
}
|
|
753
|
+
function DefaultDisplayOpacitySlider() {
|
|
754
|
+
return DefaultFontSetting({
|
|
755
|
+
label: "Opacity",
|
|
756
|
+
option: FONT_OPACITY_OPTION_WITH_ICONS,
|
|
757
|
+
type: "displayBgOpacity"
|
|
758
|
+
});
|
|
759
|
+
}
|
|
760
|
+
function DefaultResetMenuItem() {
|
|
761
|
+
const { translations } = useDefaultLayoutContext(), $label = () => i18n(translations, "Reset");
|
|
762
|
+
return html`
|
|
763
|
+
<button class="vds-menu-item" role="menuitem" @click=${onFontReset}>
|
|
764
|
+
<span class="vds-menu-item-label">${$signal($label)}</span>
|
|
765
|
+
</button>
|
|
766
|
+
`;
|
|
767
|
+
}
|
|
768
|
+
function DefaultFontSetting({ label, option, type }) {
|
|
769
|
+
const { player } = useMediaContext(), { translations } = useDefaultLayoutContext(), $currentValue = FONT_SIGNALS[type], $label = () => i18n(translations, label);
|
|
770
|
+
function notify() {
|
|
771
|
+
tick();
|
|
772
|
+
player.dispatchEvent(new Event("vds-font-change"));
|
|
773
|
+
}
|
|
774
|
+
if (option.type === "color") {
|
|
775
|
+
let onColorChange2 = function(event) {
|
|
776
|
+
$currentValue.set(event.target.value);
|
|
777
|
+
notify();
|
|
778
|
+
};
|
|
779
|
+
return DefaultMenuItem({
|
|
780
|
+
label: $signal($label),
|
|
781
|
+
children: html`
|
|
782
|
+
<input
|
|
783
|
+
class="vds-color-picker"
|
|
784
|
+
type="color"
|
|
785
|
+
.value=${$signal($currentValue)}
|
|
786
|
+
@input=${onColorChange2}
|
|
787
|
+
/>
|
|
788
|
+
`
|
|
789
|
+
});
|
|
790
|
+
}
|
|
791
|
+
if (option.type === "slider") {
|
|
792
|
+
let onSliderValueChange2 = function(event) {
|
|
793
|
+
$currentValue.set(event.detail + "%");
|
|
794
|
+
notify();
|
|
795
|
+
};
|
|
796
|
+
const { min, max, step, upIcon, downIcon } = option;
|
|
797
|
+
return DefaultMenuSliderItem({
|
|
798
|
+
label: $signal($label),
|
|
799
|
+
value: $signal($currentValue),
|
|
800
|
+
upIcon,
|
|
801
|
+
downIcon,
|
|
802
|
+
isMin: () => $currentValue() === min + "%",
|
|
803
|
+
isMax: () => $currentValue() === max + "%",
|
|
804
|
+
children: html`
|
|
805
|
+
<media-slider
|
|
806
|
+
class="vds-slider"
|
|
807
|
+
min=${min}
|
|
808
|
+
max=${max}
|
|
809
|
+
step=${step}
|
|
810
|
+
key-step=${step}
|
|
811
|
+
.value=${$signal(() => parseInt($currentValue()))}
|
|
812
|
+
aria-label=${$signal($label)}
|
|
813
|
+
@value-change=${onSliderValueChange2}
|
|
814
|
+
@drag-value-change=${onSliderValueChange2}
|
|
815
|
+
>
|
|
816
|
+
${DefaultSliderParts()}${DefaultSliderSteps()}
|
|
817
|
+
</media-slider>
|
|
818
|
+
`
|
|
819
|
+
});
|
|
820
|
+
}
|
|
821
|
+
const radioOptions = createRadioOptions(option.values), $hint = () => {
|
|
822
|
+
const value = $currentValue(), label2 = radioOptions.find((radio) => radio.value === value)?.label || "";
|
|
823
|
+
return i18n(translations, isString(label2) ? label2 : label2());
|
|
824
|
+
};
|
|
825
|
+
return html`
|
|
826
|
+
<media-menu class=${`vds-${camelToKebabCase(type)}-menu vds-menu`}>
|
|
827
|
+
${DefaultMenuButton({ label: $label, hint: $hint })}
|
|
828
|
+
<media-menu-items class="vds-menu-items">
|
|
829
|
+
${DefaultRadioGroup({
|
|
830
|
+
value: $currentValue,
|
|
831
|
+
options: radioOptions,
|
|
832
|
+
onChange({ detail: value }) {
|
|
833
|
+
$currentValue.set(value);
|
|
834
|
+
notify();
|
|
835
|
+
}
|
|
836
|
+
})}
|
|
837
|
+
</media-menu-items>
|
|
838
|
+
</media-menu>
|
|
839
|
+
`;
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
function DefaultMenuCheckbox({
|
|
843
|
+
label,
|
|
844
|
+
checked,
|
|
845
|
+
defaultChecked = false,
|
|
846
|
+
storageKey,
|
|
847
|
+
onChange
|
|
848
|
+
}) {
|
|
849
|
+
const { translations } = useDefaultLayoutContext(), savedValue = storageKey ? localStorage.getItem(storageKey) : null, $checked = signal(!!(savedValue ?? defaultChecked)), $active = signal(false), $ariaChecked = $signal($ariaBool($checked)), $label = $i18n(translations, label);
|
|
850
|
+
if (storageKey) onChange(peek($checked));
|
|
851
|
+
if (checked) {
|
|
852
|
+
effect(() => void $checked.set(checked()));
|
|
853
|
+
}
|
|
854
|
+
function onPress(event) {
|
|
855
|
+
if (event?.button === 1) return;
|
|
856
|
+
$checked.set((checked2) => !checked2);
|
|
857
|
+
if (storageKey) localStorage.setItem(storageKey, $checked() ? "1" : "");
|
|
858
|
+
onChange($checked(), event);
|
|
859
|
+
$active.set(false);
|
|
860
|
+
}
|
|
861
|
+
function onKeyDown(event) {
|
|
862
|
+
if (isKeyboardClick(event)) onPress();
|
|
863
|
+
}
|
|
864
|
+
function onActive(event) {
|
|
865
|
+
if (event.button !== 0) return;
|
|
866
|
+
$active.set(true);
|
|
867
|
+
}
|
|
868
|
+
return html`
|
|
869
|
+
<div
|
|
870
|
+
class="vds-menu-checkbox"
|
|
871
|
+
role="menuitemcheckbox"
|
|
872
|
+
tabindex="0"
|
|
873
|
+
aria-label=${$label}
|
|
874
|
+
aria-checked=${$ariaChecked}
|
|
875
|
+
data-active=${$signal(() => $active() ? "" : null)}
|
|
876
|
+
@pointerup=${onPress}
|
|
877
|
+
@pointerdown=${onActive}
|
|
878
|
+
@keydown=${onKeyDown}
|
|
879
|
+
></div>
|
|
880
|
+
`;
|
|
881
|
+
}
|
|
882
|
+
|
|
883
|
+
function DefaultAccessibilityMenu() {
|
|
884
|
+
return $signal(() => {
|
|
885
|
+
const { translations } = useDefaultLayoutContext();
|
|
886
|
+
return html`
|
|
887
|
+
<media-menu class="vds-accessibility-menu vds-menu">
|
|
888
|
+
${DefaultMenuButton({
|
|
889
|
+
label: () => i18n(translations, "Accessibility"),
|
|
890
|
+
icon: "menu-accessibility"
|
|
891
|
+
})}
|
|
892
|
+
<media-menu-items class="vds-menu-items">
|
|
893
|
+
${[
|
|
894
|
+
DefaultMenuSection({
|
|
895
|
+
children: [
|
|
896
|
+
DefaultAnnouncementsMenuCheckbox(),
|
|
897
|
+
DefaultKeyboardAnimationsMenuCheckbox()
|
|
898
|
+
]
|
|
899
|
+
}),
|
|
900
|
+
DefaultMenuSection({
|
|
901
|
+
children: [DefaultFontMenu()]
|
|
902
|
+
})
|
|
903
|
+
]}
|
|
904
|
+
</media-menu-items>
|
|
905
|
+
</media-menu>
|
|
906
|
+
`;
|
|
907
|
+
});
|
|
908
|
+
}
|
|
909
|
+
function DefaultAnnouncementsMenuCheckbox() {
|
|
910
|
+
const { userPrefersAnnouncements, translations } = useDefaultLayoutContext(), label = "Announcements";
|
|
911
|
+
return DefaultMenuItem({
|
|
912
|
+
label: $i18n(translations, label),
|
|
913
|
+
children: DefaultMenuCheckbox({
|
|
914
|
+
label,
|
|
915
|
+
storageKey: "vds-player::announcements",
|
|
916
|
+
onChange(checked) {
|
|
917
|
+
userPrefersAnnouncements.set(checked);
|
|
918
|
+
}
|
|
919
|
+
})
|
|
920
|
+
});
|
|
921
|
+
}
|
|
922
|
+
function DefaultKeyboardAnimationsMenuCheckbox() {
|
|
923
|
+
return $signal(() => {
|
|
924
|
+
const { translations, userPrefersKeyboardAnimations, noKeyboardAnimations } = useDefaultLayoutContext(), { viewType } = useMediaState(), $disabled = computed(() => viewType() !== "video" || noKeyboardAnimations());
|
|
925
|
+
if ($disabled()) return null;
|
|
926
|
+
const label = "Keyboard Animations";
|
|
927
|
+
return DefaultMenuItem({
|
|
928
|
+
label: $i18n(translations, label),
|
|
929
|
+
children: DefaultMenuCheckbox({
|
|
930
|
+
label,
|
|
931
|
+
defaultChecked: true,
|
|
932
|
+
storageKey: "vds-player::keyboard-animations",
|
|
933
|
+
onChange(checked) {
|
|
934
|
+
userPrefersKeyboardAnimations.set(checked);
|
|
935
|
+
}
|
|
936
|
+
})
|
|
937
|
+
});
|
|
938
|
+
});
|
|
939
|
+
}
|
|
940
|
+
|
|
941
|
+
function DefaultAudioMenu() {
|
|
942
|
+
return $signal(() => {
|
|
943
|
+
const { noAudioGain, translations } = useDefaultLayoutContext(), { audioTracks, canSetAudioGain } = useMediaState(), $disabled = computed(() => {
|
|
944
|
+
const hasGainSlider = canSetAudioGain() && !noAudioGain();
|
|
945
|
+
return !hasGainSlider && audioTracks().length <= 1;
|
|
946
|
+
});
|
|
947
|
+
if ($disabled()) return null;
|
|
948
|
+
return html`
|
|
949
|
+
<media-menu class="vds-audio-menu vds-menu">
|
|
950
|
+
${DefaultMenuButton({
|
|
951
|
+
label: () => i18n(translations, "Audio"),
|
|
952
|
+
icon: "menu-audio"
|
|
953
|
+
})}
|
|
954
|
+
<media-menu-items class="vds-menu-items">
|
|
955
|
+
${[DefaultAudioTracksMenu(), DefaultAudioBoostSection()]}
|
|
956
|
+
</media-menu-items>
|
|
957
|
+
</media-menu>
|
|
958
|
+
`;
|
|
959
|
+
});
|
|
960
|
+
}
|
|
961
|
+
function DefaultAudioTracksMenu() {
|
|
962
|
+
return $signal(() => {
|
|
963
|
+
const { translations } = useDefaultLayoutContext(), { audioTracks } = useMediaState(), $defaultText = $i18n(translations, "Default"), $disabled = computed(() => audioTracks().length <= 1);
|
|
964
|
+
if ($disabled()) return null;
|
|
965
|
+
return DefaultMenuSection({
|
|
966
|
+
children: html`
|
|
967
|
+
<media-menu class="vds-audio-tracks-menu vds-menu">
|
|
968
|
+
${DefaultMenuButton({
|
|
969
|
+
label: () => i18n(translations, "Track")
|
|
970
|
+
})}
|
|
971
|
+
<media-menu-items class="vds-menu-items">
|
|
972
|
+
<media-audio-radio-group
|
|
973
|
+
class="vds-audio-track-radio-group vds-radio-group"
|
|
974
|
+
empty-label=${$defaultText}
|
|
975
|
+
>
|
|
976
|
+
<template>
|
|
977
|
+
<media-radio class="vds-audio-track-radio vds-radio">
|
|
978
|
+
<slot name="menu-radio-check-icon" data-class="vds-icon"></slot>
|
|
979
|
+
<span class="vds-radio-label" data-part="label"></span>
|
|
980
|
+
</media-radio>
|
|
981
|
+
</template>
|
|
982
|
+
</media-audio-radio-group>
|
|
983
|
+
</media-menu-items>
|
|
984
|
+
</media-menu>
|
|
985
|
+
`
|
|
986
|
+
});
|
|
987
|
+
});
|
|
988
|
+
}
|
|
989
|
+
function DefaultAudioBoostSection() {
|
|
990
|
+
return $signal(() => {
|
|
991
|
+
const { noAudioGain, translations } = useDefaultLayoutContext(), { canSetAudioGain } = useMediaState(), $disabled = computed(() => !canSetAudioGain() || noAudioGain());
|
|
992
|
+
if ($disabled()) return null;
|
|
993
|
+
const { audioGain } = useMediaState();
|
|
994
|
+
return DefaultMenuSection({
|
|
995
|
+
label: $i18n(translations, "Boost"),
|
|
996
|
+
value: $signal(() => Math.round(((audioGain() ?? 1) - 1) * 100) + "%"),
|
|
997
|
+
children: [
|
|
998
|
+
DefaultMenuSliderItem({
|
|
999
|
+
upIcon: "menu-audio-boost-up",
|
|
1000
|
+
downIcon: "menu-audio-boost-down",
|
|
1001
|
+
children: DefaultAudioGainSlider(),
|
|
1002
|
+
isMin: () => ((audioGain() ?? 1) - 1) * 100 <= getGainMin(),
|
|
1003
|
+
isMax: () => ((audioGain() ?? 1) - 1) * 100 === getGainMax()
|
|
1004
|
+
})
|
|
1005
|
+
]
|
|
1006
|
+
});
|
|
1007
|
+
});
|
|
1008
|
+
}
|
|
1009
|
+
function DefaultAudioGainSlider() {
|
|
1010
|
+
const { translations } = useDefaultLayoutContext(), $label = $i18n(translations, "Boost"), $min = getGainMin, $max = getGainMax, $step = getGainStep;
|
|
1011
|
+
return html`
|
|
1012
|
+
<media-audio-gain-slider
|
|
1013
|
+
class="vds-audio-gain-slider vds-slider"
|
|
1014
|
+
aria-label=${$label}
|
|
1015
|
+
min=${$signal($min)}
|
|
1016
|
+
max=${$signal($max)}
|
|
1017
|
+
step=${$signal($step)}
|
|
1018
|
+
key-step=${$signal($step)}
|
|
1019
|
+
>
|
|
1020
|
+
${DefaultSliderParts()}${DefaultSliderSteps()}
|
|
1021
|
+
</media-audio-gain-slider>
|
|
1022
|
+
`;
|
|
1023
|
+
}
|
|
1024
|
+
function getGainMin() {
|
|
1025
|
+
const { audioGains } = useDefaultLayoutContext(), gains = audioGains();
|
|
1026
|
+
return isArray(gains) ? gains[0] ?? 0 : gains.min;
|
|
1027
|
+
}
|
|
1028
|
+
function getGainMax() {
|
|
1029
|
+
const { audioGains } = useDefaultLayoutContext(), gains = audioGains();
|
|
1030
|
+
return isArray(gains) ? gains[gains.length - 1] ?? 300 : gains.max;
|
|
1031
|
+
}
|
|
1032
|
+
function getGainStep() {
|
|
1033
|
+
const { audioGains } = useDefaultLayoutContext(), gains = audioGains();
|
|
1034
|
+
return isArray(gains) ? gains[1] - gains[0] || 25 : gains.step;
|
|
1035
|
+
}
|
|
1036
|
+
|
|
1037
|
+
const LANG_FLAGS = {
|
|
1038
|
+
en: "gb",
|
|
1039
|
+
eng: "gb",
|
|
1040
|
+
english: "gb",
|
|
1041
|
+
id: "id",
|
|
1042
|
+
ind: "id",
|
|
1043
|
+
indonesian: "id",
|
|
1044
|
+
ja: "jp",
|
|
1045
|
+
jpn: "jp",
|
|
1046
|
+
japanese: "jp",
|
|
1047
|
+
ko: "kr",
|
|
1048
|
+
kor: "kr",
|
|
1049
|
+
korean: "kr",
|
|
1050
|
+
zh: "cn",
|
|
1051
|
+
zho: "cn",
|
|
1052
|
+
chi: "cn",
|
|
1053
|
+
chinese: "cn",
|
|
1054
|
+
es: "es",
|
|
1055
|
+
spa: "es",
|
|
1056
|
+
spanish: "es",
|
|
1057
|
+
fr: "fr",
|
|
1058
|
+
fra: "fr",
|
|
1059
|
+
french: "fr",
|
|
1060
|
+
de: "de",
|
|
1061
|
+
deu: "de",
|
|
1062
|
+
ger: "de",
|
|
1063
|
+
german: "de",
|
|
1064
|
+
pt: "br",
|
|
1065
|
+
por: "br",
|
|
1066
|
+
portuguese: "br",
|
|
1067
|
+
ru: "ru",
|
|
1068
|
+
rus: "ru",
|
|
1069
|
+
russian: "ru",
|
|
1070
|
+
ar: "sa",
|
|
1071
|
+
ara: "sa",
|
|
1072
|
+
arabic: "sa",
|
|
1073
|
+
hi: "in",
|
|
1074
|
+
hin: "in",
|
|
1075
|
+
hindi: "in",
|
|
1076
|
+
th: "th",
|
|
1077
|
+
tha: "th",
|
|
1078
|
+
thai: "th",
|
|
1079
|
+
vi: "vn",
|
|
1080
|
+
vie: "vn",
|
|
1081
|
+
vietnamese: "vn",
|
|
1082
|
+
it: "it",
|
|
1083
|
+
ita: "it",
|
|
1084
|
+
italian: "it",
|
|
1085
|
+
tr: "tr",
|
|
1086
|
+
tur: "tr",
|
|
1087
|
+
turkish: "tr",
|
|
1088
|
+
pl: "pl",
|
|
1089
|
+
pol: "pl",
|
|
1090
|
+
polish: "pl",
|
|
1091
|
+
nl: "nl",
|
|
1092
|
+
nld: "nl",
|
|
1093
|
+
dutch: "nl",
|
|
1094
|
+
ms: "my",
|
|
1095
|
+
msa: "my",
|
|
1096
|
+
malay: "my"
|
|
1097
|
+
};
|
|
1098
|
+
function getFlagCode(label) {
|
|
1099
|
+
const lower = label.toLowerCase().replace(/\s\d+$/, "").trim();
|
|
1100
|
+
if (LANG_FLAGS[lower]) return LANG_FLAGS[lower];
|
|
1101
|
+
for (const [key, code] of Object.entries(LANG_FLAGS)) {
|
|
1102
|
+
if (lower.startsWith(key) || lower.includes(key)) return code;
|
|
1103
|
+
}
|
|
1104
|
+
return null;
|
|
1105
|
+
}
|
|
1106
|
+
function DefaultCaptionsMenu() {
|
|
1107
|
+
return $signal(() => {
|
|
1108
|
+
const { translations } = useDefaultLayoutContext(), { hasCaptions, textTracks, textTrack } = useMediaState(), $offText = $i18n(translations, "Off"), media = useMediaContext();
|
|
1109
|
+
if (!hasCaptions()) return null;
|
|
1110
|
+
const activeTrack = textTrack();
|
|
1111
|
+
const tracks = textTracks().filter(isTrackCaptionKind);
|
|
1112
|
+
const grouped = /* @__PURE__ */ new Map();
|
|
1113
|
+
for (const track of tracks) {
|
|
1114
|
+
const normalizedLabel = track.label.replace(/\s\d+$/, "").trim();
|
|
1115
|
+
if (!grouped.has(normalizedLabel)) {
|
|
1116
|
+
grouped.set(normalizedLabel, []);
|
|
1117
|
+
}
|
|
1118
|
+
grouped.get(normalizedLabel).push(track);
|
|
1119
|
+
}
|
|
1120
|
+
const priorities = ["indonesian", "english", "japanese", "korean", "chinese"];
|
|
1121
|
+
const getPriority = (label) => {
|
|
1122
|
+
const lower = label.toLowerCase();
|
|
1123
|
+
const pIndex = priorities.findIndex((p) => lower.includes(p));
|
|
1124
|
+
return pIndex !== -1 ? pIndex : 999;
|
|
1125
|
+
};
|
|
1126
|
+
const sortedGroups = Array.from(grouped.entries()).sort((a, b) => {
|
|
1127
|
+
const pa = getPriority(a[0]);
|
|
1128
|
+
const pb = getPriority(b[0]);
|
|
1129
|
+
if (pa !== pb) return pa - pb;
|
|
1130
|
+
return a[0].localeCompare(b[0]);
|
|
1131
|
+
});
|
|
1132
|
+
const isOff = tracks.every((t) => t.mode !== "showing");
|
|
1133
|
+
const onOffSelect = (e) => {
|
|
1134
|
+
const selected = media.textTracks.selected;
|
|
1135
|
+
if (selected) {
|
|
1136
|
+
const idx = media.textTracks.indexOf(selected);
|
|
1137
|
+
media.remote.changeTextTrackMode(idx, "disabled", e);
|
|
1138
|
+
}
|
|
1139
|
+
};
|
|
1140
|
+
return html`
|
|
1141
|
+
<media-menu class="vds-captions-menu vds-menu">
|
|
1142
|
+
${DefaultMenuButton({
|
|
1143
|
+
label: () => i18n(translations, "Captions"),
|
|
1144
|
+
icon: "menu-captions"
|
|
1145
|
+
})}
|
|
1146
|
+
<media-menu-items class="vds-menu-items">
|
|
1147
|
+
|
|
1148
|
+
<media-radio-group value=${isOff ? "off" : "none"}>
|
|
1149
|
+
<media-radio
|
|
1150
|
+
class="vds-caption-radio vds-radio"
|
|
1151
|
+
value="off"
|
|
1152
|
+
@change=${onOffSelect}
|
|
1153
|
+
>
|
|
1154
|
+
<slot name="menu-radio-check-icon" data-class="vds-icon"></slot>
|
|
1155
|
+
<span class="vds-radio-label">${$offText}</span>
|
|
1156
|
+
</media-radio>
|
|
1157
|
+
</media-radio-group>
|
|
1158
|
+
|
|
1159
|
+
${sortedGroups.map(([groupLabel, groupTracks]) => {
|
|
1160
|
+
const flagCode = getFlagCode(groupLabel);
|
|
1161
|
+
const title = html`
|
|
1162
|
+
<div style="display: flex; align-items: center; gap: 8px;">
|
|
1163
|
+
${flagCode ? html`<span class="fi fi-${flagCode}" style="font-size: 1.25em; border-radius: 2px; width: 1.33em; height: 1em; display: inline-block; background-image: url('https://cdnjs.cloudflare.com/ajax/libs/flag-icons/7.1.0/flags/4x3/${flagCode}.svg'); background-size: cover; background-position: center;"></span>` : ""}
|
|
1164
|
+
<span>${groupLabel}</span>
|
|
1165
|
+
</div>
|
|
1166
|
+
`;
|
|
1167
|
+
const activeIndex = groupTracks.findIndex((t) => t === activeTrack);
|
|
1168
|
+
return html`
|
|
1169
|
+
<media-menu class="vds-captions-group-menu vds-menu">
|
|
1170
|
+
${DefaultMenuButton({
|
|
1171
|
+
label: () => title
|
|
1172
|
+
})}
|
|
1173
|
+
<media-menu-items class="vds-menu-items">
|
|
1174
|
+
<media-radio-group value=${String(activeIndex)}>
|
|
1175
|
+
${groupTracks.map((track, idx) => {
|
|
1176
|
+
const displayLabel = groupTracks.length > 1 ? `${groupLabel} ${idx + 1}` : groupLabel;
|
|
1177
|
+
const onSelect = (e) => {
|
|
1178
|
+
const globalIdx = media.textTracks.indexOf(track);
|
|
1179
|
+
media.remote.changeTextTrackMode(globalIdx, "showing", e);
|
|
1180
|
+
};
|
|
1181
|
+
return html`
|
|
1182
|
+
<media-radio
|
|
1183
|
+
class="vds-caption-radio vds-radio"
|
|
1184
|
+
value=${String(idx)}
|
|
1185
|
+
@change=${onSelect}
|
|
1186
|
+
>
|
|
1187
|
+
<slot name="menu-radio-check-icon" data-class="vds-icon"></slot>
|
|
1188
|
+
<span class="vds-radio-label">${displayLabel}</span>
|
|
1189
|
+
</media-radio>
|
|
1190
|
+
`;
|
|
1191
|
+
})}
|
|
1192
|
+
</media-radio-group>
|
|
1193
|
+
</media-menu-items>
|
|
1194
|
+
</media-menu>
|
|
1195
|
+
`;
|
|
1196
|
+
})}
|
|
1197
|
+
|
|
1198
|
+
</media-menu-items>
|
|
1199
|
+
</media-menu>
|
|
1200
|
+
`;
|
|
1201
|
+
});
|
|
1202
|
+
}
|
|
1203
|
+
|
|
1204
|
+
function DefaultPlaybackMenu() {
|
|
1205
|
+
return $signal(() => {
|
|
1206
|
+
const { translations } = useDefaultLayoutContext();
|
|
1207
|
+
return html`
|
|
1208
|
+
<media-menu class="vds-playback-menu vds-menu">
|
|
1209
|
+
${DefaultMenuButton({
|
|
1210
|
+
label: () => i18n(translations, "Playback"),
|
|
1211
|
+
icon: "menu-playback"
|
|
1212
|
+
})}
|
|
1213
|
+
<media-menu-items class="vds-menu-items">
|
|
1214
|
+
${[
|
|
1215
|
+
DefaultMenuSection({
|
|
1216
|
+
children: DefaultLoopCheckbox()
|
|
1217
|
+
}),
|
|
1218
|
+
DefaultSpeedMenuSection(),
|
|
1219
|
+
DefaultQualityMenuSection()
|
|
1220
|
+
]}
|
|
1221
|
+
</media-menu-items>
|
|
1222
|
+
</media-menu>
|
|
1223
|
+
`;
|
|
1224
|
+
});
|
|
1225
|
+
}
|
|
1226
|
+
function DefaultLoopCheckbox() {
|
|
1227
|
+
const { remote } = useMediaContext(), { translations } = useDefaultLayoutContext(), label = "Loop";
|
|
1228
|
+
return DefaultMenuItem({
|
|
1229
|
+
label: $i18n(translations, label),
|
|
1230
|
+
children: DefaultMenuCheckbox({
|
|
1231
|
+
label,
|
|
1232
|
+
storageKey: "vds-player::user-loop",
|
|
1233
|
+
onChange(checked, trigger) {
|
|
1234
|
+
remote.userPrefersLoopChange(checked, trigger);
|
|
1235
|
+
}
|
|
1236
|
+
})
|
|
1237
|
+
});
|
|
1238
|
+
}
|
|
1239
|
+
function DefaultSpeedMenuSection() {
|
|
1240
|
+
return $signal(() => {
|
|
1241
|
+
const { translations } = useDefaultLayoutContext(), { canSetPlaybackRate, playbackRate } = useMediaState();
|
|
1242
|
+
if (!canSetPlaybackRate()) return null;
|
|
1243
|
+
return DefaultMenuSection({
|
|
1244
|
+
label: $i18n(translations, "Speed"),
|
|
1245
|
+
value: $signal(
|
|
1246
|
+
() => playbackRate() === 1 ? i18n(translations, "Normal") : playbackRate() + "x"
|
|
1247
|
+
),
|
|
1248
|
+
children: [
|
|
1249
|
+
DefaultMenuSliderItem({
|
|
1250
|
+
upIcon: "menu-speed-up",
|
|
1251
|
+
downIcon: "menu-speed-down",
|
|
1252
|
+
children: DefaultSpeedSlider(),
|
|
1253
|
+
isMin: () => playbackRate() === getSpeedMin(),
|
|
1254
|
+
isMax: () => playbackRate() === getSpeedMax()
|
|
1255
|
+
})
|
|
1256
|
+
]
|
|
1257
|
+
});
|
|
1258
|
+
});
|
|
1259
|
+
}
|
|
1260
|
+
function getSpeedMin() {
|
|
1261
|
+
const { playbackRates } = useDefaultLayoutContext(), rates = playbackRates();
|
|
1262
|
+
return isArray(rates) ? rates[0] ?? 0 : rates.min;
|
|
1263
|
+
}
|
|
1264
|
+
function getSpeedMax() {
|
|
1265
|
+
const { playbackRates } = useDefaultLayoutContext(), rates = playbackRates();
|
|
1266
|
+
return isArray(rates) ? rates[rates.length - 1] ?? 2 : rates.max;
|
|
1267
|
+
}
|
|
1268
|
+
function getSpeedStep() {
|
|
1269
|
+
const { playbackRates } = useDefaultLayoutContext(), rates = playbackRates();
|
|
1270
|
+
return isArray(rates) ? rates[1] - rates[0] || 0.25 : rates.step;
|
|
1271
|
+
}
|
|
1272
|
+
function DefaultSpeedSlider() {
|
|
1273
|
+
const { translations } = useDefaultLayoutContext(), $label = $i18n(translations, "Speed"), $min = getSpeedMin, $max = getSpeedMax, $step = getSpeedStep;
|
|
1274
|
+
return html`
|
|
1275
|
+
<media-speed-slider
|
|
1276
|
+
class="vds-speed-slider vds-slider"
|
|
1277
|
+
aria-label=${$label}
|
|
1278
|
+
min=${$signal($min)}
|
|
1279
|
+
max=${$signal($max)}
|
|
1280
|
+
step=${$signal($step)}
|
|
1281
|
+
key-step=${$signal($step)}
|
|
1282
|
+
>
|
|
1283
|
+
${DefaultSliderParts()}${DefaultSliderSteps()}
|
|
1284
|
+
</media-speed-slider>
|
|
1285
|
+
`;
|
|
1286
|
+
}
|
|
1287
|
+
function DefaultAutoQualityCheckbox() {
|
|
1288
|
+
const { remote, qualities } = useMediaContext(), { autoQuality, canSetQuality, qualities: $qualities } = useMediaState(), { translations } = useDefaultLayoutContext(), label = "Auto", $disabled = computed(() => !canSetQuality() || $qualities().length <= 1);
|
|
1289
|
+
if ($disabled()) return null;
|
|
1290
|
+
return DefaultMenuItem({
|
|
1291
|
+
label: $i18n(translations, label),
|
|
1292
|
+
children: DefaultMenuCheckbox({
|
|
1293
|
+
label,
|
|
1294
|
+
checked: autoQuality,
|
|
1295
|
+
onChange(checked, trigger) {
|
|
1296
|
+
if (checked) {
|
|
1297
|
+
remote.requestAutoQuality(trigger);
|
|
1298
|
+
} else {
|
|
1299
|
+
remote.changeQuality(qualities.selectedIndex, trigger);
|
|
1300
|
+
}
|
|
1301
|
+
}
|
|
1302
|
+
})
|
|
1303
|
+
});
|
|
1304
|
+
}
|
|
1305
|
+
function DefaultQualityMenuSection() {
|
|
1306
|
+
return $signal(() => {
|
|
1307
|
+
const { hideQualityBitrate, translations } = useDefaultLayoutContext(), { canSetQuality, qualities, quality } = useMediaState(), $disabled = computed(() => !canSetQuality() || qualities().length <= 1), $sortedQualities = computed(() => sortVideoQualities(qualities()));
|
|
1308
|
+
if ($disabled()) return null;
|
|
1309
|
+
return DefaultMenuSection({
|
|
1310
|
+
label: $i18n(translations, "Quality"),
|
|
1311
|
+
value: $signal(() => {
|
|
1312
|
+
const height = quality()?.height, label = quality()?.label, bitrate = !hideQualityBitrate() ? quality()?.bitrate : null, bitrateText = bitrate && bitrate > 0 ? `${(bitrate / 1e6).toFixed(2)} Mbps` : null, autoText = i18n(translations, "Auto");
|
|
1313
|
+
const rootText = label ?? (height ? `${height}p` : "");
|
|
1314
|
+
return rootText ? `${rootText}${bitrateText ? ` (${bitrateText})` : ""}` : autoText;
|
|
1315
|
+
}),
|
|
1316
|
+
children: [
|
|
1317
|
+
DefaultMenuSliderItem({
|
|
1318
|
+
upIcon: "menu-quality-up",
|
|
1319
|
+
downIcon: "menu-quality-down",
|
|
1320
|
+
children: DefaultQualitySlider(),
|
|
1321
|
+
isMin: () => $sortedQualities()[0] === quality(),
|
|
1322
|
+
isMax: () => $sortedQualities().at(-1) === quality()
|
|
1323
|
+
}),
|
|
1324
|
+
DefaultAutoQualityCheckbox()
|
|
1325
|
+
]
|
|
1326
|
+
});
|
|
1327
|
+
});
|
|
1328
|
+
}
|
|
1329
|
+
function DefaultQualitySlider() {
|
|
1330
|
+
const { translations } = useDefaultLayoutContext(), $label = $i18n(translations, "Quality");
|
|
1331
|
+
return html`
|
|
1332
|
+
<media-quality-slider class="vds-quality-slider vds-slider" aria-label=${$label}>
|
|
1333
|
+
${DefaultSliderParts()}${DefaultSliderSteps()}
|
|
1334
|
+
</media-quality-slider>
|
|
1335
|
+
`;
|
|
1336
|
+
}
|
|
1337
|
+
|
|
1338
|
+
function DefaultSettingsMenu({
|
|
1339
|
+
placement,
|
|
1340
|
+
portal,
|
|
1341
|
+
tooltip
|
|
1342
|
+
}) {
|
|
1343
|
+
return $signal(() => {
|
|
1344
|
+
const { viewType } = useMediaState(), {
|
|
1345
|
+
translations,
|
|
1346
|
+
menuPortal,
|
|
1347
|
+
noModal,
|
|
1348
|
+
menuGroup,
|
|
1349
|
+
smallWhen: smWhen
|
|
1350
|
+
} = useDefaultLayoutContext(), $placement = computed(
|
|
1351
|
+
() => noModal() ? unwrap(placement) : !smWhen() ? unwrap(placement) : null
|
|
1352
|
+
), $offset = computed(
|
|
1353
|
+
() => !smWhen() && menuGroup() === "bottom" && viewType() === "video" ? 26 : 0
|
|
1354
|
+
), $isOpen = signal(false);
|
|
1355
|
+
function onOpen() {
|
|
1356
|
+
$isOpen.set(true);
|
|
1357
|
+
}
|
|
1358
|
+
function onClose() {
|
|
1359
|
+
$isOpen.set(false);
|
|
1360
|
+
}
|
|
1361
|
+
const items = html`
|
|
1362
|
+
<media-menu-items
|
|
1363
|
+
class="vds-settings-menu-items vds-menu-items"
|
|
1364
|
+
placement=${$signal($placement)}
|
|
1365
|
+
offset=${$signal($offset)}
|
|
1366
|
+
>
|
|
1367
|
+
${$signal(() => {
|
|
1368
|
+
if (!$isOpen()) {
|
|
1369
|
+
return null;
|
|
1370
|
+
}
|
|
1371
|
+
return [
|
|
1372
|
+
DefaultPlaybackMenu(),
|
|
1373
|
+
DefaultAccessibilityMenu(),
|
|
1374
|
+
DefaultAudioMenu(),
|
|
1375
|
+
DefaultCaptionsMenu()
|
|
1376
|
+
];
|
|
1377
|
+
})}
|
|
1378
|
+
</media-menu-items>
|
|
1379
|
+
`;
|
|
1380
|
+
return html`
|
|
1381
|
+
<media-menu class="vds-settings-menu vds-menu" @open=${onOpen} @close=${onClose}>
|
|
1382
|
+
<media-tooltip class="vds-tooltip">
|
|
1383
|
+
<media-tooltip-trigger>
|
|
1384
|
+
<media-menu-button
|
|
1385
|
+
class="vds-menu-button vds-button"
|
|
1386
|
+
aria-label=${$i18n(translations, "Settings")}
|
|
1387
|
+
>
|
|
1388
|
+
${IconSlot("menu-settings", "vds-rotate-icon")}
|
|
1389
|
+
</media-menu-button>
|
|
1390
|
+
</media-tooltip-trigger>
|
|
1391
|
+
<media-tooltip-content
|
|
1392
|
+
class="vds-tooltip-content"
|
|
1393
|
+
placement=${isFunction(tooltip) ? $signal(tooltip) : tooltip}
|
|
1394
|
+
>
|
|
1395
|
+
${$i18n(translations, "Settings")}
|
|
1396
|
+
</media-tooltip-content>
|
|
1397
|
+
</media-tooltip>
|
|
1398
|
+
${MenuPortal(menuPortal, items) }
|
|
1399
|
+
</media-menu>
|
|
1400
|
+
`;
|
|
1401
|
+
});
|
|
1402
|
+
}
|
|
1403
|
+
|
|
1404
|
+
function DefaultVolumePopup({
|
|
1405
|
+
orientation,
|
|
1406
|
+
tooltip
|
|
1407
|
+
}) {
|
|
1408
|
+
return $signal(() => {
|
|
1409
|
+
const { pointer, muted, canSetVolume } = useMediaState();
|
|
1410
|
+
if (pointer() === "coarse" && !muted()) return null;
|
|
1411
|
+
if (!canSetVolume()) {
|
|
1412
|
+
return DefaultMuteButton({ tooltip });
|
|
1413
|
+
}
|
|
1414
|
+
const $rootRef = signal(void 0), $isRootActive = useActive($rootRef);
|
|
1415
|
+
return html`
|
|
1416
|
+
<div class="vds-volume" ?data-active=${$signal($isRootActive)} ${ref($rootRef.set)}>
|
|
1417
|
+
${DefaultMuteButton({ tooltip })}
|
|
1418
|
+
<div class="vds-volume-popup">${DefaultVolumeSlider({ orientation })}</div>
|
|
1419
|
+
</div>
|
|
1420
|
+
`;
|
|
1421
|
+
});
|
|
1422
|
+
}
|
|
1423
|
+
function DefaultVolumeSlider({ orientation } = {}) {
|
|
1424
|
+
const { translations } = useDefaultLayoutContext(), $label = $i18n(translations, "Volume");
|
|
1425
|
+
return html`
|
|
1426
|
+
<media-volume-slider
|
|
1427
|
+
class="vds-volume-slider vds-slider"
|
|
1428
|
+
aria-label=${$label}
|
|
1429
|
+
orientation=${ifDefined(orientation)}
|
|
1430
|
+
>
|
|
1431
|
+
<div class="vds-slider-track"></div>
|
|
1432
|
+
<div class="vds-slider-track-fill vds-slider-track"></div>
|
|
1433
|
+
<media-slider-preview class="vds-slider-preview" no-clamp>
|
|
1434
|
+
<media-slider-value class="vds-slider-value"></media-slider-value>
|
|
1435
|
+
</media-slider-preview>
|
|
1436
|
+
<div class="vds-slider-thumb"></div>
|
|
1437
|
+
</media-volume-slider>
|
|
1438
|
+
`;
|
|
1439
|
+
}
|
|
1440
|
+
function DefaultTimeSlider() {
|
|
1441
|
+
const $ref = signal(void 0), $width = signal(0), {
|
|
1442
|
+
thumbnails,
|
|
1443
|
+
translations,
|
|
1444
|
+
sliderChaptersMinWidth,
|
|
1445
|
+
disableTimeSlider,
|
|
1446
|
+
seekStep,
|
|
1447
|
+
noScrubGesture
|
|
1448
|
+
} = useDefaultLayoutContext(), $label = $i18n(translations, "Seek"), $isDisabled = $signal(disableTimeSlider), $isChaptersDisabled = $signal(() => $width() < sliderChaptersMinWidth()), $thumbnails = $signal(thumbnails);
|
|
1449
|
+
useResizeObserver($ref, () => {
|
|
1450
|
+
const el = $ref();
|
|
1451
|
+
el && $width.set(el.clientWidth);
|
|
1452
|
+
});
|
|
1453
|
+
return html`
|
|
1454
|
+
<media-time-slider
|
|
1455
|
+
class="vds-time-slider vds-slider"
|
|
1456
|
+
aria-label=${$label}
|
|
1457
|
+
key-step=${$signal(seekStep)}
|
|
1458
|
+
?disabled=${$isDisabled}
|
|
1459
|
+
?no-swipe-gesture=${$signal(noScrubGesture)}
|
|
1460
|
+
${ref($ref.set)}
|
|
1461
|
+
>
|
|
1462
|
+
<media-slider-chapters class="vds-slider-chapters" ?disabled=${$isChaptersDisabled}>
|
|
1463
|
+
<template>
|
|
1464
|
+
<div class="vds-slider-chapter">
|
|
1465
|
+
<div class="vds-slider-track"></div>
|
|
1466
|
+
<div class="vds-slider-track-fill vds-slider-track"></div>
|
|
1467
|
+
<div class="vds-slider-progress vds-slider-track"></div>
|
|
1468
|
+
</div>
|
|
1469
|
+
</template>
|
|
1470
|
+
</media-slider-chapters>
|
|
1471
|
+
<div class="vds-slider-thumb"></div>
|
|
1472
|
+
<media-slider-preview class="vds-slider-preview">
|
|
1473
|
+
<media-slider-thumbnail
|
|
1474
|
+
class="vds-slider-thumbnail vds-thumbnail"
|
|
1475
|
+
.src=${$thumbnails}
|
|
1476
|
+
></media-slider-thumbnail>
|
|
1477
|
+
<div class="vds-slider-chapter-title" data-part="chapter-title"></div>
|
|
1478
|
+
<media-slider-value class="vds-slider-value"></media-slider-value>
|
|
1479
|
+
</media-slider-preview>
|
|
1480
|
+
</media-time-slider>
|
|
1481
|
+
`;
|
|
1482
|
+
}
|
|
1483
|
+
|
|
1484
|
+
function DefaultTimeGroup() {
|
|
1485
|
+
return html`
|
|
1486
|
+
<div class="vds-time-group">
|
|
1487
|
+
${$signal(() => {
|
|
1488
|
+
const { duration } = useMediaState();
|
|
1489
|
+
if (!duration()) return null;
|
|
1490
|
+
return [
|
|
1491
|
+
html`<media-time class="vds-time" type="current"></media-time>`,
|
|
1492
|
+
html`<div class="vds-time-divider">/</div>`,
|
|
1493
|
+
html`<media-time class="vds-time" type="duration"></media-time>`
|
|
1494
|
+
];
|
|
1495
|
+
})}
|
|
1496
|
+
</div>
|
|
1497
|
+
`;
|
|
1498
|
+
}
|
|
1499
|
+
function DefaultTimeInvert() {
|
|
1500
|
+
return $signal(() => {
|
|
1501
|
+
const { live, duration } = useMediaState();
|
|
1502
|
+
return live() ? DefaultLiveButton() : duration() ? html`<media-time class="vds-time" type="current" toggle remainder></media-time>` : null;
|
|
1503
|
+
});
|
|
1504
|
+
}
|
|
1505
|
+
function DefaultTimeInfo() {
|
|
1506
|
+
return $signal(() => {
|
|
1507
|
+
const { live } = useMediaState();
|
|
1508
|
+
return live() ? DefaultLiveButton() : DefaultTimeGroup();
|
|
1509
|
+
});
|
|
1510
|
+
}
|
|
1511
|
+
|
|
1512
|
+
function DefaultTitle() {
|
|
1513
|
+
return $signal(() => {
|
|
1514
|
+
const { textTracks } = useMediaContext(), { title, started } = useMediaState(), $hasChapters = signal(null);
|
|
1515
|
+
watchActiveTextTrack(textTracks, "chapters", $hasChapters.set);
|
|
1516
|
+
return $hasChapters() && (started() || !title()) ? DefaultChapterTitle() : html`<media-title class="vds-chapter-title"></media-title>`;
|
|
1517
|
+
});
|
|
1518
|
+
}
|
|
1519
|
+
function DefaultChapterTitle() {
|
|
1520
|
+
return html`<media-chapter-title class="vds-chapter-title"></media-chapter-title>`;
|
|
1521
|
+
}
|
|
1522
|
+
|
|
1523
|
+
function DefaultAudioLayout() {
|
|
1524
|
+
return [
|
|
1525
|
+
DefaultAnnouncer(),
|
|
1526
|
+
DefaultCaptions(),
|
|
1527
|
+
html`
|
|
1528
|
+
<media-controls class="vds-controls">
|
|
1529
|
+
<media-controls-group class="vds-controls-group">
|
|
1530
|
+
${[
|
|
1531
|
+
DefaultSeekButton({ backward: true, tooltip: "top start" }),
|
|
1532
|
+
DefaultPlayButton({ tooltip: "top" }),
|
|
1533
|
+
DefaultSeekButton({ tooltip: "top" }),
|
|
1534
|
+
DefaultAudioTitle(),
|
|
1535
|
+
DefaultTimeSlider(),
|
|
1536
|
+
DefaultTimeInvert(),
|
|
1537
|
+
DefaultVolumePopup({ orientation: "vertical", tooltip: "top" }),
|
|
1538
|
+
DefaultCaptionButton({ tooltip: "top" }),
|
|
1539
|
+
DefaultDownloadButton(),
|
|
1540
|
+
DefaultAirPlayButton({ tooltip: "top" }),
|
|
1541
|
+
DefaultAudioMenus()
|
|
1542
|
+
]}
|
|
1543
|
+
</media-controls-group>
|
|
1544
|
+
</media-controls>
|
|
1545
|
+
`
|
|
1546
|
+
];
|
|
1547
|
+
}
|
|
1548
|
+
function DefaultAudioTitle() {
|
|
1549
|
+
return $signal(() => {
|
|
1550
|
+
let $ref = signal(void 0), $isTextOverflowing = signal(false), media = useMediaContext(), { title, started, currentTime, ended } = useMediaState(), { translations } = useDefaultLayoutContext(), $isTransitionActive = useTransitionActive($ref), $isContinued = () => started() || currentTime() > 0;
|
|
1551
|
+
const $title = () => {
|
|
1552
|
+
const word = ended() ? "Replay" : $isContinued() ? "Continue" : "Play";
|
|
1553
|
+
return `${i18n(translations, word)}: ${title()}`;
|
|
1554
|
+
};
|
|
1555
|
+
effect(() => {
|
|
1556
|
+
if ($isTransitionActive() && document.activeElement === document.body) {
|
|
1557
|
+
media.player.el?.focus({ preventScroll: true });
|
|
1558
|
+
}
|
|
1559
|
+
});
|
|
1560
|
+
function onResize() {
|
|
1561
|
+
const el = $ref(), isOverflowing = !!el && !$isTransitionActive() && el.clientWidth < el.children[0].clientWidth;
|
|
1562
|
+
el && toggleClass(el, "vds-marquee", isOverflowing);
|
|
1563
|
+
$isTextOverflowing.set(isOverflowing);
|
|
1564
|
+
}
|
|
1565
|
+
function Title() {
|
|
1566
|
+
return html`
|
|
1567
|
+
<span class="vds-title-text">
|
|
1568
|
+
${$signal($title)}${$signal(() => $isContinued() ? DefaultChapterTitle() : null)}
|
|
1569
|
+
</span>
|
|
1570
|
+
`;
|
|
1571
|
+
}
|
|
1572
|
+
useResizeObserver($ref, onResize);
|
|
1573
|
+
return title() ? html`
|
|
1574
|
+
<span class="vds-title" title=${$signal($title)} ${ref($ref.set)}>
|
|
1575
|
+
${[
|
|
1576
|
+
Title(),
|
|
1577
|
+
$signal(() => $isTextOverflowing() && !$isTransitionActive() ? Title() : null)
|
|
1578
|
+
]}
|
|
1579
|
+
</span>
|
|
1580
|
+
` : DefaultControlsSpacer();
|
|
1581
|
+
});
|
|
1582
|
+
}
|
|
1583
|
+
function DefaultAudioMenus() {
|
|
1584
|
+
const placement = "top end";
|
|
1585
|
+
return [
|
|
1586
|
+
DefaultChaptersMenu({ tooltip: "top", placement, portal: true }),
|
|
1587
|
+
DefaultSettingsMenu({ tooltip: "top end", placement, portal: true })
|
|
1588
|
+
];
|
|
1589
|
+
}
|
|
1590
|
+
|
|
1591
|
+
class DefaultLayoutIconsLoader extends LayoutIconsLoader {
|
|
1592
|
+
async loadIcons() {
|
|
1593
|
+
const paths = (await import('./vidstack-P_QDjYIl.js')).icons, icons = {};
|
|
1594
|
+
for (const iconName of Object.keys(paths)) {
|
|
1595
|
+
icons[iconName] = Icon({ name: iconName, paths: paths[iconName] });
|
|
1596
|
+
}
|
|
1597
|
+
return icons;
|
|
1598
|
+
}
|
|
1599
|
+
}
|
|
1600
|
+
|
|
1601
|
+
class MediaAudioLayoutElement extends Host(LitElement, DefaultAudioLayout$1) {
|
|
1602
|
+
static tagName = "media-audio-layout";
|
|
1603
|
+
static attrs = {
|
|
1604
|
+
smallWhen: {
|
|
1605
|
+
converter(value) {
|
|
1606
|
+
return value !== "never" && !!value;
|
|
1607
|
+
}
|
|
1608
|
+
}
|
|
1609
|
+
};
|
|
1610
|
+
#media;
|
|
1611
|
+
#scrubbing = signal(false);
|
|
1612
|
+
onSetup() {
|
|
1613
|
+
this.forwardKeepAlive = false;
|
|
1614
|
+
this.#media = useMediaContext();
|
|
1615
|
+
this.classList.add("vds-audio-layout");
|
|
1616
|
+
this.#setupWatchScrubbing();
|
|
1617
|
+
}
|
|
1618
|
+
onConnect() {
|
|
1619
|
+
setLayoutName("audio", () => this.isMatch);
|
|
1620
|
+
this.#setupMenuContainer();
|
|
1621
|
+
}
|
|
1622
|
+
render() {
|
|
1623
|
+
return $signal(this.#render.bind(this));
|
|
1624
|
+
}
|
|
1625
|
+
#render() {
|
|
1626
|
+
return this.isMatch ? DefaultAudioLayout() : null;
|
|
1627
|
+
}
|
|
1628
|
+
#setupMenuContainer() {
|
|
1629
|
+
const { menuPortal } = useDefaultLayoutContext();
|
|
1630
|
+
effect(() => {
|
|
1631
|
+
if (!this.isMatch) return;
|
|
1632
|
+
const container = createMenuContainer(
|
|
1633
|
+
this,
|
|
1634
|
+
this.menuContainer,
|
|
1635
|
+
"vds-audio-layout",
|
|
1636
|
+
() => this.isSmallLayout
|
|
1637
|
+
), roots = container ? [this, container] : [this];
|
|
1638
|
+
const iconsManager = this.$props.customIcons() ? new SlotManager(roots) : new DefaultLayoutIconsLoader(roots);
|
|
1639
|
+
iconsManager.connect();
|
|
1640
|
+
menuPortal.set(container);
|
|
1641
|
+
return () => {
|
|
1642
|
+
container.remove();
|
|
1643
|
+
menuPortal.set(null);
|
|
1644
|
+
};
|
|
1645
|
+
});
|
|
1646
|
+
}
|
|
1647
|
+
#setupWatchScrubbing() {
|
|
1648
|
+
const { pointer } = this.#media.$state;
|
|
1649
|
+
effect(() => {
|
|
1650
|
+
if (pointer() !== "coarse") return;
|
|
1651
|
+
effect(this.#watchScrubbing.bind(this));
|
|
1652
|
+
});
|
|
1653
|
+
}
|
|
1654
|
+
#watchScrubbing() {
|
|
1655
|
+
if (!this.#scrubbing()) {
|
|
1656
|
+
listenEvent(this, "pointerdown", this.#onStartScrubbing.bind(this));
|
|
1657
|
+
return;
|
|
1658
|
+
}
|
|
1659
|
+
listenEvent(window, "pointerdown", this.#onStopScrubbing.bind(this));
|
|
1660
|
+
}
|
|
1661
|
+
#onStartScrubbing(event) {
|
|
1662
|
+
const { target } = event, hasTimeSlider = !!(isHTMLElement(target) && target.closest(".vds-time-slider"));
|
|
1663
|
+
if (!hasTimeSlider) return;
|
|
1664
|
+
event.stopImmediatePropagation();
|
|
1665
|
+
this.setAttribute("data-scrubbing", "");
|
|
1666
|
+
this.#scrubbing.set(true);
|
|
1667
|
+
}
|
|
1668
|
+
#onStopScrubbing() {
|
|
1669
|
+
this.#scrubbing.set(false);
|
|
1670
|
+
this.removeAttribute("data-scrubbing");
|
|
1671
|
+
}
|
|
1672
|
+
}
|
|
1673
|
+
|
|
1674
|
+
class DefaultVideoLayout extends DefaultLayout {
|
|
1675
|
+
static props = {
|
|
1676
|
+
...super.props,
|
|
1677
|
+
when: ({ viewType }) => viewType === "video",
|
|
1678
|
+
smallWhen: ({ width, height }) => width < 576 || height < 380
|
|
1679
|
+
};
|
|
1680
|
+
}
|
|
1681
|
+
|
|
1682
|
+
function DefaultKeyboardDisplay() {
|
|
1683
|
+
return $signal(() => {
|
|
1684
|
+
const media = useMediaContext(), { noKeyboardAnimations, userPrefersKeyboardAnimations } = useDefaultLayoutContext(), $disabled = computed(() => noKeyboardAnimations() || !userPrefersKeyboardAnimations());
|
|
1685
|
+
if ($disabled()) {
|
|
1686
|
+
return null;
|
|
1687
|
+
}
|
|
1688
|
+
const visible = signal(false), { lastKeyboardAction } = media.$state;
|
|
1689
|
+
effect(() => {
|
|
1690
|
+
visible.set(!!lastKeyboardAction());
|
|
1691
|
+
const id = setTimeout(() => visible.set(false), 500);
|
|
1692
|
+
return () => {
|
|
1693
|
+
visible.set(false);
|
|
1694
|
+
window.clearTimeout(id);
|
|
1695
|
+
};
|
|
1696
|
+
});
|
|
1697
|
+
const $actionDataAttr = computed(() => {
|
|
1698
|
+
const action = lastKeyboardAction()?.action;
|
|
1699
|
+
return action && visible() ? camelToKebabCase(action) : null;
|
|
1700
|
+
});
|
|
1701
|
+
const $classList = computed(() => `vds-kb-action${!visible() ? " hidden" : ""}`), $text = computed(getText), $iconSlot = computed(() => {
|
|
1702
|
+
const name = getIconName();
|
|
1703
|
+
return name ? createSlot(name) : null;
|
|
1704
|
+
});
|
|
1705
|
+
function Icon() {
|
|
1706
|
+
const $slot = $iconSlot();
|
|
1707
|
+
if (!$slot) return null;
|
|
1708
|
+
return html`
|
|
1709
|
+
<div class="vds-kb-bezel">
|
|
1710
|
+
<div class="vds-kb-icon">${$slot}</div>
|
|
1711
|
+
</div>
|
|
1712
|
+
`;
|
|
1713
|
+
}
|
|
1714
|
+
return html`
|
|
1715
|
+
<div class=${$signal($classList)} data-action=${$signal($actionDataAttr)}>
|
|
1716
|
+
<div class="vds-kb-text-wrapper">
|
|
1717
|
+
<div class="vds-kb-text">${$signal($text)}</div>
|
|
1718
|
+
</div>
|
|
1719
|
+
${$signal(() => keyed(lastKeyboardAction(), Icon()))}
|
|
1720
|
+
</div>
|
|
1721
|
+
`;
|
|
1722
|
+
});
|
|
1723
|
+
}
|
|
1724
|
+
function getText() {
|
|
1725
|
+
const { $state } = useMediaContext(), action = $state.lastKeyboardAction()?.action, audioGain = $state.audioGain() ?? 1;
|
|
1726
|
+
switch (action) {
|
|
1727
|
+
case "toggleMuted":
|
|
1728
|
+
return $state.muted() ? "0%" : getVolumeText($state.volume(), audioGain);
|
|
1729
|
+
case "volumeUp":
|
|
1730
|
+
case "volumeDown":
|
|
1731
|
+
return getVolumeText($state.volume(), audioGain);
|
|
1732
|
+
default:
|
|
1733
|
+
return "";
|
|
1734
|
+
}
|
|
1735
|
+
}
|
|
1736
|
+
function getVolumeText(volume, gain) {
|
|
1737
|
+
return `${Math.round(volume * gain * 100)}%`;
|
|
1738
|
+
}
|
|
1739
|
+
function getIconName() {
|
|
1740
|
+
const { $state } = useMediaContext(), action = $state.lastKeyboardAction()?.action;
|
|
1741
|
+
switch (action) {
|
|
1742
|
+
case "togglePaused":
|
|
1743
|
+
return !$state.paused() ? "kb-play-icon" : "kb-pause-icon";
|
|
1744
|
+
case "toggleMuted":
|
|
1745
|
+
return $state.muted() || $state.volume() === 0 ? "kb-mute-icon" : $state.volume() >= 0.5 ? "kb-volume-up-icon" : "kb-volume-down-icon";
|
|
1746
|
+
case "toggleFullscreen":
|
|
1747
|
+
return `kb-fs-${$state.fullscreen() ? "enter" : "exit"}-icon`;
|
|
1748
|
+
case "togglePictureInPicture":
|
|
1749
|
+
return `kb-pip-${$state.pictureInPicture() ? "enter" : "exit"}-icon`;
|
|
1750
|
+
case "toggleCaptions":
|
|
1751
|
+
return $state.hasCaptions() ? `kb-cc-${$state.textTrack() ? "on" : "off"}-icon` : null;
|
|
1752
|
+
case "volumeUp":
|
|
1753
|
+
return "kb-volume-up-icon";
|
|
1754
|
+
case "volumeDown":
|
|
1755
|
+
return "kb-volume-down-icon";
|
|
1756
|
+
case "seekForward":
|
|
1757
|
+
return "kb-seek-forward-icon";
|
|
1758
|
+
case "seekBackward":
|
|
1759
|
+
return "kb-seek-backward-icon";
|
|
1760
|
+
default:
|
|
1761
|
+
return null;
|
|
1762
|
+
}
|
|
1763
|
+
}
|
|
1764
|
+
|
|
1765
|
+
function DefaultVideoLayoutLarge() {
|
|
1766
|
+
const { episodes, smallWhen: smWhen } = useDefaultLayoutContext(), { fullscreen } = useMediaState(), $episodesOpen = signal(false);
|
|
1767
|
+
effect(() => {
|
|
1768
|
+
if (!fullscreen()) $episodesOpen.set(false);
|
|
1769
|
+
});
|
|
1770
|
+
function onEpisodesToggle() {
|
|
1771
|
+
if (!fullscreen() && !smWhen() || !episodes()?.length) return;
|
|
1772
|
+
$episodesOpen.set(!$episodesOpen());
|
|
1773
|
+
}
|
|
1774
|
+
function onEpisodesClose() {
|
|
1775
|
+
$episodesOpen.set(false);
|
|
1776
|
+
}
|
|
1777
|
+
return [
|
|
1778
|
+
DefaultAnnouncer(),
|
|
1779
|
+
DefaultVideoGestures(),
|
|
1780
|
+
DefaultBufferingIndicator(),
|
|
1781
|
+
DefaultKeyboardDisplay(),
|
|
1782
|
+
DefaultCaptions(),
|
|
1783
|
+
html`<div class="vds-scrim"></div>`,
|
|
1784
|
+
html`
|
|
1785
|
+
<media-controls class="vds-controls" @vds-episodes-open=${onEpisodesToggle}>
|
|
1786
|
+
${[
|
|
1787
|
+
DefaultControlsGroupTop(),
|
|
1788
|
+
DefaultControlsSpacer(),
|
|
1789
|
+
html`
|
|
1790
|
+
<media-controls-group class="vds-controls-group">
|
|
1791
|
+
${DefaultTimeSlider()}
|
|
1792
|
+
</media-controls-group>
|
|
1793
|
+
`,
|
|
1794
|
+
html`
|
|
1795
|
+
<media-controls-group class="vds-controls-group vds-controls-group-bottom">
|
|
1796
|
+
${[
|
|
1797
|
+
DefaultSeekButton({ backward: true, tooltip: "top" }),
|
|
1798
|
+
DefaultPlayButton({ tooltip: "top start" }),
|
|
1799
|
+
DefaultSeekButton({ backward: false, tooltip: "top" }),
|
|
1800
|
+
DefaultVolumePopup({ orientation: "horizontal", tooltip: "top" }),
|
|
1801
|
+
DefaultTimeInfo(),
|
|
1802
|
+
DefaultTitle(),
|
|
1803
|
+
DefaultControlsSpacer(),
|
|
1804
|
+
$signal(
|
|
1805
|
+
() => (fullscreen() || smWhen()) && episodes()?.length ? DefaultEpisodeButton({ tooltip: "top" }) : null
|
|
1806
|
+
),
|
|
1807
|
+
DefaultCaptionButton({ tooltip: "top" }),
|
|
1808
|
+
DefaultBottomMenuGroup(),
|
|
1809
|
+
DefaultDownloadButton(),
|
|
1810
|
+
DefaultPIPButton(),
|
|
1811
|
+
DefaultFullscreenButton({ tooltip: "top end" })
|
|
1812
|
+
]}
|
|
1813
|
+
</media-controls-group>
|
|
1814
|
+
`
|
|
1815
|
+
]}
|
|
1816
|
+
</media-controls>
|
|
1817
|
+
`,
|
|
1818
|
+
DefaultEpisodesSidebar($episodesOpen, onEpisodesClose)
|
|
1819
|
+
];
|
|
1820
|
+
}
|
|
1821
|
+
function DefaultBottomMenuGroup() {
|
|
1822
|
+
return $signal(() => {
|
|
1823
|
+
const { menuGroup } = useDefaultLayoutContext();
|
|
1824
|
+
return menuGroup() === "bottom" ? DefaultVideoMenus() : null;
|
|
1825
|
+
});
|
|
1826
|
+
}
|
|
1827
|
+
function DefaultControlsGroupTop() {
|
|
1828
|
+
return html`
|
|
1829
|
+
<media-controls-group class="vds-controls-group">
|
|
1830
|
+
${$signal(() => {
|
|
1831
|
+
const { menuGroup } = useDefaultLayoutContext();
|
|
1832
|
+
return menuGroup() === "top" ? [DefaultControlsSpacer(), DefaultVideoMenus()] : null;
|
|
1833
|
+
})}
|
|
1834
|
+
</media-controls-group>
|
|
1835
|
+
`;
|
|
1836
|
+
}
|
|
1837
|
+
function DefaultVideoLayoutSmall() {
|
|
1838
|
+
const { episodes, smallWhen: smWhen } = useDefaultLayoutContext(), { fullscreen } = useMediaState(), $episodesOpen = signal(false);
|
|
1839
|
+
effect(() => {
|
|
1840
|
+
if (!fullscreen()) $episodesOpen.set(false);
|
|
1841
|
+
});
|
|
1842
|
+
function onEpisodesToggle() {
|
|
1843
|
+
if (!fullscreen() && !smWhen() || !episodes()?.length) return;
|
|
1844
|
+
$episodesOpen.set(!$episodesOpen());
|
|
1845
|
+
}
|
|
1846
|
+
function onEpisodesClose() {
|
|
1847
|
+
$episodesOpen.set(false);
|
|
1848
|
+
}
|
|
1849
|
+
return [
|
|
1850
|
+
DefaultAnnouncer(),
|
|
1851
|
+
DefaultVideoGestures(),
|
|
1852
|
+
DefaultBufferingIndicator(),
|
|
1853
|
+
DefaultCaptions(),
|
|
1854
|
+
DefaultKeyboardDisplay(),
|
|
1855
|
+
html`<div class="vds-scrim"></div>`,
|
|
1856
|
+
html`
|
|
1857
|
+
<media-controls class="vds-controls" @vds-episodes-open=${onEpisodesToggle}>
|
|
1858
|
+
<media-controls-group class="vds-controls-group">
|
|
1859
|
+
${[
|
|
1860
|
+
DefaultControlsSpacer(),
|
|
1861
|
+
DefaultCaptionButton({ tooltip: "bottom" }),
|
|
1862
|
+
DefaultDownloadButton(),
|
|
1863
|
+
DefaultVideoMenus(),
|
|
1864
|
+
DefaultVolumePopup({ orientation: "vertical", tooltip: "bottom end" })
|
|
1865
|
+
]}
|
|
1866
|
+
</media-controls-group>
|
|
1867
|
+
|
|
1868
|
+
${DefaultControlsSpacer()}
|
|
1869
|
+
|
|
1870
|
+
<media-controls-group class="vds-controls-group">
|
|
1871
|
+
${DefaultTimeSlider()}
|
|
1872
|
+
</media-controls-group>
|
|
1873
|
+
|
|
1874
|
+
<media-controls-group class="vds-controls-group vds-controls-group-bottom">
|
|
1875
|
+
${[
|
|
1876
|
+
DefaultSeekButton({ backward: true, tooltip: "top" }),
|
|
1877
|
+
DefaultPlayButton({ tooltip: "top" }),
|
|
1878
|
+
DefaultSeekButton({ backward: false, tooltip: "top" }),
|
|
1879
|
+
DefaultTimeInfo(),
|
|
1880
|
+
DefaultControlsSpacer(),
|
|
1881
|
+
$signal(
|
|
1882
|
+
() => (fullscreen() || smWhen()) && episodes()?.length ? DefaultEpisodeButton({ tooltip: "top" }) : null
|
|
1883
|
+
),
|
|
1884
|
+
DefaultFullscreenButton({ tooltip: "top end" })
|
|
1885
|
+
]}
|
|
1886
|
+
</media-controls-group>
|
|
1887
|
+
</media-controls>
|
|
1888
|
+
`,
|
|
1889
|
+
StartDuration(),
|
|
1890
|
+
DefaultEpisodesSidebar($episodesOpen, onEpisodesClose)
|
|
1891
|
+
];
|
|
1892
|
+
}
|
|
1893
|
+
function DefaultVideoLoadLayout() {
|
|
1894
|
+
return html`
|
|
1895
|
+
<div class="vds-load-container">
|
|
1896
|
+
${[DefaultBufferingIndicator(), DefaultPlayButton({ tooltip: "top" })]}
|
|
1897
|
+
</div>
|
|
1898
|
+
`;
|
|
1899
|
+
}
|
|
1900
|
+
function StartDuration() {
|
|
1901
|
+
return $signal(() => {
|
|
1902
|
+
const { duration } = useMediaState();
|
|
1903
|
+
if (duration() === 0) return null;
|
|
1904
|
+
return html`
|
|
1905
|
+
<div class="vds-start-duration">
|
|
1906
|
+
<media-time class="vds-time" type="duration"></media-time>
|
|
1907
|
+
</div>
|
|
1908
|
+
`;
|
|
1909
|
+
});
|
|
1910
|
+
}
|
|
1911
|
+
function DefaultBufferingIndicator() {
|
|
1912
|
+
return html`
|
|
1913
|
+
<div class="vds-buffering-indicator">
|
|
1914
|
+
<media-spinner class="vds-buffering-spinner"></media-spinner>
|
|
1915
|
+
</div>
|
|
1916
|
+
`;
|
|
1917
|
+
}
|
|
1918
|
+
function formatMinutesLeftLabel(secondsLeft) {
|
|
1919
|
+
if (secondsLeft <= 0) return null;
|
|
1920
|
+
if (secondsLeft < 60) return "<1m left";
|
|
1921
|
+
return `${Math.floor(secondsLeft / 60)}m left`;
|
|
1922
|
+
}
|
|
1923
|
+
function DefaultEpisodesSidebar($open, onClose) {
|
|
1924
|
+
const { episodes, episodesTitle, smallWhen: smWhen } = useDefaultLayoutContext(), { fullscreen, currentTime, duration } = useMediaState();
|
|
1925
|
+
return $signal(() => {
|
|
1926
|
+
const list = episodes() ?? [];
|
|
1927
|
+
if (!fullscreen() && !smWhen() || !list.length) return null;
|
|
1928
|
+
const ct = currentTime(), dur = duration();
|
|
1929
|
+
return html`
|
|
1930
|
+
<div
|
|
1931
|
+
class="vds-episodes-backdrop"
|
|
1932
|
+
data-open=${$open() ? "true" : "false"}
|
|
1933
|
+
@pointerup=${(event) => {
|
|
1934
|
+
if (event.target === event.currentTarget) onClose();
|
|
1935
|
+
}}
|
|
1936
|
+
>
|
|
1937
|
+
<aside
|
|
1938
|
+
class="vds-episodes-panel"
|
|
1939
|
+
data-open=${$open() ? "true" : "false"}
|
|
1940
|
+
@keydown=${(event) => {
|
|
1941
|
+
if (event.key === "Escape") onClose();
|
|
1942
|
+
}}
|
|
1943
|
+
>
|
|
1944
|
+
<header class="vds-episodes-panel-header">
|
|
1945
|
+
<h3 class="vds-episodes-panel-title">${episodesTitle()}</h3>
|
|
1946
|
+
<button
|
|
1947
|
+
type="button"
|
|
1948
|
+
class="vds-episodes-close-btn"
|
|
1949
|
+
aria-label="Close episodes"
|
|
1950
|
+
@pointerup=${(event) => {
|
|
1951
|
+
event.stopPropagation();
|
|
1952
|
+
onClose();
|
|
1953
|
+
}}
|
|
1954
|
+
>
|
|
1955
|
+
<span aria-hidden="true">✕</span>
|
|
1956
|
+
</button>
|
|
1957
|
+
</header>
|
|
1958
|
+
<div class="vds-episodes-list" role="list">
|
|
1959
|
+
${list.map((episode, index) => {
|
|
1960
|
+
const episodeName = episode.episodeTitle || `Episode ${episode.episodeNumber ?? index + 1}`, seasonEpLabel = episode.seasonNumber != null && episode.episodeNumber != null ? `S${String(episode.seasonNumber).padStart(2, "0")} \xB7 E${String(
|
|
1961
|
+
episode.episodeNumber
|
|
1962
|
+
).padStart(2, "0")}` : episodeName, isActive = episode.isActive === true;
|
|
1963
|
+
let runtimeText = null;
|
|
1964
|
+
if (isActive && dur > 0) {
|
|
1965
|
+
const secsLeft = Math.max(0, dur - ct);
|
|
1966
|
+
runtimeText = formatMinutesLeftLabel(secsLeft);
|
|
1967
|
+
} else if (episode.timeLeft != null && episode.timeLeft > 0) {
|
|
1968
|
+
runtimeText = `${episode.timeLeft}m left`;
|
|
1969
|
+
} else if (Number.isFinite(episode.runtime) && (episode.runtime ?? 0) > 0) {
|
|
1970
|
+
runtimeText = `${episode.runtime}m`;
|
|
1971
|
+
}
|
|
1972
|
+
let progressPct = 0;
|
|
1973
|
+
if (isActive && dur > 0) {
|
|
1974
|
+
progressPct = Math.min(100, ct / dur * 100);
|
|
1975
|
+
} else if (episode.progressPercent != null && episode.progressPercent > 0) {
|
|
1976
|
+
progressPct = Math.min(100, episode.progressPercent);
|
|
1977
|
+
}
|
|
1978
|
+
const showSubtitle = !!episode.episodeTitle && episode.episodeTitle.trim() !== "" && episode.episodeTitle !== episode.title;
|
|
1979
|
+
const onEpisodeSelect = (event) => {
|
|
1980
|
+
event.stopPropagation();
|
|
1981
|
+
if (isActive) return;
|
|
1982
|
+
event.currentTarget?.dispatchEvent(
|
|
1983
|
+
new CustomEvent("vds-episode-select", {
|
|
1984
|
+
bubbles: true,
|
|
1985
|
+
composed: true,
|
|
1986
|
+
detail: { episode, index }
|
|
1987
|
+
})
|
|
1988
|
+
);
|
|
1989
|
+
onClose();
|
|
1990
|
+
};
|
|
1991
|
+
return html`
|
|
1992
|
+
<article
|
|
1993
|
+
class="vds-episode-item"
|
|
1994
|
+
data-active=${isActive ? "true" : "false"}
|
|
1995
|
+
aria-current=${isActive ? "true" : void 0}
|
|
1996
|
+
role="button"
|
|
1997
|
+
tabindex="0"
|
|
1998
|
+
aria-label=${episode.title || episodeName}
|
|
1999
|
+
@pointerup=${onEpisodeSelect}
|
|
2000
|
+
@keydown=${(event) => {
|
|
2001
|
+
if (event.key === "Enter" || event.key === " ") onEpisodeSelect(event);
|
|
2002
|
+
}}
|
|
2003
|
+
>
|
|
2004
|
+
<div class="vds-episode-thumb-wrap">
|
|
2005
|
+
${episode.thumbnail ? html`
|
|
2006
|
+
<img
|
|
2007
|
+
class="vds-episode-thumb"
|
|
2008
|
+
src=${episode.thumbnail}
|
|
2009
|
+
alt=${episode.title || episodeName}
|
|
2010
|
+
loading="lazy"
|
|
2011
|
+
decoding="async"
|
|
2012
|
+
/>
|
|
2013
|
+
` : html`<div class="vds-episode-thumb vds-episode-thumb-placeholder"></div>`}
|
|
2014
|
+
${progressPct > 0 ? html`
|
|
2015
|
+
<div class="vds-episode-progress-track" aria-hidden="true">
|
|
2016
|
+
<div
|
|
2017
|
+
class="vds-episode-progress-fill"
|
|
2018
|
+
style=${`width: ${progressPct}%;`}
|
|
2019
|
+
></div>
|
|
2020
|
+
</div>
|
|
2021
|
+
` : null}
|
|
2022
|
+
</div>
|
|
2023
|
+
<div class="vds-episode-body">
|
|
2024
|
+
<div class="vds-episode-meta-row">
|
|
2025
|
+
<div class="vds-episode-meta-primary">
|
|
2026
|
+
${isActive ? html`<span class="vds-episode-now-chip">Playing</span>` : null}
|
|
2027
|
+
<span class="vds-episode-label">${seasonEpLabel}</span>
|
|
2028
|
+
</div>
|
|
2029
|
+
${runtimeText ? html`<span class="vds-episode-runtime">${runtimeText}</span>` : null}
|
|
2030
|
+
</div>
|
|
2031
|
+
<h4 class="vds-episode-title" title=${episode.title || ""}>
|
|
2032
|
+
${episode.title || "-"}
|
|
2033
|
+
</h4>
|
|
2034
|
+
${showSubtitle ? html`<p class="vds-episode-subtitle" title=${episode.episodeTitle}>
|
|
2035
|
+
${episode.episodeTitle}
|
|
2036
|
+
</p>` : null}
|
|
2037
|
+
${episode.overview ? html`<p class="vds-episode-desc" title=${episode.overview}>
|
|
2038
|
+
${episode.overview}
|
|
2039
|
+
</p>` : null}
|
|
2040
|
+
</div>
|
|
2041
|
+
</article>
|
|
2042
|
+
`;
|
|
2043
|
+
})}
|
|
2044
|
+
</div>
|
|
2045
|
+
</aside>
|
|
2046
|
+
</div>
|
|
2047
|
+
`;
|
|
2048
|
+
});
|
|
2049
|
+
}
|
|
2050
|
+
function DefaultVideoMenus() {
|
|
2051
|
+
const { menuGroup, smallWhen: smWhen } = useDefaultLayoutContext(), $side = () => menuGroup() === "top" || smWhen() ? "bottom" : "top", $tooltip = computed(() => `${$side()} ${menuGroup() === "top" ? "end" : "center"}`), $placement = computed(() => `${$side()} end`);
|
|
2052
|
+
return [
|
|
2053
|
+
DefaultChaptersMenu({ tooltip: $tooltip, placement: $placement, portal: true }),
|
|
2054
|
+
DefaultSettingsMenu({ tooltip: $tooltip, placement: $placement, portal: true })
|
|
2055
|
+
];
|
|
2056
|
+
}
|
|
2057
|
+
function DefaultVideoGestures() {
|
|
2058
|
+
return $signal(() => {
|
|
2059
|
+
const { noGestures } = useDefaultLayoutContext();
|
|
2060
|
+
if (noGestures()) return null;
|
|
2061
|
+
return html`
|
|
2062
|
+
<div class="vds-gestures">
|
|
2063
|
+
<media-gesture class="vds-gesture" event="pointerup" action="toggle:paused"></media-gesture>
|
|
2064
|
+
<media-gesture
|
|
2065
|
+
class="vds-gesture"
|
|
2066
|
+
event="pointerup"
|
|
2067
|
+
action="toggle:controls"
|
|
2068
|
+
></media-gesture>
|
|
2069
|
+
<media-gesture
|
|
2070
|
+
class="vds-gesture"
|
|
2071
|
+
event="dblpointerup"
|
|
2072
|
+
action="toggle:fullscreen"
|
|
2073
|
+
></media-gesture>
|
|
2074
|
+
<media-gesture class="vds-gesture" event="dblpointerup" action="seek:-10"></media-gesture>
|
|
2075
|
+
<media-gesture class="vds-gesture" event="dblpointerup" action="seek:10"></media-gesture>
|
|
2076
|
+
</div>
|
|
2077
|
+
`;
|
|
2078
|
+
});
|
|
2079
|
+
}
|
|
2080
|
+
|
|
2081
|
+
class MediaVideoLayoutElement extends Host(LitElement, DefaultVideoLayout) {
|
|
2082
|
+
static tagName = "media-video-layout";
|
|
2083
|
+
static attrs = {
|
|
2084
|
+
smallWhen: {
|
|
2085
|
+
converter(value) {
|
|
2086
|
+
return value !== "never" && !!value;
|
|
2087
|
+
}
|
|
2088
|
+
},
|
|
2089
|
+
episodes: {
|
|
2090
|
+
converter(value) {
|
|
2091
|
+
if (!value) return null;
|
|
2092
|
+
try {
|
|
2093
|
+
const parsed = JSON.parse(value);
|
|
2094
|
+
return Array.isArray(parsed) ? parsed : null;
|
|
2095
|
+
} catch {
|
|
2096
|
+
return null;
|
|
2097
|
+
}
|
|
2098
|
+
}
|
|
2099
|
+
}
|
|
2100
|
+
};
|
|
2101
|
+
#media;
|
|
2102
|
+
onSetup() {
|
|
2103
|
+
this.forwardKeepAlive = false;
|
|
2104
|
+
this.#media = useMediaContext();
|
|
2105
|
+
this.classList.add("vds-video-layout");
|
|
2106
|
+
}
|
|
2107
|
+
onConnect() {
|
|
2108
|
+
setLayoutName("video", () => this.isMatch);
|
|
2109
|
+
this.#setupMenuContainer();
|
|
2110
|
+
}
|
|
2111
|
+
render() {
|
|
2112
|
+
return $signal(this.#render.bind(this));
|
|
2113
|
+
}
|
|
2114
|
+
#setupMenuContainer() {
|
|
2115
|
+
const { menuPortal } = useDefaultLayoutContext();
|
|
2116
|
+
effect(() => {
|
|
2117
|
+
if (!this.isMatch) return;
|
|
2118
|
+
const container = createMenuContainer(
|
|
2119
|
+
this,
|
|
2120
|
+
this.menuContainer,
|
|
2121
|
+
"vds-video-layout",
|
|
2122
|
+
() => this.isSmallLayout
|
|
2123
|
+
), roots = container ? [this, container] : [this];
|
|
2124
|
+
const iconsManager = this.$props.customIcons() ? new SlotManager(roots) : new DefaultLayoutIconsLoader(roots);
|
|
2125
|
+
iconsManager.connect();
|
|
2126
|
+
menuPortal.set(container);
|
|
2127
|
+
return () => {
|
|
2128
|
+
container.remove();
|
|
2129
|
+
menuPortal.set(null);
|
|
2130
|
+
};
|
|
2131
|
+
});
|
|
2132
|
+
}
|
|
2133
|
+
#render() {
|
|
2134
|
+
const { load } = this.#media.$props, { canLoad, streamType, nativeControls } = this.#media.$state;
|
|
2135
|
+
return !nativeControls() && this.isMatch ? load() === "play" && !canLoad() ? DefaultVideoLoadLayout() : streamType() === "unknown" ? DefaultBufferingIndicator() : this.isSmallLayout ? DefaultVideoLayoutSmall() : DefaultVideoLayoutLarge() : null;
|
|
2136
|
+
}
|
|
2137
|
+
}
|
|
2138
|
+
|
|
2139
|
+
export { MediaAudioLayoutElement, MediaVideoLayoutElement };
|