ProtectedscopeStatic ReadonlyBaseStatic ReadonlydefineDefine a functional wavesurfer plugin from a setup function.
setup runs once per (re-)init on a fresh Scope; whatever it returns is
merged onto the plugin instance as its public API. Resources registered
via ctx.scope.add(...) are torn down when the plugin is destroyed.
Api methods only exist on the instance after _init() has run (i.e.
after wavesurfer.registerPlugin(...)); accessing them beforehand is
undefined behavior. Symmetrically: calling an api method AFTER the
plugin has been destroyed is also undefined behavior — ctx.wavesurfer
is typed non-null, but destroy() sets the underlying field to
undefined, so a post-destroy read returns undefined at runtime
despite the type.
new Plugin(options) / Plugin.create(options): the options argument
is optional when (and only when) Options has no required properties
(see PluginCtorArgs below) — same ergonomics a hand-written
constructor(options?: Options) would give. When it's omitted, setup
is called with options === undefined, not {}; a setup for an
all-optional Options type must default it itself (e.g.
Object.assign({}, defaultOptions, options)), exactly as it already had
to for any individually-omitted field.
Static ReadonlydomUnmount wavesurfer. Terminal: the instance is not usable afterwards -- load()/loadBlob() reject, registerPlugin() throws, and everything else is a safe no-op. Create a new instance instead of reusing a destroyed one.
ProtectedemitEmit an event
Empty the waveform
Export the waveform image as a data-URI or a blob.
The format of the exported image, can be image/png, image/jpeg, image/webp or any other format supported by the browser.
The quality of the exported image, for image/jpeg or image/webp. Must be between 0 and 1.
The type of the exported image, can be dataURL (default) or blob.
A promise that resolves with an array of data-URLs or blobs, one for each canvas element.
Export the waveform image as a data-URI or a blob.
The format of the exported image, can be image/png, image/jpeg, image/webp or any other format supported by the browser.
The quality of the exported image, for image/jpeg or image/webp. Must be between 0 and 1.
The type of the exported image, can be dataURL (default) or blob.
A promise that resolves with an array of data-URLs or blobs, one for each canvas element.
Get all registered plugins
Get the current audio position in seconds
Get the decoded audio data
Get the duration of the audio in seconds
Get the HTML media element.
Returns null under the WebAudio backend (i.e. when the current media is
a WebAudioPlayer -- either backend: 'WebAudio' or a user-supplied
WebAudioPlayer), which has no HTML media element. Breaking change in v8:
previously the WebAudioPlayer itself was returned, mistyped as an
HTMLMediaElement.
Get the audio muted state
Get the playback speed
Get the renderer instance for plugin access to reactive streams
Get the current scroll position in pixels
Get the reactive state for advanced use cases
Get the audio volume
For plugins only: get the scroll container client width
For plugins only: get the waveform wrapper div
Check if the audio is playing
Check if the audio is seeking
Load an audio file by URL, with optional pre-decoded audio data. If a newer load()/loadBlob() supersedes this call before it completes, the returned promise rejects with an AbortError DOMException (and no 'error' event is emitted for it).
OptionalchannelData: (Float32Array<ArrayBufferLike> | number[])[]Optionalduration: numberLoad an audio blob. If a newer load()/loadBlob() supersedes this call before it completes, the returned promise rejects with an AbortError DOMException (and no 'error' event is emitted for it).
OptionalchannelData: (Float32Array<ArrayBufferLike> | number[])[]Optionalduration: numberSubscribe to an event. Returns an unsubscribe function.
Optionaloptions: { once?: boolean }Subscribe to an event only once
Pause the audio
Start playing the audio
Optionalstart: numberOptionalend: numberPlay or pause the audio
Seek to a ratio of audio as [0..1] (0 = beginning, 1 = end)
Set HTML media element
Mute or unmute the audio
Set new wavesurfer options and re-render it
Set the playback speed, pass an optional false to NOT preserve the pitch
OptionalpreservePitch: booleanSet the current scroll position in pixels
Move the start of the viewing window to a specific time in the audio (in seconds)
Set a sink id to change the audio output device
Jump to a specific time in the audio (in seconds)
Set the audio volume
Skip N or -N seconds from the current position
Stop the audio and go to the beginning
Toggle if the waveform should react to clicks
Unsubscribe from an event
Clear all events
Unregister a wavesurfer.js plugin
Zoom the waveform by a given pixels-per-second factor
Staticcreate
Create a new WaveSurfer instance