@thalassic/ui 22.20.1 → 22.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/fesm2022/thalassic-ui-charts.mjs +5 -3
- package/fesm2022/thalassic-ui-charts.mjs.map +1 -1
- package/fesm2022/thalassic-ui-media.mjs +1194 -0
- package/fesm2022/thalassic-ui-media.mjs.map +1 -0
- package/fesm2022/thalassic-ui-rich-text-editor.mjs +49 -23
- package/fesm2022/thalassic-ui-rich-text-editor.mjs.map +1 -1
- package/fesm2022/thalassic-ui.mjs +12451 -6503
- package/fesm2022/thalassic-ui.mjs.map +1 -1
- package/package.json +5 -1
- package/types/thalassic-ui-charts.d.ts +5 -0
- package/types/thalassic-ui-media.d.ts +300 -0
- package/types/thalassic-ui-rich-text-editor.d.ts +18 -0
- package/types/thalassic-ui.d.ts +2929 -129
|
@@ -0,0 +1,1194 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { InjectionToken, inject, DestroyRef, signal, computed, Injectable, DOCUMENT, Component, viewChild, input, booleanAttribute, output, afterNextRender, effect, ElementRef, makeEnvironmentProviders } from '@angular/core';
|
|
3
|
+
import { Icon, Menu, MenuTriggerDirective, Loader } from '@thalassic/ui';
|
|
4
|
+
import { Directionality } from '@angular/cdk/bidi';
|
|
5
|
+
import { deepMerge } from '@thalassic/core';
|
|
6
|
+
|
|
7
|
+
/** Seconds a single arrow-key or double-tap seek moves the playhead. */
|
|
8
|
+
const DEFAULT_SEEK_STEP = 5;
|
|
9
|
+
/** Playback-rate choices offered by the settings menu, in ascending order. */
|
|
10
|
+
const DEFAULT_RATE_OPTIONS = [0.5, 0.75, 1, 1.25, 1.5, 2];
|
|
11
|
+
/** Milliseconds of pointer idle before the video controls fade out during playback. */
|
|
12
|
+
const DEFAULT_CONTROLS_HIDE_DELAY = 2500;
|
|
13
|
+
/** Fraction of full volume (`[0, 1]`) a single arrow-key press applies — 5 on the `[0, 100]` scale. */
|
|
14
|
+
const VOLUME_STEP = 0.05;
|
|
15
|
+
/**
|
|
16
|
+
* Milliseconds the transient seek-feedback badge stays visible after a
|
|
17
|
+
* keyboard seek; presses within the window accumulate into one total.
|
|
18
|
+
*/
|
|
19
|
+
const SEEK_FEEDBACK_DURATION = 800;
|
|
20
|
+
|
|
21
|
+
const DEFAULT_MEDIA_PLAYER_CONFIG = {
|
|
22
|
+
seekStep: DEFAULT_SEEK_STEP,
|
|
23
|
+
rateOptions: DEFAULT_RATE_OPTIONS,
|
|
24
|
+
controlsHideDelay: DEFAULT_CONTROLS_HIDE_DELAY,
|
|
25
|
+
preload: 'metadata',
|
|
26
|
+
labels: {
|
|
27
|
+
play: 'Play',
|
|
28
|
+
pause: 'Pause',
|
|
29
|
+
replay: 'Replay',
|
|
30
|
+
mute: 'Mute',
|
|
31
|
+
unmute: 'Unmute',
|
|
32
|
+
volume: 'Volume',
|
|
33
|
+
seek: 'Seek',
|
|
34
|
+
timeSeparator: 'of',
|
|
35
|
+
settings: 'Settings',
|
|
36
|
+
captions: 'Captions',
|
|
37
|
+
captionsOff: 'Off',
|
|
38
|
+
playbackRate: 'Speed',
|
|
39
|
+
quality: 'Quality',
|
|
40
|
+
fullscreen: 'Enter fullscreen',
|
|
41
|
+
exitFullscreen: 'Exit fullscreen',
|
|
42
|
+
pictureInPicture: 'Picture in picture',
|
|
43
|
+
errorMessage: 'The media could not be played.',
|
|
44
|
+
retry: 'Retry',
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const MEDIA_PLAYER_CONFIG = new InjectionToken('MEDIA_PLAYER_CONFIG', {
|
|
49
|
+
factory: () => DEFAULT_MEDIA_PLAYER_CONFIG,
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
const MEDIA_SOURCE_ENGINE = new InjectionToken('MEDIA_SOURCE_ENGINE');
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Headless playback state over one `HTMLMediaElement`. Provided per player
|
|
56
|
+
* instance; the single place in the feature that touches the element. All
|
|
57
|
+
* signals are written exclusively from element events (plus one eager sync at
|
|
58
|
+
* attach, since a cached or autoplaying source can already be past
|
|
59
|
+
* `loadedmetadata` and will not re-fire it).
|
|
60
|
+
*/
|
|
61
|
+
class MediaController {
|
|
62
|
+
// Injections
|
|
63
|
+
_destroyRef = inject(DestroyRef);
|
|
64
|
+
_engine = inject(MEDIA_SOURCE_ENGINE, { optional: true });
|
|
65
|
+
_config = inject(MEDIA_PLAYER_CONFIG);
|
|
66
|
+
// State
|
|
67
|
+
_media = null;
|
|
68
|
+
_detachRegistered = false;
|
|
69
|
+
_playing = signal(false, /* @ts-ignore */
|
|
70
|
+
...(ngDevMode ? [{ debugName: "_playing" }] : /* istanbul ignore next */ []));
|
|
71
|
+
_currentTime = signal(0, /* @ts-ignore */
|
|
72
|
+
...(ngDevMode ? [{ debugName: "_currentTime" }] : /* istanbul ignore next */ []));
|
|
73
|
+
_duration = signal(0, /* @ts-ignore */
|
|
74
|
+
...(ngDevMode ? [{ debugName: "_duration" }] : /* istanbul ignore next */ []));
|
|
75
|
+
_buffered = signal([], /* @ts-ignore */
|
|
76
|
+
...(ngDevMode ? [{ debugName: "_buffered" }] : /* istanbul ignore next */ []));
|
|
77
|
+
_volume = signal(1, /* @ts-ignore */
|
|
78
|
+
...(ngDevMode ? [{ debugName: "_volume" }] : /* istanbul ignore next */ []));
|
|
79
|
+
_muted = signal(false, /* @ts-ignore */
|
|
80
|
+
...(ngDevMode ? [{ debugName: "_muted" }] : /* istanbul ignore next */ []));
|
|
81
|
+
_rate = signal(1, /* @ts-ignore */
|
|
82
|
+
...(ngDevMode ? [{ debugName: "_rate" }] : /* istanbul ignore next */ []));
|
|
83
|
+
_state = signal('idle', /* @ts-ignore */
|
|
84
|
+
...(ngDevMode ? [{ debugName: "_state" }] : /* istanbul ignore next */ []));
|
|
85
|
+
_error = signal(null, /* @ts-ignore */
|
|
86
|
+
...(ngDevMode ? [{ debugName: "_error" }] : /* istanbul ignore next */ []));
|
|
87
|
+
_textTracks = signal([], /* @ts-ignore */
|
|
88
|
+
...(ngDevMode ? [{ debugName: "_textTracks" }] : /* istanbul ignore next */ []));
|
|
89
|
+
_scrubbing = signal(false, /* @ts-ignore */
|
|
90
|
+
...(ngDevMode ? [{ debugName: "_scrubbing" }] : /* istanbul ignore next */ []));
|
|
91
|
+
_scrubTime = signal(0, /* @ts-ignore */
|
|
92
|
+
...(ngDevMode ? [{ debugName: "_scrubTime" }] : /* istanbul ignore next */ []));
|
|
93
|
+
playing = this._playing.asReadonly();
|
|
94
|
+
currentTime = computed(() => this._scrubbing() ? this._scrubTime() : this._currentTime(), /* @ts-ignore */
|
|
95
|
+
...(ngDevMode ? [{ debugName: "currentTime" }] : /* istanbul ignore next */ []));
|
|
96
|
+
duration = this._duration.asReadonly();
|
|
97
|
+
buffered = this._buffered.asReadonly();
|
|
98
|
+
volume = this._volume.asReadonly();
|
|
99
|
+
muted = this._muted.asReadonly();
|
|
100
|
+
rate = this._rate.asReadonly();
|
|
101
|
+
state = this._state.asReadonly();
|
|
102
|
+
error = this._error.asReadonly();
|
|
103
|
+
textTracks = this._textTracks.asReadonly();
|
|
104
|
+
// Public methods
|
|
105
|
+
attach(media) {
|
|
106
|
+
this._media = media;
|
|
107
|
+
this._listen(media, 'play', () => this._playing.set(true));
|
|
108
|
+
this._listen(media, 'pause', () => this._playing.set(false));
|
|
109
|
+
this._listen(media, 'ended', () => {
|
|
110
|
+
this._playing.set(false);
|
|
111
|
+
this._state.set('ended');
|
|
112
|
+
});
|
|
113
|
+
this._listen(media, 'timeupdate', () => {
|
|
114
|
+
if (!this._scrubbing())
|
|
115
|
+
this._syncTime(media);
|
|
116
|
+
});
|
|
117
|
+
this._listen(media, 'seeked', () => {
|
|
118
|
+
if (!this._scrubbing())
|
|
119
|
+
this._syncTime(media);
|
|
120
|
+
});
|
|
121
|
+
this._listen(media, 'durationchange', () => this._syncDuration(media));
|
|
122
|
+
this._listen(media, 'loadedmetadata', () => {
|
|
123
|
+
this._syncDuration(media);
|
|
124
|
+
this._syncBuffered(media);
|
|
125
|
+
this._syncTextTracks(media);
|
|
126
|
+
});
|
|
127
|
+
this._listen(media, 'progress', () => this._syncBuffered(media));
|
|
128
|
+
this._listen(media, 'volumechange', () => {
|
|
129
|
+
this._volume.set(media.volume);
|
|
130
|
+
this._muted.set(media.muted);
|
|
131
|
+
});
|
|
132
|
+
this._listen(media, 'ratechange', () => this._rate.set(media.playbackRate));
|
|
133
|
+
this._listen(media, 'waiting', () => this._state.set('loading'));
|
|
134
|
+
this._listen(media, 'canplay', () => {
|
|
135
|
+
if (!this._playing())
|
|
136
|
+
this._state.set('ready');
|
|
137
|
+
});
|
|
138
|
+
this._listen(media, 'playing', () => this._state.set('playing'));
|
|
139
|
+
this._listen(media, 'emptied', () => this._state.set('idle'));
|
|
140
|
+
this._listen(media, 'error', () => {
|
|
141
|
+
this._error.set(media.error);
|
|
142
|
+
this._state.set('error');
|
|
143
|
+
});
|
|
144
|
+
this._listen(media.textTracks, 'change', () => this._syncTextTracks(media));
|
|
145
|
+
this._syncInitial(media);
|
|
146
|
+
this._registerMediaSession();
|
|
147
|
+
}
|
|
148
|
+
play() {
|
|
149
|
+
const media = this._requireMedia();
|
|
150
|
+
return media.play();
|
|
151
|
+
}
|
|
152
|
+
pause() {
|
|
153
|
+
this._requireMedia().pause();
|
|
154
|
+
}
|
|
155
|
+
togglePlay() {
|
|
156
|
+
if (this._playing()) {
|
|
157
|
+
this.pause();
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
// A rejected play (autoplay policy) leaves the poster and play affordance
|
|
161
|
+
// in place; there is nothing further to do here.
|
|
162
|
+
this.play().catch(() => undefined);
|
|
163
|
+
}
|
|
164
|
+
seek(seconds) {
|
|
165
|
+
const media = this._requireMedia();
|
|
166
|
+
const clampedSeconds = this._clampTime(seconds);
|
|
167
|
+
media.currentTime = clampedSeconds;
|
|
168
|
+
// Optimistic signal update: the element completes a seek asynchronously
|
|
169
|
+
// (`seeked` can arrive much later on a network source), and waiting for it
|
|
170
|
+
// would snap the playhead back to the stale time in between — visible as a
|
|
171
|
+
// flicker when a scrub commits.
|
|
172
|
+
this._currentTime.set(clampedSeconds);
|
|
173
|
+
}
|
|
174
|
+
seekBy(delta) {
|
|
175
|
+
this.seek(this.currentTime() + delta);
|
|
176
|
+
}
|
|
177
|
+
beginScrub() {
|
|
178
|
+
this._scrubTime.set(this._currentTime());
|
|
179
|
+
this._scrubbing.set(true);
|
|
180
|
+
}
|
|
181
|
+
scrubTo(seconds) {
|
|
182
|
+
this._scrubTime.set(this._clampTime(seconds));
|
|
183
|
+
}
|
|
184
|
+
endScrub() {
|
|
185
|
+
this._scrubbing.set(false);
|
|
186
|
+
this.seek(this._scrubTime());
|
|
187
|
+
}
|
|
188
|
+
setVolume(volume) {
|
|
189
|
+
const media = this._requireMedia();
|
|
190
|
+
media.volume = Math.min(Math.max(volume, 0), 1);
|
|
191
|
+
if (media.volume > 0)
|
|
192
|
+
media.muted = false;
|
|
193
|
+
}
|
|
194
|
+
toggleMute() {
|
|
195
|
+
const media = this._requireMedia();
|
|
196
|
+
media.muted = !media.muted;
|
|
197
|
+
}
|
|
198
|
+
setRate(rate) {
|
|
199
|
+
this._requireMedia().playbackRate = rate;
|
|
200
|
+
}
|
|
201
|
+
setSource(source) {
|
|
202
|
+
const media = this._requireMedia();
|
|
203
|
+
const engine = this._engine;
|
|
204
|
+
if (engine && engine.canPlay(source)) {
|
|
205
|
+
// A previously attached engine must release its own resources before a
|
|
206
|
+
// new source takes over the element.
|
|
207
|
+
if (this._detachRegistered)
|
|
208
|
+
engine.detach();
|
|
209
|
+
engine.attach(media, source);
|
|
210
|
+
if (!this._detachRegistered) {
|
|
211
|
+
this._detachRegistered = true;
|
|
212
|
+
this._destroyRef.onDestroy(() => engine.detach());
|
|
213
|
+
}
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
media.src = source;
|
|
217
|
+
}
|
|
218
|
+
selectTextTrack(id) {
|
|
219
|
+
const media = this._requireMedia();
|
|
220
|
+
for (let index = 0; index < media.textTracks.length; index++) {
|
|
221
|
+
const track = media.textTracks[index];
|
|
222
|
+
if (track.kind !== 'subtitles' && track.kind !== 'captions')
|
|
223
|
+
continue;
|
|
224
|
+
const trackId = track.id !== '' ? track.id : `${track.language}-${index}`;
|
|
225
|
+
track.mode = trackId === id ? 'showing' : 'disabled';
|
|
226
|
+
}
|
|
227
|
+
this._syncTextTracks(media);
|
|
228
|
+
}
|
|
229
|
+
setMetadata(metadata) {
|
|
230
|
+
if (typeof navigator === 'undefined')
|
|
231
|
+
return;
|
|
232
|
+
if (!('mediaSession' in navigator) || !navigator.mediaSession)
|
|
233
|
+
return;
|
|
234
|
+
navigator.mediaSession.metadata = new MediaMetadata(metadata);
|
|
235
|
+
}
|
|
236
|
+
// Private methods
|
|
237
|
+
_requireMedia() {
|
|
238
|
+
if (!this._media)
|
|
239
|
+
throw new Error('MediaController is not attached to a media element.');
|
|
240
|
+
return this._media;
|
|
241
|
+
}
|
|
242
|
+
_clampTime(seconds) {
|
|
243
|
+
return Math.min(Math.max(seconds, 0), this._duration());
|
|
244
|
+
}
|
|
245
|
+
_registerMediaSession() {
|
|
246
|
+
if (typeof navigator === 'undefined')
|
|
247
|
+
return;
|
|
248
|
+
if (!('mediaSession' in navigator) || !navigator.mediaSession)
|
|
249
|
+
return;
|
|
250
|
+
const session = navigator.mediaSession;
|
|
251
|
+
const actions = ['play', 'pause', 'seekbackward', 'seekforward', 'seekto'];
|
|
252
|
+
session.setActionHandler('play', () => this.togglePlay());
|
|
253
|
+
session.setActionHandler('pause', () => this.pause());
|
|
254
|
+
session.setActionHandler('seekbackward', () => this.seekBy(-this._config.seekStep));
|
|
255
|
+
session.setActionHandler('seekforward', () => this.seekBy(this._config.seekStep));
|
|
256
|
+
session.setActionHandler('seekto', (details) => {
|
|
257
|
+
if (details.seekTime !== undefined)
|
|
258
|
+
this.seek(details.seekTime);
|
|
259
|
+
});
|
|
260
|
+
this._destroyRef.onDestroy(() => {
|
|
261
|
+
for (const action of actions)
|
|
262
|
+
session.setActionHandler(action, null);
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
_listen(target, type, handler) {
|
|
266
|
+
target.addEventListener(type, handler);
|
|
267
|
+
this._destroyRef.onDestroy(() => target.removeEventListener(type, handler));
|
|
268
|
+
}
|
|
269
|
+
_syncInitial(media) {
|
|
270
|
+
this._syncDuration(media);
|
|
271
|
+
this._syncTime(media);
|
|
272
|
+
this._syncBuffered(media);
|
|
273
|
+
this._syncTextTracks(media);
|
|
274
|
+
this._volume.set(media.volume);
|
|
275
|
+
this._muted.set(media.muted);
|
|
276
|
+
this._rate.set(media.playbackRate);
|
|
277
|
+
if (!media.paused) {
|
|
278
|
+
this._playing.set(true);
|
|
279
|
+
this._state.set('playing');
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
_syncTime(media) {
|
|
283
|
+
this._currentTime.set(media.currentTime);
|
|
284
|
+
}
|
|
285
|
+
_syncDuration(media) {
|
|
286
|
+
this._duration.set(Number.isFinite(media.duration) ? media.duration : 0);
|
|
287
|
+
}
|
|
288
|
+
_syncBuffered(media) {
|
|
289
|
+
const ranges = [];
|
|
290
|
+
for (let index = 0; index < media.buffered.length; index++) {
|
|
291
|
+
ranges.push({ start: media.buffered.start(index), end: media.buffered.end(index) });
|
|
292
|
+
}
|
|
293
|
+
this._buffered.set(ranges);
|
|
294
|
+
}
|
|
295
|
+
_syncTextTracks(media) {
|
|
296
|
+
const tracks = [];
|
|
297
|
+
for (let index = 0; index < media.textTracks.length; index++) {
|
|
298
|
+
const track = media.textTracks[index];
|
|
299
|
+
if (track.kind !== 'subtitles' && track.kind !== 'captions')
|
|
300
|
+
continue;
|
|
301
|
+
tracks.push({
|
|
302
|
+
id: track.id !== '' ? track.id : `${track.language}-${index}`,
|
|
303
|
+
label: track.label,
|
|
304
|
+
language: track.language,
|
|
305
|
+
active: track.mode === 'showing',
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
this._textTracks.set(tracks);
|
|
309
|
+
}
|
|
310
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: MediaController, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
311
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: MediaController });
|
|
312
|
+
}
|
|
313
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: MediaController, decorators: [{
|
|
314
|
+
type: Injectable
|
|
315
|
+
}] });
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* Fullscreen and Picture-in-Picture state for a video player: fullscreen is
|
|
319
|
+
* requested on the player container (so the chrome stays visible), PiP on the
|
|
320
|
+
* video element itself. Feature support is detected per element at attach, so
|
|
321
|
+
* the chrome can hide unavailable buttons.
|
|
322
|
+
*/
|
|
323
|
+
class FullscreenController {
|
|
324
|
+
// Injections
|
|
325
|
+
_document = inject(DOCUMENT);
|
|
326
|
+
_destroyRef = inject(DestroyRef);
|
|
327
|
+
// State
|
|
328
|
+
_container = null;
|
|
329
|
+
_video = null;
|
|
330
|
+
_fullscreen = signal(false, /* @ts-ignore */
|
|
331
|
+
...(ngDevMode ? [{ debugName: "_fullscreen" }] : /* istanbul ignore next */ []));
|
|
332
|
+
_pictureInPicture = signal(false, /* @ts-ignore */
|
|
333
|
+
...(ngDevMode ? [{ debugName: "_pictureInPicture" }] : /* istanbul ignore next */ []));
|
|
334
|
+
_fullscreenSupported = signal(false, /* @ts-ignore */
|
|
335
|
+
...(ngDevMode ? [{ debugName: "_fullscreenSupported" }] : /* istanbul ignore next */ []));
|
|
336
|
+
_pictureInPictureSupported = signal(false, /* @ts-ignore */
|
|
337
|
+
...(ngDevMode ? [{ debugName: "_pictureInPictureSupported" }] : /* istanbul ignore next */ []));
|
|
338
|
+
fullscreen = this._fullscreen.asReadonly();
|
|
339
|
+
pictureInPicture = this._pictureInPicture.asReadonly();
|
|
340
|
+
fullscreenSupported = this._fullscreenSupported.asReadonly();
|
|
341
|
+
pictureInPictureSupported = this._pictureInPictureSupported.asReadonly();
|
|
342
|
+
// Public methods
|
|
343
|
+
attach(container, video) {
|
|
344
|
+
this._container = container;
|
|
345
|
+
this._video = video;
|
|
346
|
+
this._fullscreenSupported.set(typeof container.requestFullscreen === 'function');
|
|
347
|
+
this._pictureInPictureSupported.set('requestPictureInPicture' in video);
|
|
348
|
+
const onFullscreenChange = () => this._fullscreen.set(this._document.fullscreenElement === container);
|
|
349
|
+
this._document.addEventListener('fullscreenchange', onFullscreenChange);
|
|
350
|
+
this._destroyRef.onDestroy(() => this._document.removeEventListener('fullscreenchange', onFullscreenChange));
|
|
351
|
+
const onEnterPip = () => this._pictureInPicture.set(true);
|
|
352
|
+
const onLeavePip = () => this._pictureInPicture.set(false);
|
|
353
|
+
video.addEventListener('enterpictureinpicture', onEnterPip);
|
|
354
|
+
video.addEventListener('leavepictureinpicture', onLeavePip);
|
|
355
|
+
this._destroyRef.onDestroy(() => {
|
|
356
|
+
video.removeEventListener('enterpictureinpicture', onEnterPip);
|
|
357
|
+
video.removeEventListener('leavepictureinpicture', onLeavePip);
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
async toggleFullscreen() {
|
|
361
|
+
if (!this._container)
|
|
362
|
+
return;
|
|
363
|
+
if (this._fullscreen()) {
|
|
364
|
+
await this._document.exitFullscreen();
|
|
365
|
+
return;
|
|
366
|
+
}
|
|
367
|
+
await this._container.requestFullscreen();
|
|
368
|
+
}
|
|
369
|
+
async togglePictureInPicture() {
|
|
370
|
+
const video = this._video;
|
|
371
|
+
if (!video)
|
|
372
|
+
return;
|
|
373
|
+
if (this._pictureInPicture()) {
|
|
374
|
+
await this._document.exitPictureInPicture();
|
|
375
|
+
return;
|
|
376
|
+
}
|
|
377
|
+
await video.requestPictureInPicture();
|
|
378
|
+
}
|
|
379
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: FullscreenController, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
380
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: FullscreenController });
|
|
381
|
+
}
|
|
382
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: FullscreenController, decorators: [{
|
|
383
|
+
type: Injectable
|
|
384
|
+
}] });
|
|
385
|
+
|
|
386
|
+
/** Toggles playback, swapping its icon and accessible name between play, pause and replay. */
|
|
387
|
+
class MediaPlayToggle {
|
|
388
|
+
// Injections
|
|
389
|
+
_controller = inject(MediaController);
|
|
390
|
+
_config = inject(MEDIA_PLAYER_CONFIG);
|
|
391
|
+
labels = this._config.labels;
|
|
392
|
+
// Computed
|
|
393
|
+
playing = this._controller.playing;
|
|
394
|
+
ended = computed(() => this._controller.state() === 'ended', /* @ts-ignore */
|
|
395
|
+
...(ngDevMode ? [{ debugName: "ended" }] : /* istanbul ignore next */ []));
|
|
396
|
+
label = computed(() => {
|
|
397
|
+
if (this.ended())
|
|
398
|
+
return this.labels.replay;
|
|
399
|
+
return this.playing() ? this.labels.pause : this.labels.play;
|
|
400
|
+
}, /* @ts-ignore */
|
|
401
|
+
...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
|
|
402
|
+
iconName = computed(() => {
|
|
403
|
+
if (this.ended())
|
|
404
|
+
return 'replay';
|
|
405
|
+
return this.playing() ? 'pause' : 'play';
|
|
406
|
+
}, /* @ts-ignore */
|
|
407
|
+
...(ngDevMode ? [{ debugName: "iconName" }] : /* istanbul ignore next */ []));
|
|
408
|
+
// Protected methods
|
|
409
|
+
toggle() {
|
|
410
|
+
this._controller.togglePlay();
|
|
411
|
+
}
|
|
412
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: MediaPlayToggle, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
413
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "22.0.5", type: MediaPlayToggle, isStandalone: true, selector: "tls-media-play-toggle", host: { classAttribute: "tls-media-play-toggle" }, ngImport: i0, template: "<button type=\"button\" class=\"button\" [attr.aria-label]=\"label()\" (click)=\"toggle()\">\n <tls-icon [name]=\"iconName()\" />\n</button>\n", styles: [":host{display:inline-flex}:host .button{position:relative;width:var(--tls-media-control-size, 36px);height:var(--tls-media-control-size, 36px);display:inline-flex;align-items:center;justify-content:center;border:none;color:inherit;cursor:pointer}\n"], dependencies: [{ kind: "component", type: Icon, selector: "tls-icon", inputs: ["name", "iconSrc", "alt", "allowedSources"] }] });
|
|
414
|
+
}
|
|
415
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: MediaPlayToggle, decorators: [{
|
|
416
|
+
type: Component,
|
|
417
|
+
args: [{ selector: 'tls-media-play-toggle', imports: [Icon], host: {
|
|
418
|
+
class: 'tls-media-play-toggle',
|
|
419
|
+
}, template: "<button type=\"button\" class=\"button\" [attr.aria-label]=\"label()\" (click)=\"toggle()\">\n <tls-icon [name]=\"iconName()\" />\n</button>\n", styles: [":host{display:inline-flex}:host .button{position:relative;width:var(--tls-media-control-size, 36px);height:var(--tls-media-control-size, 36px);display:inline-flex;align-items:center;justify-content:center;border:none;color:inherit;cursor:pointer}\n"] }]
|
|
420
|
+
}] });
|
|
421
|
+
|
|
422
|
+
/** Formats whole seconds as `m:ss` (or `h:mm:ss` past an hour). */
|
|
423
|
+
const formatMediaTime = (totalSeconds) => {
|
|
424
|
+
const seconds = Math.floor(totalSeconds % 60);
|
|
425
|
+
const minutes = Math.floor((totalSeconds / 60) % 60);
|
|
426
|
+
const hours = Math.floor(totalSeconds / 3600);
|
|
427
|
+
const padded = (value) => String(value).padStart(2, '0');
|
|
428
|
+
if (hours > 0)
|
|
429
|
+
return `${hours}:${padded(minutes)}:${padded(seconds)}`;
|
|
430
|
+
return `${minutes}:${padded(seconds)}`;
|
|
431
|
+
};
|
|
432
|
+
/**
|
|
433
|
+
* Playhead slider for a media player. Drives the attached {@link MediaController}'s
|
|
434
|
+
* scrub lock while dragging so timeupdate events from playback do not fight the
|
|
435
|
+
* thumb, and commits the seek on release.
|
|
436
|
+
*/
|
|
437
|
+
class MediaScrubber {
|
|
438
|
+
// Injections
|
|
439
|
+
_controller = inject(MediaController);
|
|
440
|
+
_config = inject(MEDIA_PLAYER_CONFIG);
|
|
441
|
+
_directionality = inject(Directionality);
|
|
442
|
+
// State
|
|
443
|
+
_dragging = false;
|
|
444
|
+
_pointerId = null;
|
|
445
|
+
labels = this._config.labels;
|
|
446
|
+
// Computed
|
|
447
|
+
duration = computed(() => Math.round(this._controller.duration()), /* @ts-ignore */
|
|
448
|
+
...(ngDevMode ? [{ debugName: "duration" }] : /* istanbul ignore next */ []));
|
|
449
|
+
currentTime = computed(() => Math.round(this._controller.currentTime()), /* @ts-ignore */
|
|
450
|
+
...(ngDevMode ? [{ debugName: "currentTime" }] : /* istanbul ignore next */ []));
|
|
451
|
+
valueText = computed(() => `${formatMediaTime(this.currentTime())} ${this.labels.timeSeparator} ${formatMediaTime(this.duration())}`, /* @ts-ignore */
|
|
452
|
+
...(ngDevMode ? [{ debugName: "valueText" }] : /* istanbul ignore next */ []));
|
|
453
|
+
playedFraction = computed(() => {
|
|
454
|
+
const duration = this._controller.duration();
|
|
455
|
+
if (duration <= 0)
|
|
456
|
+
return 0;
|
|
457
|
+
return this._controller.currentTime() / duration;
|
|
458
|
+
}, /* @ts-ignore */
|
|
459
|
+
...(ngDevMode ? [{ debugName: "playedFraction" }] : /* istanbul ignore next */ []));
|
|
460
|
+
bufferedFraction = computed(() => {
|
|
461
|
+
const duration = this._controller.duration();
|
|
462
|
+
const ranges = this._controller.buffered();
|
|
463
|
+
if (duration <= 0 || ranges.length === 0)
|
|
464
|
+
return 0;
|
|
465
|
+
return ranges[ranges.length - 1].end / duration;
|
|
466
|
+
}, /* @ts-ignore */
|
|
467
|
+
...(ngDevMode ? [{ debugName: "bufferedFraction" }] : /* istanbul ignore next */ []));
|
|
468
|
+
// Protected methods
|
|
469
|
+
onPointerDown(event) {
|
|
470
|
+
// Only the primary button starts a drag: a secondary press (context menu)
|
|
471
|
+
// never delivers a matching pointerup, which would strand the scrub lock
|
|
472
|
+
// and freeze the displayed playhead.
|
|
473
|
+
if (event.button !== 0)
|
|
474
|
+
return;
|
|
475
|
+
this._dragging = true;
|
|
476
|
+
this._pointerId = event.pointerId;
|
|
477
|
+
const host = event.currentTarget;
|
|
478
|
+
host.setPointerCapture(event.pointerId);
|
|
479
|
+
this._controller.beginScrub();
|
|
480
|
+
this._controller.scrubTo(this._timeFromPointer(event, host));
|
|
481
|
+
}
|
|
482
|
+
onPointerMove(event) {
|
|
483
|
+
if (!this._dragging || event.pointerId !== this._pointerId)
|
|
484
|
+
return;
|
|
485
|
+
this._controller.scrubTo(this._timeFromPointer(event, event.currentTarget));
|
|
486
|
+
}
|
|
487
|
+
onPointerUp(event) {
|
|
488
|
+
if (!this._dragging || event.pointerId !== this._pointerId)
|
|
489
|
+
return;
|
|
490
|
+
this._dragging = false;
|
|
491
|
+
this._pointerId = null;
|
|
492
|
+
event.currentTarget.releasePointerCapture(event.pointerId);
|
|
493
|
+
this._controller.endScrub();
|
|
494
|
+
}
|
|
495
|
+
/**
|
|
496
|
+
* Aborted pointers (touch cancellation, capture loss) must still release the
|
|
497
|
+
* scrub lock or the displayed playhead freezes; the last scrubbed position is
|
|
498
|
+
* committed as if the pointer had lifted there.
|
|
499
|
+
*/
|
|
500
|
+
onPointerCancel() {
|
|
501
|
+
if (!this._dragging)
|
|
502
|
+
return;
|
|
503
|
+
this._dragging = false;
|
|
504
|
+
this._pointerId = null;
|
|
505
|
+
this._controller.endScrub();
|
|
506
|
+
}
|
|
507
|
+
onKeydown(event) {
|
|
508
|
+
const step = this._config.seekStep;
|
|
509
|
+
const forwardKey = this._directionality.value === 'rtl' ? 'ArrowLeft' : 'ArrowRight';
|
|
510
|
+
const backwardKey = this._directionality.value === 'rtl' ? 'ArrowRight' : 'ArrowLeft';
|
|
511
|
+
if (event.key === forwardKey)
|
|
512
|
+
this._controller.seekBy(step);
|
|
513
|
+
else if (event.key === backwardKey)
|
|
514
|
+
this._controller.seekBy(-step);
|
|
515
|
+
else if (event.key === 'Home')
|
|
516
|
+
this._controller.seek(0);
|
|
517
|
+
else if (event.key === 'End')
|
|
518
|
+
this._controller.seek(this._controller.duration());
|
|
519
|
+
else
|
|
520
|
+
return;
|
|
521
|
+
event.preventDefault();
|
|
522
|
+
event.stopPropagation();
|
|
523
|
+
}
|
|
524
|
+
// Private methods
|
|
525
|
+
_timeFromPointer(event, host) {
|
|
526
|
+
const rect = host.getBoundingClientRect();
|
|
527
|
+
let fraction = (event.clientX - rect.left) / rect.width;
|
|
528
|
+
if (this._directionality.value === 'rtl')
|
|
529
|
+
fraction = 1 - fraction;
|
|
530
|
+
return Math.min(Math.max(fraction, 0), 1) * this._controller.duration();
|
|
531
|
+
}
|
|
532
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: MediaScrubber, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
533
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "22.0.5", type: MediaScrubber, isStandalone: true, selector: "tls-media-scrubber", host: { attributes: { "role": "slider", "tabindex": "0", "aria-valuemin": "0" }, listeners: { "pointerdown": "onPointerDown($event)", "pointermove": "onPointerMove($event)", "pointerup": "onPointerUp($event)", "pointercancel": "onPointerCancel()", "keydown": "onKeydown($event)" }, properties: { "attr.aria-valuemax": "duration()", "attr.aria-valuenow": "currentTime()", "attr.aria-valuetext": "valueText()", "attr.aria-label": "labels.seek", "style.--tls-media-played": "playedFraction()", "style.--tls-media-buffered": "bufferedFraction()" }, classAttribute: "tls-media-scrubber" }, ngImport: i0, template: "<div class=\"track\">\n <div class=\"track__fills\">\n <div class=\"track__buffered\"></div>\n <div class=\"track__played\"></div>\n </div>\n <div class=\"track__thumb\"></div>\n</div>\n", styles: [":host{position:relative;display:block;cursor:pointer;touch-action:none}:host:before{content:\"\";position:absolute;inset-block-start:calc(-1 * var(--spacing-4));inset-block-end:calc(-1 * var(--spacing-1));inset-inline:0}:host .track{position:relative;height:var(--tls-media-scrubber-height, 4px);border-radius:var(--radius-xl)}:host .track__fills{position:absolute;inset:0;border-radius:var(--radius-xl);overflow:hidden}:host .track__buffered,:host .track__played{position:absolute;inset-block:0;inset-inline-start:0}:host .track__buffered{width:calc(var(--tls-media-buffered, 0) * 100%)}:host .track__played{width:calc(var(--tls-media-played, 0) * 100%)}:host .track__thumb{position:absolute;inset-block-start:50%;inset-inline-start:calc(var(--tls-media-played, 0) * 100%)}\n"] });
|
|
534
|
+
}
|
|
535
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: MediaScrubber, decorators: [{
|
|
536
|
+
type: Component,
|
|
537
|
+
args: [{ selector: 'tls-media-scrubber', host: {
|
|
538
|
+
role: 'slider',
|
|
539
|
+
tabindex: '0',
|
|
540
|
+
class: 'tls-media-scrubber',
|
|
541
|
+
'aria-valuemin': '0',
|
|
542
|
+
'[attr.aria-valuemax]': 'duration()',
|
|
543
|
+
'[attr.aria-valuenow]': 'currentTime()',
|
|
544
|
+
'[attr.aria-valuetext]': 'valueText()',
|
|
545
|
+
'[attr.aria-label]': 'labels.seek',
|
|
546
|
+
'[style.--tls-media-played]': 'playedFraction()',
|
|
547
|
+
'[style.--tls-media-buffered]': 'bufferedFraction()',
|
|
548
|
+
'(pointerdown)': 'onPointerDown($event)',
|
|
549
|
+
'(pointermove)': 'onPointerMove($event)',
|
|
550
|
+
'(pointerup)': 'onPointerUp($event)',
|
|
551
|
+
'(pointercancel)': 'onPointerCancel()',
|
|
552
|
+
'(keydown)': 'onKeydown($event)',
|
|
553
|
+
}, template: "<div class=\"track\">\n <div class=\"track__fills\">\n <div class=\"track__buffered\"></div>\n <div class=\"track__played\"></div>\n </div>\n <div class=\"track__thumb\"></div>\n</div>\n", styles: [":host{position:relative;display:block;cursor:pointer;touch-action:none}:host:before{content:\"\";position:absolute;inset-block-start:calc(-1 * var(--spacing-4));inset-block-end:calc(-1 * var(--spacing-1));inset-inline:0}:host .track{position:relative;height:var(--tls-media-scrubber-height, 4px);border-radius:var(--radius-xl)}:host .track__fills{position:absolute;inset:0;border-radius:var(--radius-xl);overflow:hidden}:host .track__buffered,:host .track__played{position:absolute;inset-block:0;inset-inline-start:0}:host .track__buffered{width:calc(var(--tls-media-buffered, 0) * 100%)}:host .track__played{width:calc(var(--tls-media-played, 0) * 100%)}:host .track__thumb{position:absolute;inset-block-start:50%;inset-inline-start:calc(var(--tls-media-played, 0) * 100%)}\n"] }]
|
|
554
|
+
}] });
|
|
555
|
+
|
|
556
|
+
/**
|
|
557
|
+
* Gear-triggered popup assembling the player's configurable choices —
|
|
558
|
+
* playback rate, caption track and, when the attached source engine reports
|
|
559
|
+
* renditions, quality — as radio groups inside one `tls-menu`. Renders
|
|
560
|
+
* nothing when there is only the default rate and no tracks or levels to
|
|
561
|
+
* choose between, since a settings affordance with a single, fixed choice
|
|
562
|
+
* offers nothing to configure.
|
|
563
|
+
*/
|
|
564
|
+
class MediaSettingsMenu {
|
|
565
|
+
// Injections
|
|
566
|
+
_controller = inject(MediaController);
|
|
567
|
+
_config = inject(MEDIA_PLAYER_CONFIG);
|
|
568
|
+
_engine = inject(MEDIA_SOURCE_ENGINE, { optional: true });
|
|
569
|
+
labels = this._config.labels;
|
|
570
|
+
iconName = 'settings';
|
|
571
|
+
// State
|
|
572
|
+
menu = viewChild('menu', /* @ts-ignore */
|
|
573
|
+
...(ngDevMode ? [{ debugName: "menu" }] : /* istanbul ignore next */ []));
|
|
574
|
+
// Computed
|
|
575
|
+
_rateItems = computed(() => this._config.rateOptions.map(rate => ({
|
|
576
|
+
type: 'item',
|
|
577
|
+
role: 'menuitemradio',
|
|
578
|
+
label: rate === 1 ? '1×' : `${rate}×`,
|
|
579
|
+
checked: this._controller.rate() === rate,
|
|
580
|
+
closeOnSelect: false,
|
|
581
|
+
action: () => this._controller.setRate(rate),
|
|
582
|
+
})), /* @ts-ignore */
|
|
583
|
+
...(ngDevMode ? [{ debugName: "_rateItems" }] : /* istanbul ignore next */ []));
|
|
584
|
+
_captionItems = computed(() => {
|
|
585
|
+
const tracks = this._controller.textTracks();
|
|
586
|
+
if (tracks.length === 0)
|
|
587
|
+
return [];
|
|
588
|
+
const items = [
|
|
589
|
+
{ type: 'divider' },
|
|
590
|
+
{ type: 'label', label: this.labels.captions },
|
|
591
|
+
{
|
|
592
|
+
type: 'item',
|
|
593
|
+
role: 'menuitemradio',
|
|
594
|
+
label: this.labels.captionsOff,
|
|
595
|
+
checked: !tracks.some(track => track.active),
|
|
596
|
+
closeOnSelect: false,
|
|
597
|
+
action: () => this._controller.selectTextTrack(null),
|
|
598
|
+
},
|
|
599
|
+
];
|
|
600
|
+
for (const track of tracks) {
|
|
601
|
+
items.push({
|
|
602
|
+
type: 'item',
|
|
603
|
+
role: 'menuitemradio',
|
|
604
|
+
label: track.label,
|
|
605
|
+
checked: track.active,
|
|
606
|
+
closeOnSelect: false,
|
|
607
|
+
action: () => this._controller.selectTextTrack(track.id),
|
|
608
|
+
});
|
|
609
|
+
}
|
|
610
|
+
return items;
|
|
611
|
+
}, /* @ts-ignore */
|
|
612
|
+
...(ngDevMode ? [{ debugName: "_captionItems" }] : /* istanbul ignore next */ []));
|
|
613
|
+
_levelItems = computed(() => {
|
|
614
|
+
if (!this._engine)
|
|
615
|
+
return [];
|
|
616
|
+
if (!this._engine.levels)
|
|
617
|
+
return [];
|
|
618
|
+
const levels = this._engine.levels();
|
|
619
|
+
if (levels.length === 0)
|
|
620
|
+
return [];
|
|
621
|
+
const items = [
|
|
622
|
+
{ type: 'divider' },
|
|
623
|
+
{ type: 'label', label: this.labels.quality },
|
|
624
|
+
];
|
|
625
|
+
// MediaSourceEngine reports available renditions but neither which one is
|
|
626
|
+
// active nor a way to select one, so these items stay disabled until the
|
|
627
|
+
// engine contract exposes a selection surface.
|
|
628
|
+
for (const level of levels) {
|
|
629
|
+
items.push({
|
|
630
|
+
type: 'item',
|
|
631
|
+
role: 'menuitemradio',
|
|
632
|
+
label: level.label,
|
|
633
|
+
closeOnSelect: false,
|
|
634
|
+
disabled: true,
|
|
635
|
+
});
|
|
636
|
+
}
|
|
637
|
+
return items;
|
|
638
|
+
}, /* @ts-ignore */
|
|
639
|
+
...(ngDevMode ? [{ debugName: "_levelItems" }] : /* istanbul ignore next */ []));
|
|
640
|
+
items = computed(() => [
|
|
641
|
+
{ type: 'label', label: this.labels.playbackRate },
|
|
642
|
+
...this._rateItems(),
|
|
643
|
+
...this._captionItems(),
|
|
644
|
+
...this._levelItems(),
|
|
645
|
+
], /* @ts-ignore */
|
|
646
|
+
...(ngDevMode ? [{ debugName: "items" }] : /* istanbul ignore next */ []));
|
|
647
|
+
hasSettings = computed(() => {
|
|
648
|
+
if (this._config.rateOptions.length > 1)
|
|
649
|
+
return true;
|
|
650
|
+
if (this._controller.textTracks().length > 0)
|
|
651
|
+
return true;
|
|
652
|
+
if (this._engine && this._engine.levels && this._engine.levels().length > 0)
|
|
653
|
+
return true;
|
|
654
|
+
return false;
|
|
655
|
+
}, /* @ts-ignore */
|
|
656
|
+
...(ngDevMode ? [{ debugName: "hasSettings" }] : /* istanbul ignore next */ []));
|
|
657
|
+
/** Whether the popup is currently open, reflecting the underlying menu's overlay state. */
|
|
658
|
+
open = computed(() => {
|
|
659
|
+
const menu = this.menu();
|
|
660
|
+
if (!menu)
|
|
661
|
+
return false;
|
|
662
|
+
return menu.isOpen();
|
|
663
|
+
}, /* @ts-ignore */
|
|
664
|
+
...(ngDevMode ? [{ debugName: "open" }] : /* istanbul ignore next */ []));
|
|
665
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: MediaSettingsMenu, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
666
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.5", type: MediaSettingsMenu, isStandalone: true, selector: "tls-media-settings-menu", host: { classAttribute: "tls-media-settings-menu" }, viewQueries: [{ propertyName: "menu", first: true, predicate: ["menu"], descendants: true, isSignal: true }], ngImport: i0, template: "@if (hasSettings()) {\n <button type=\"button\" class=\"button\" [attr.aria-label]=\"labels.settings\" [tlsMenuTrigger]=\"menu\">\n <tls-icon [name]=\"iconName\" />\n </button>\n <tls-menu #menu [items]=\"items()\" />\n}\n", styles: [":host{display:inline-flex}:host .button{position:relative;width:var(--tls-media-control-size, 36px);height:var(--tls-media-control-size, 36px);display:inline-flex;align-items:center;justify-content:center;border:none;color:inherit;cursor:pointer}\n"], dependencies: [{ kind: "component", type: Icon, selector: "tls-icon", inputs: ["name", "iconSrc", "alt", "allowedSources"] }, { kind: "component", type: Menu, selector: "tls-menu", inputs: ["items", "position", "offset", "ariaLabel", "inline", "panelClass"] }, { kind: "directive", type: MenuTriggerDirective, selector: "[tlsMenuTrigger]", inputs: ["tlsMenuTrigger"] }] });
|
|
667
|
+
}
|
|
668
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: MediaSettingsMenu, decorators: [{
|
|
669
|
+
type: Component,
|
|
670
|
+
args: [{ selector: 'tls-media-settings-menu', imports: [Icon, Menu, MenuTriggerDirective], host: {
|
|
671
|
+
class: 'tls-media-settings-menu',
|
|
672
|
+
}, template: "@if (hasSettings()) {\n <button type=\"button\" class=\"button\" [attr.aria-label]=\"labels.settings\" [tlsMenuTrigger]=\"menu\">\n <tls-icon [name]=\"iconName\" />\n </button>\n <tls-menu #menu [items]=\"items()\" />\n}\n", styles: [":host{display:inline-flex}:host .button{position:relative;width:var(--tls-media-control-size, 36px);height:var(--tls-media-control-size, 36px);display:inline-flex;align-items:center;justify-content:center;border:none;color:inherit;cursor:pointer}\n"] }]
|
|
673
|
+
}], propDecorators: { menu: [{ type: i0.ViewChild, args: ['menu', { isSignal: true }] }] } });
|
|
674
|
+
|
|
675
|
+
/**
|
|
676
|
+
* Renders playback position as `current / total`, e.g. `1:23 / 4:05`. Purely
|
|
677
|
+
* decorative: the scrubber's `aria-valuetext` already announces the same
|
|
678
|
+
* information to assistive technology, so this display is hidden from it.
|
|
679
|
+
*/
|
|
680
|
+
class MediaTimeDisplay {
|
|
681
|
+
// Injections
|
|
682
|
+
_controller = inject(MediaController);
|
|
683
|
+
// Computed
|
|
684
|
+
current = computed(() => formatMediaTime(this._controller.currentTime()), /* @ts-ignore */
|
|
685
|
+
...(ngDevMode ? [{ debugName: "current" }] : /* istanbul ignore next */ []));
|
|
686
|
+
total = computed(() => formatMediaTime(this._controller.duration()), /* @ts-ignore */
|
|
687
|
+
...(ngDevMode ? [{ debugName: "total" }] : /* istanbul ignore next */ []));
|
|
688
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: MediaTimeDisplay, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
689
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "22.0.5", type: MediaTimeDisplay, isStandalone: true, selector: "tls-media-time-display", host: { attributes: { "aria-hidden": "true" }, classAttribute: "tls-media-time-display" }, ngImport: i0, template: "<span class=\"time\">{{ current() }}</span> / <span class=\"time\">{{ total() }}</span>\n", styles: [":host{display:inline-flex;align-items:center;gap:var(--spacing-1);font-variant-numeric:tabular-nums}\n"] });
|
|
690
|
+
}
|
|
691
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: MediaTimeDisplay, decorators: [{
|
|
692
|
+
type: Component,
|
|
693
|
+
args: [{ selector: 'tls-media-time-display', host: {
|
|
694
|
+
class: 'tls-media-time-display',
|
|
695
|
+
'aria-hidden': 'true',
|
|
696
|
+
}, template: "<span class=\"time\">{{ current() }}</span> / <span class=\"time\">{{ total() }}</span>\n", styles: [":host{display:inline-flex;align-items:center;gap:var(--spacing-1);font-variant-numeric:tabular-nums}\n"] }]
|
|
697
|
+
}] });
|
|
698
|
+
|
|
699
|
+
/**
|
|
700
|
+
* Mute toggle paired with a `role="slider"` volume bar over `[0, 1]`, mirroring
|
|
701
|
+
* the scrubber's pointer-drag and keyboard-step pattern. Reads and writes
|
|
702
|
+
* through the attached {@link MediaController}; horizontal arrow keys are
|
|
703
|
+
* direction-resolved so "increase" always points toward higher volume.
|
|
704
|
+
*
|
|
705
|
+
* On fine pointers the slider stays collapsed until the control is hovered or
|
|
706
|
+
* holds focus; the drag modifier keeps it out while a captured pointer roams
|
|
707
|
+
* beyond the host. Coarse pointers have no hover, so there the slider is
|
|
708
|
+
* always expanded.
|
|
709
|
+
*/
|
|
710
|
+
class MediaVolumeControl {
|
|
711
|
+
// Injections
|
|
712
|
+
_controller = inject(MediaController);
|
|
713
|
+
_config = inject(MEDIA_PLAYER_CONFIG);
|
|
714
|
+
_directionality = inject(Directionality);
|
|
715
|
+
// State
|
|
716
|
+
dragging = signal(false, /* @ts-ignore */
|
|
717
|
+
...(ngDevMode ? [{ debugName: "dragging" }] : /* istanbul ignore next */ []));
|
|
718
|
+
_pointerId = null;
|
|
719
|
+
labels = this._config.labels;
|
|
720
|
+
// Computed
|
|
721
|
+
muted = this._controller.muted;
|
|
722
|
+
volume = this._controller.volume;
|
|
723
|
+
muteLabel = computed(() => this.muted() ? this.labels.unmute : this.labels.mute, /* @ts-ignore */
|
|
724
|
+
...(ngDevMode ? [{ debugName: "muteLabel" }] : /* istanbul ignore next */ []));
|
|
725
|
+
muteIcon = computed(() => this.muted() ? 'volume-muted' : 'volume', /* @ts-ignore */
|
|
726
|
+
...(ngDevMode ? [{ debugName: "muteIcon" }] : /* istanbul ignore next */ []));
|
|
727
|
+
/** Visual fill only — collapses to empty when muted; mute state itself is conveyed by the mute button's `aria-pressed`. */
|
|
728
|
+
filledFraction = computed(() => this.muted() ? 0 : this.volume(), /* @ts-ignore */
|
|
729
|
+
...(ngDevMode ? [{ debugName: "filledFraction" }] : /* istanbul ignore next */ []));
|
|
730
|
+
/** ARIA value always reports the retained volume, unaffected by mute, so a muted slider still announces its true level. */
|
|
731
|
+
valueNow = computed(() => Math.round(this.volume() * 100), /* @ts-ignore */
|
|
732
|
+
...(ngDevMode ? [{ debugName: "valueNow" }] : /* istanbul ignore next */ []));
|
|
733
|
+
// Protected methods
|
|
734
|
+
toggleMute() {
|
|
735
|
+
this._controller.toggleMute();
|
|
736
|
+
}
|
|
737
|
+
onPointerDown(event) {
|
|
738
|
+
// Only the primary button starts a drag: a secondary press (context menu)
|
|
739
|
+
// never delivers a matching pointerup, which would strand the drag state.
|
|
740
|
+
if (event.button !== 0)
|
|
741
|
+
return;
|
|
742
|
+
this.dragging.set(true);
|
|
743
|
+
this._pointerId = event.pointerId;
|
|
744
|
+
const host = event.currentTarget;
|
|
745
|
+
host.setPointerCapture(event.pointerId);
|
|
746
|
+
this._controller.setVolume(this._volumeFromPointer(event, host));
|
|
747
|
+
}
|
|
748
|
+
onPointerMove(event) {
|
|
749
|
+
if (!this.dragging() || event.pointerId !== this._pointerId)
|
|
750
|
+
return;
|
|
751
|
+
this._controller.setVolume(this._volumeFromPointer(event, event.currentTarget));
|
|
752
|
+
}
|
|
753
|
+
onPointerUp(event) {
|
|
754
|
+
if (!this.dragging() || event.pointerId !== this._pointerId)
|
|
755
|
+
return;
|
|
756
|
+
this.dragging.set(false);
|
|
757
|
+
this._pointerId = null;
|
|
758
|
+
event.currentTarget.releasePointerCapture(event.pointerId);
|
|
759
|
+
}
|
|
760
|
+
/** Aborted pointers (touch cancellation, capture loss) must release the drag state or the reveal sticks open. */
|
|
761
|
+
onPointerCancel() {
|
|
762
|
+
this.dragging.set(false);
|
|
763
|
+
this._pointerId = null;
|
|
764
|
+
}
|
|
765
|
+
onKeydown(event) {
|
|
766
|
+
const increaseKey = this._directionality.value === 'rtl' ? 'ArrowLeft' : 'ArrowRight';
|
|
767
|
+
const decreaseKey = this._directionality.value === 'rtl' ? 'ArrowRight' : 'ArrowLeft';
|
|
768
|
+
if (event.key === increaseKey || event.key === 'ArrowUp') {
|
|
769
|
+
this._controller.setVolume(this.volume() + VOLUME_STEP);
|
|
770
|
+
}
|
|
771
|
+
else if (event.key === decreaseKey || event.key === 'ArrowDown') {
|
|
772
|
+
this._controller.setVolume(this.volume() - VOLUME_STEP);
|
|
773
|
+
}
|
|
774
|
+
else if (event.key === 'Home') {
|
|
775
|
+
this._controller.setVolume(0);
|
|
776
|
+
}
|
|
777
|
+
else if (event.key === 'End') {
|
|
778
|
+
this._controller.setVolume(1);
|
|
779
|
+
}
|
|
780
|
+
else
|
|
781
|
+
return;
|
|
782
|
+
event.preventDefault();
|
|
783
|
+
event.stopPropagation();
|
|
784
|
+
}
|
|
785
|
+
// Private methods
|
|
786
|
+
_volumeFromPointer(event, host) {
|
|
787
|
+
const rect = host.getBoundingClientRect();
|
|
788
|
+
let fraction = (event.clientX - rect.left) / rect.width;
|
|
789
|
+
if (this._directionality.value === 'rtl')
|
|
790
|
+
fraction = 1 - fraction;
|
|
791
|
+
return Math.min(Math.max(fraction, 0), 1);
|
|
792
|
+
}
|
|
793
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: MediaVolumeControl, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
794
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "22.0.5", type: MediaVolumeControl, isStandalone: true, selector: "tls-media-volume-control", host: { properties: { "class.tls-media-volume-control--dragging": "dragging()" }, classAttribute: "tls-media-volume-control" }, ngImport: i0, template: "<button\n type=\"button\"\n class=\"mute\"\n [attr.aria-label]=\"muteLabel()\"\n [attr.aria-pressed]=\"muted()\"\n (click)=\"toggleMute()\"\n>\n <tls-icon [name]=\"muteIcon()\" />\n</button>\n<div\n class=\"track\"\n role=\"slider\"\n tabindex=\"0\"\n aria-valuemin=\"0\"\n aria-valuemax=\"100\"\n [attr.aria-valuenow]=\"valueNow()\"\n [attr.aria-label]=\"labels.volume\"\n [style.--tls-media-volume]=\"filledFraction()\"\n (pointerdown)=\"onPointerDown($event)\"\n (pointermove)=\"onPointerMove($event)\"\n (pointerup)=\"onPointerUp($event)\"\n (pointercancel)=\"onPointerCancel()\"\n (keydown)=\"onKeydown($event)\"\n>\n <div class=\"track__fills\">\n <div class=\"track__fill\"></div>\n </div>\n <div class=\"track__thumb\"></div>\n</div>\n", styles: [":host{display:inline-flex;align-items:center}:host .mute{position:relative;width:var(--tls-media-control-size, 36px);height:var(--tls-media-control-size, 36px);display:inline-flex;align-items:center;justify-content:center;border:none;color:inherit;cursor:pointer}:host .track{position:relative;width:0;height:var(--tls-media-scrubber-height, 4px);margin-inline:0;border-radius:var(--radius-xl);opacity:0;cursor:pointer;pointer-events:none;touch-action:none}:host .track:before{content:\"\";position:absolute;inset-block:calc(-1 * var(--spacing-3));inset-inline:0}:root[data-motion=essential] :host .track,:root[data-motion=full] :host .track{transition:width var(--motion-fast) var(--motion-ease-out),margin-inline-start var(--motion-fast) var(--motion-ease-out),margin-inline-end var(--motion-fast) var(--motion-ease-out),opacity var(--motion-fast) var(--motion-ease-out)}@media(pointer:coarse){:host .track{width:var(--tls-media-volume-track-width, 64px);margin-inline-start:var(--spacing-1);margin-inline-end:var(--spacing-4);opacity:1;pointer-events:auto}}:host .track__fills{position:absolute;inset:0;border-radius:var(--radius-xl);overflow:hidden}:host .track__fill{position:absolute;inset-block:0;inset-inline-start:0;width:calc(var(--tls-media-volume, 0) * 100%)}:host .track__thumb{position:absolute;inset-block-start:50%;inset-inline-start:calc(var(--tls-media-volume, 0) * 100%)}@media(hover:hover){:host:hover .track{width:var(--tls-media-volume-track-width, 64px);margin-inline-start:var(--spacing-1);margin-inline-end:var(--spacing-4);opacity:1;pointer-events:auto}}:host:focus-within .track{width:var(--tls-media-volume-track-width, 64px);margin-inline-start:var(--spacing-1);margin-inline-end:var(--spacing-4);opacity:1;pointer-events:auto}:host(.tls-media-volume-control--dragging) .track{width:var(--tls-media-volume-track-width, 64px);margin-inline-start:var(--spacing-1);margin-inline-end:var(--spacing-4);opacity:1;pointer-events:auto}\n"], dependencies: [{ kind: "component", type: Icon, selector: "tls-icon", inputs: ["name", "iconSrc", "alt", "allowedSources"] }] });
|
|
795
|
+
}
|
|
796
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: MediaVolumeControl, decorators: [{
|
|
797
|
+
type: Component,
|
|
798
|
+
args: [{ selector: 'tls-media-volume-control', imports: [Icon], host: {
|
|
799
|
+
class: 'tls-media-volume-control',
|
|
800
|
+
'[class.tls-media-volume-control--dragging]': 'dragging()',
|
|
801
|
+
}, template: "<button\n type=\"button\"\n class=\"mute\"\n [attr.aria-label]=\"muteLabel()\"\n [attr.aria-pressed]=\"muted()\"\n (click)=\"toggleMute()\"\n>\n <tls-icon [name]=\"muteIcon()\" />\n</button>\n<div\n class=\"track\"\n role=\"slider\"\n tabindex=\"0\"\n aria-valuemin=\"0\"\n aria-valuemax=\"100\"\n [attr.aria-valuenow]=\"valueNow()\"\n [attr.aria-label]=\"labels.volume\"\n [style.--tls-media-volume]=\"filledFraction()\"\n (pointerdown)=\"onPointerDown($event)\"\n (pointermove)=\"onPointerMove($event)\"\n (pointerup)=\"onPointerUp($event)\"\n (pointercancel)=\"onPointerCancel()\"\n (keydown)=\"onKeydown($event)\"\n>\n <div class=\"track__fills\">\n <div class=\"track__fill\"></div>\n </div>\n <div class=\"track__thumb\"></div>\n</div>\n", styles: [":host{display:inline-flex;align-items:center}:host .mute{position:relative;width:var(--tls-media-control-size, 36px);height:var(--tls-media-control-size, 36px);display:inline-flex;align-items:center;justify-content:center;border:none;color:inherit;cursor:pointer}:host .track{position:relative;width:0;height:var(--tls-media-scrubber-height, 4px);margin-inline:0;border-radius:var(--radius-xl);opacity:0;cursor:pointer;pointer-events:none;touch-action:none}:host .track:before{content:\"\";position:absolute;inset-block:calc(-1 * var(--spacing-3));inset-inline:0}:root[data-motion=essential] :host .track,:root[data-motion=full] :host .track{transition:width var(--motion-fast) var(--motion-ease-out),margin-inline-start var(--motion-fast) var(--motion-ease-out),margin-inline-end var(--motion-fast) var(--motion-ease-out),opacity var(--motion-fast) var(--motion-ease-out)}@media(pointer:coarse){:host .track{width:var(--tls-media-volume-track-width, 64px);margin-inline-start:var(--spacing-1);margin-inline-end:var(--spacing-4);opacity:1;pointer-events:auto}}:host .track__fills{position:absolute;inset:0;border-radius:var(--radius-xl);overflow:hidden}:host .track__fill{position:absolute;inset-block:0;inset-inline-start:0;width:calc(var(--tls-media-volume, 0) * 100%)}:host .track__thumb{position:absolute;inset-block-start:50%;inset-inline-start:calc(var(--tls-media-volume, 0) * 100%)}@media(hover:hover){:host:hover .track{width:var(--tls-media-volume-track-width, 64px);margin-inline-start:var(--spacing-1);margin-inline-end:var(--spacing-4);opacity:1;pointer-events:auto}}:host:focus-within .track{width:var(--tls-media-volume-track-width, 64px);margin-inline-start:var(--spacing-1);margin-inline-end:var(--spacing-4);opacity:1;pointer-events:auto}:host(.tls-media-volume-control--dragging) .track{width:var(--tls-media-volume-track-width, 64px);margin-inline-start:var(--spacing-1);margin-inline-end:var(--spacing-4);opacity:1;pointer-events:auto}\n"] }]
|
|
802
|
+
}] });
|
|
803
|
+
|
|
804
|
+
/**
|
|
805
|
+
* Audio playback surface assembling the headless {@link MediaController} with
|
|
806
|
+
* the feature's control set — play toggle, time display, scrubber, volume and
|
|
807
|
+
* settings — behind a `role="group"` host. The single place in the feature
|
|
808
|
+
* that owns an `<audio>` element and attaches the controller to it.
|
|
809
|
+
*/
|
|
810
|
+
class AudioPlayer {
|
|
811
|
+
// Injections
|
|
812
|
+
_controller = inject(MediaController);
|
|
813
|
+
_config = inject(MEDIA_PLAYER_CONFIG);
|
|
814
|
+
// Inputs
|
|
815
|
+
source = input.required(/* @ts-ignore */
|
|
816
|
+
...(ngDevMode ? [{ debugName: "source" }] : /* istanbul ignore next */ []));
|
|
817
|
+
title = input(undefined, /* @ts-ignore */
|
|
818
|
+
...(ngDevMode ? [{ debugName: "title" }] : /* istanbul ignore next */ []));
|
|
819
|
+
/**
|
|
820
|
+
* Requests playback as soon as the source can play. Browsers only honor
|
|
821
|
+
* autoplay when the element is also muted — an unmuted request is silently
|
|
822
|
+
* rejected, and the rejection is not surfaced as an error; the player falls
|
|
823
|
+
* back to the ordinary play affordance so the user can start playback (with
|
|
824
|
+
* sound) explicitly.
|
|
825
|
+
*/
|
|
826
|
+
autoplay = input(false, { ...(ngDevMode ? { debugName: "autoplay" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
827
|
+
loop = input(false, { ...(ngDevMode ? { debugName: "loop" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
828
|
+
preload = input(this._config.preload, /* @ts-ignore */
|
|
829
|
+
...(ngDevMode ? [{ debugName: "preload" }] : /* istanbul ignore next */ []));
|
|
830
|
+
ariaLabel = input(undefined, /* @ts-ignore */
|
|
831
|
+
...(ngDevMode ? [{ debugName: "ariaLabel" }] : /* istanbul ignore next */ []));
|
|
832
|
+
ariaLabelledby = input(undefined, /* @ts-ignore */
|
|
833
|
+
...(ngDevMode ? [{ debugName: "ariaLabelledby" }] : /* istanbul ignore next */ []));
|
|
834
|
+
// Outputs
|
|
835
|
+
// eslint-disable-next-line @angular-eslint/no-output-native -- mirrors the native <audio> 'ended' event this output relays, which is the clearest name for that meaning.
|
|
836
|
+
ended = output();
|
|
837
|
+
playingChange = output();
|
|
838
|
+
// State
|
|
839
|
+
_audioElement = viewChild.required('audioElement');
|
|
840
|
+
_attached = signal(false, /* @ts-ignore */
|
|
841
|
+
...(ngDevMode ? [{ debugName: "_attached" }] : /* istanbul ignore next */ []));
|
|
842
|
+
_skipInitialPlayingChange = true;
|
|
843
|
+
// constructor
|
|
844
|
+
constructor() {
|
|
845
|
+
afterNextRender(() => {
|
|
846
|
+
this._controller.attach(this._audioElement().nativeElement);
|
|
847
|
+
this._attached.set(true);
|
|
848
|
+
});
|
|
849
|
+
// Re-runs whenever `source` (or `title`) changes after attach — not just once
|
|
850
|
+
// at startup — so swapping either input mid-lifetime reaches the media element.
|
|
851
|
+
effect(() => {
|
|
852
|
+
if (!this._attached())
|
|
853
|
+
return;
|
|
854
|
+
this._controller.setSource(this.source());
|
|
855
|
+
});
|
|
856
|
+
effect(() => {
|
|
857
|
+
if (!this._attached())
|
|
858
|
+
return;
|
|
859
|
+
const title = this.title();
|
|
860
|
+
if (title)
|
|
861
|
+
this._controller.setMetadata({ title });
|
|
862
|
+
});
|
|
863
|
+
effect(() => {
|
|
864
|
+
const playing = this._controller.playing();
|
|
865
|
+
if (this._skipInitialPlayingChange) {
|
|
866
|
+
this._skipInitialPlayingChange = false;
|
|
867
|
+
return;
|
|
868
|
+
}
|
|
869
|
+
this.playingChange.emit(playing);
|
|
870
|
+
});
|
|
871
|
+
effect(() => {
|
|
872
|
+
if (this._controller.state() === 'ended')
|
|
873
|
+
this.ended.emit();
|
|
874
|
+
});
|
|
875
|
+
}
|
|
876
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: AudioPlayer, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
877
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "22.0.5", type: AudioPlayer, isStandalone: true, selector: "tls-audio-player", inputs: { source: { classPropertyName: "source", publicName: "source", isSignal: true, isRequired: true, transformFunction: null }, title: { classPropertyName: "title", publicName: "title", isSignal: true, isRequired: false, transformFunction: null }, autoplay: { classPropertyName: "autoplay", publicName: "autoplay", isSignal: true, isRequired: false, transformFunction: null }, loop: { classPropertyName: "loop", publicName: "loop", isSignal: true, isRequired: false, transformFunction: null }, preload: { classPropertyName: "preload", publicName: "preload", isSignal: true, isRequired: false, transformFunction: null }, ariaLabel: { classPropertyName: "ariaLabel", publicName: "ariaLabel", isSignal: true, isRequired: false, transformFunction: null }, ariaLabelledby: { classPropertyName: "ariaLabelledby", publicName: "ariaLabelledby", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { ended: "ended", playingChange: "playingChange" }, host: { attributes: { "role": "group" }, properties: { "attr.aria-label": "ariaLabel() ?? null", "attr.aria-labelledby": "ariaLabelledby() ?? null" }, classAttribute: "tls-audio-player" }, providers: [MediaController], viewQueries: [{ propertyName: "_audioElement", first: true, predicate: ["audioElement"], descendants: true, isSignal: true }], ngImport: i0, template: "<audio #audioElement [attr.preload]=\"preload()\" [loop]=\"loop()\" [autoplay]=\"autoplay()\"></audio>\n\n<tls-media-play-toggle />\n<tls-media-time-display />\n<tls-media-scrubber class=\"scrubber\" />\n<tls-media-volume-control />\n<tls-media-settings-menu />\n", styles: [":host{padding:var(--spacing-2) var(--spacing-3);display:flex;align-items:center;gap:var(--spacing-2);border-radius:var(--radius-md)}:host .scrubber{flex:1 1 0}\n"], dependencies: [{ kind: "component", type: MediaPlayToggle, selector: "tls-media-play-toggle" }, { kind: "component", type: MediaScrubber, selector: "tls-media-scrubber" }, { kind: "component", type: MediaTimeDisplay, selector: "tls-media-time-display" }, { kind: "component", type: MediaVolumeControl, selector: "tls-media-volume-control" }, { kind: "component", type: MediaSettingsMenu, selector: "tls-media-settings-menu" }] });
|
|
878
|
+
}
|
|
879
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: AudioPlayer, decorators: [{
|
|
880
|
+
type: Component,
|
|
881
|
+
args: [{ selector: 'tls-audio-player', imports: [
|
|
882
|
+
MediaPlayToggle,
|
|
883
|
+
MediaScrubber,
|
|
884
|
+
MediaTimeDisplay,
|
|
885
|
+
MediaVolumeControl,
|
|
886
|
+
MediaSettingsMenu,
|
|
887
|
+
], providers: [MediaController], host: {
|
|
888
|
+
role: 'group',
|
|
889
|
+
class: 'tls-audio-player',
|
|
890
|
+
'[attr.aria-label]': 'ariaLabel() ?? null',
|
|
891
|
+
'[attr.aria-labelledby]': 'ariaLabelledby() ?? null',
|
|
892
|
+
}, template: "<audio #audioElement [attr.preload]=\"preload()\" [loop]=\"loop()\" [autoplay]=\"autoplay()\"></audio>\n\n<tls-media-play-toggle />\n<tls-media-time-display />\n<tls-media-scrubber class=\"scrubber\" />\n<tls-media-volume-control />\n<tls-media-settings-menu />\n", styles: [":host{padding:var(--spacing-2) var(--spacing-3);display:flex;align-items:center;gap:var(--spacing-2);border-radius:var(--radius-md)}:host .scrubber{flex:1 1 0}\n"] }]
|
|
893
|
+
}], ctorParameters: () => [], propDecorators: { source: [{ type: i0.Input, args: [{ isSignal: true, alias: "source", required: true }] }], title: [{ type: i0.Input, args: [{ isSignal: true, alias: "title", required: false }] }], autoplay: [{ type: i0.Input, args: [{ isSignal: true, alias: "autoplay", required: false }] }], loop: [{ type: i0.Input, args: [{ isSignal: true, alias: "loop", required: false }] }], preload: [{ type: i0.Input, args: [{ isSignal: true, alias: "preload", required: false }] }], ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "ariaLabel", required: false }] }], ariaLabelledby: [{ type: i0.Input, args: [{ isSignal: true, alias: "ariaLabelledby", required: false }] }], ended: [{ type: i0.Output, args: ["ended"] }], playingChange: [{ type: i0.Output, args: ["playingChange"] }], _audioElement: [{ type: i0.ViewChild, args: ['audioElement', { isSignal: true }] }] } });
|
|
894
|
+
|
|
895
|
+
/**
|
|
896
|
+
* Video playback surface assembling the headless {@link MediaController} and
|
|
897
|
+
* {@link FullscreenController} with the feature's control set behind a
|
|
898
|
+
* `role="group"` host. The single place in the feature that owns a `<video>`
|
|
899
|
+
* element, attaches both controllers to it, and maps player-level keyboard
|
|
900
|
+
* shortcuts (space/k play, arrow seek/volume, m mute, f fullscreen, c
|
|
901
|
+
* captions, Home/End) to controller calls. Controls fade out during playback
|
|
902
|
+
* once the pointer has been idle for the configured delay, and reappear on
|
|
903
|
+
* pointer activity, keyboard focus, or while the settings menu is open.
|
|
904
|
+
*/
|
|
905
|
+
class VideoPlayer {
|
|
906
|
+
// Injections
|
|
907
|
+
_controller = inject(MediaController);
|
|
908
|
+
_fullscreenController = inject(FullscreenController);
|
|
909
|
+
_config = inject(MEDIA_PLAYER_CONFIG);
|
|
910
|
+
_directionality = inject(Directionality);
|
|
911
|
+
_host = inject((ElementRef));
|
|
912
|
+
_destroyRef = inject(DestroyRef);
|
|
913
|
+
// Inputs
|
|
914
|
+
source = input.required(/* @ts-ignore */
|
|
915
|
+
...(ngDevMode ? [{ debugName: "source" }] : /* istanbul ignore next */ []));
|
|
916
|
+
title = input(undefined, /* @ts-ignore */
|
|
917
|
+
...(ngDevMode ? [{ debugName: "title" }] : /* istanbul ignore next */ []));
|
|
918
|
+
poster = input(undefined, /* @ts-ignore */
|
|
919
|
+
...(ngDevMode ? [{ debugName: "poster" }] : /* istanbul ignore next */ []));
|
|
920
|
+
captions = input([], /* @ts-ignore */
|
|
921
|
+
...(ngDevMode ? [{ debugName: "captions" }] : /* istanbul ignore next */ []));
|
|
922
|
+
/**
|
|
923
|
+
* Requests playback as soon as the source can play. Browsers only honor
|
|
924
|
+
* autoplay when the element is also muted — an unmuted request is silently
|
|
925
|
+
* rejected, and the rejection is not surfaced as an error; the player falls
|
|
926
|
+
* back to its poster with the ordinary play affordance so the user can start
|
|
927
|
+
* playback (with sound) explicitly.
|
|
928
|
+
*/
|
|
929
|
+
autoplay = input(false, { ...(ngDevMode ? { debugName: "autoplay" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
930
|
+
loop = input(false, { ...(ngDevMode ? { debugName: "loop" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
931
|
+
muted = input(false, { ...(ngDevMode ? { debugName: "muted" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
932
|
+
preload = input(this._config.preload, /* @ts-ignore */
|
|
933
|
+
...(ngDevMode ? [{ debugName: "preload" }] : /* istanbul ignore next */ []));
|
|
934
|
+
ariaLabel = input(undefined, /* @ts-ignore */
|
|
935
|
+
...(ngDevMode ? [{ debugName: "ariaLabel" }] : /* istanbul ignore next */ []));
|
|
936
|
+
ariaLabelledby = input(undefined, /* @ts-ignore */
|
|
937
|
+
...(ngDevMode ? [{ debugName: "ariaLabelledby" }] : /* istanbul ignore next */ []));
|
|
938
|
+
// Outputs
|
|
939
|
+
// eslint-disable-next-line @angular-eslint/no-output-native -- mirrors the native <video> 'ended' event this output relays, which is the clearest name for that meaning.
|
|
940
|
+
ended = output();
|
|
941
|
+
playingChange = output();
|
|
942
|
+
// State
|
|
943
|
+
_videoElement = viewChild.required('videoElement');
|
|
944
|
+
_settingsMenu = viewChild(MediaSettingsMenu, /* @ts-ignore */
|
|
945
|
+
...(ngDevMode ? [{ debugName: "_settingsMenu" }] : /* istanbul ignore next */ []));
|
|
946
|
+
_pointerIdle = signal(false, /* @ts-ignore */
|
|
947
|
+
...(ngDevMode ? [{ debugName: "_pointerIdle" }] : /* istanbul ignore next */ []));
|
|
948
|
+
_focusWithin = signal(false, /* @ts-ignore */
|
|
949
|
+
...(ngDevMode ? [{ debugName: "_focusWithin" }] : /* istanbul ignore next */ []));
|
|
950
|
+
_attached = signal(false, /* @ts-ignore */
|
|
951
|
+
...(ngDevMode ? [{ debugName: "_attached" }] : /* istanbul ignore next */ []));
|
|
952
|
+
/** Accumulated signed seconds of the in-flight keyboard-seek feedback badge, `null` when hidden. */
|
|
953
|
+
seekFeedback = signal(null, /* @ts-ignore */
|
|
954
|
+
...(ngDevMode ? [{ debugName: "seekFeedback" }] : /* istanbul ignore next */ []));
|
|
955
|
+
_hideTimer = null;
|
|
956
|
+
_seekFeedbackTimer = null;
|
|
957
|
+
_skipInitialPlayingChange = true;
|
|
958
|
+
labels = this._config.labels;
|
|
959
|
+
// Computed
|
|
960
|
+
state = this._controller.state;
|
|
961
|
+
fullscreen = this._fullscreenController.fullscreen;
|
|
962
|
+
fullscreenSupported = this._fullscreenController.fullscreenSupported;
|
|
963
|
+
pictureInPictureSupported = this._fullscreenController.pictureInPictureSupported;
|
|
964
|
+
_menuOpen = computed(() => {
|
|
965
|
+
const menu = this._settingsMenu();
|
|
966
|
+
if (!menu)
|
|
967
|
+
return false;
|
|
968
|
+
return menu.open();
|
|
969
|
+
}, /* @ts-ignore */
|
|
970
|
+
...(ngDevMode ? [{ debugName: "_menuOpen" }] : /* istanbul ignore next */ []));
|
|
971
|
+
controlsHidden = computed(() => {
|
|
972
|
+
if (!this._controller.playing())
|
|
973
|
+
return false;
|
|
974
|
+
if (this._focusWithin())
|
|
975
|
+
return false;
|
|
976
|
+
if (this._menuOpen())
|
|
977
|
+
return false;
|
|
978
|
+
return this._pointerIdle();
|
|
979
|
+
}, /* @ts-ignore */
|
|
980
|
+
...(ngDevMode ? [{ debugName: "controlsHidden" }] : /* istanbul ignore next */ []));
|
|
981
|
+
seekFeedbackText = computed(() => {
|
|
982
|
+
const deltaSeconds = this.seekFeedback();
|
|
983
|
+
if (deltaSeconds === null)
|
|
984
|
+
return '';
|
|
985
|
+
return `${deltaSeconds > 0 ? '+' : '−'}${Math.abs(deltaSeconds)}s`;
|
|
986
|
+
}, /* @ts-ignore */
|
|
987
|
+
...(ngDevMode ? [{ debugName: "seekFeedbackText" }] : /* istanbul ignore next */ []));
|
|
988
|
+
/** Chevrons pointing in the physical direction the playhead moved; forward points left under RTL. */
|
|
989
|
+
seekFeedbackIcon = computed(() => {
|
|
990
|
+
const deltaSeconds = this.seekFeedback();
|
|
991
|
+
const forward = deltaSeconds !== null && deltaSeconds > 0;
|
|
992
|
+
const rtl = this._directionality.value === 'rtl';
|
|
993
|
+
return forward !== rtl ? 'chevrons-right' : 'chevrons-left';
|
|
994
|
+
}, /* @ts-ignore */
|
|
995
|
+
...(ngDevMode ? [{ debugName: "seekFeedbackIcon" }] : /* istanbul ignore next */ []));
|
|
996
|
+
// constructor
|
|
997
|
+
constructor() {
|
|
998
|
+
afterNextRender(() => {
|
|
999
|
+
const videoElement = this._videoElement().nativeElement;
|
|
1000
|
+
this._controller.attach(videoElement);
|
|
1001
|
+
this._fullscreenController.attach(this._host.nativeElement, videoElement);
|
|
1002
|
+
this._attached.set(true);
|
|
1003
|
+
});
|
|
1004
|
+
// Re-runs whenever `source` (or `title`) changes after attach — not just once
|
|
1005
|
+
// at startup — so swapping either input mid-lifetime reaches the media element.
|
|
1006
|
+
effect(() => {
|
|
1007
|
+
if (!this._attached())
|
|
1008
|
+
return;
|
|
1009
|
+
this._controller.setSource(this.source());
|
|
1010
|
+
});
|
|
1011
|
+
effect(() => {
|
|
1012
|
+
if (!this._attached())
|
|
1013
|
+
return;
|
|
1014
|
+
const title = this.title();
|
|
1015
|
+
if (title)
|
|
1016
|
+
this._controller.setMetadata({ title });
|
|
1017
|
+
});
|
|
1018
|
+
effect(() => {
|
|
1019
|
+
const playing = this._controller.playing();
|
|
1020
|
+
if (this._skipInitialPlayingChange) {
|
|
1021
|
+
this._skipInitialPlayingChange = false;
|
|
1022
|
+
return;
|
|
1023
|
+
}
|
|
1024
|
+
this.playingChange.emit(playing);
|
|
1025
|
+
});
|
|
1026
|
+
effect(() => {
|
|
1027
|
+
if (this._controller.state() === 'ended')
|
|
1028
|
+
this.ended.emit();
|
|
1029
|
+
});
|
|
1030
|
+
// Controls fade out during playback even without pointer movement — armed
|
|
1031
|
+
// as soon as playback starts, and cancelled the moment it stops so the
|
|
1032
|
+
// chrome is visible again for a paused or ended surface.
|
|
1033
|
+
effect(() => {
|
|
1034
|
+
if (this._controller.playing()) {
|
|
1035
|
+
this._armHideTimer();
|
|
1036
|
+
}
|
|
1037
|
+
else {
|
|
1038
|
+
this._cancelHideTimer();
|
|
1039
|
+
this._pointerIdle.set(false);
|
|
1040
|
+
}
|
|
1041
|
+
});
|
|
1042
|
+
this._destroyRef.onDestroy(() => {
|
|
1043
|
+
this._cancelHideTimer();
|
|
1044
|
+
if (this._seekFeedbackTimer !== null)
|
|
1045
|
+
clearTimeout(this._seekFeedbackTimer);
|
|
1046
|
+
});
|
|
1047
|
+
}
|
|
1048
|
+
// Protected methods
|
|
1049
|
+
onKeydown(event) {
|
|
1050
|
+
if (event.target !== this._host.nativeElement)
|
|
1051
|
+
return;
|
|
1052
|
+
const step = this._config.seekStep;
|
|
1053
|
+
const rtl = this._directionality.value === 'rtl';
|
|
1054
|
+
switch (event.key) {
|
|
1055
|
+
case ' ':
|
|
1056
|
+
case 'k':
|
|
1057
|
+
this._controller.togglePlay();
|
|
1058
|
+
break;
|
|
1059
|
+
case 'ArrowRight':
|
|
1060
|
+
this._seekWithFeedback(rtl ? -step : step);
|
|
1061
|
+
break;
|
|
1062
|
+
case 'ArrowLeft':
|
|
1063
|
+
this._seekWithFeedback(rtl ? step : -step);
|
|
1064
|
+
break;
|
|
1065
|
+
case 'ArrowUp':
|
|
1066
|
+
this._controller.setVolume(this._controller.volume() + VOLUME_STEP);
|
|
1067
|
+
break;
|
|
1068
|
+
case 'ArrowDown':
|
|
1069
|
+
this._controller.setVolume(this._controller.volume() - VOLUME_STEP);
|
|
1070
|
+
break;
|
|
1071
|
+
case 'm':
|
|
1072
|
+
this._controller.toggleMute();
|
|
1073
|
+
break;
|
|
1074
|
+
case 'f':
|
|
1075
|
+
this._fullscreenController.toggleFullscreen();
|
|
1076
|
+
break;
|
|
1077
|
+
case 'c':
|
|
1078
|
+
this._toggleCaptions();
|
|
1079
|
+
break;
|
|
1080
|
+
case 'Home':
|
|
1081
|
+
this._controller.seek(0);
|
|
1082
|
+
break;
|
|
1083
|
+
case 'End':
|
|
1084
|
+
this._controller.seek(this._controller.duration());
|
|
1085
|
+
break;
|
|
1086
|
+
default:
|
|
1087
|
+
return;
|
|
1088
|
+
}
|
|
1089
|
+
event.preventDefault();
|
|
1090
|
+
}
|
|
1091
|
+
onPointerActivity() {
|
|
1092
|
+
this._pointerIdle.set(false);
|
|
1093
|
+
this._armHideTimer();
|
|
1094
|
+
}
|
|
1095
|
+
onFocusIn() {
|
|
1096
|
+
this._focusWithin.set(true);
|
|
1097
|
+
}
|
|
1098
|
+
onFocusOut(event) {
|
|
1099
|
+
const relatedTarget = event.relatedTarget;
|
|
1100
|
+
if (relatedTarget !== null && this._host.nativeElement.contains(relatedTarget))
|
|
1101
|
+
return;
|
|
1102
|
+
this._focusWithin.set(false);
|
|
1103
|
+
}
|
|
1104
|
+
onSurfaceClick() {
|
|
1105
|
+
this._controller.togglePlay();
|
|
1106
|
+
}
|
|
1107
|
+
togglePictureInPicture() {
|
|
1108
|
+
this._fullscreenController.togglePictureInPicture();
|
|
1109
|
+
}
|
|
1110
|
+
toggleFullscreen() {
|
|
1111
|
+
this._fullscreenController.toggleFullscreen();
|
|
1112
|
+
}
|
|
1113
|
+
retry() {
|
|
1114
|
+
this._controller.setSource(this.source());
|
|
1115
|
+
// A rejected play (autoplay policy or a still-broken source) leaves the
|
|
1116
|
+
// error panel's retry affordance in place; there is nothing further to do here.
|
|
1117
|
+
this._controller.play().catch(() => undefined);
|
|
1118
|
+
}
|
|
1119
|
+
// Private methods
|
|
1120
|
+
_toggleCaptions() {
|
|
1121
|
+
const tracks = this._controller.textTracks();
|
|
1122
|
+
const activeTrack = tracks.find(track => track.active);
|
|
1123
|
+
if (activeTrack) {
|
|
1124
|
+
this._controller.selectTextTrack(null);
|
|
1125
|
+
return;
|
|
1126
|
+
}
|
|
1127
|
+
if (tracks.length > 0)
|
|
1128
|
+
this._controller.selectTextTrack(tracks[0].id);
|
|
1129
|
+
}
|
|
1130
|
+
_armHideTimer() {
|
|
1131
|
+
this._cancelHideTimer();
|
|
1132
|
+
this._hideTimer = setTimeout(() => this._pointerIdle.set(true), this._config.controlsHideDelay);
|
|
1133
|
+
}
|
|
1134
|
+
_cancelHideTimer() {
|
|
1135
|
+
if (this._hideTimer !== null)
|
|
1136
|
+
clearTimeout(this._hideTimer);
|
|
1137
|
+
this._hideTimer = null;
|
|
1138
|
+
}
|
|
1139
|
+
/**
|
|
1140
|
+
* Seeks and surfaces the transient feedback badge. Presses within the badge's
|
|
1141
|
+
* lifetime accumulate into one running total; a press in the opposite
|
|
1142
|
+
* direction restarts the count from its own step.
|
|
1143
|
+
*/
|
|
1144
|
+
_seekWithFeedback(deltaSeconds) {
|
|
1145
|
+
this._controller.seekBy(deltaSeconds);
|
|
1146
|
+
const current = this.seekFeedback();
|
|
1147
|
+
const sameDirection = current !== null && Math.sign(current) === Math.sign(deltaSeconds);
|
|
1148
|
+
this.seekFeedback.set(sameDirection ? current + deltaSeconds : deltaSeconds);
|
|
1149
|
+
if (this._seekFeedbackTimer !== null)
|
|
1150
|
+
clearTimeout(this._seekFeedbackTimer);
|
|
1151
|
+
this._seekFeedbackTimer = setTimeout(() => this.seekFeedback.set(null), SEEK_FEEDBACK_DURATION);
|
|
1152
|
+
}
|
|
1153
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: VideoPlayer, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1154
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.5", type: VideoPlayer, isStandalone: true, selector: "tls-video-player", inputs: { source: { classPropertyName: "source", publicName: "source", isSignal: true, isRequired: true, transformFunction: null }, title: { classPropertyName: "title", publicName: "title", isSignal: true, isRequired: false, transformFunction: null }, poster: { classPropertyName: "poster", publicName: "poster", isSignal: true, isRequired: false, transformFunction: null }, captions: { classPropertyName: "captions", publicName: "captions", isSignal: true, isRequired: false, transformFunction: null }, autoplay: { classPropertyName: "autoplay", publicName: "autoplay", isSignal: true, isRequired: false, transformFunction: null }, loop: { classPropertyName: "loop", publicName: "loop", isSignal: true, isRequired: false, transformFunction: null }, muted: { classPropertyName: "muted", publicName: "muted", isSignal: true, isRequired: false, transformFunction: null }, preload: { classPropertyName: "preload", publicName: "preload", isSignal: true, isRequired: false, transformFunction: null }, ariaLabel: { classPropertyName: "ariaLabel", publicName: "ariaLabel", isSignal: true, isRequired: false, transformFunction: null }, ariaLabelledby: { classPropertyName: "ariaLabelledby", publicName: "ariaLabelledby", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { ended: "ended", playingChange: "playingChange" }, host: { attributes: { "role": "group", "tabindex": "0" }, listeners: { "keydown": "onKeydown($event)", "pointermove": "onPointerActivity()", "focusin": "onFocusIn()", "focusout": "onFocusOut($event)" }, properties: { "attr.aria-label": "ariaLabel() ?? null", "attr.aria-labelledby": "ariaLabelledby() ?? null", "class.tls-video-player--controls-hidden": "controlsHidden()" }, classAttribute: "tls-video-player" }, providers: [MediaController, FullscreenController], viewQueries: [{ propertyName: "_videoElement", first: true, predicate: ["videoElement"], descendants: true, isSignal: true }, { propertyName: "_settingsMenu", first: true, predicate: MediaSettingsMenu, descendants: true, isSignal: true }], ngImport: i0, template: "<video\n #videoElement\n class=\"video\"\n [attr.poster]=\"poster() ?? null\"\n [attr.preload]=\"preload()\"\n [muted]=\"muted()\"\n [loop]=\"loop()\"\n [autoplay]=\"autoplay()\"\n playsinline\n (click)=\"onSurfaceClick()\"\n>\n @for (caption of captions(); track caption.src) {\n <track\n kind=\"subtitles\"\n [attr.src]=\"caption.src\"\n [attr.srclang]=\"caption.srclang\"\n [attr.label]=\"caption.label\"\n [attr.default]=\"caption.default ? '' : null\"\n />\n }\n</video>\n\n@if (state() === 'loading') {\n <tls-loader class=\"loader\" />\n}\n\n@if (seekFeedback(); as feedbackSeconds) {\n <div\n class=\"seek-feedback\"\n [class.seek-feedback--backward]=\"feedbackSeconds < 0\"\n aria-hidden=\"true\"\n animate.leave=\"seek-feedback--leave\"\n >\n <tls-icon [name]=\"seekFeedbackIcon()\" />\n <span class=\"seek-feedback__seconds\">{{ seekFeedbackText() }}</span>\n </div>\n}\n\n@if (state() === 'error') {\n <div class=\"error\" role=\"alert\">\n <span class=\"error__message\">{{ labels.errorMessage }}</span>\n <button type=\"button\" class=\"error__retry\" (click)=\"retry()\">{{ labels.retry }}</button>\n </div>\n}\n\n<div class=\"controls\" [class.controls--hidden]=\"controlsHidden()\">\n <tls-media-scrubber class=\"controls__scrubber\" />\n <div class=\"controls__row\">\n <tls-media-play-toggle />\n <tls-media-volume-control />\n <tls-media-time-display />\n <span class=\"controls__spacer\"></span>\n <tls-media-settings-menu />\n @if (pictureInPictureSupported()) {\n <button type=\"button\" class=\"controls__button\" [attr.aria-label]=\"labels.pictureInPicture\"\n (click)=\"togglePictureInPicture()\">\n <tls-icon name=\"picture-in-picture\" />\n </button>\n }\n @if (fullscreenSupported()) {\n <button type=\"button\" class=\"controls__button\"\n [attr.aria-label]=\"fullscreen() ? labels.exitFullscreen : labels.fullscreen\"\n (click)=\"toggleFullscreen()\">\n <tls-icon [name]=\"fullscreen() ? 'fullscreen-exit' : 'fullscreen'\" />\n </button>\n }\n </div>\n</div>\n", styles: [":host{position:relative;display:grid;grid-template-rows:100%;grid-template-columns:100%;aspect-ratio:var(--tls-media-aspect, 16/9);overflow:hidden}:host .video{width:100%;height:100%;grid-area:1/1;object-fit:contain}:host .loader{grid-area:1/1;place-self:center}:host .seek-feedback{grid-area:1/1;margin-inline:var(--spacing-8);display:flex;align-items:center;align-self:center;justify-self:end;gap:var(--spacing-1);pointer-events:none}:host .seek-feedback--backward{justify-self:start}:root[data-motion=essential] :host .seek-feedback--leave,:root[data-motion=full] :host .seek-feedback--leave{animation:seek-feedback-leave var(--motion-fast) var(--motion-ease-out) forwards}:host .error{grid-area:1/1;place-self:center;display:flex;flex-direction:column;align-items:center;gap:var(--spacing-3)}:host .controls{position:relative;grid-area:1/1;align-self:end;padding:var(--spacing-3);display:flex;flex-direction:column;gap:var(--spacing-2)}:host .controls__row{display:flex;align-items:center;gap:var(--spacing-2)}:host .controls__button{position:relative;width:var(--tls-media-control-size, 36px);height:var(--tls-media-control-size, 36px);display:inline-flex;align-items:center;justify-content:center;border:none;color:inherit;cursor:pointer}:host .controls__spacer{flex:1 1 0}:host .controls--hidden{visibility:hidden;opacity:0}:root[data-motion=essential] :host .controls,:root[data-motion=full] :host .controls{transition:opacity var(--motion-fast) var(--motion-ease-out),visibility var(--motion-fast)}:host(:fullscreen){width:100%;height:100%;aspect-ratio:auto;border-radius:0}@keyframes seek-feedback-leave{to{opacity:0}}\n"], dependencies: [{ kind: "component", type: Icon, selector: "tls-icon", inputs: ["name", "iconSrc", "alt", "allowedSources"] }, { kind: "component", type: Loader, selector: "tls-loader", inputs: ["size", "width", "widthRatio", "ariaLabel"] }, { kind: "component", type: MediaPlayToggle, selector: "tls-media-play-toggle" }, { kind: "component", type: MediaScrubber, selector: "tls-media-scrubber" }, { kind: "component", type: MediaSettingsMenu, selector: "tls-media-settings-menu" }, { kind: "component", type: MediaTimeDisplay, selector: "tls-media-time-display" }, { kind: "component", type: MediaVolumeControl, selector: "tls-media-volume-control" }] });
|
|
1155
|
+
}
|
|
1156
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: VideoPlayer, decorators: [{
|
|
1157
|
+
type: Component,
|
|
1158
|
+
args: [{ selector: 'tls-video-player', imports: [
|
|
1159
|
+
Icon,
|
|
1160
|
+
Loader,
|
|
1161
|
+
MediaPlayToggle,
|
|
1162
|
+
MediaScrubber,
|
|
1163
|
+
MediaSettingsMenu,
|
|
1164
|
+
MediaTimeDisplay,
|
|
1165
|
+
MediaVolumeControl,
|
|
1166
|
+
], providers: [MediaController, FullscreenController], host: {
|
|
1167
|
+
role: 'group',
|
|
1168
|
+
class: 'tls-video-player',
|
|
1169
|
+
tabindex: '0',
|
|
1170
|
+
'[attr.aria-label]': 'ariaLabel() ?? null',
|
|
1171
|
+
'[attr.aria-labelledby]': 'ariaLabelledby() ?? null',
|
|
1172
|
+
'[class.tls-video-player--controls-hidden]': 'controlsHidden()',
|
|
1173
|
+
'(keydown)': 'onKeydown($event)',
|
|
1174
|
+
'(pointermove)': 'onPointerActivity()',
|
|
1175
|
+
'(focusin)': 'onFocusIn()',
|
|
1176
|
+
'(focusout)': 'onFocusOut($event)',
|
|
1177
|
+
}, template: "<video\n #videoElement\n class=\"video\"\n [attr.poster]=\"poster() ?? null\"\n [attr.preload]=\"preload()\"\n [muted]=\"muted()\"\n [loop]=\"loop()\"\n [autoplay]=\"autoplay()\"\n playsinline\n (click)=\"onSurfaceClick()\"\n>\n @for (caption of captions(); track caption.src) {\n <track\n kind=\"subtitles\"\n [attr.src]=\"caption.src\"\n [attr.srclang]=\"caption.srclang\"\n [attr.label]=\"caption.label\"\n [attr.default]=\"caption.default ? '' : null\"\n />\n }\n</video>\n\n@if (state() === 'loading') {\n <tls-loader class=\"loader\" />\n}\n\n@if (seekFeedback(); as feedbackSeconds) {\n <div\n class=\"seek-feedback\"\n [class.seek-feedback--backward]=\"feedbackSeconds < 0\"\n aria-hidden=\"true\"\n animate.leave=\"seek-feedback--leave\"\n >\n <tls-icon [name]=\"seekFeedbackIcon()\" />\n <span class=\"seek-feedback__seconds\">{{ seekFeedbackText() }}</span>\n </div>\n}\n\n@if (state() === 'error') {\n <div class=\"error\" role=\"alert\">\n <span class=\"error__message\">{{ labels.errorMessage }}</span>\n <button type=\"button\" class=\"error__retry\" (click)=\"retry()\">{{ labels.retry }}</button>\n </div>\n}\n\n<div class=\"controls\" [class.controls--hidden]=\"controlsHidden()\">\n <tls-media-scrubber class=\"controls__scrubber\" />\n <div class=\"controls__row\">\n <tls-media-play-toggle />\n <tls-media-volume-control />\n <tls-media-time-display />\n <span class=\"controls__spacer\"></span>\n <tls-media-settings-menu />\n @if (pictureInPictureSupported()) {\n <button type=\"button\" class=\"controls__button\" [attr.aria-label]=\"labels.pictureInPicture\"\n (click)=\"togglePictureInPicture()\">\n <tls-icon name=\"picture-in-picture\" />\n </button>\n }\n @if (fullscreenSupported()) {\n <button type=\"button\" class=\"controls__button\"\n [attr.aria-label]=\"fullscreen() ? labels.exitFullscreen : labels.fullscreen\"\n (click)=\"toggleFullscreen()\">\n <tls-icon [name]=\"fullscreen() ? 'fullscreen-exit' : 'fullscreen'\" />\n </button>\n }\n </div>\n</div>\n", styles: [":host{position:relative;display:grid;grid-template-rows:100%;grid-template-columns:100%;aspect-ratio:var(--tls-media-aspect, 16/9);overflow:hidden}:host .video{width:100%;height:100%;grid-area:1/1;object-fit:contain}:host .loader{grid-area:1/1;place-self:center}:host .seek-feedback{grid-area:1/1;margin-inline:var(--spacing-8);display:flex;align-items:center;align-self:center;justify-self:end;gap:var(--spacing-1);pointer-events:none}:host .seek-feedback--backward{justify-self:start}:root[data-motion=essential] :host .seek-feedback--leave,:root[data-motion=full] :host .seek-feedback--leave{animation:seek-feedback-leave var(--motion-fast) var(--motion-ease-out) forwards}:host .error{grid-area:1/1;place-self:center;display:flex;flex-direction:column;align-items:center;gap:var(--spacing-3)}:host .controls{position:relative;grid-area:1/1;align-self:end;padding:var(--spacing-3);display:flex;flex-direction:column;gap:var(--spacing-2)}:host .controls__row{display:flex;align-items:center;gap:var(--spacing-2)}:host .controls__button{position:relative;width:var(--tls-media-control-size, 36px);height:var(--tls-media-control-size, 36px);display:inline-flex;align-items:center;justify-content:center;border:none;color:inherit;cursor:pointer}:host .controls__spacer{flex:1 1 0}:host .controls--hidden{visibility:hidden;opacity:0}:root[data-motion=essential] :host .controls,:root[data-motion=full] :host .controls{transition:opacity var(--motion-fast) var(--motion-ease-out),visibility var(--motion-fast)}:host(:fullscreen){width:100%;height:100%;aspect-ratio:auto;border-radius:0}@keyframes seek-feedback-leave{to{opacity:0}}\n"] }]
|
|
1178
|
+
}], ctorParameters: () => [], propDecorators: { source: [{ type: i0.Input, args: [{ isSignal: true, alias: "source", required: true }] }], title: [{ type: i0.Input, args: [{ isSignal: true, alias: "title", required: false }] }], poster: [{ type: i0.Input, args: [{ isSignal: true, alias: "poster", required: false }] }], captions: [{ type: i0.Input, args: [{ isSignal: true, alias: "captions", required: false }] }], autoplay: [{ type: i0.Input, args: [{ isSignal: true, alias: "autoplay", required: false }] }], loop: [{ type: i0.Input, args: [{ isSignal: true, alias: "loop", required: false }] }], muted: [{ type: i0.Input, args: [{ isSignal: true, alias: "muted", required: false }] }], preload: [{ type: i0.Input, args: [{ isSignal: true, alias: "preload", required: false }] }], ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "ariaLabel", required: false }] }], ariaLabelledby: [{ type: i0.Input, args: [{ isSignal: true, alias: "ariaLabelledby", required: false }] }], ended: [{ type: i0.Output, args: ["ended"] }], playingChange: [{ type: i0.Output, args: ["playingChange"] }], _videoElement: [{ type: i0.ViewChild, args: ['videoElement', { isSignal: true }] }], _settingsMenu: [{ type: i0.ViewChild, args: [i0.forwardRef(() => MediaSettingsMenu), { isSignal: true }] }] } });
|
|
1179
|
+
|
|
1180
|
+
const provideThalassicMediaConfig = (config = {}) => makeEnvironmentProviders([
|
|
1181
|
+
{
|
|
1182
|
+
provide: MEDIA_PLAYER_CONFIG,
|
|
1183
|
+
// `labels` is a deep-partial override; deepMerge merges it recursively, but its
|
|
1184
|
+
// `Partial<T>` signature only models a shallow partial, so cast to it.
|
|
1185
|
+
useValue: deepMerge(DEFAULT_MEDIA_PLAYER_CONFIG, config),
|
|
1186
|
+
},
|
|
1187
|
+
]);
|
|
1188
|
+
|
|
1189
|
+
/**
|
|
1190
|
+
* Generated bundle index. Do not edit.
|
|
1191
|
+
*/
|
|
1192
|
+
|
|
1193
|
+
export { AudioPlayer, DEFAULT_MEDIA_PLAYER_CONFIG, FullscreenController, MEDIA_PLAYER_CONFIG, MEDIA_SOURCE_ENGINE, MediaController, VideoPlayer, provideThalassicMediaConfig };
|
|
1194
|
+
//# sourceMappingURL=thalassic-ui-media.mjs.map
|