Nocturna
    Preparing search index...

    Class NocturnaAudio

    NocturnaAudio manages all audio playback in Nocturna using Babylon.js's audio engine.

    Responsibilities:

    • Implements the singleton pattern to ensure only one audio manager exists.
    • Initializes and unlocks the Babylon.js audio engine.
    • Handles background music playback, including play, stop, resume, mute, and volume control.
    • Ensures background music is properly disposed and replaced when changed.

    Usage:

    • Use await NocturnaAudio.getInstance() to get the singleton instance.
    • Use setBackgroundMusic to play or change background music.
    • Use muteBackgroundMusic, stopBackgroundMusic, resumeBackgroundMusic, and setVolume for playback control.
    Index

    Methods

    • Mutes or unmutes the background music.

      Parameters

      • mute: boolean

        True to mute, false to unmute.

      Returns void

    • Resumes the background music playback if paused.

      Returns void

    • Plays or changes the background music. Disposes the previous background music if it exists.

      Parameters

      • musicUrl: string

        The URL of the music file to play.

      • Optionalvolume: number

      Returns Promise<void>

    • Sets the global audio engine volume.

      Parameters

      • volume: number

        The volume level (0.0 to 1.0).

      Returns void

    • Stops the background music playback.

      Returns void

    • Unlocks the audio engine (required by some browsers before playback).

      Returns Promise<void>