Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to load microphone request and keep it live

Currently, I am working on a project where I need to work with an audio from the users. I need to ask the user for a micrphone to be connected so I can intialize his speaking with x-webkit speech - the main problem is that the user need's to click on a button and to speak always when he needs to speak - I want the browser to ask the user if the website can make use of the micrphone and if the user accepts the request the x-webkit will work and stay live. How can I make the x-webkit speech stay live without forcing the user clicking over the button?

Thanks!

like image 531
cynd7us Avatar asked Sep 30 '13 16:09

cynd7us


1 Answers

I think you need Webrtc getusermedia`

//get audio    
navigator.getUserMedia({audio:true}, gotStream);

.

//display audio
function gotStream(stream) {
    window.AudioContext = window.AudioContext || window.webkitAudioContext;
    var audioContext = new AudioContext();

    // Create an AudioNode from the stream
    var mediaStreamSource = audioContext.createMediaStreamSource(stream);

    // Connect it to destination to hear yourself
    // or any other node for processing!
    mediaStreamSource.connect(audioContext.destination);
}

Quick start: http://www.html5rocks.com/en/tutorials/webrtc/basics/

like image 197
Pixeladed Avatar answered Oct 22 '22 05:10

Pixeladed