From fdfa8561fbc884418bffa424876eb0e4e6756ecc Mon Sep 17 00:00:00 2001 From: sanine Date: Sat, 6 Jul 2024 22:17:20 -0500 Subject: fix audio loading --- main.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'main.js') diff --git a/main.js b/main.js index 94d5e77..e41a89a 100644 --- a/main.js +++ b/main.js @@ -63,20 +63,20 @@ window.onload = () => setTimeout(() => { audio.createMediaElementSource(sfx.listAppearAudio).connect(audio.destination); sfx.resourceAudio = document.getElementById('sfx-resource'); - sfx.resourceSource = audio.createMediaElementSource(sfx.resourceAudio); - sfx.resourceSource.connect(audio.destination); + audio.createMediaElementSource(sfx.resourceAudio).connect(audio.destination); sfx.doneAudio = document.getElementById('sfx-done'); - sfx.doneSource = audio.createMediaElementSource(sfx.doneAudio); - sfx.doneSource.connect(audio.destination); + audio.createMediaElementSource(sfx.doneAudio).connect(audio.destination); sfx.wrongAudio = document.getElementById('sfx-wrong'); - sfx.wrongSource = audio.createMediaElementSource(sfx.wrongAudio); - sfx.wrongSource.connect(audio.destination); + audio.createMediaElementSource(sfx.wrongAudio).connect(audio.destination); // const level = setupLevel([[2, 2], [3,3]], [7, 7]); // const ui = setupLevelUi(level, root, audio); - setupLevelSelectUi(root, sfx); + + Promise.all([...Object.values(sfx)].map(x => x.load())).then( + () => setupLevelSelectUi(root, sfx) + ); }; root.appendChild(start); }, 200); -- cgit v1.2.1