@flexiui/svelte-rich-text 0.0.24 → 0.0.26
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/dist/AudioPlayerSimple.svelte +7 -0
- package/dist/AudioPlayerSimple.svelte.d.ts +25 -0
- package/dist/RichText.svelte +110 -5
- package/dist/extensions/Audio.d.ts +29 -0
- package/dist/extensions/Audio.js +123 -0
- package/dist/extensions/AudioPlayer.svelte +622 -0
- package/dist/extensions/AudioPlayer.svelte.d.ts +20 -0
- package/dist/extensions/AudioPlayerWrapper.svelte +123 -0
- package/dist/extensions/AudioPlayerWrapper.svelte.d.ts +21 -0
- package/dist/extensions/MediaGrid/MediaGrid.d.ts +2 -0
- package/dist/extensions/MediaGrid/MediaGrid.js +90 -0
- package/dist/extensions/MediaGrid/MediaGrid.svelte +265 -0
- package/dist/extensions/MediaGrid/MediaGrid.svelte.d.ts +14 -0
- package/dist/extensions/MediaGrid/MediaGridItem.d.ts +2 -0
- package/dist/extensions/MediaGrid/MediaGridItem.js +24 -0
- package/dist/extensions/MediaGrid/MediaGridItem.svelte +484 -0
- package/dist/extensions/MediaGrid/MediaGridItem.svelte.d.ts +14 -0
- package/dist/extensions/MediaGrid/auth-service.d.ts +1 -0
- package/dist/extensions/MediaGrid/auth-service.js +11 -0
- package/dist/extensions/Table/CustomTableCell.d.ts +19 -0
- package/dist/extensions/Table/CustomTableCell.js +86 -0
- package/dist/extensions/Table/CustomTableHeader.d.ts +1 -0
- package/dist/extensions/Table/CustomTableHeader.js +33 -0
- package/dist/extensions/Table/TableCellControls.d.ts +0 -0
- package/dist/extensions/Table/TableCellControls.js +0 -0
- package/dist/extensions/Table/TableCellNodeView.svelte +576 -0
- package/dist/extensions/Table/TableCellNodeView.svelte.d.ts +14 -0
- package/dist/extensions/Table/TableCellSelection.d.ts +12 -0
- package/dist/extensions/Table/TableCellSelection.js +35 -0
- package/dist/extensions/audioStore.d.ts +1 -0
- package/dist/extensions/audioStore.js +2 -0
- package/dist/extensions/extensions.d.ts +7 -0
- package/dist/extensions/extensions.js +86 -0
- package/dist/styles.css +182 -0
- package/package.json +2 -1
|
@@ -0,0 +1,622 @@
|
|
|
1
|
+
<svelte:options customElement={{
|
|
2
|
+
tag: 'fl-audio-player',
|
|
3
|
+
}} />
|
|
4
|
+
|
|
5
|
+
<script lang="ts">
|
|
6
|
+
import { onMount, tick } from "svelte";
|
|
7
|
+
import WaveSurfer from "wavesurfer.js";
|
|
8
|
+
import { activeAudioId } from "./audioStore";
|
|
9
|
+
|
|
10
|
+
export let id: string = "audio-" + Math.random().toString(36).slice(2);
|
|
11
|
+
export let src: string;
|
|
12
|
+
export let showSeekbar: boolean = true;
|
|
13
|
+
export let config: any = {};
|
|
14
|
+
|
|
15
|
+
export let playerType: "waveform" | "seekbar" = "waveform";
|
|
16
|
+
|
|
17
|
+
let wavesurfer: WaveSurfer | null = null;
|
|
18
|
+
let wavesurferReady: boolean = false;
|
|
19
|
+
let loading: boolean = true;
|
|
20
|
+
let audio: any = null;
|
|
21
|
+
let playing: boolean = false;
|
|
22
|
+
let mounted: boolean = false;
|
|
23
|
+
let seekbarEl: HTMLDivElement | null = null;
|
|
24
|
+
let progressEl: HTMLSpanElement | null = null;
|
|
25
|
+
|
|
26
|
+
let volume: number = 0.5;
|
|
27
|
+
let volumeSeekbarEl: HTMLDivElement | null = null;
|
|
28
|
+
let volumeProgressEl: HTMLSpanElement | null = null;
|
|
29
|
+
|
|
30
|
+
let audioDuration: number = 0;
|
|
31
|
+
let audioCurrentTime: number = 0;
|
|
32
|
+
|
|
33
|
+
function formatTime(seconds: number) {
|
|
34
|
+
if (isNaN(seconds) || seconds < 0) return "0:00";
|
|
35
|
+
|
|
36
|
+
const totalSeconds = Math.floor(seconds);
|
|
37
|
+
const minutes = Math.floor(totalSeconds / 60);
|
|
38
|
+
const secondsLeft = totalSeconds % 60;
|
|
39
|
+
|
|
40
|
+
return `${minutes}:${secondsLeft.toString().padStart(2, "0")}`;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function togglePlayPause() {
|
|
44
|
+
playing = !playing;
|
|
45
|
+
console.log({ playing });
|
|
46
|
+
|
|
47
|
+
if (playing) {
|
|
48
|
+
activeAudioId.set(id);
|
|
49
|
+
|
|
50
|
+
if (wavesurferReady) {
|
|
51
|
+
wavesurfer?.play();
|
|
52
|
+
} else {
|
|
53
|
+
audio.play();
|
|
54
|
+
}
|
|
55
|
+
} else {
|
|
56
|
+
if (wavesurferReady) {
|
|
57
|
+
wavesurfer?.pause();
|
|
58
|
+
} else {
|
|
59
|
+
audio.pause();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function handleSeekClick(e: MouseEvent) {
|
|
65
|
+
if (!audio || !seekbarEl || !audio.duration) return;
|
|
66
|
+
const rect = seekbarEl.getBoundingClientRect();
|
|
67
|
+
const clickX = e.clientX - rect.left;
|
|
68
|
+
const percentage = clickX / rect.width;
|
|
69
|
+
const newTime = percentage * audio.duration;
|
|
70
|
+
audio.currentTime = newTime;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function handleVolumeClick(e: MouseEvent) {
|
|
74
|
+
if (!audio || !volumeSeekbarEl || !audio.duration) return;
|
|
75
|
+
const rect = volumeSeekbarEl.getBoundingClientRect();
|
|
76
|
+
const clickX = e.clientX - rect.left;
|
|
77
|
+
let volumeValue = clickX / rect.width;
|
|
78
|
+
if (volumeValue > 1) {
|
|
79
|
+
volumeValue = 1;
|
|
80
|
+
}
|
|
81
|
+
// if (percentage > 100) {
|
|
82
|
+
// percentage = 100;
|
|
83
|
+
// }
|
|
84
|
+
|
|
85
|
+
volume = volumeValue;
|
|
86
|
+
audio.volume = volume;
|
|
87
|
+
|
|
88
|
+
if (wavesurferReady) {
|
|
89
|
+
wavesurfer?.setVolume(volume);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
onMount(async () => {
|
|
94
|
+
const unsubscribe = activeAudioId.subscribe((currentId) => {
|
|
95
|
+
if (currentId !== id && playing) {
|
|
96
|
+
// Otro reproductor ha sido activado → este se pausa
|
|
97
|
+
playing = false;
|
|
98
|
+
audio?.pause();
|
|
99
|
+
wavesurfer?.pause();
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
console.log({ src });
|
|
103
|
+
console.log({ WaveSurfer });
|
|
104
|
+
|
|
105
|
+
if (WaveSurfer) {
|
|
106
|
+
|
|
107
|
+
setTimeout(() => {
|
|
108
|
+
wavesurfer = WaveSurfer?.create({
|
|
109
|
+
container: "#waveform-" + id,
|
|
110
|
+
height: 46,
|
|
111
|
+
normalize: false,
|
|
112
|
+
waveColor: "#b0b0b0",
|
|
113
|
+
progressColor: "#5e17eb",
|
|
114
|
+
cursorColor: "#ddd5e9",
|
|
115
|
+
cursorWidth: 4,
|
|
116
|
+
barWidth: 3,
|
|
117
|
+
barGap: 3,
|
|
118
|
+
barRadius: 30,
|
|
119
|
+
barHeight: 1,
|
|
120
|
+
minPxPerSec: 40,
|
|
121
|
+
fillParent: true,
|
|
122
|
+
mediaControls: false,
|
|
123
|
+
autoplay: false,
|
|
124
|
+
interact: true,
|
|
125
|
+
dragToSeek: true,
|
|
126
|
+
hideScrollbar: true,
|
|
127
|
+
audioRate: 1,
|
|
128
|
+
autoScroll: true,
|
|
129
|
+
autoCenter: true,
|
|
130
|
+
sampleRate: 8000,
|
|
131
|
+
url: src,
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// wavesurfer.on("ready", () => {
|
|
138
|
+
// console.log("WaveSurfer is ready");
|
|
139
|
+
// wavesurferReady = true;
|
|
140
|
+
// wavesurfer?.setVolume(volume);
|
|
141
|
+
// });
|
|
142
|
+
|
|
143
|
+
// wavesurfer.on("finish", () => {
|
|
144
|
+
// playing = false;
|
|
145
|
+
// console.log("Playback finished");
|
|
146
|
+
// // stop the audio
|
|
147
|
+
// wavesurfer?.stop();
|
|
148
|
+
// });
|
|
149
|
+
|
|
150
|
+
audio = new Audio(src);
|
|
151
|
+
audio.volume = volume;
|
|
152
|
+
audio.preload = "auto";
|
|
153
|
+
audio.load();
|
|
154
|
+
|
|
155
|
+
audio.addEventListener("loadedmetadata", () => {
|
|
156
|
+
audioDuration = audio.duration;
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
audio.onended = () => {
|
|
160
|
+
playing = false;
|
|
161
|
+
console.log("Audio playback ended");
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
audio.addEventListener("timeupdate", () => {
|
|
165
|
+
audioCurrentTime = audio.currentTime;
|
|
166
|
+
if (seekbarEl && progressEl) {
|
|
167
|
+
progressEl.style.width = `${(audio.currentTime / audio.duration) * 100}%`;
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
setTimeout(() => {
|
|
172
|
+
loading = false;
|
|
173
|
+
}, 500);
|
|
174
|
+
mounted = true;
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
let isDragging = false;
|
|
178
|
+
let playingBeforeDragging = false;
|
|
179
|
+
|
|
180
|
+
function onCurrentTimeGrabMouseDown(e: MouseEvent) {
|
|
181
|
+
e.preventDefault();
|
|
182
|
+
isDragging = true;
|
|
183
|
+
playingBeforeDragging = playing;
|
|
184
|
+
if (playing) togglePlayPause(); // Pause
|
|
185
|
+
|
|
186
|
+
window.addEventListener("mousemove", onCurrentTimeGrabMouseMove);
|
|
187
|
+
window.addEventListener("mouseup", onCurrentTimeGrabMouseUp);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
function onCurrentTimeGrabMouseMove(e: MouseEvent) {
|
|
191
|
+
if (!isDragging || !seekbarEl || !progressEl || !audio || !audio.duration)
|
|
192
|
+
return;
|
|
193
|
+
|
|
194
|
+
const rect = seekbarEl.getBoundingClientRect();
|
|
195
|
+
const x = e.clientX - rect.left;
|
|
196
|
+
const percentage = Math.min(Math.max(x / rect.width, 0), 1);
|
|
197
|
+
|
|
198
|
+
// Actualiza visualmente el progreso
|
|
199
|
+
progressEl.style.width = `${percentage * 100}%`;
|
|
200
|
+
|
|
201
|
+
// Muestra el tiempo actual estimado
|
|
202
|
+
audioCurrentTime = percentage * audio.duration;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
function onCurrentTimeGrabMouseUp(e: MouseEvent) {
|
|
206
|
+
if (!isDragging) return;
|
|
207
|
+
isDragging = false;
|
|
208
|
+
|
|
209
|
+
if (playingBeforeDragging) togglePlayPause(); // Resume
|
|
210
|
+
|
|
211
|
+
window.removeEventListener("mousemove", onCurrentTimeGrabMouseMove);
|
|
212
|
+
window.removeEventListener("mouseup", onCurrentTimeGrabMouseUp);
|
|
213
|
+
|
|
214
|
+
if (!seekbarEl || !audio || !audio.duration) return;
|
|
215
|
+
|
|
216
|
+
const rect = seekbarEl.getBoundingClientRect();
|
|
217
|
+
const x = e.clientX - rect.left;
|
|
218
|
+
const percentage = Math.min(Math.max(x / rect.width, 0), 1);
|
|
219
|
+
|
|
220
|
+
// Ajusta el tiempo real del audio
|
|
221
|
+
audio.currentTime = percentage * audio.duration;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
function onVolumeGrabMouseDown(e: MouseEvent) {
|
|
225
|
+
e.preventDefault();
|
|
226
|
+
isDragging = true;
|
|
227
|
+
|
|
228
|
+
window.addEventListener("mousemove", onVolumeGrabMouseMove);
|
|
229
|
+
window.addEventListener("mouseup", onVolumeGrabMouseUp);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
function onVolumeGrabMouseMove(e: MouseEvent) {
|
|
233
|
+
if (!isDragging || !volumeSeekbarEl || !volumeProgressEl || !audio) return;
|
|
234
|
+
|
|
235
|
+
const rect = volumeSeekbarEl.getBoundingClientRect();
|
|
236
|
+
const x = e.clientX - rect.left;
|
|
237
|
+
const percentage = Math.min(Math.max(x / rect.width, 0), 1);
|
|
238
|
+
|
|
239
|
+
// Actualiza visualmente el progreso
|
|
240
|
+
volumeProgressEl.style.width = `${percentage * 100}%`;
|
|
241
|
+
|
|
242
|
+
// Muestra el tiempo actual estimado
|
|
243
|
+
|
|
244
|
+
audio.volume = percentage;
|
|
245
|
+
|
|
246
|
+
if (wavesurferReady) {
|
|
247
|
+
wavesurfer?.setVolume(percentage);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
function onVolumeGrabMouseUp(e: MouseEvent) {
|
|
252
|
+
if (!isDragging) return;
|
|
253
|
+
isDragging = false;
|
|
254
|
+
|
|
255
|
+
window.removeEventListener("mousemove", onVolumeGrabMouseMove);
|
|
256
|
+
window.removeEventListener("mouseup", onVolumeGrabMouseUp);
|
|
257
|
+
}
|
|
258
|
+
</script>
|
|
259
|
+
|
|
260
|
+
<div class="audio-player" {id} class:playing>
|
|
261
|
+
<button
|
|
262
|
+
onclick={() => togglePlayPause()}
|
|
263
|
+
type="button"
|
|
264
|
+
class="media-item-play-btn"
|
|
265
|
+
class:playing
|
|
266
|
+
aria-label="Reproducir audio"
|
|
267
|
+
>
|
|
268
|
+
{#if playing}
|
|
269
|
+
<svg
|
|
270
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
271
|
+
width="24"
|
|
272
|
+
height="24"
|
|
273
|
+
viewBox="0 0 24 24"
|
|
274
|
+
fill="currentColor"
|
|
275
|
+
class="icon icon-tabler icons-tabler-filled icon-tabler-player-pause"
|
|
276
|
+
><path stroke="none" d="M0 0h24v24H0z" fill="none" /><path
|
|
277
|
+
d="M9 4h-2a2 2 0 0 0 -2 2v12a2 2 0 0 0 2 2h2a2 2 0 0 0 2 -2v-12a2 2 0 0 0 -2 -2z"
|
|
278
|
+
/><path
|
|
279
|
+
d="M17 4h-2a2 2 0 0 0 -2 2v12a2 2 0 0 0 2 2h2a2 2 0 0 0 2 -2v-12a2 2 0 0 0 -2 -2z"
|
|
280
|
+
/></svg
|
|
281
|
+
>
|
|
282
|
+
{:else}
|
|
283
|
+
<svg
|
|
284
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
285
|
+
width="24"
|
|
286
|
+
height="24"
|
|
287
|
+
viewBox="0 0 24 24"
|
|
288
|
+
fill="currentColor"
|
|
289
|
+
class="icon icon-tabler icons-tabler-filled icon-tabler-player-play"
|
|
290
|
+
><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path
|
|
291
|
+
d="M6 4v16a1 1 0 0 0 1.524 .852l13 -8a1 1 0 0 0 0 -1.704l-13 -8a1 1 0 0 0 -1.524 .852z"
|
|
292
|
+
></path></svg
|
|
293
|
+
>
|
|
294
|
+
{/if}
|
|
295
|
+
</button>
|
|
296
|
+
<!-- <span class="media-item-number">{index+1}</span> -->
|
|
297
|
+
|
|
298
|
+
<div
|
|
299
|
+
class="audio-player-wave"
|
|
300
|
+
id={"waveform-" + id}
|
|
301
|
+
class:hidden={mounted && !wavesurferReady}
|
|
302
|
+
></div>
|
|
303
|
+
|
|
304
|
+
<!-- {#if playerType === 'seekbar'}
|
|
305
|
+
<div class="audio-player-seekbar">
|
|
306
|
+
<span class="audio-player-seekbar-progress"></span>
|
|
307
|
+
</div>
|
|
308
|
+
{/if} -->
|
|
309
|
+
|
|
310
|
+
<div class="audio-player-time">
|
|
311
|
+
<span class="audio-player-current-time"
|
|
312
|
+
>{formatTime(audioCurrentTime || 0)}</span
|
|
313
|
+
>
|
|
314
|
+
<span class="audio-player-sep">/</span>
|
|
315
|
+
<span class="audio-player-duration">{formatTime(audioDuration)}</span>
|
|
316
|
+
</div>
|
|
317
|
+
|
|
318
|
+
{#if (playerType === "waveform" && !wavesurferReady && !loading) || playerType === "seekbar"}
|
|
319
|
+
<div
|
|
320
|
+
role="slider"
|
|
321
|
+
tabindex="0"
|
|
322
|
+
aria-label="Seekbar"
|
|
323
|
+
aria-controls="audio-player-seekbar"
|
|
324
|
+
aria-valuemin="0"
|
|
325
|
+
aria-valuemax={audio.duration}
|
|
326
|
+
aria-valuenow={audio.currentTime}
|
|
327
|
+
bind:this={seekbarEl}
|
|
328
|
+
class="audio-player-seekbar"
|
|
329
|
+
onclick={handleSeekClick}
|
|
330
|
+
onkeydown={(e) => {
|
|
331
|
+
if (e.key === "ArrowRight" || e.key === "ArrowUp") {
|
|
332
|
+
e.preventDefault();
|
|
333
|
+
audio.currentTime = audio.currentTime + 10;
|
|
334
|
+
} else if (e.key === "ArrowLeft" || e.key === "ArrowDown") {
|
|
335
|
+
e.preventDefault();
|
|
336
|
+
audio.currentTime = audio.currentTime - 10;
|
|
337
|
+
} else if (e.key === " " || e.key === "Enter") {
|
|
338
|
+
e.preventDefault();
|
|
339
|
+
togglePlayPause();
|
|
340
|
+
}
|
|
341
|
+
}}
|
|
342
|
+
>
|
|
343
|
+
<div bind:this={progressEl} class="audio-player-seekbar-progress">
|
|
344
|
+
<button
|
|
345
|
+
aria-label="Mover al punto actual"
|
|
346
|
+
type="button"
|
|
347
|
+
tabindex="-1"
|
|
348
|
+
class="audio-player-seekbar-grab"
|
|
349
|
+
onmousedown={onCurrentTimeGrabMouseDown}
|
|
350
|
+
></button>
|
|
351
|
+
</div>
|
|
352
|
+
</div>
|
|
353
|
+
{/if}
|
|
354
|
+
|
|
355
|
+
{#if loading}
|
|
356
|
+
<div
|
|
357
|
+
role="slider"
|
|
358
|
+
tabindex="0"
|
|
359
|
+
aria-label="Seekbar"
|
|
360
|
+
aria-controls="audio-player-seekbar"
|
|
361
|
+
aria-valuemin="0"
|
|
362
|
+
class="audio-player-seekbar"
|
|
363
|
+
>
|
|
364
|
+
<div class="audio-player-seekbar-progress">
|
|
365
|
+
<button
|
|
366
|
+
aria-label="Mover al punto actual"
|
|
367
|
+
type="button"
|
|
368
|
+
tabindex="-1"
|
|
369
|
+
class="audio-player-seekbar-grab"
|
|
370
|
+
></button>
|
|
371
|
+
</div>
|
|
372
|
+
</div>
|
|
373
|
+
{/if}
|
|
374
|
+
|
|
375
|
+
<div
|
|
376
|
+
style="display: flex;gap: 5px;flex: unset;align-items: center;white-space: nowrap;"
|
|
377
|
+
class="audio-player-options"
|
|
378
|
+
>
|
|
379
|
+
<div class="audio-player-volume">
|
|
380
|
+
<div
|
|
381
|
+
role="slider"
|
|
382
|
+
tabindex="0"
|
|
383
|
+
aria-label="Volume"
|
|
384
|
+
aria-controls="audio-player-volume-slider"
|
|
385
|
+
aria-valuemin="0"
|
|
386
|
+
aria-valuemax="100"
|
|
387
|
+
aria-valuenow={volume * 100}
|
|
388
|
+
bind:this={volumeSeekbarEl}
|
|
389
|
+
onclick={handleVolumeClick}
|
|
390
|
+
onkeydown={(e) => {
|
|
391
|
+
if (e.key === "ArrowUp" || e.key === "ArrowRight") {
|
|
392
|
+
e.preventDefault();
|
|
393
|
+
volume = Math.min(audio.volume + 0.1, 1);
|
|
394
|
+
audio.volume = volume;
|
|
395
|
+
} else if (e.key === "ArrowDown" || e.key === "ArrowLeft") {
|
|
396
|
+
e.preventDefault();
|
|
397
|
+
volume = Math.max(audio.volume - 0.1, 0);
|
|
398
|
+
audio.volume = volume;
|
|
399
|
+
}
|
|
400
|
+
}}
|
|
401
|
+
class="audio-player-seekbar audio-player-seekbar--volume"
|
|
402
|
+
style="max-width: 70px;"
|
|
403
|
+
>
|
|
404
|
+
<span
|
|
405
|
+
bind:this={volumeProgressEl}
|
|
406
|
+
class="audio-player-seekbar-progress"
|
|
407
|
+
style="width: {volume * 100}%;"
|
|
408
|
+
>
|
|
409
|
+
<button
|
|
410
|
+
aria-label="Mover al punto actual"
|
|
411
|
+
type="button"
|
|
412
|
+
tabindex="-1"
|
|
413
|
+
class="audio-player-seekbar-grab"
|
|
414
|
+
onmousedown={onVolumeGrabMouseDown}
|
|
415
|
+
>
|
|
416
|
+
</button>
|
|
417
|
+
</span>
|
|
418
|
+
</div>
|
|
419
|
+
<button
|
|
420
|
+
aria-label="Silenciar audio"
|
|
421
|
+
type="button"
|
|
422
|
+
class="fl-audio-volume-btn"
|
|
423
|
+
>
|
|
424
|
+
<svg
|
|
425
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
426
|
+
height="24px"
|
|
427
|
+
viewBox="0 -960 960 960"
|
|
428
|
+
width="24px"
|
|
429
|
+
fill="currentColor"
|
|
430
|
+
><path
|
|
431
|
+
d="M560-131v-82q90-26 145-100t55-168q0-94-55-168T560-749v-82q124 28 202 125.5T840-481q0 127-78 224.5T560-131ZM120-360v-240h160l200-200v640L280-360H120Zm440 40v-322q47 22 73.5 66t26.5 96q0 51-26.5 94.5T560-320Z"
|
|
432
|
+
></path></svg
|
|
433
|
+
>
|
|
434
|
+
</button>
|
|
435
|
+
</div>
|
|
436
|
+
</div>
|
|
437
|
+
|
|
438
|
+
<!-- {#if mounted && !wavesurferReady}
|
|
439
|
+
<div class="audio-player-time">
|
|
440
|
+
0:51
|
|
441
|
+
</div>
|
|
442
|
+
{/if} -->
|
|
443
|
+
</div>
|
|
444
|
+
|
|
445
|
+
<style>
|
|
446
|
+
:host {
|
|
447
|
+
display: block;
|
|
448
|
+
width: 100%;
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
.audio-player {
|
|
452
|
+
--player-primary-color: #5e17eb;
|
|
453
|
+
--player-bg-color: #455f7414;
|
|
454
|
+
--player-border-radius: 18px;
|
|
455
|
+
--player-seekbar-bg: #8d8d8d3a;
|
|
456
|
+
--player-seekbar-height: 6px;
|
|
457
|
+
--player-progress-default-bg: #f5f5f5;
|
|
458
|
+
--player-play-btn-bg: #8d8d8d26;
|
|
459
|
+
--player-play-btn-color: #fff;
|
|
460
|
+
|
|
461
|
+
display: flex;
|
|
462
|
+
align-items: center;
|
|
463
|
+
gap: 14px;
|
|
464
|
+
background: var(--player-bg-color);
|
|
465
|
+
border-radius: var(--player-border-radius);
|
|
466
|
+
padding: 12px;
|
|
467
|
+
width: 100%;
|
|
468
|
+
box-sizing: border-box;
|
|
469
|
+
|
|
470
|
+
&.playing {
|
|
471
|
+
.audio-player-wave {
|
|
472
|
+
filter: grayscale(0);
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
.audio-player-seekbar-progress {
|
|
476
|
+
color: var(--player-primary-color);
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
.media-item-play-btn {
|
|
482
|
+
min-width: 42px;
|
|
483
|
+
height: 42px;
|
|
484
|
+
display: inline-flex;
|
|
485
|
+
align-items: center;
|
|
486
|
+
justify-content: center;
|
|
487
|
+
background: var(--player-play-btn-bg);
|
|
488
|
+
color: var(--player-play-btn-color);
|
|
489
|
+
border: 2px solid transparent;
|
|
490
|
+
border-radius: 100%;
|
|
491
|
+
outline-offset: 4px;
|
|
492
|
+
outline-color: var(--player-play-btn-bg);
|
|
493
|
+
|
|
494
|
+
svg {
|
|
495
|
+
width: 20px;
|
|
496
|
+
height: 20px;
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
&.playing {
|
|
500
|
+
background: var(--player-primary-color);
|
|
501
|
+
color: #fff;
|
|
502
|
+
outline-color: var(--player-primary-color);
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
.audio-player-wave {
|
|
507
|
+
width: 100%;
|
|
508
|
+
width: 200px;
|
|
509
|
+
flex: auto;
|
|
510
|
+
filter: grayscale(1);
|
|
511
|
+
|
|
512
|
+
&.hidden {
|
|
513
|
+
display: none;
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
.audio-player-seekbar {
|
|
518
|
+
height: var(--player-seekbar-height);
|
|
519
|
+
flex: auto;
|
|
520
|
+
background: var(--player-seekbar-bg);
|
|
521
|
+
border-radius: 16px;
|
|
522
|
+
position: relative;
|
|
523
|
+
cursor: pointer;
|
|
524
|
+
min-width: 0;
|
|
525
|
+
transition: all 0.3s ease;
|
|
526
|
+
|
|
527
|
+
&::before {
|
|
528
|
+
content: "";
|
|
529
|
+
width: 100%;
|
|
530
|
+
height: 100%;
|
|
531
|
+
position: absolute;
|
|
532
|
+
top: 0;
|
|
533
|
+
left: 0;
|
|
534
|
+
transform: scaleY(3);
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
&:hover,
|
|
538
|
+
&:focus-within {
|
|
539
|
+
.audio-player-seekbar-progress {
|
|
540
|
+
.audio-player-seekbar-grab {
|
|
541
|
+
visibility: visible;
|
|
542
|
+
transform: scale(1);
|
|
543
|
+
border: none;
|
|
544
|
+
padding: 0;
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
.audio-player-seekbar-progress {
|
|
551
|
+
width: 0;
|
|
552
|
+
height: 100%;
|
|
553
|
+
color: var(--player-progress-default-bg);
|
|
554
|
+
background: currentColor;
|
|
555
|
+
display: flex;
|
|
556
|
+
border-radius: inherit;
|
|
557
|
+
position: relative;
|
|
558
|
+
|
|
559
|
+
.audio-player-seekbar-grab {
|
|
560
|
+
content: "";
|
|
561
|
+
width: 12px;
|
|
562
|
+
height: 12px;
|
|
563
|
+
background: currentColor;
|
|
564
|
+
border-radius: 100%;
|
|
565
|
+
position: absolute;
|
|
566
|
+
right: calc(-1 * var(--player-seekbar-height));
|
|
567
|
+
top: calc((12px - var(--player-seekbar-height)) / -2);
|
|
568
|
+
box-shadow: 1px 1px 12px rgba(0, 0, 0, 0.1);
|
|
569
|
+
visibility: hidden;
|
|
570
|
+
transition: transform 0.3s ease;
|
|
571
|
+
transform: scale(0);
|
|
572
|
+
color: inherit;
|
|
573
|
+
background: currentColor;
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
.audio-player-volume {
|
|
578
|
+
display: flex;
|
|
579
|
+
align-items: center;
|
|
580
|
+
border-radius: 20px;
|
|
581
|
+
margin-right: 4px;
|
|
582
|
+
|
|
583
|
+
&:hover {
|
|
584
|
+
background: #0d121612;
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
&:hover .audio-player-seekbar,
|
|
588
|
+
&:focus-within .audio-player-seekbar {
|
|
589
|
+
min-width: 70px;
|
|
590
|
+
margin-left: 14px;
|
|
591
|
+
margin-right: 4px;
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
.audio-player-time {
|
|
596
|
+
min-width: 70px;
|
|
597
|
+
font-size: 0.8rem;
|
|
598
|
+
color: inherit;
|
|
599
|
+
text-align: center;
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
.audio-player-current-time {
|
|
603
|
+
display: inline-block;
|
|
604
|
+
min-width: 32px;
|
|
605
|
+
font-variant-numeric: tabular-nums;
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
.audio-player-duration {
|
|
609
|
+
display: inline-block;
|
|
610
|
+
min-width: 32px;
|
|
611
|
+
font-variant-numeric: tabular-nums;
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
.fl-audio-volume-btn {
|
|
615
|
+
border: none;
|
|
616
|
+
padding: 4px;
|
|
617
|
+
background: #0d121600;
|
|
618
|
+
border-radius: 100%;
|
|
619
|
+
height: 36px;
|
|
620
|
+
width: 36px;
|
|
621
|
+
}
|
|
622
|
+
</style>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
id?: string;
|
|
5
|
+
src: string;
|
|
6
|
+
showSeekbar?: boolean;
|
|
7
|
+
config?: any;
|
|
8
|
+
playerType?: "waveform" | "seekbar";
|
|
9
|
+
};
|
|
10
|
+
events: {
|
|
11
|
+
[evt: string]: CustomEvent<any>;
|
|
12
|
+
};
|
|
13
|
+
slots: {};
|
|
14
|
+
};
|
|
15
|
+
export type AudioPlayerProps = typeof __propDef.props;
|
|
16
|
+
export type AudioPlayerEvents = typeof __propDef.events;
|
|
17
|
+
export type AudioPlayerSlots = typeof __propDef.slots;
|
|
18
|
+
export default class AudioPlayer extends SvelteComponentTyped<AudioPlayerProps, AudioPlayerEvents, AudioPlayerSlots> {
|
|
19
|
+
}
|
|
20
|
+
export {};
|