@game-vir/audio - v15.1.1
    Preparing search index...

    Class AudioPlayer<Files>

    An audio manager which handles keeping track of, loading, and playing multiple audio files.

    Type Parameters

    Hierarchy

    Index

    Constructors

    • Type Parameters

      • const Files extends Readonly<
            Readonly<
                Record<
                    string,
                    Readonly<
                        Pick<
                            Readonly<
                                { sources: readonly AudioFileSource[] } & PartialWithUndefined<
                                    {
                                        audioCache: AudioFileCache;
                                        audioContext: BaseAudioContext;
                                        createEffects: (
                                            audioContext: BaseAudioContext,
                                        ) => (...) | (...) | (...);
                                        fetch: (url: string) => Promise<(...)>;
                                        loadOnPlay: boolean;
                                        outputNode: AudioNode;
                                        volume: number;
                                    },
                                >,
                            >,
                            "fetch"
                            | "volume"
                            | "createEffects"
                            | "sources",
                        >,
                    >,
                >,
            >,
        >

      Parameters

      Returns AudioPlayer<Files>

    Properties

    audioCache: AudioFileCache = {}
    audioContext: AudioContext = ...
    audioFiles: Partial<Record<keyof Files, AudioFile>> = {}
    gainNode: GainNode

    Controls volume for all audio files. Modify gain.value on this to change playback volume.

    initFiles: Readonly<Files>
    isAudioAllowed: boolean = ...

    If true, indicates that an internal AudioFile instance has detected that the current browser session is allowing audio playback. Most browsers these days block audio on initial page load until the user has interacted with the page.

    isDestroyed: boolean = ...
    options: Readonly<PartialWithUndefined<AudioPlayerOptions>> = {}
    outputNode: AudioNode
    play: Record<keyof Files, () => Promise<boolean>>

    Play a specific audio file.

    Methods

    • Load all audio files at once.

      Parameters

      Returns Promise<
          Record<
              keyof {
                  [Prop in string
                  | number
                  | symbol as InnerMappedValues<Readonly<Files>, true>[Prop] extends true
                      ? Prop
                      : never]: Prop
              },
              AudioFile,
          >,
      >