catch any error

This commit is contained in:
Klemek
2024-10-18 18:45:31 +02:00
parent 95c6bb9072
commit b25828f961
+10 -6
View File
@@ -165,12 +165,16 @@ let app = {
}); });
}, },
playRandomSound() { playRandomSound() {
const sound = random.element(this.sounds.filter(sound => sound.active)); try {
if (sound !== null) { const sound = random.element(this.sounds.filter(sound => sound.active));
console.log(`Playing ${sound.id}`); if (sound !== null) {
sound.audio.playbackRate = this.randomPitch ? random.float(0.8, 1.2) : 1; console.log(`Playing ${sound.id}`);
sound.audio.volume = this.volume / 100; sound.audio.playbackRate = this.randomPitch ? random.float(0.8, 1.2) : 1;
sound.audio.play(); sound.audio.volume = this.volume / 100;
sound.audio.play();
}
} catch (error) {
console.error(error);
} }
this.trigger(); this.trigger();
}, },