wavesurfer.js 7.8.5-beta.0 → 7.8.6
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/plugins/minimap.cjs +1 -1
- package/dist/plugins/minimap.d.ts +27 -1
- package/dist/plugins/minimap.esm.js +1 -1
- package/dist/plugins/minimap.js +1 -1
- package/dist/plugins/minimap.min.js +1 -1
- package/dist/plugins/spectrogram.cjs +1 -1
- package/dist/plugins/spectrogram.esm.js +1 -1
- package/dist/plugins/spectrogram.js +1 -1
- package/dist/plugins/spectrogram.min.js +1 -1
- package/dist/renderer.js +2 -1
- package/dist/types.d.ts +2 -0
- package/dist/wavesurfer.cjs +1 -1
- package/dist/wavesurfer.d.ts +2 -0
- package/dist/wavesurfer.esm.js +1 -1
- package/dist/wavesurfer.min.js +1 -1
- package/package.json +2 -1
- package/dist/plugins/base-plugin.d.ts +0 -21
- package/dist/plugins/decoder.d.ts +0 -9
- package/dist/plugins/dom.d.ts +0 -13
- package/dist/plugins/draggable.d.ts +0 -1
- package/dist/plugins/event-emitter.d.ts +0 -21
- package/dist/plugins/fetcher.d.ts +0 -5
- package/dist/plugins/player.d.ts +0 -50
- package/dist/plugins/plugins/envelope.d.ts +0 -79
- package/dist/plugins/plugins/hover.d.ts +0 -36
- package/dist/plugins/plugins/minimap.d.ts +0 -39
- package/dist/plugins/plugins/record.d.ts +0 -89
- package/dist/plugins/plugins/regions.d.ts +0 -139
- package/dist/plugins/plugins/spectrogram.d.ts +0 -98
- package/dist/plugins/plugins/timeline.d.ts +0 -54
- package/dist/plugins/plugins/zoom.d.ts +0 -55
- package/dist/plugins/renderer.d.ts +0 -63
- package/dist/plugins/timer.d.ts +0 -11
- package/dist/plugins/wavesurfer.d.ts +0 -221
- package/dist/plugins/webaudio.d.ts +0 -63
|
@@ -1,221 +0,0 @@
|
|
|
1
|
-
import BasePlugin, { type GenericPlugin } from './base-plugin.js';
|
|
2
|
-
import * as dom from './dom.js';
|
|
3
|
-
import Player from './player.js';
|
|
4
|
-
export type WaveSurferOptions = {
|
|
5
|
-
/** Required: an HTML element or selector where the waveform will be rendered */
|
|
6
|
-
container: HTMLElement | string;
|
|
7
|
-
/** The height of the waveform in pixels, or "auto" to fill the container height */
|
|
8
|
-
height?: number | 'auto';
|
|
9
|
-
/** The width of the waveform in pixels or any CSS value; defaults to 100% */
|
|
10
|
-
width?: number | string;
|
|
11
|
-
/** The color of the waveform */
|
|
12
|
-
waveColor?: string | string[] | CanvasGradient;
|
|
13
|
-
/** The color of the progress mask */
|
|
14
|
-
progressColor?: string | string[] | CanvasGradient;
|
|
15
|
-
/** The color of the playpack cursor */
|
|
16
|
-
cursorColor?: string;
|
|
17
|
-
/** The cursor width */
|
|
18
|
-
cursorWidth?: number;
|
|
19
|
-
/** If set, the waveform will be rendered with bars like this: ▁ ▂ ▇ ▃ ▅ ▂ */
|
|
20
|
-
barWidth?: number;
|
|
21
|
-
/** Spacing between bars in pixels */
|
|
22
|
-
barGap?: number;
|
|
23
|
-
/** Rounded borders for bars */
|
|
24
|
-
barRadius?: number;
|
|
25
|
-
/** A vertical scaling factor for the waveform */
|
|
26
|
-
barHeight?: number;
|
|
27
|
-
/** Vertical bar alignment */
|
|
28
|
-
barAlign?: 'top' | 'bottom';
|
|
29
|
-
/** Minimum pixels per second of audio (i.e. the zoom level) */
|
|
30
|
-
minPxPerSec?: number;
|
|
31
|
-
/** Stretch the waveform to fill the container, true by default */
|
|
32
|
-
fillParent?: boolean;
|
|
33
|
-
/** Audio URL */
|
|
34
|
-
url?: string;
|
|
35
|
-
/** Pre-computed audio data, arrays of floats for each channel */
|
|
36
|
-
peaks?: Array<Float32Array | number[]>;
|
|
37
|
-
/** Pre-computed audio duration in seconds */
|
|
38
|
-
duration?: number;
|
|
39
|
-
/** Use an existing media element instead of creating one */
|
|
40
|
-
media?: HTMLMediaElement;
|
|
41
|
-
/** Whether to show default audio element controls */
|
|
42
|
-
mediaControls?: boolean;
|
|
43
|
-
/** Play the audio on load */
|
|
44
|
-
autoplay?: boolean;
|
|
45
|
-
/** Pass false to disable clicks on the waveform */
|
|
46
|
-
interact?: boolean;
|
|
47
|
-
/** Allow to drag the cursor to seek to a new position. If an object with `debounceTime` is provided instead
|
|
48
|
-
* then `dragToSeek` will also be true. If `true` the default is 200ms
|
|
49
|
-
*/
|
|
50
|
-
dragToSeek?: boolean | {
|
|
51
|
-
debounceTime: number;
|
|
52
|
-
};
|
|
53
|
-
/** Hide the scrollbar */
|
|
54
|
-
hideScrollbar?: boolean;
|
|
55
|
-
/** Audio rate, i.e. the playback speed */
|
|
56
|
-
audioRate?: number;
|
|
57
|
-
/** Automatically scroll the container to keep the current position in viewport */
|
|
58
|
-
autoScroll?: boolean;
|
|
59
|
-
/** If autoScroll is enabled, keep the cursor in the center of the waveform during playback */
|
|
60
|
-
autoCenter?: boolean;
|
|
61
|
-
/** Decoding sample rate. Doesn't affect the playback. Defaults to 8000 */
|
|
62
|
-
sampleRate?: number;
|
|
63
|
-
/** Render each audio channel as a separate waveform */
|
|
64
|
-
splitChannels?: Array<Partial<WaveSurferOptions> & {
|
|
65
|
-
overlay?: boolean;
|
|
66
|
-
}>;
|
|
67
|
-
/** Stretch the waveform to the full height */
|
|
68
|
-
normalize?: boolean;
|
|
69
|
-
/** The list of plugins to initialize on start */
|
|
70
|
-
plugins?: GenericPlugin[];
|
|
71
|
-
/** Custom render function */
|
|
72
|
-
renderFunction?: (peaks: Array<Float32Array | number[]>, ctx: CanvasRenderingContext2D) => void;
|
|
73
|
-
/** Options to pass to the fetch method */
|
|
74
|
-
fetchParams?: RequestInit;
|
|
75
|
-
/** Playback "backend" to use, defaults to MediaElement */
|
|
76
|
-
backend?: 'WebAudio' | 'MediaElement';
|
|
77
|
-
};
|
|
78
|
-
declare const defaultOptions: {
|
|
79
|
-
waveColor: string;
|
|
80
|
-
progressColor: string;
|
|
81
|
-
cursorWidth: number;
|
|
82
|
-
minPxPerSec: number;
|
|
83
|
-
fillParent: boolean;
|
|
84
|
-
interact: boolean;
|
|
85
|
-
dragToSeek: boolean;
|
|
86
|
-
autoScroll: boolean;
|
|
87
|
-
autoCenter: boolean;
|
|
88
|
-
sampleRate: number;
|
|
89
|
-
};
|
|
90
|
-
export type WaveSurferEvents = {
|
|
91
|
-
/** After wavesurfer is created */
|
|
92
|
-
init: [];
|
|
93
|
-
/** When audio starts loading */
|
|
94
|
-
load: [url: string];
|
|
95
|
-
/** During audio loading */
|
|
96
|
-
loading: [percent: number];
|
|
97
|
-
/** When the audio has been decoded */
|
|
98
|
-
decode: [duration: number];
|
|
99
|
-
/** When the audio is both decoded and can play */
|
|
100
|
-
ready: [duration: number];
|
|
101
|
-
/** When visible waveform is drawn */
|
|
102
|
-
redraw: [];
|
|
103
|
-
/** When all audio channel chunks of the waveform have drawn */
|
|
104
|
-
redrawcomplete: [];
|
|
105
|
-
/** When the audio starts playing */
|
|
106
|
-
play: [];
|
|
107
|
-
/** When the audio pauses */
|
|
108
|
-
pause: [];
|
|
109
|
-
/** When the audio finishes playing */
|
|
110
|
-
finish: [];
|
|
111
|
-
/** On audio position change, fires continuously during playback */
|
|
112
|
-
timeupdate: [currentTime: number];
|
|
113
|
-
/** An alias of timeupdate but only when the audio is playing */
|
|
114
|
-
audioprocess: [currentTime: number];
|
|
115
|
-
/** When the user seeks to a new position */
|
|
116
|
-
seeking: [currentTime: number];
|
|
117
|
-
/** When the user interacts with the waveform (i.g. clicks or drags on it) */
|
|
118
|
-
interaction: [newTime: number];
|
|
119
|
-
/** When the user clicks on the waveform */
|
|
120
|
-
click: [relativeX: number, relativeY: number];
|
|
121
|
-
/** When the user double-clicks on the waveform */
|
|
122
|
-
dblclick: [relativeX: number, relativeY: number];
|
|
123
|
-
/** When the user drags the cursor */
|
|
124
|
-
drag: [relativeX: number];
|
|
125
|
-
/** When the user starts dragging the cursor */
|
|
126
|
-
dragstart: [relativeX: number];
|
|
127
|
-
/** When the user ends dragging the cursor */
|
|
128
|
-
dragend: [relativeX: number];
|
|
129
|
-
/** When the waveform is scrolled (panned) */
|
|
130
|
-
scroll: [visibleStartTime: number, visibleEndTime: number, scrollLeft: number, scrollRight: number];
|
|
131
|
-
/** When the zoom level changes */
|
|
132
|
-
zoom: [minPxPerSec: number];
|
|
133
|
-
/** Just before the waveform is destroyed so you can clean up your events */
|
|
134
|
-
destroy: [];
|
|
135
|
-
/** When source file is unable to be fetched, decoded, or an error is thrown by media element */
|
|
136
|
-
error: [error: Error];
|
|
137
|
-
};
|
|
138
|
-
declare class WaveSurfer extends Player<WaveSurferEvents> {
|
|
139
|
-
options: WaveSurferOptions & typeof defaultOptions;
|
|
140
|
-
private renderer;
|
|
141
|
-
private timer;
|
|
142
|
-
private plugins;
|
|
143
|
-
private decodedData;
|
|
144
|
-
protected subscriptions: Array<() => void>;
|
|
145
|
-
protected mediaSubscriptions: Array<() => void>;
|
|
146
|
-
protected abortController: AbortController | null;
|
|
147
|
-
static readonly BasePlugin: typeof BasePlugin;
|
|
148
|
-
static readonly dom: typeof dom;
|
|
149
|
-
/** Create a new WaveSurfer instance */
|
|
150
|
-
static create(options: WaveSurferOptions): WaveSurfer;
|
|
151
|
-
/** Create a new WaveSurfer instance */
|
|
152
|
-
constructor(options: WaveSurferOptions);
|
|
153
|
-
private updateProgress;
|
|
154
|
-
private initTimerEvents;
|
|
155
|
-
private initPlayerEvents;
|
|
156
|
-
private initRendererEvents;
|
|
157
|
-
private initPlugins;
|
|
158
|
-
private unsubscribePlayerEvents;
|
|
159
|
-
/** Set new wavesurfer options and re-render it */
|
|
160
|
-
setOptions(options: Partial<WaveSurferOptions>): void;
|
|
161
|
-
/** Register a wavesurfer.js plugin */
|
|
162
|
-
registerPlugin<T extends GenericPlugin>(plugin: T): T;
|
|
163
|
-
/** For plugins only: get the waveform wrapper div */
|
|
164
|
-
getWrapper(): HTMLElement;
|
|
165
|
-
/** For plugins only: get the scroll container client width */
|
|
166
|
-
getWidth(): number;
|
|
167
|
-
/** Get the current scroll position in pixels */
|
|
168
|
-
getScroll(): number;
|
|
169
|
-
/** Set the current scroll position in pixels */
|
|
170
|
-
setScroll(pixels: number): void;
|
|
171
|
-
/** Move the start of the viewing window to a specific time in the audio (in seconds) */
|
|
172
|
-
setScrollTime(time: number): void;
|
|
173
|
-
/** Get all registered plugins */
|
|
174
|
-
getActivePlugins(): GenericPlugin[];
|
|
175
|
-
private loadAudio;
|
|
176
|
-
/** Load an audio file by URL, with optional pre-decoded audio data */
|
|
177
|
-
load(url: string, channelData?: WaveSurferOptions['peaks'], duration?: number): Promise<void>;
|
|
178
|
-
/** Load an audio blob */
|
|
179
|
-
loadBlob(blob: Blob, channelData?: WaveSurferOptions['peaks'], duration?: number): Promise<void>;
|
|
180
|
-
/** Zoom the waveform by a given pixels-per-second factor */
|
|
181
|
-
zoom(minPxPerSec: number): void;
|
|
182
|
-
/** Get the decoded audio data */
|
|
183
|
-
getDecodedData(): AudioBuffer | null;
|
|
184
|
-
/** Get decoded peaks */
|
|
185
|
-
exportPeaks({ channels, maxLength, precision }?: {
|
|
186
|
-
channels?: number | undefined;
|
|
187
|
-
maxLength?: number | undefined;
|
|
188
|
-
precision?: number | undefined;
|
|
189
|
-
}): Array<number[]>;
|
|
190
|
-
/** Get the duration of the audio in seconds */
|
|
191
|
-
getDuration(): number;
|
|
192
|
-
/** Toggle if the waveform should react to clicks */
|
|
193
|
-
toggleInteraction(isInteractive: boolean): void;
|
|
194
|
-
/** Jump to a specific time in the audio (in seconds) */
|
|
195
|
-
setTime(time: number): void;
|
|
196
|
-
/** Seek to a percentage of audio as [0..1] (0 = beginning, 1 = end) */
|
|
197
|
-
seekTo(progress: number): void;
|
|
198
|
-
/** Play or pause the audio */
|
|
199
|
-
playPause(): Promise<void>;
|
|
200
|
-
/** Stop the audio and go to the beginning */
|
|
201
|
-
stop(): void;
|
|
202
|
-
/** Skip N or -N seconds from the current position */
|
|
203
|
-
skip(seconds: number): void;
|
|
204
|
-
/** Empty the waveform */
|
|
205
|
-
empty(): void;
|
|
206
|
-
/** Set HTML media element */
|
|
207
|
-
setMediaElement(element: HTMLMediaElement): void;
|
|
208
|
-
/**
|
|
209
|
-
* Export the waveform image as a data-URI or a blob.
|
|
210
|
-
*
|
|
211
|
-
* @param format The format of the exported image, can be `image/png`, `image/jpeg`, `image/webp` or any other format supported by the browser.
|
|
212
|
-
* @param quality The quality of the exported image, for `image/jpeg` or `image/webp`. Must be between 0 and 1.
|
|
213
|
-
* @param type The type of the exported image, can be `dataURL` (default) or `blob`.
|
|
214
|
-
* @returns A promise that resolves with an array of data-URLs or blobs, one for each canvas element.
|
|
215
|
-
*/
|
|
216
|
-
exportImage(format: string, quality: number, type: 'dataURL'): Promise<string[]>;
|
|
217
|
-
exportImage(format: string, quality: number, type: 'blob'): Promise<Blob[]>;
|
|
218
|
-
/** Unmount wavesurfer */
|
|
219
|
-
destroy(): void;
|
|
220
|
-
}
|
|
221
|
-
export default WaveSurfer;
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import EventEmitter from './event-emitter.js';
|
|
2
|
-
type WebAudioPlayerEvents = {
|
|
3
|
-
loadedmetadata: [];
|
|
4
|
-
canplay: [];
|
|
5
|
-
play: [];
|
|
6
|
-
pause: [];
|
|
7
|
-
seeking: [];
|
|
8
|
-
timeupdate: [];
|
|
9
|
-
volumechange: [];
|
|
10
|
-
emptied: [];
|
|
11
|
-
ended: [];
|
|
12
|
-
};
|
|
13
|
-
/**
|
|
14
|
-
* A Web Audio buffer player emulating the behavior of an HTML5 Audio element.
|
|
15
|
-
*/
|
|
16
|
-
declare class WebAudioPlayer extends EventEmitter<WebAudioPlayerEvents> {
|
|
17
|
-
private audioContext;
|
|
18
|
-
private gainNode;
|
|
19
|
-
private bufferNode;
|
|
20
|
-
private playStartTime;
|
|
21
|
-
private playedDuration;
|
|
22
|
-
private _muted;
|
|
23
|
-
private _playbackRate;
|
|
24
|
-
private _duration;
|
|
25
|
-
private buffer;
|
|
26
|
-
currentSrc: string;
|
|
27
|
-
paused: boolean;
|
|
28
|
-
crossOrigin: string | null;
|
|
29
|
-
seeking: boolean;
|
|
30
|
-
autoplay: boolean;
|
|
31
|
-
constructor(audioContext?: AudioContext);
|
|
32
|
-
/** Subscribe to an event. Returns an unsubscribe function. */
|
|
33
|
-
addEventListener: <EventName extends keyof WebAudioPlayerEvents>(event: EventName, listener: (...args: WebAudioPlayerEvents[EventName]) => void, options?: {
|
|
34
|
-
once?: boolean;
|
|
35
|
-
}) => () => void;
|
|
36
|
-
/** Unsubscribe from an event */
|
|
37
|
-
removeEventListener: <EventName extends keyof WebAudioPlayerEvents>(event: EventName, listener: (...args: WebAudioPlayerEvents[EventName]) => void) => void;
|
|
38
|
-
load(): Promise<void>;
|
|
39
|
-
get src(): string;
|
|
40
|
-
set src(value: string);
|
|
41
|
-
private _play;
|
|
42
|
-
private _pause;
|
|
43
|
-
play(): Promise<void>;
|
|
44
|
-
pause(): void;
|
|
45
|
-
stopAt(timeSeconds: number): void;
|
|
46
|
-
setSinkId(deviceId: string): Promise<void>;
|
|
47
|
-
get playbackRate(): number;
|
|
48
|
-
set playbackRate(value: number);
|
|
49
|
-
get currentTime(): number;
|
|
50
|
-
set currentTime(value: number);
|
|
51
|
-
get duration(): number;
|
|
52
|
-
set duration(value: number);
|
|
53
|
-
get volume(): number;
|
|
54
|
-
set volume(value: number);
|
|
55
|
-
get muted(): boolean;
|
|
56
|
-
set muted(value: boolean);
|
|
57
|
-
canPlayType(mimeType: string): boolean;
|
|
58
|
-
/** Get the GainNode used to play the audio. Can be used to attach filters. */
|
|
59
|
-
getGainNode(): GainNode;
|
|
60
|
-
/** Get decoded audio */
|
|
61
|
-
getChannelData(): Float32Array[];
|
|
62
|
-
}
|
|
63
|
-
export default WebAudioPlayer;
|