Reputation: 33399
I want to access the microphone input with navigator.getUserMedia()
, but am unsure of how to proceed.
I can start the audio just fine, but I have no idea what to do with it after that.
if (!navigator.getUserMedia) {
navigator.getUserMedia = navigator.getUserMedia
|| navigator.webkitGetUserMedia
|| navigator.mozGetUserMedia
|| navigator.msGetUserMedia;
}
if (navigator.getUserMedia) {
navigator.getUserMedia({audio: true}, function (e) {
// what goes here?
}, function (e) {
alert('Error capturing audio.');
});
} else {
alert('getUserMedia not supported in this browser.');
}
I would like to access it as a stream. I don't even need stereo, just a way to get the data.
EDIT: I want to send the data back to the server using websockets, to create a sort of intercom system. Here, i need to be able to access a simple audio stream, stopping and starting it on certain events.
Upvotes: 0
Views: 8352
Reputation: 13908
If you mean you want access to the raw samples of the ongoing audio stream - use a ScriptProcessorNode in Web Audio (http://webaudio.github.io/web-audio-api/#ScriptProcessorNode). RecordJS, mentioned above, will help show you how to do this.
Upvotes: 5