Im using the WebAudio API with new Audio()
object as a source. The following is a simplified version of what i am doing. This however, doesnt play any sounds in firefox 25.0.1.
var context;
if(window.webkitAudioContext) {
context = new webkitAudioContext();
} else {
context = new AudioContext();
}
var audio = new Audio();
// This file does seem to have CORS Header
audio.src = "http://upload.wikimedia.org/wikipedia/en/4/45/ACDC_-_Back_In_Black-sample.ogg";
var source;
function onCanPlay() {
console.log("can play called");
source = context.createMediaElementSource(audio);
source.connect(context.destination);
audio.removeEventListener("canplay", onCanPlay);
audio.play();
}
if(audio.readyState < 3) {
audio.addEventListener("canplay", onCanPlay);
} else {
onCanPlay();
}
jsFiddle: http://jsfiddle.net/7bJUU/
I read in another question that createMediaElementSource
requires CORS. The file in above example does seem to have Access-Control-Allow-Origin: *
but it still doesnt work in firefox. If i run the same example locally with a local audio file, everything works fine.
Not sure if this is a bug or if im doing something terribly wrong. Any help is appreciated.