Using html5 to capture microphone input on mobile chrome

I am trying to record from a microphone using HTML5 in Chrome 29 Beta for Android (it turned on web audio support in beta 29). In the code below, ProcessAudio is a web audio filter function in which I receive an input buffer from a microphone. I get the correct sample size. However, the pcm audio samples in mobile chrome are always null. Does Chrome turn off input sound filters in its mobile version? Has anyone received an audio recording using HTML5 in the Chrome version of Chrome? The following code works fine in chrome (desktop version).

<!DOCTYPE HTML> <html> <head> <script> function GetMedia(obj, fnSuccess, fnFailure) { if(navigator.getUserMedia) { return navigator.getUserMedia(obj, fnSuccess, fnFailure); } else if(navigator.webkitGetUserMedia) { return navigator.webkitGetUserMedia(obj, fnSuccess, fnFailure); } else if(navigator.mozGetUserMedia) { return navigator.mozGetUserMedia(obj, fnSuccess, fnFailure); } else if(navigator.msGetUserMedia) { return navigator.msGetUserMedia(obj, fnSuccess, fnFailure); } alert("no audio capture"); } var incrementer = 0; function ProcessAudio(e) { var inputBuffer = e.inputBuffer.getChannelData(0); var outputBuffer = e.outputBuffer.getChannelData(0); outputBuffer.set(inputBuffer, 0); document.getElementById("display").innerText = incrementer + " " + inputBuffer[0]; incrementer++; } var context = null; function Success(localMediaStream) { context = new window.webkitAudioContext(); var microphone = context.createMediaStreamSource(localMediaStream); var node = context.createScriptProcessor(4096, 1, 1); node.onaudioprocess = ProcessAudio; microphone.connect(node); node.connect(context.destination); } function Error(err) { alert("no audio support"); } function load(e) { GetMedia({audio:true,video:false}, Success, Error); } </script> </head> <body onload="load(event)"> <div>Audio Player</div> <div id="display"></div> <video id="localvideo" autoplay="autoplay" style="opacity:1"></video> </body> </html> 
+4
source share
2 answers

The problem with inputBuffer in the beta version of Chrome for Android right now - it always contains zeros (at least on the devices that I tested), as you mentioned, is confirmed. This doesn’t help much, but for demonstration purposes, the best I could achieve right now is a live input stream through the <audio> object. See here . Click "record" and then start playing the audio object. The rest besides this is TARFU in the current beta. Guess I'm waiting for the G-people to fix it as soon as possible. However, I found that zingaya.com works great (i.e., records your sound and plays it back) in Chrome Beta for Android. Just try them and they will play your stream. Apparently, this is achieved through the use of WebRTC. In other words, you can obviously record an audio stream this way, I still haven't figured out how to do it. Try if you come up with something. G guys, on the other hand, are fast - they released a new beta version less than a week ago, which, at least, can play audio from XHR. The version could not do this before.

+1
source

Now we have a Web Audio login running in Chrome for Android Beta (31.0.1650.11).

+2
source

Source: https://habr.com/ru/post/1492684/


All Articles