Options
All
  • Public
  • Public/Protected
  • All
Menu

A thin wrapper around a Howl object with:

  • Handling of callbacks when the sound is not yet loaded.
  • Automatic clamping when calling setRate to ensure a valid value is passed to Howler.js.
  • Automatic clamping when calling setVolume so that the volume is always between 0 and 1.
memberof

gdjs

Hierarchy

  • HowlerSound

Index

Constructors

  • new HowlerSound(howl: Howl, volume: number, loop: boolean, rate: number): HowlerSound
  • Parameters

    • howl: Howl
    • volume: number
    • loop: boolean
    • rate: number

    Returns HowlerSound

Methods

  • fade(from: number, to: number, duration: number): HowlerSound
  • Fade the volume sound.

    Parameters

    • from: number
    • to: number
    • duration: number

    Returns HowlerSound

    The current instance for chaining.

  • getLoop(): boolean
  • Get if the sound is looping.

    Returns boolean

  • getMute(): boolean
  • Get if the sound is muted.

    Returns boolean

  • getRate(): number
  • Get the sound playback rate. This 1 for the default speed. This value is not clamped (any value greater than 0 is valid), but the underlying audio system might not play the sound at the required rate if it's very low or very high.

    Returns number

  • getSeek(): number
  • Get the sound seek.

    Returns number

  • getSpatialPosition(axis: "x" | "y" | "z"): number
  • Get the sound spatial position.

    Parameters

    • axis: "x" | "y" | "z"

    Returns number

  • getVolume(): number
  • Get the sound volume.

    Returns number

    A float from 0 to 1.

  • isLoaded(): boolean
  • Returns true if the associated howl is fully loaded.

    Returns boolean

  • off(event: HowlEvent, handler: HowlCallback): HowlerSound
  • Removes an event listener to the howl.

    Parameters

    • event: HowlEvent
    • handler: HowlCallback

    Returns HowlerSound

  • on(event: HowlEvent, handler: HowlCallback): HowlerSound
  • Adds an event listener to the howl.

    Parameters

    • event: HowlEvent
    • handler: HowlCallback

    Returns HowlerSound

  • once(event: HowlEvent, handler: HowlCallback): HowlerSound
  • Adds an event listener to the howl that removes itself after being called. If the event is play and the sound is being played, the handler is called synchronously.

    Parameters

    • event: HowlEvent
    • handler: HowlCallback

    Returns HowlerSound

  • Pauses playback of the sound, saving the seek of playback.

    Returns HowlerSound

    The current instance for chaining.

  • paused(): boolean
  • Check if the sound is currently paused.

    Returns boolean

  • Begins playback of the sound, or if the Howl is still loading, schedule playing for once it loads.

    Returns HowlerSound

    The current instance for chaining.

  • playing(): boolean
  • Check if the sound is currently playing. Note that a loading sound is considered as playing (as it will be played as soon as it's loaded). To avoid loading at runtime, prefer to preload the sounds.

    Returns boolean

  • Set if the sound is looping.

    Parameters

    • loop: boolean

    Returns HowlerSound

    The current instance for chaining.

  • Set if the sound is muted.

    Parameters

    • mute: boolean

    Returns HowlerSound

    The current instance for chaining.

  • Set the playback rate. This value is not clamped (any value greater than 0 is valid), but the underlying audio system might not play the sound at the required rate if it's very low or very high.

    Parameters

    • rate: number

    Returns HowlerSound

    The current instance for chaining.

  • Set the sound seek.

    Parameters

    • seek: number

    Returns HowlerSound

    The current instance for chaining.

  • setSpatialPosition(x: number, y: number, z: number): HowlerSound
  • Set the sound spatial position.

    Parameters

    • x: number
    • y: number
    • z: number

    Returns HowlerSound

    The current instance for chaining.

  • Set the sound volume.

    Parameters

    • volume: number

      A float from 0 to 1. The value is clamped if too high or too low.

    Returns HowlerSound

    The current instance for chaining.

  • Stops playback of the sound, resetting seek to 0.

    Returns HowlerSound

    The current instance for chaining.

  • stopped(): boolean
  • Check if the sound is currently stopped.

    Returns boolean

Generated using TypeDoc