From 755ca9785779eaa120c7e4372b61979362e7ceb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=8B=E3=81=A3=E3=81=93=E3=81=8B=E3=82=8A?= <67428053+kakkokari-gtyih@users.noreply.github.com> Date: Sun, 26 Nov 2023 13:20:46 +0900 Subject: [PATCH] =?UTF-8?q?fix(frontend):=20=E9=80=9A=E7=9F=A5=E9=9F=B3?= =?UTF-8?q?=E3=81=8C=E3=81=BB=E3=81=BC=E5=90=8C=E6=99=82=E3=81=AB=E9=B3=B4?= =?UTF-8?q?=E3=81=A3=E3=81=9F=E5=A0=B4=E5=90=88=E3=81=AF=E5=86=8D=E7=94=9F?= =?UTF-8?q?=E3=82=92=E3=83=96=E3=83=AD=E3=83=83=E3=82=AF=E3=81=99=E3=82=8B?= =?UTF-8?q?=E3=82=88=E3=81=86=E3=81=AB=EF=BC=88=E9=9F=B3=E5=89=B2=E3=82=8C?= =?UTF-8?q?=E9=98=B2=E6=AD=A2=EF=BC=89=20(#12433)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * (fix) 通知音がダブって音割れしないように * Update Changelog --- CHANGELOG.md | 1 + packages/frontend/src/scripts/sound.ts | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7f02d462b2..7a1bdd233d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,7 @@ - Fix: ウィジェットのジョブキューにて音声の発音方法変更に追従できていなかったのを修正 #12367 - Fix: コードエディタが正しく表示されない問題を修正 - Fix: プロフィールの「ファイル」にセンシティブな画像がある際のデザインを修正 +- Fix: 一度に大量の通知が入った際に通知音が音割れする問題を修正 ### Server - Enhance: MFM `$[ruby ]` が他ソフトウェアと連合されるように diff --git a/packages/frontend/src/scripts/sound.ts b/packages/frontend/src/scripts/sound.ts index 4d7ef9bdee..47ec4171af 100644 --- a/packages/frontend/src/scripts/sound.ts +++ b/packages/frontend/src/scripts/sound.ts @@ -7,6 +7,7 @@ import { defaultStore } from '@/store.js'; const ctx = new AudioContext(); const cache = new Map(); +let canPlay = true; export const soundsTypes = [ null, @@ -82,8 +83,15 @@ export async function loadAudio(file: string, useCache = true) { export function play(type: 'noteMy' | 'note' | 'antenna' | 'channel' | 'notification' | 'reaction') { const sound = defaultStore.state[`sound_${type}`]; if (_DEV_) console.log('play', type, sound); - if (sound.type == null) return; - playFile(sound.type, sound.volume); + if (sound.type == null || !canPlay) return; + + canPlay = false; + playFile(sound.type, sound.volume).then(() => { + // ごく短時間に音が重複しないように + setTimeout(() => { + canPlay = true; + }, 25); + }); } export async function playFile(file: string, volume: number) {