-
Notifications
You must be signed in to change notification settings - Fork 2
/
AudioState.ts
26 lines (23 loc) · 1013 Bytes
/
AudioState.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
export type ActiveAudioClipState =
| { type: 'paused' }
| { type: 'pause_requested'; fade: number | undefined } // Pause has been requested but clip is in process of playing, and will be paused once it starts playing
| { type: 'pausing' } // Clip is currently pausing with a fade
| { type: 'playing' }
| { type: 'play_requested' } // Play has been requested but clip hasn't actually started playing yet
| { type: 'stopping' } // Clip is currently stopping with a fade
| { type: 'stop_requested'; fade: number | undefined }; // Stop has been requested but clip is in process of playing, and will be stopped once it starts playing
export interface AudioClip {
config: { preload: boolean; ephemeral: boolean };
activeClips: { [soundId: number]: ActiveClip };
}
export interface ActiveClip {
state: ActiveAudioClipState;
loop: boolean;
volume: number;
playId: string;
}
export interface AudioState {
isPlaying: boolean;
globalVolume: number;
clips: { [path: string]: AudioClip };
}