Question

I just have the most basic (I think) implementation of Chrome's Web Audio.

I'm on Chrome 13 with Web Audio enabled, but my sound just doesn't play. I see it gets loaded (http://pieterhordijk.com/sandbox/html5-audio-api/webkit-audiocontext-interface), but it just doesn't play.

window.onload = init;

var context;
var source;

function loadSample(url) {
    var request = new XMLHttpRequest();
    request.open("GET", url, true);
    request.responseType = "arraybuffer";

    request.onload = function() {
      source.buffer = context.createBuffer(request.response, false);
      source.looping = true;
      source.noteOn(0);
    }

    request.send();
}

function init()
{
    context = new webkitAudioContext();
    source = context.createBufferSource();

    loadSample("/sandbox/test.oga");
}
Was it helpful?

Solution

Ok found the answer myself I had to connect it to the output.

source.connect(context.destination);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top