Bläddra i källkod

Added a basic demo of sound

tags/v0.1.0
Fen Dweller 6 år sedan
förälder
incheckning
7e144db282
Ingen känd nyckel hittad för denna signaturen i databasen GPG-nyckel ID: E80B35A6F11C3656
3 ändrade filer med 25 tillägg och 15 borttagningar
  1. +5
    -3
      audio.js
  2. +4
    -10
      satiate.html
  3. +16
    -2
      satiate.js

+ 5
- 3
audio.js Visa fil

@@ -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);
}


+ 4
- 10
satiate.html Visa fil

@@ -34,16 +34,10 @@
</div>
<div id="control-area">
<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 id="desc">
this is a description of your action


+ 16
- 2
satiate.js Visa fil

@@ -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");
});

}



Laddar…
Avbryt
Spara