Skip to content
Evandro Leopoldino Gonçalves edited this page Jul 13, 2020 · 1 revision

To listen to an event, use the following method:

audio.on(eventType: string, callback: (param: { data: any }) => void)

Event Types

  • ready
    Triggered after the audio file has been loaded and decoded.
    data returns a AudioBuffer with the following properties:

    • duration: a float representing the sample rate, in samples per second, of the PCM data stored in the buffer.
    • length: an integer representing the length, in sample-frames, of the PCM data stored in the buffer.
    • numberOfChannels: a double representing the duration, in seconds, of the PCM data stored in the buffer.
    • sampleRate: an integer representing the number of discrete audio channels described by the PCM data stored in the buffer.
  • start
    Triggered as soon as the audio is played for the first time.

  • state Fires when the audio context's state changes. data returns the possible values:

    • suspended: the audio has been suspended.
    • running: the audio is running.
    • closed: the audio has been closed.