summaryrefslogtreecommitdiff
path: root/packages/frontend/src/scripts/sound.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/frontend/src/scripts/sound.ts')
-rw-r--r--packages/frontend/src/scripts/sound.ts4
1 files changed, 4 insertions, 0 deletions
diff --git a/packages/frontend/src/scripts/sound.ts b/packages/frontend/src/scripts/sound.ts
index 05f82fce7d..2008afe045 100644
--- a/packages/frontend/src/scripts/sound.ts
+++ b/packages/frontend/src/scripts/sound.ts
@@ -93,6 +93,10 @@ export async function loadAudio(url: string, options?: { useCache?: boolean; })
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (ctx == null) {
ctx = new AudioContext();
+
+ window.addEventListener('beforeunload', () => {
+ ctx.close();
+ });
}
if (options?.useCache ?? true) {
if (cache.has(url)) {