Menu

Class WebAudioPlayer

Audio player built around the Web Audio API

Capable of playing PCM streams, with volume adjustment and an optional equalizer. Only available in browser contexts

Hierarchy

  • WebAudioPlayer

Index

Constructors

constructor

Properties

analyser

analyser: AnalyserNode

ctx

ctx: AudioContext

Audio context, see AudioContext

eqSettings

eqSettings: [number, number][] = [[31.25, 4.1],[62.5, 1.2],[125, 0],[250, -4.1],[500, -2.3],[1000, 0.5],[2000, 6.5],[8000, 5.1],[16000, 5.1]]

Default equalizer settings. Credit to Sudomemo for these

sampleRate

sampleRate: number

Audio sample rate

useAnalyser

useAnalyser: boolean = false

Whether to connect the output to an audio analyser (see analyser)

useEq

useEq: boolean = false

Whether the audio is being run through an equalizer or not

Accessors

loop

  • get loop(): boolean
  • set loop(value: boolean): void

volume

  • get volume(): number
  • set volume(value: number): void

Methods

destroy

  • destroy(): Promise<void>

getCurrentTime

  • getCurrentTime(): number

playFrom

  • playFrom(currentTime: number): void
  • Begin playback from a specific point

    Note that the WebAudioPlayer doesn't keep track of audio playback itself. We rely on the Player API for that.

    Parameters

    • currentTime: number

      initial playback position, in seconds

    Returns void

setAnalyserEnabled

  • setAnalyserEnabled(on: boolean): void

setBuffer

setVolume

  • setVolume(value: number): void

stop

  • stop(): void