diff --git a/audio.js b/audio.js index 4daba61..6c4db5d 100644 --- a/audio.js +++ b/audio.js @@ -1,5 +1,7 @@ let playing = []; -looping = {}; +let looping = {}; + +const audioBaseUrl = "http://localhost:8000/media/audio/"; let audioDict = {}; @@ -111,9 +113,9 @@ function loadRemoteAudio(name) { xhr.open("GET", audioBaseUrl + name, true); xhr.responseType = "arraybuffer"; - xhr.onload = (xhr) => { + xhr.onload = (res) => { if (xhr.status == 200) - cacheAndParse(name, xhr.data); + cacheAndParse(name, xhr.response); else console.log("Couldn't load " + name); } diff --git a/satiate.html b/satiate.html index 5746bb1..41547f4 100644 --- a/satiate.html +++ b/satiate.html @@ -34,16 +34,10 @@
- - - - - - - - - - + + + +
this is a description of your action diff --git a/satiate.js b/satiate.js index 8f4b63c..d95f7c2 100644 --- a/satiate.js +++ b/satiate.js @@ -1,7 +1,5 @@ "use strict" -let audioBaseUrl = "http://localhost:8000/media/audio/"; - let audioContext; // setup the game @@ -9,6 +7,22 @@ let audioContext; function init() { initAudio(); + document.querySelector("#load").addEventListener("click", () => { + loadAudio("sfx/test.ogg"); + loadAudio("loop/test.ogg"); + }); + + document.querySelector("#sfx").addEventListener("click", () => { + playSfx("sfx/test.ogg"); + }); + + document.querySelector("#loop").addEventListener("click", () => { + playLoop("loop/test.ogg"); + }); + + document.querySelector("#stop").addEventListener("click", () => { + stopLoop("loop/test.ogg"); + }); }