summaryrefslogtreecommitdiff
path: root/packages/frontend/src/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/frontend/src/scripts')
-rw-r--r--packages/frontend/src/scripts/sound.ts5
1 files changed, 4 insertions, 1 deletions
diff --git a/packages/frontend/src/scripts/sound.ts b/packages/frontend/src/scripts/sound.ts
index 47ec4171af..d28d629227 100644
--- a/packages/frontend/src/scripts/sound.ts
+++ b/packages/frontend/src/scripts/sound.ts
@@ -5,7 +5,7 @@
import { defaultStore } from '@/store.js';
-const ctx = new AudioContext();
+let ctx: AudioContext;
const cache = new Map<string, AudioBuffer>();
let canPlay = true;
@@ -65,6 +65,9 @@ export const soundsTypes = [
] as const;
export async function loadAudio(file: string, useCache = true) {
+ if (ctx == null) {
+ ctx = new AudioContext();
+ }
if (useCache && cache.has(file)) {
return cache.get(file)!;
}