Hierarchy

Constructors

Properties

abortController: null | AbortController = null
decodedData: null | AudioBuffer = null
media: HTMLMediaElement
mediaSubscriptions: (() => void)[] = []

Type declaration

    • (): void
    • Returns void

options: WaveSurferOptions & {
    autoCenter: boolean;
    autoScroll: boolean;
    cursorWidth: number;
    dragToSeek: boolean;
    fillParent: boolean;
    interact: boolean;
    minPxPerSec: number;
    progressColor: string;
    sampleRate: number;
    waveColor: string;
}

Type declaration

  • autoCenter: boolean
  • autoScroll: boolean
  • cursorWidth: number
  • dragToSeek: boolean
  • fillParent: boolean
  • interact: boolean
  • minPxPerSec: number
  • progressColor: string
  • sampleRate: number
  • waveColor: string
plugins: GenericPlugin[] = []
renderer: Renderer
subscriptions: (() => void)[] = []

Type declaration

    • (): void
    • Returns void

timer: Timer
BasePlugin: typeof BasePlugin = BasePlugin
dom: __module = dom

Methods

  • Unmount wavesurfer

    Returns void

  • Emit an event

    Type Parameters

    Parameters

    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.

  • Parameters

    • format: string
    • quality: number
    • type: "blob"

    Returns Promise<Blob[]>

  • Get decoded peaks

    Parameters

    • __namedParameters: {
          channels: undefined | number;
          maxLength: undefined | number;
          precision: undefined | number;
      } = {}
      • channels: undefined | number
      • maxLength: undefined | number
      • precision: undefined | number

    Returns number[][]

  • Get all registered plugins

    Returns GenericPlugin[]

  • Get the current audio position in seconds

    Returns number

  • Get the decoded audio data

    Returns null | AudioBuffer

  • Get the duration of the audio in seconds

    Returns number

  • Get the HTML media element

    Returns HTMLMediaElement

  • Get the audio muted state

    Returns boolean

  • Get the playback speed

    Returns number

  • Get the current scroll position in pixels

    Returns number

  • Returns string

  • 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

    Parameters

    • url: string
    • Optional channelData: (Float32Array | number[])[]
    • Optional duration: number

    Returns Promise<void>

  • Parameters

    • url: string
    • Optional blob: Blob
    • Optional channelData: (Float32Array | number[])[]
    • Optional duration: number

    Returns Promise<void>

  • Load an audio blob

    Parameters

    • blob: Blob
    • Optional channelData: (Float32Array | number[])[]
    • Optional duration: number

    Returns Promise<void>

  • Subscribe to an event. Returns an unsubscribe function.

    Type Parameters

    Parameters

    • event: EventName
    • listener: EventListener<WaveSurferEvents, EventName>
    • Optional options: {
          once?: boolean;
      }
      • Optional once?: boolean

    Returns (() => void)

      • (): void
      • Subscribe to an event. Returns an unsubscribe function.

        Returns void

  • Type Parameters

    • K extends keyof HTMLElementEventMap

    Parameters

    • event: K
    • callback: ((ev) => void)
        • (ev): void
        • Parameters

          • ev: HTMLElementEventMap[K]

          Returns void

    • Optional options: boolean | AddEventListenerOptions

    Returns (() => void)

      • (): void
      • Returns void

  • Subscribe to an event only once

    Type Parameters

    Parameters

    Returns (() => void)

      • (): void
      • Subscribe to an event only once

        Returns void

  • Pause the audio

    Returns void

  • Start playing the audio

    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 percentage 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 the playback speed, pass an optional false to NOT preserve the pitch

    Parameters

    • rate: number
    • Optional preservePitch: 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>

  • Parameters

    • url: string
    • Optional blob: Blob

    Returns 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

  • Unsubscribe from an event

    Type Parameters

    Parameters

    Returns void

  • Clear all events

    Returns void

  • Parameters

    • currentTime: number = ...

    Returns number

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

    Parameters

    • minPxPerSec: number

    Returns void

Generated using TypeDoc