summaryrefslogtreecommitdiff
path: root/packages/frontend/src/scripts/sound.ts
diff options
context:
space:
mode:
authorAcid Chicken (硫酸鶏) <root@acid-chicken.com>2023-11-26 14:38:34 +0900
committerGitHub <noreply@github.com>2023-11-26 14:38:34 +0900
commitccb951f11e8cc3c884eef799bef82d09f138d28c (patch)
tree042b72a29952413865649db553753931791ac785 /packages/frontend/src/scripts/sound.ts
parentfix(frontend): 通知音がほぼ同時に鳴った場合は再生をブロ... (diff)
downloadsharkey-ccb951f11e8cc3c884eef799bef82d09f138d28c.tar.gz
sharkey-ccb951f11e8cc3c884eef799bef82d09f138d28c.tar.bz2
sharkey-ccb951f11e8cc3c884eef799bef82d09f138d28c.zip
chore: create AudioContext when it is needed (#12460)
Diffstat (limited to 'packages/frontend/src/scripts/sound.ts')
-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)!;
}