Web Audio analyser returns zeros when using createMediaElementSource

853 views Asked by At

I am trying to analyse a live audio stream from a url.

I have tested my code with mic input and it works well however when I change

createMediaStreamSource(micStream)

To

var streamURL = new Audio(['http://urlOnRemoteServer'])
createMediaStreamSource(streamURL)

Then getByteFrequencyData just returns arrays of zeros (with mic input it returns real data instead of zeros).

It looks like firefox has a Same-origin policy so I moved my code to a web server and used a temporary audio file, however this produces the same results on both Firefox and Chrome so I assume this isn't to do with browser support...

Example JSFiddle: https://jsfiddle.net/j68fhz9x/

I am using Firefox/Chrome on Debian Linux

Thanks in advance

UPDATE

After looking into CORS I instead tried to run the app locally, however the problem persists even if I have both the script and audio file on a local computer.

1

There are 1 answers

4
cwilso On

You need to use a same origin file or CORS, for Firefox and chrome.