Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is HTML5's getUserMedia for audio recording working now?

I had searched a lot of DEMO and examples about getUserMedia , but most are just camera capturing, not microphone.

So I downloaded some examples and tried on my own computer , camera capturing is work , But when I changed

navigator.webkitGetUserMedia({video : true},gotStream);

to

navigator.webkitGetUserMedia({audio : true},gotStream);

The browser ask me to allow microphone access first, and then it failed at

document.getElementById("audio").src = window.webkitURL.createObjectURL(stream); 

The message is :

GET blob:http%3A//localhost/a5077b7e-097a-4281-b444-8c1d3e327eb4 404 (Not Found)

This is my code: getUserMedia_simple_audio_test

Did I do something wrong? Or only getUserMedia can work for camera now ?

like image 333
user1422542 Avatar asked May 28 '12 23:05

user1422542


People also ask

What is Get user Media?

getUserMedia() method prompts the user for permission to use up to one video input device (such as a camera or shared screen) and up to one audio input device (such as a microphone) as the source for a MediaStream .


2 Answers

It is currently not available in Google Chrome. See Issue 112367.

You can see in the demo, it will always throw an error saying

GET blob:http%3A//whatever.it.is/b0058260-9579-419b-b409-18024ef7c6da 404 (Not Found)

And also you can't listen to the microphone either in

{
    video: true,
    audio: true
}
like image 135
Derek 朕會功夫 Avatar answered Sep 24 '22 17:09

Derek 朕會功夫


It is currently supported in Chrome Canary. You need to type about:flags into the address bar then enable Web Audio Input.

The following code connects the audio input to the speakers. WATCH OUT FOR THE FEEDBACK!

<script>
// this is to store a reference to the input so we can kill it later 
var liveSource;
// creates an audiocontext and hooks up the audio input
function connectAudioInToSpeakers(){
  var context = new webkitAudioContext();  
  navigator.webkitGetUserMedia({audio: true}, function(stream) {
    console.log("Connected live audio input");
    liveSource = context.createMediaStreamSource(stream);
    liveSource.connect(context.destination);
  });
 }
// disconnects the audio input
function makeItStop(){
   console.log("killing audio!");
   liveSource.disconnect();
 }
// run this when the page loads
connectAudioInToSpeakers();
</script>
<input type="button" value="please make it stop!" onclick="makeItStop()"/>
like image 5
Matthew Yee-King Avatar answered Sep 26 '22 17:09

Matthew Yee-King