0

I have this code which accesses the microphone and reproduces the sound created from my microphone to my speakers. But it seems that it's not working. It accesses the microphone, and a red circle blinks slowly in the favicon, but seems like it's not producing any sound. I'm not sure but I think it's a problem with the tag. What do you think is the error here?

    try {
        navigator.getMedia = ( navigator.getUserMedia    || navigator.webkitGetUserMedia ||
                               navigator.mozGetUserMedia ||navigator.msGetUserMedia);

        navigator.getMedia ({
                audio: true
            },
            function(stream) {
                var audio = document.getElementById('audio');
                var streamer = window.URL.createObjectURL(stream);
                audio.src = streamer;


            },
            function(err) {
                // No permissions
            }
        );
    }

    catch(e) {
        alert('Error');
    }

Above that script, the audio tag lies.

<audio src="" id="audio" controls="controls" autoplay>Sad twinkies does not have audio</audio>

So what do you think is the problem here?

thisjt
  • 163
  • 2
  • 14
  • Try not setting the element to autoplay, and trigger `.play()` after setting the `src`. – Joseph May 20 '13 at 01:41
  • will audio.play() work with that? Or does it need jQuery? EDIT: It does. But still no luck fixing the error. It still does not sound. – thisjt May 20 '13 at 04:35
  • It works fine for me on Chrome, version 29. But it makes a horrible screeching noise. – jrullmann Oct 08 '13 at 02:58
  • @jrullmann that `horrible screeching noise` is just audio feedback closed loop which if true may indicate code is working --- use headphones or turn volume down to avoid – Scott Stensland Jan 15 '16 at 20:25

0 Answers0