2

I am trying to record audio and upload it to server using javascript.I am using Recorder js by Matt Diamond.But the issue is file getting generated is of 0 mins. When debugged through firebug console found out the audiocontext property was suspended. When googled found out for recording the audiocontext's state should be in running state. Don't know exactly if the issue is because of state or am I missing on something. Wanted to know what causes the state of audiocontext to be in suspended mode. If I try on other browsers the state is running and file is getting generated. But my restriction is I want to use firefox for my application

Firefox version: 42.0

Below is the code

if(audioRecorder)
{
 audioRecorder.clear();
 audioRecorder.record();

 setTimeout(stopRecorder,9000);   // 9 secs 
}
function stopRecorder()
{
  if(audioRecorder)
    {
       audioRecorder.stop();
       audioRecorder.exportWAV(function(blob){
       alert("Blob size : "+blob.size);
       // code for sending the blob to server 

          });
     }
}

when debugged the above code in firebug audiocontext was suspended.

Thanks in advance

bfmags
  • 2,885
  • 2
  • 17
  • 28
vegeta
  • 39
  • 4

2 Answers2

0

this is not a direct answer, but it solves the issue, taken from my other answer, if all you need is to send audio files to server, instead of using bulky uncompressed wav files, you can easily( and native-ly) record the audio in compressed ogg format using MediaRecorder API, supported in firefox since v25 and chrome since v47.

Community
  • 1
  • 1
mido
  • 24,198
  • 15
  • 92
  • 117
0

Created a JSFiddle and tested it a few times - works correctly on Firefox 42 [macosx]


function createDownloadLink() {
   recorder && recorder.exportWAV(function(blob) {
     var url = URL.createObjectURL(blob);
     var li = document.createElement('li');
     var au = document.createElement('audio');
     var hf = document.createElement('a');
     au.controls = true;
     au.src = url;
     hf.href = url;
     hf.download = new Date().toISOString() + '.wav';
     hf.innerHTML = hf.download;
     li.appendChild(au);
     li.appendChild(hf);
     recordingslist.appendChild(li);
});


Issue 139 Sometimes it is creating wav file of 0.0 duration on firefox #139

bfmags
  • 2,885
  • 2
  • 17
  • 28