Class SoundPlayer<T>

Use this to play sounds. If you want to position your sounds, use a SoundSource instead.

Type Parameters

Hierarchy (view full)

Constructors

Properties

channels: Map<string, AudioBufferSourceNode> = ...

All sounds played on a channel.

node: T

The destination node to connect AudioBufferSourceNode AudioBufferSourceNodes to. In the case of a SoundSource, this will be the panner node.

sounds: AudioBufferSourceNode[] = []

All free sounds (those not played on a channel).

Methods

  • Will be called when an AudioBufferSourceNode ended.

    Parameters

    Returns void

  • Play an audio buffer on a channel. If an AudioBufferSourceNode is already running on the specified channel, it will be stopped first.

    Parameters

    • channel: string

      The channel to play the buffer on.

    • audioBuffer: AudioBuffer

      The buffer to play.

    • Optional options: PlayOptions

      The options to apply on playback.

    Returns AudioBufferSourceNode

    A new AudioBufferSourceNode.

  • Stop the AudioBufferSourceNode on a channel if any is currently playing.

    Parameters

    • channel: string

      The channel to stop.

    Returns void