Skip to content

Commit

Permalink
fix(frontend): 通知音がほぼ同時に鳴った場合は再生をブロックするように(音割れ防止) (misskey-dev#12433)
Browse files Browse the repository at this point in the history
* (fix) 通知音がダブって音割れしないように

* Update Changelog
  • Loading branch information
kakkokari-gtyih authored Nov 26, 2023
1 parent 5bdae9f commit 755ca97
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
- Fix: ウィジェットのジョブキューにて音声の発音方法変更に追従できていなかったのを修正 #12367
- Fix: コードエディタが正しく表示されない問題を修正
- Fix: プロフィールの「ファイル」にセンシティブな画像がある際のデザインを修正
- Fix: 一度に大量の通知が入った際に通知音が音割れする問題を修正

### Server
- Enhance: MFM `$[ruby ]` が他ソフトウェアと連合されるように
Expand Down
12 changes: 10 additions & 2 deletions packages/frontend/src/scripts/sound.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { defaultStore } from '@/store.js';

const ctx = new AudioContext();
const cache = new Map<string, AudioBuffer>();
let canPlay = true;

export const soundsTypes = [
null,
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 755ca97

Please sign in to comment.