| @@ -1,5 +1,7 @@ | |||||
| let playing = []; | let playing = []; | ||||
| looping = {}; | |||||
| let looping = {}; | |||||
| const audioBaseUrl = "http://localhost:8000/media/audio/"; | |||||
| let audioDict = {}; | let audioDict = {}; | ||||
| @@ -111,9 +113,9 @@ function loadRemoteAudio(name) { | |||||
| xhr.open("GET", audioBaseUrl + name, true); | xhr.open("GET", audioBaseUrl + name, true); | ||||
| xhr.responseType = "arraybuffer"; | xhr.responseType = "arraybuffer"; | ||||
| xhr.onload = (xhr) => { | |||||
| xhr.onload = (res) => { | |||||
| if (xhr.status == 200) | if (xhr.status == 200) | ||||
| cacheAndParse(name, xhr.data); | |||||
| cacheAndParse(name, xhr.response); | |||||
| else | else | ||||
| console.log("Couldn't load " + name); | console.log("Couldn't load " + name); | ||||
| } | } | ||||
| @@ -34,16 +34,10 @@ | |||||
| </div> | </div> | ||||
| <div id="control-area"> | <div id="control-area"> | ||||
| <div id="actions"> | <div id="actions"> | ||||
| <button class="action-button">potato 1</button> | |||||
| <button class="action-button">potato 2</button> | |||||
| <button class="action-button">potato 3</button> | |||||
| <button class="action-button">potato 4</button> | |||||
| <button class="action-button">potato 5</button> | |||||
| <button class="action-button">potato 6</button> | |||||
| <button class="action-button">potato 7</button> | |||||
| <button class="action-button">potato 8</button> | |||||
| <button class="action-button">potato 9</button> | |||||
| <button class="action-button">potato 10</button> | |||||
| <button class="action-button" id="load">Load Sounds</button> | |||||
| <button class="action-button" id="sfx">Play Sound</button> | |||||
| <button class="action-button" id="loop">Play Loop</button> | |||||
| <button class="action-button" id="stop">Stop Loop</button> | |||||
| </div> | </div> | ||||
| <div id="desc"> | <div id="desc"> | ||||
| this is a description of your action | this is a description of your action | ||||
| @@ -1,7 +1,5 @@ | |||||
| "use strict" | "use strict" | ||||
| let audioBaseUrl = "http://localhost:8000/media/audio/"; | |||||
| let audioContext; | let audioContext; | ||||
| // setup the game | // setup the game | ||||
| @@ -9,6 +7,22 @@ let audioContext; | |||||
| function init() { | function init() { | ||||
| initAudio(); | 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"); | |||||
| }); | |||||
| } | } | ||||