initialising error sound only when its needed

This commit is contained in:
Jack 2021-09-22 23:32:28 +01:00
parent 9cd89f768b
commit c745d5e3ce

View file

@ -1,9 +1,14 @@
import Config from "./config";
import { Howl } from "howler";
let errorSound = new Howl({ src: ["../sound/error.wav"] });
let errorSound = null;
let clickSounds = null;
export function initErrorSound() {
if (errorSound !== null) return;
errorSound = new Howl({ src: ["../sound/error.wav"] });
}
export function init() {
if (clickSounds !== null) return;
clickSounds = {
@ -139,6 +144,7 @@ export function playClick() {
export function playError() {
if (!Config.playSoundOnError) return;
if (errorSound === null) initErrorSound();
errorSound.seek(0);
errorSound.play();
}