fix: crashing with JS error
This commit is contained in:
parent
a98461ade0
commit
ba5c4fe706
1 changed files with 2 additions and 1 deletions
|
|
@ -24,6 +24,7 @@ const prepareSound = () =>
|
||||||
let playingTimeout: ReturnType<typeof setTimeout> | null = null;
|
let playingTimeout: ReturnType<typeof setTimeout> | null = null;
|
||||||
let playing = false;
|
let playing = false;
|
||||||
async function playSound() {
|
async function playSound() {
|
||||||
|
if (!soundPrepared) return;
|
||||||
try {
|
try {
|
||||||
if (playing) {
|
if (playing) {
|
||||||
if (playingTimeout != null) clearTimeout(playingTimeout);
|
if (playingTimeout != null) clearTimeout(playingTimeout);
|
||||||
|
|
@ -34,7 +35,7 @@ async function playSound() {
|
||||||
await DCDSoundManager.play(SOUND_ID);
|
await DCDSoundManager.play(SOUND_ID);
|
||||||
playingTimeout = setTimeout(() => {
|
playingTimeout = setTimeout(() => {
|
||||||
playing = false;
|
playing = false;
|
||||||
DCDSoundManager.stop(SOUND_ID);
|
if (soundPrepared) DCDSoundManager.stop(SOUND_ID);
|
||||||
playingTimeout = null;
|
playingTimeout = null;
|
||||||
}, SOUND_DURATION);
|
}, SOUND_DURATION);
|
||||||
} catch {
|
} catch {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue