Skip to content

Commit

Permalink
chore: 音声が一切鳴らなくなる可能性を軽減
Browse files Browse the repository at this point in the history
  • Loading branch information
anatawa12 committed Nov 28, 2023
1 parent 4e5b776 commit d361ebb
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 @@ -160,13 +160,17 @@ export function play(operationType: OperationType) {
if (_DEV_) console.log('play', operationType, sound);
if (sound.type == null || !canPlay) return;

canPlay = false;
playFile(sound).then(() => {
// ごく短時間に音が重複しないように
setTimeout(() => {
canPlay = true;
}, 25);
});
(async () => {
canPlay = false;
try {
await playFile(sound);
} finally {
// ごく短時間に音が重複しないように
setTimeout(() => {
canPlay = true;
}, 25);
}
})();
}

/**
Expand Down

0 comments on commit d361ebb

Please sign in to comment.