UNPKG

narraleaf-react

Version:

A React visual novel player framework

49 lines (48 loc) 1.93 kB
import { Sound as SoundElement, SoundType } from "../../nlcore/elements/sound"; import { FadeOptions } from "../../nlcore/elements/type"; import { Awaitable } from "../../../util/data"; import { GameState } from "../gameState"; import { LogicAction } from "../../nlcore/action/logicAction"; export type AudioDataRaw = { isPlaying: boolean; position: number; }; export type AudioManagerDataRaw = { sounds: [string, AudioDataRaw][]; groups: [SoundType, number][]; }; export declare class AudioManager { private gameState; private state; private channels; private channelVolumes; private globalVolume; private sound; private ready; private isReady; constructor(gameState: GameState); /** * Must be called ONCE on the client side to prepare audio subsystem. * Doing it here avoids "AudioContext is not defined" on the server. */ initialize(): void; play(sound: SoundElement, options?: FadeOptions): Awaitable<void>; stop(sound: SoundElement, duration?: number): Awaitable<void>; setVolume(sound: SoundElement, volume: number, duration?: number): Awaitable<void>; pause(sound: SoundElement, duration?: number): Awaitable<void>; resume(sound: SoundElement, duration?: number): Awaitable<void>; setRate(sound: SoundElement, rate: number): Awaitable<void>; getPosition(sound: SoundElement): number; isPlaying(sound: SoundElement): boolean; toData(): AudioManagerDataRaw; fromData(data: AudioManagerDataRaw, elementMap: Map<string, LogicAction.GameElement>): this; soundFromData(sound: SoundElement, data: AudioDataRaw): void; isManaged(sound: SoundElement): boolean; reset(): void; setGroupVolume(type: SoundType, volume: number): void; setGlobalVolume(volume: number): void; getGlobalVolume(): number; getGroupVolume(type: SoundType): number; destroy(): void; private setupGroupVolume; }