0

I am playing around with getUserMedia to gain access to the users microphone in Chrome(Version 28.0.1500.72 m). I am able to record and play back the users input when they use an internal microphone with internal speakers.

As soon as I plug in a usb microphone headset I am no longer able to record the users input. I have switched the device in the chrome setting under privacy and content settings. So chrome does see the newly plugged in microphone. I have restarted chrome and tried it again after plugging in the mic as well. Still no user input.

Thanks In Advance.

Below is the current code I am using.

    window.AudioContext = window.AudioContext||window.webkitAudioContext;
    var html5Recorder;
    var audioContext = new AudioContext();
    navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia || navigator.oGetUserMedia;
    if(navigator.getUserMedia){
        navigator.getUserMedia({audio:true},handleAudioStream, audioError)
    }else{
        console.log('Use Flash')
    }

    function handleAudioStream(stream){
        var mediaStream = audioContext.createMediaStreamSource(stream);
        mediaStream.connect( audioContext.destination );
        html5Recorder = new HTML5Recorder(mediaStream);
        html5Recorder.stop();
        html5Recorder.clear();
    }

    function audioError(error){
        console.log(error);
    }

    function record(){
        html5Recorder.record();
    }

    function stopRecording(){
        html5Recorder.stop();
        html5Recorder.exportWAV(function(e){
            console.log(e);
            console.log(window.URL.createObjectURL(e));
           document.getElementById('audio1').src =  window.URL.createObjectURL(e);
            HTML5Recorder.forceDownload(e);
        });
    }
unknown
  • 125
  • 1
  • 8

3 Answers3

1

This was a bug in the current chrome build I was using (28). Chrome canary works fine.

unknown
  • 125
  • 1
  • 8
0

Can you check the sampling rate on the two audio devices?

There is an existing bug that the non-default microphone only works if the sample rate is the same as the default microphone: https://code.google.com/p/chromium/issues/detail?id=164058.

Also, are you on OSX or Linux? The comments in the bug make it look like it should be fixed on Windows.

tomtheengineer
  • 4,127
  • 1
  • 17
  • 15
0

Try selecting the USB mic as the default one. Chrome does not mange audio devices and it always uses the default mic.

Jacek
  • 321
  • 3
  • 2