Question

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);
        });
    }
Was it helpful?

Solution

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

OTHER TIPS

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.

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top