var audio = document.getElementById("audio");
audio.src = "http://SAMEDOMAIN:8000/stream.ogg"; // works with if(0)
//audio.src = "test.ogg"; // Works always
//audio.src = "http://SAMEDOMAIN/test.ogg"; // works always
console.log(audio.src);
if(1){ // vars below are defined as globals.
audioCtx = new AudioContext();
audioSrc = audioCtx.createMediaElementSource(audio);
analyser = audioCtx.createAnalyser();
audioSrc.connect(analyser);
audioSrc.connect(audioCtx.destination);
}
audio.play();
status("Init stream.");
I'm not sure if this is some weird limitation with Firefox and Chrome, but both will play back the data, and when the AudioContext code is used on the stream.ogg from an Icecast server, both the audio fails to play, and the analyser data are all zeros. However without the AudioContext code, it plays just fine.
The controls for the audio element show that it is receiving data, and in Firefox at least, the mozGetMetadata() function shows accurate track information.
My best guess would be that it seems to be related to it not knowing the full file size/track length.
EDIT: Turns out it was a cross origin issue, even though it was the same domain, just a different port. And it only affected things when an Audio Context was used. Alexey pointed that out, and I shoved it all onto the same port, and it started working. If only browsers would report something like that in the development consoles, that would have solved so much headaches.