forked from phenom/healer-man
Release Healer Man 0.1.4
This commit is contained in:
1 parent
5bb170039a
commit
f4c9cf356c
63 files changed
+2694
-81
No files matched your search
@@ -121,14 +121,32 @@ export function manastormCueForStatusTransition(
|
||||
}
|
||||
|
||||
function browserAudioFactory(url: string): ManastormAudioHandle {
|
||||
return new Audio(url);
|
||||
let stopPlayback: (() => void) | null = null;
|
||||
let stopped = false;
|
||||
const handle: ManastormAudioHandle = {
|
||||
currentTime: 0,
|
||||
preload: "auto",
|
||||
volume: 1,
|
||||
pause: () => {
|
||||
stopped = true;
|
||||
stopPlayback?.();
|
||||
stopPlayback = null;
|
||||
},
|
||||
play: async () => {
|
||||
stopped = false;
|
||||
const stop = await playMasterAudioCue(url, handle.volume);
|
||||
if (!stop) throw new Error("Web Audio is unavailable.");
|
||||
if (stopped) stop();
|
||||
else stopPlayback = stop;
|
||||
},
|
||||
};
|
||||
return handle;
|
||||
}
|
||||
|
||||
export async function playManastormClientCue(
|
||||
cueId: ManastormPortalCueId,
|
||||
audioFactory: ManastormAudioFactory = browserAudioFactory,
|
||||
): Promise<boolean> {
|
||||
if (audioFactory === browserAudioFactory && typeof Audio === "undefined") return false;
|
||||
const cue = manastormPortalAudioCue(cueId);
|
||||
try {
|
||||
activeAudio?.pause();
|
||||
@@ -149,3 +167,4 @@ export function stopManastormClientCue(): void {
|
||||
activeAudio?.pause();
|
||||
activeAudio = null;
|
||||
}
|
||||
import { playMasterAudioCue } from "./combatAudio";
|
||||
Reference in new issue
Block a user