@molecule/app-audio-player-angular 0.0.0-stage → 1.1.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/LICENSE +202 -0
- package/README.md +388 -2
- package/dist/audio-player.component.d.ts +260 -0
- package/dist/audio-player.component.d.ts.map +1 -0
- package/dist/audio-player.component.js +707 -0
- package/dist/audio-player.component.js.map +1 -0
- package/dist/index.d.ts +48 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +48 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +51 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +8 -0
- package/dist/types.js.map +1 -0
- package/package.json +69 -4
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
import { type AfterViewInit, type DoCheck, ElementRef, type OnChanges, type OnDestroy, type OnInit, type SimpleChanges, type TemplateRef } from '@angular/core';
|
|
2
|
+
import type { UIClassMap } from '@molecule/app-ui';
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
/**
|
|
5
|
+
* HTML5 audio player chrome — play/pause, scrub, time, mute, optional
|
|
6
|
+
* visualizer slot.
|
|
7
|
+
*
|
|
8
|
+
* The host IS the outer `<div>` (`div[mol-audio-player]`), matching React's
|
|
9
|
+
* root exactly, so the wrapper's ClassMap classes are the host's. The
|
|
10
|
+
* `<audio>` element, the optional title / subtitle header, the visualizer and
|
|
11
|
+
* the controls row render inside it, in React's order.
|
|
12
|
+
*
|
|
13
|
+
* Angular projection needs always-mounted `<ng-content>` capture points, so
|
|
14
|
+
* the header (and each of its spans) and the visualizer wrapper live in the
|
|
15
|
+
* template unconditionally and {@link AudioPlayer.ngDoCheck} reconciles them
|
|
16
|
+
* against React's DOM — React omits the header when neither title nor subtitle
|
|
17
|
+
* renders, and renders the visualizer bare, without a wrapper element.
|
|
18
|
+
*/
|
|
19
|
+
export declare class AudioPlayer implements OnInit, AfterViewInit, DoCheck, OnChanges, OnDestroy {
|
|
20
|
+
/** Audio source URL (a file, a stream or a data URI). */
|
|
21
|
+
src: string;
|
|
22
|
+
/** Optional title / track name: a string input, or projected `[slot=title]` content. */
|
|
23
|
+
title?: unknown;
|
|
24
|
+
/** Optional artist / source label: a string input, or projected `[slot=subtitle]` content. */
|
|
25
|
+
subtitle?: unknown;
|
|
26
|
+
/** Optional waveform / visualizer: projected `[slot=visualizer]` content. */
|
|
27
|
+
visualizer?: unknown;
|
|
28
|
+
/**
|
|
29
|
+
* WebVTT captions file URL. When set, the player loads it on the media
|
|
30
|
+
* element's captions `<track>` and shows the current caption under the
|
|
31
|
+
* controls, in a polite live region that screen readers announce. Without
|
|
32
|
+
* it the track is empty and no caption line is shown.
|
|
33
|
+
*/
|
|
34
|
+
captions?: string;
|
|
35
|
+
/** BCP 47 language of the captions (the track's `srclang`). */
|
|
36
|
+
captionsLang?: string;
|
|
37
|
+
/**
|
|
38
|
+
* Human-readable name of the captions track. Defaults through i18n
|
|
39
|
+
* (`audio.captions`, English "Captions").
|
|
40
|
+
*/
|
|
41
|
+
captionsLabel?: string;
|
|
42
|
+
/** Initial muted state. */
|
|
43
|
+
defaultMuted?: boolean;
|
|
44
|
+
/** Autoplay (browser may block). */
|
|
45
|
+
autoPlay?: boolean;
|
|
46
|
+
/** Called when the media starts playing. */
|
|
47
|
+
onPlay?: () => void;
|
|
48
|
+
/** Called when the media is paused. */
|
|
49
|
+
onPause?: () => void;
|
|
50
|
+
/** Called when the media reaches its end. */
|
|
51
|
+
onEnded?: () => void;
|
|
52
|
+
/** Extra classes on the outer wrapper. */
|
|
53
|
+
className?: string;
|
|
54
|
+
/** The hidden media element. */
|
|
55
|
+
audioRef?: ElementRef<HTMLAudioElement>;
|
|
56
|
+
/** The captions track element (its text track fires `cuechange`). */
|
|
57
|
+
trackRef?: ElementRef<HTMLTrackElement>;
|
|
58
|
+
/** The title / subtitle header (present only while React renders it). */
|
|
59
|
+
headerRef?: ElementRef<HTMLElement>;
|
|
60
|
+
/** The title span (present only while React renders it). */
|
|
61
|
+
titleSpanRef?: ElementRef<HTMLElement>;
|
|
62
|
+
/** The subtitle span (present only while React renders it). */
|
|
63
|
+
subtitleSpanRef?: ElementRef<HTMLElement>;
|
|
64
|
+
/** The visualizer's capture wrapper (unwrapped when React renders content). */
|
|
65
|
+
visualizerSlotRef?: ElementRef<HTMLElement>;
|
|
66
|
+
/** Whether the media is playing (React's `playing` state). */
|
|
67
|
+
playing: boolean;
|
|
68
|
+
/** Whether the player is muted (React's `muted` state). */
|
|
69
|
+
muted: boolean;
|
|
70
|
+
/** The media duration in seconds (React's `duration` state). */
|
|
71
|
+
duration: number;
|
|
72
|
+
/** The current position in seconds (React's `current` state). */
|
|
73
|
+
current: number;
|
|
74
|
+
/** The active cues' text (React's `caption` state). */
|
|
75
|
+
caption: string;
|
|
76
|
+
private readonly i18n;
|
|
77
|
+
private readonly cd;
|
|
78
|
+
private readonly host;
|
|
79
|
+
private readonly renderer;
|
|
80
|
+
private readonly slots;
|
|
81
|
+
/** Whether `[slot=title]` content was projected. */
|
|
82
|
+
private hasTitleSlot;
|
|
83
|
+
/** Whether `[slot=subtitle]` content was projected. */
|
|
84
|
+
private hasSubtitleSlot;
|
|
85
|
+
/** Whether `[slot=visualizer]` content was projected. */
|
|
86
|
+
private hasVisualizerSlot;
|
|
87
|
+
/** Whether the visualizer's projected nodes were moved out of their wrapper. */
|
|
88
|
+
private visualizerOpen;
|
|
89
|
+
/** The visualizer nodes, while they live outside the wrapper. */
|
|
90
|
+
private visualizerChildren;
|
|
91
|
+
/** The positioned listener cleanups, for the teardown. */
|
|
92
|
+
private detach;
|
|
93
|
+
/** Whether the view (and with it the `<track>` element) exists. */
|
|
94
|
+
private viewReady;
|
|
95
|
+
/** Removes the captions `cuechange` listener, while it is attached. */
|
|
96
|
+
private detachCaptions;
|
|
97
|
+
/**
|
|
98
|
+
* The current class map.
|
|
99
|
+
* @returns The UIClassMap.
|
|
100
|
+
*/
|
|
101
|
+
cm(): UIClassMap;
|
|
102
|
+
/**
|
|
103
|
+
* Computes the wrapper class list (React's `cm.cn(cm.stack(2), cm.sp('p', 3), className)`).
|
|
104
|
+
* @returns The class string.
|
|
105
|
+
*/
|
|
106
|
+
classes(): string;
|
|
107
|
+
/**
|
|
108
|
+
* The title span's classes (React's `cm.cn(cm.textSize('sm'), cm.fontWeight('semibold'))`).
|
|
109
|
+
* @returns The class string.
|
|
110
|
+
*/
|
|
111
|
+
titleClasses(): string;
|
|
112
|
+
/**
|
|
113
|
+
* The subtitle span's classes (React's `cm.textSize('xs')`).
|
|
114
|
+
* @returns The class string.
|
|
115
|
+
*/
|
|
116
|
+
subtitleClasses(): string;
|
|
117
|
+
/**
|
|
118
|
+
* The caption line's classes (React's `cm.textSize('sm')`).
|
|
119
|
+
* @returns The class string.
|
|
120
|
+
*/
|
|
121
|
+
captionClasses(): string;
|
|
122
|
+
/**
|
|
123
|
+
* The header's classes (React's `cm.stack(0)`).
|
|
124
|
+
* @returns The class string.
|
|
125
|
+
*/
|
|
126
|
+
stackClasses(): string;
|
|
127
|
+
/**
|
|
128
|
+
* The elapsed / total span's classes (React's `cm.textSize('xs')`).
|
|
129
|
+
* @returns The class string.
|
|
130
|
+
*/
|
|
131
|
+
timeClasses(): string;
|
|
132
|
+
/**
|
|
133
|
+
* The range input's classes (React's `cm.flex1`).
|
|
134
|
+
* @returns The class string.
|
|
135
|
+
*/
|
|
136
|
+
seekClasses(): string;
|
|
137
|
+
/**
|
|
138
|
+
* The controls row's classes (React's `cm.flex({ align: 'center', gap: 'sm' })`).
|
|
139
|
+
* @returns The class string.
|
|
140
|
+
*/
|
|
141
|
+
controlsClasses(): string;
|
|
142
|
+
/** Reads React's `useState` initializers, once the inputs are bound. */
|
|
143
|
+
ngOnInit(): void;
|
|
144
|
+
/**
|
|
145
|
+
* Tears the captions setup down and rebuilds it after a `captions` input
|
|
146
|
+
* change (React's effect over the `captions` dependency) — nothing to do
|
|
147
|
+
* before the view exists ({@link AudioPlayer.ngAfterViewInit} runs it then).
|
|
148
|
+
* @param changes - The inputs that changed.
|
|
149
|
+
*/
|
|
150
|
+
ngOnChanges(changes: SimpleChanges): void;
|
|
151
|
+
/**
|
|
152
|
+
* Attaches the media listeners (React's effect) and reads the projected
|
|
153
|
+
* slots' presence — view queries resolve only at view init.
|
|
154
|
+
*/
|
|
155
|
+
ngAfterViewInit(): void;
|
|
156
|
+
/** Re-reconciles React's conditional DOM after input writes and state changes. */
|
|
157
|
+
ngDoCheck(): void;
|
|
158
|
+
/** Removes the media listeners and the captions listener (React's effect cleanup). */
|
|
159
|
+
ngOnDestroy(): void;
|
|
160
|
+
/**
|
|
161
|
+
* Whether React's `{node && …}` branch renders for a node-valued prop: a
|
|
162
|
+
* projected template always does, a plain value only when truthy.
|
|
163
|
+
* @param value - The node-valued prop.
|
|
164
|
+
* @returns True when React renders it.
|
|
165
|
+
*/
|
|
166
|
+
shows(value: unknown): boolean;
|
|
167
|
+
/**
|
|
168
|
+
* Whether a value is a projected node template.
|
|
169
|
+
* @param value - The field value.
|
|
170
|
+
* @returns True for a projected node template.
|
|
171
|
+
*/
|
|
172
|
+
isTemplate(value: unknown): value is TemplateRef<unknown>;
|
|
173
|
+
/**
|
|
174
|
+
* The value as a template (call under {@link AudioPlayer.isTemplate}).
|
|
175
|
+
* @param value - The field value.
|
|
176
|
+
* @returns The template.
|
|
177
|
+
*/
|
|
178
|
+
asTemplate(value: unknown): TemplateRef<unknown>;
|
|
179
|
+
/**
|
|
180
|
+
* The title input's text (a string input renders as text; projected nodes
|
|
181
|
+
* render through the capture point instead).
|
|
182
|
+
* @returns The title text, or `''` when absent.
|
|
183
|
+
*/
|
|
184
|
+
titleText(): string;
|
|
185
|
+
/**
|
|
186
|
+
* The subtitle input's text.
|
|
187
|
+
* @returns The subtitle text, or `''` when absent.
|
|
188
|
+
*/
|
|
189
|
+
subtitleText(): string;
|
|
190
|
+
/**
|
|
191
|
+
* The visualizer input's text.
|
|
192
|
+
* @returns The visualizer text, or `''` when absent.
|
|
193
|
+
*/
|
|
194
|
+
visualizerText(): string;
|
|
195
|
+
/**
|
|
196
|
+
* The elapsed / total display (React's `{fmt(current)} / {fmt(duration)}`).
|
|
197
|
+
* @returns The time text.
|
|
198
|
+
*/
|
|
199
|
+
timeText(): string;
|
|
200
|
+
/**
|
|
201
|
+
* The play/pause control's accessible name (React's `aria-label`).
|
|
202
|
+
* @returns The label text.
|
|
203
|
+
*/
|
|
204
|
+
toggleLabel(): string;
|
|
205
|
+
/**
|
|
206
|
+
* The mute control's accessible name (React's `aria-label`).
|
|
207
|
+
* @returns The label text.
|
|
208
|
+
*/
|
|
209
|
+
muteLabel(): string;
|
|
210
|
+
/**
|
|
211
|
+
* The seek control's accessible name (React's `aria-label`).
|
|
212
|
+
* @returns The label text.
|
|
213
|
+
*/
|
|
214
|
+
seekLabel(): string;
|
|
215
|
+
/**
|
|
216
|
+
* The captions track's accessible name (React's `label`): the
|
|
217
|
+
* `captionsLabel` input, or the i18n default.
|
|
218
|
+
* @returns The label text.
|
|
219
|
+
*/
|
|
220
|
+
trackLabel(): string;
|
|
221
|
+
/** Toggles play/pause on the audio element (React's `toggle`). */
|
|
222
|
+
toggle(): void;
|
|
223
|
+
/**
|
|
224
|
+
* Seeks the audio element to a position in seconds (React's `seek`). React
|
|
225
|
+
* restores a controlled input to the state value right after the change
|
|
226
|
+
* handler returns, so the range is written back too.
|
|
227
|
+
* @param event - The range input's native input event.
|
|
228
|
+
*/
|
|
229
|
+
onSeek(event: Event): void;
|
|
230
|
+
/** Toggles the muted state on the media element and in the state (React's `toggleMute`). */
|
|
231
|
+
toggleMute(): void;
|
|
232
|
+
/**
|
|
233
|
+
* Removes the captions `cuechange` listener and clears the caption (React's
|
|
234
|
+
* effect cleanup; the `<track>` element the listener rode on stays).
|
|
235
|
+
*/
|
|
236
|
+
private dropCaptions;
|
|
237
|
+
/**
|
|
238
|
+
* Puts the captions track in `hidden` mode — a hidden track still fires
|
|
239
|
+
* `cuechange`, while the hidden `<audio>` paints nothing — and listens for
|
|
240
|
+
* `cuechange` to show the active cues' text (React's captions effect).
|
|
241
|
+
*/
|
|
242
|
+
private syncCaptions;
|
|
243
|
+
/**
|
|
244
|
+
* Applies React's conditional DOM: the header and each span render only when
|
|
245
|
+
* React would render them, and the visualizer's projected nodes sit bare in
|
|
246
|
+
* the wrapper's place.
|
|
247
|
+
*/
|
|
248
|
+
private reconcile;
|
|
249
|
+
/**
|
|
250
|
+
* Keeps the range input's live value on React's controlled value (its
|
|
251
|
+
* state): an attribute binding alone does not re-write the property after a
|
|
252
|
+
* user edit, and React re-writes the property on every render.
|
|
253
|
+
*/
|
|
254
|
+
private syncRange;
|
|
255
|
+
/** Applies React's visualizer DOM: the wrapper is unwrapped, or kept out of the DOM empty. */
|
|
256
|
+
private reconcileVisualizer;
|
|
257
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<AudioPlayer, never>;
|
|
258
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<AudioPlayer, "div[mol-audio-player]", never, { "src": { "alias": "src"; "required": false; }; "title": { "alias": "title"; "required": false; }; "subtitle": { "alias": "subtitle"; "required": false; }; "visualizer": { "alias": "visualizer"; "required": false; }; "captions": { "alias": "captions"; "required": false; }; "captionsLang": { "alias": "captionsLang"; "required": false; }; "captionsLabel": { "alias": "captionsLabel"; "required": false; }; "defaultMuted": { "alias": "defaultMuted"; "required": false; }; "autoPlay": { "alias": "autoPlay"; "required": false; }; "onPlay": { "alias": "onPlay"; "required": false; }; "onPause": { "alias": "onPause"; "required": false; }; "onEnded": { "alias": "onEnded"; "required": false; }; "className": { "alias": "className"; "required": false; }; }, {}, never, ["[slot=title]", "[slot=subtitle]", "[slot=visualizer]"], true, never>;
|
|
259
|
+
}
|
|
260
|
+
//# sourceMappingURL=audio-player.component.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audio-player.component.d.ts","sourceRoot":"","sources":["../src/audio-player.component.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,KAAK,a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