Skip to main content

WebAudioInstance

Internal class representing a Web Audio AudioBufferSourceNode instance

@see

Implements

Index

Constructors

constructor

Accessors

publicduration

  • get duration(): number
  • set duration(duration: number): void
  • Returns the set duration to play, otherwise returns the total duration if unset


    Returns number

  • Set the duration that this audio should play.

    Note: if you seek to a specific point the duration will start from that point, for example

    If you have a 10 second clip, seek to 5 seconds, then set the duration to 2, it will play the clip from 5-7 seconds.


    Parameters

    • duration: number

    Returns void

publicloop

  • get loop(): boolean
  • set loop(value: boolean): void
  • Whether the audio should loop (repeat forever)


    Returns boolean

  • Whether the audio should loop (repeat forever)


    Parameters

    • value: boolean

    Returns void

publicplaybackRate

  • get playbackRate(): number
  • set playbackRate(playbackRate: number): void
  • Set the playbackRate, default is 1.0 at normal speed. For example 2.0 is double speed, and 0.5 is half speed.


    Returns number

  • Set the playbackRate, default is 1.0 at normal speed. For example 2.0 is double speed, and 0.5 is half speed.


    Parameters

    • playbackRate: number

    Returns void

publicvolume

  • get volume(): number
  • set volume(value: number): void
  • The volume (between 0 and 1)


    Returns number

  • The volume (between 0 and 1)


    Parameters

    • value: number

    Returns void

Methods

publicgetPlaybackPosition

  • getPlaybackPosition(): number
  • Return the current playback time of the playing track in seconds from the start


    Returns number

publicgetTotalPlaybackDuration

  • getTotalPlaybackDuration(): number
  • Return the duration of the sound


    Returns number

publicisPaused

  • isPaused(): boolean
  • Returns if the audio is paused


    Returns boolean

publicisPlaying

  • isPlaying(): boolean
  • Whether or not any audio is playing


    Returns boolean

publicisStopped

  • isStopped(): boolean
  • Returns if the audio is stopped


    Returns boolean

publicpause

  • pause(): void
  • Pause the sound


    Returns void

publicplay

  • play(playStarted?: () => any): Promise<boolean>
  • Will play the sound or resume if paused


    Parameters

    • playStarted: () => any = ...

    Returns Promise<boolean>

publicseek

  • seek(position: number): void
  • Seek to a position (in seconds) in the audio


    Parameters

    • position: number

    Returns void

publicstop

  • stop(): void
  • Stop playing the sound and reset


    Returns void