Skip to content

Commit

Permalink
chore: 音声が一切鳴らなくなる可能性を軽減
Browse files Browse the repository at this point in the history
  • Loading branch information
anatawa12 committed Nov 27, 2023
1 parent 9a2e2b3 commit 1dd7916
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions packages/frontend/src/scripts/sound.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 1dd7916

Please sign in to comment.