From ccb951f11e8cc3c884eef799bef82d09f138d28c Mon Sep 17 00:00:00 2001 From: "Acid Chicken (硫酸鶏)" Date: Sun, 26 Nov 2023 14:38:34 +0900 Subject: chore: create AudioContext when it is needed (#12460) --- packages/frontend/src/scripts/sound.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'packages/frontend/src/scripts') 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(); 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)!; } -- cgit v1.2.3-freya