From 1dd79161fb8ef268af4314c38358eb173f70f697 Mon Sep 17 00:00:00 2001 From: anatawa12 Date: Mon, 27 Nov 2023 17:07:57 +0900 Subject: [PATCH] =?UTF-8?q?chore:=20=E9=9F=B3=E5=A3=B0=E3=81=8C=E4=B8=80?= =?UTF-8?q?=E5=88=87=E9=B3=B4=E3=82=89=E3=81=AA=E3=81=8F=E3=81=AA=E3=82=8B?= =?UTF-8?q?=E5=8F=AF=E8=83=BD=E6=80=A7=E3=82=92=E8=BB=BD=E6=B8=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://github.com/misskey-dev/misskey/pull/12433#discussion_r1405774767 --- packages/frontend/src/scripts/sound.ts | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/packages/frontend/src/scripts/sound.ts b/packages/frontend/src/scripts/sound.ts index a423e35724bc..b2739290db2c 100644 --- a/packages/frontend/src/scripts/sound.ts +++ b/packages/frontend/src/scripts/sound.ts @@ -89,13 +89,17 @@ export function play(type: 'noteMy' | 'note' | 'antenna' | 'channel' | 'notifica if (_DEV_) console.log('play', type, sound); if (sound.type == null || !canPlay) return; - canPlay = false; - playFile(sound.type, sound.volume).then(() => { - // ごく短時間に音が重複しないように - setTimeout(() => { - canPlay = true; - }, 25); - }); + (async () => { + canPlay = false; + try { + await playFile(sound.type, sound.volume); + } finally { + // ごく短時間に音が重複しないように + setTimeout(() => { + canPlay = true; + }, 25); + } + })(); } export async function playFile(file: string, volume: number) {