Gleam - v1.0.2
    Preparing search index...

    Class AudioBaseAbstract

    Shared registration, enable/disable, and teardown machinery for Sound and Music. Auto-subscribes to the "gameloopStopped" event so playback halts on loop teardown.

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    Accessors

    Methods

    Constructors

    Properties

    songs: Map<string, HTMLAudioElement> = ...

    Registered audio elements keyed by name. Subclasses read this; mutate via register.

    Accessors

    • get enabled(): boolean

      Whether playback is permitted. Setting to false invokes stop immediately.

      Returns boolean

    • set enabled(value: boolean): void

      Setting to false invokes stop immediately; subclasses (notably Music) may re-start playback when flipped back to true.

      Parameters

      • value: boolean

      Returns void

    Methods

    • Load and register one or more audio files. Each entry may be a bare URL string (the file's basename becomes the name) or a RegisterData object. Per-song volume falls back to defaultVolume. Call once per instance — throws on a second invocation, on non-finite volume, or on volume outside [0, 1]. Load failures are logged to console.error but don't throw.

      Parameters

      • defaultVolume: number = 1
      • ...songs: (string | RegisterData)[]

      Returns void

    • Base hook called when enabled flips to false and on "gameloopStopped". The default is a no-op; Sound and Music override it to cut playback. Subclass overrides should call super.stop().

      Returns void