Executing navigator.getUserMedia()
by regular browser load (not ajax) works fine:
<script>
if(navigator.getUserMedia) {
navigator.getUserMedia({audio: true}, startUserMedia, function(e) {
__log('No live audio input: ' + e);
});
} else {
__log('fail ');
}
</script>
But when I try to load this script via $.getScript
or inside a document that loads by $.ajax
, it doesn't seem to execute at all. Oddly enough, it doesn't execute the successful function startUserMedia, nor does it execute the function which logs "no live audio input".
Is there incompatibility executing the method navigator.getUserMedia()
with Ajax?
I've read over the docs and I can't see anything that would state this. Any help / comments / guidance would be appreciated, I've been going over this for the last few days with no success.
Gist of the document which is being loaded by Ajax: https://gist.github.com/markbratanov/859df0b1a70d1e15446c
As far as I am concerned, if anyone else is in the same situation, getUserMedia()
is a method that will not work properly if it is loaded through Ajax. Not sure as to why, but I've ran several test and all have failed.
The best way to use getUserMedia is at browser load time.
My opinion at least. Hope this helps someone.