Thursday, 13 June 2019

Recording audio on chrome for android devices Bug?

I'm using Media​Stream Recording API to record user's MIC. The code works fine on chrome windows but when it comes to android it just stops recording instantly after recording beep.

How can I make the API work on android devices?
Am I missing something or this is a bug with Web Audio API?

Here is the code:

  navigator.mediaDevices.getUserMedia({audio:true})
    .then(stream => {
        rec = new MediaRecorder(stream);
        rec.ondataavailable = e => {
            audioChunks.push(e.data);
            if (rec.state == "inactive"){
        let blob = new Blob(audioChunks,{type:'audio/x-mpeg-3'});
        recordedAudio.src = URL.createObjectURL(blob);

Then I just use these lines to start recording :

audioChunks = [];
rec.start();

And This one to stop and play:

rec.stop();
recordedAudio.autoplay = true;



from Recording audio on chrome for android devices Bug?

No comments:

Post a Comment