mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-02-04 21:09:18 +08:00
initialising error sound only when its needed
This commit is contained in:
parent
9cd89f768b
commit
c745d5e3ce
1 changed files with 7 additions and 1 deletions
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue