Slide 8
Slide 8 text
音声ファイルを読み込む
var context = new AudioContext();
var buffer = null;
loadSound("path/to/source")
var source = context.createBufferSource();
source.buffer = buffer;
source.connetct(context.destination)
source.start(0)
function loadSound(url) {
var req = new XMLHttpRequest();
req.open("GET", url, true);
req.responseType = "arraybuffer";
req.onload = function() {
context.decodeAudioData(req.response, function(b) {
buffer = b;
}, function() {});
}
req.send();
}