wavesurfer.js
    Preparing search index...

    Class default

    Hierarchy

    Index
    options: WaveSurferOptions & {
        autoCenter: boolean;
        autoScroll: boolean;
        cursorWidth: number;
        dragToSeek: boolean;
        fillParent: boolean;
        interact: boolean;
        minPxPerSec: number;
        progressColor: string;
        sampleRate: number;
        waveColor: string;
    }
    scope: Scope = ...
    BasePlugin: typeof BasePlugin = BasePlugin
    definePlugin: <Options, Events extends BasePluginEvents, Api extends object>(
        name: string,
        setup: PluginSetup<Options, Events, Api>,
    ) => DefinedPlugin<Options, Events, Api> = definePlugin

    Type Declaration

      • <Options, Events extends BasePluginEvents, Api extends object>(
            name: string,
            setup: PluginSetup<Options, Events, Api>,
        ): DefinedPlugin<Options, Events, Api>
      • Define 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.

        Type Parameters

        • Options
        • Events extends BasePluginEvents
        • Api extends object

        Parameters

        Returns DefinedPlugin<Options, Events, Api>

    dom: __module = dom
    • Unmount 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.

      Returns void

    • Empty the waveform

      Returns void

    • Export the waveform image as a data-URI or a blob.

      Parameters

      • format: string

        The format of the exported image, can be image/png, image/jpeg, image/webp or any other format supported by the browser.

      • quality: number

        The quality of the exported image, for image/jpeg or image/webp. Must be between 0 and 1.

      • type: "dataURL"

        The type of the exported image, can be dataURL (default) or blob.

      Returns Promise<string[]>

      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.

      Parameters

      • format: string

        The format of the exported image, can be image/png, image/jpeg, image/webp or any other format supported by the browser.

      • quality: number

        The quality of the exported image, for image/jpeg or image/webp. Must be between 0 and 1.

      • type: "blob"

        The type of the exported image, can be dataURL (default) or blob.

      Returns Promise<Blob[]>

      A promise that resolves with an array of data-URLs or blobs, one for each canvas element.

    • Get decoded peaks

      Parameters

      • __namedParameters: { channels?: number; maxLength?: number; precision?: number } = {}

      Returns number[][]

    • Get all registered plugins

      Returns GenericPlugin[]

    • Get the current audio position in seconds

      Returns number

    • Get the decoded audio data

      Returns AudioBuffer | null

    • Get the duration of the audio in seconds

      Returns number

    • 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.

      Returns HTMLMediaElement | null

    • Get the audio muted state

      Returns boolean

    • Get the playback speed

      Returns number

    • Get the renderer instance for plugin access to reactive streams

      Returns Renderer

    • Get the current scroll position in pixels

      Returns number

    • Get the audio volume

      Returns number

    • For plugins only: get the scroll container client width

      Returns number

    • For plugins only: get the waveform wrapper div

      Returns HTMLElement

    • Check if the audio is playing

      Returns boolean

    • Check if the audio is seeking

      Returns boolean

    • 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).

      Parameters

      • url: string
      • OptionalchannelData: (Float32Array<ArrayBufferLike> | number[])[]
      • Optionalduration: number

      Returns Promise<void>

    • Load 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).

      Parameters

      • blob: Blob
      • OptionalchannelData: (Float32Array<ArrayBufferLike> | number[])[]
      • Optionalduration: number

      Returns Promise<void>

    • Pause the audio

      Returns void

    • Start playing the audio

      Parameters

      • Optionalstart: number
      • Optionalend: number

      Returns Promise<void>

    • Play or pause the audio

      Returns Promise<void>

    • Register a wavesurfer.js plugin

      Type Parameters

      • T extends GenericPlugin

      Parameters

      • plugin: T

      Returns T

    • Seek to a ratio of audio as [0..1] (0 = beginning, 1 = end)

      Parameters

      • progress: number

      Returns void

    • Set HTML media element

      Parameters

      • element: HTMLMediaElement

      Returns void

    • Mute or unmute the audio

      Parameters

      • muted: boolean

      Returns void

    • Set new wavesurfer options and re-render it

      Parameters

      Returns void

    • Set the playback speed, pass an optional false to NOT preserve the pitch

      Parameters

      • rate: number
      • OptionalpreservePitch: boolean

      Returns void

    • Set the current scroll position in pixels

      Parameters

      • pixels: number

      Returns void

    • Move the start of the viewing window to a specific time in the audio (in seconds)

      Parameters

      • time: number

      Returns void

    • Set a sink id to change the audio output device

      Parameters

      • sinkId: string

      Returns Promise<void>

    • Jump to a specific time in the audio (in seconds)

      Parameters

      • time: number

      Returns void

    • Set the audio volume

      Parameters

      • volume: number

      Returns void

    • Skip N or -N seconds from the current position

      Parameters

      • seconds: number

      Returns void

    • Stop the audio and go to the beginning

      Returns void

    • Toggle if the waveform should react to clicks

      Parameters

      • isInteractive: boolean

      Returns void

    • Clear all events

      Returns void

    • Unregister a wavesurfer.js plugin

      Parameters

      • plugin: GenericPlugin

      Returns void

    • Zoom the waveform by a given pixels-per-second factor

      Parameters

      • minPxPerSec: number

      Returns void