Chrome for Android versions 30 and 31 beta on Android 4.1 does not display correctly for sound recording using HTML5 web audio and .webkitGetUserMedia navigator. (Chrome 30+ on Android must support these APIs.)
The symptom is that the code works correctly, including showing a hint about whether or not to allow access to the microphone, but the recorded data contains only zeros.
I created a simplified test file (go to http://jsfiddle.net/JCFtK/ and click the "Record" button, then select the appropriate option so that it can access your microphone). Below is the key part of the code (the "write" function is the entry point).
function processAudioBuffer(e) {
var floats = e.inputBuffer.getChannelData(0);
var min = 0, max = 0;
for (var i = 0; i < floats.length; i++) {
var current = floats[i];
min = Math.min(current, min);
max = Math.max(current, max);
}
log('Block min/max: ' + min.toFixed(3) + ', ' + max.toFixed(3));
}
function record() {
if (!window.AudioContext) {
window.AudioContext = window.webkitAudioContext;
}
if (!navigator.getUserMedia) {
navigator.getUserMedia = navigator.webkitGetUserMedia || navigator.mozGetUserMedia;
}
data.context = new AudioContext();
navigator.getUserMedia({audio: true}, function(stream) {
data.mediaStream = stream;
startAudio();
}, function(error) {
log('Stream get error: ' + error);
});
}
function startAudio() {
data.audioStream = data.context.createMediaStreamSource(data.mediaStream);
data.processor = data.context.createScriptProcessor(2048, 1, 1);
data.processor.onaudioprocess = processAudioBuffer;
data.processor.connect(data.context.destination);
data.audioStream.connect(data.processor);
log('Stream connected OK');
}
/ . - , Chrome, , min/max . , 0.000.
:
- Chrome 30 (Windows)
- Firefox 25 (Windows)
- Firefox 25 (Android 4.1) Sony Xperia M
- Firefox 25 (Android 4.1) Samsung
:
- Chrome 30 (Android 4.1) Sony Xperia M
- Chrome beta 31 (Android 4.1) Sony Xperia M
- Chrome 30 (Android 4.1) Samsung
, Safari IE, , API. Chrome Android, , .
, Chrome ( , , ), , : - , , Chrome Android?
( , JavaScript, , , , , , , , .)
, , , , .:)