Create link to download an audio recording

3

I've taken a JavaScript net example that captures audio from the device and with a button on the page you can record audio and export it:

In this code we have the buttons:

<button onclick="startRecording(this);">record</button>
<button onclick="stopRecording(this);" disabled>stop</button>

From them will command to startRecording to start recording

function startRecording(button) {
    recorder && recorder.record();
    button.disabled = true;
    button.nextElementSibling.disabled = false;
    __log('Recording...');
}

and stopRecording to stop recording

function stopRecording(button) {
    recorder && recorder.stop();
    button.disabled = true;
    button.previousElementSibling.disabled = false;
    __log('Stopped recording.');

    // create WAV download link using audio data blob
    createDownloadLink();
    //recorder.clear();
  }

In this function there is a call to the function createDownloadLink() that as far as I understand it should create a link to download the previously recorded audio and there is the problem, the link is not creating.

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);
  });
}

How do I enable the link to download audio when I click Stop?

    
asked by anonymous 24.11.2015 / 18:06

1 answer

2

This repository really is missing some files, and it would not be feasible to put it here. The full repository you can find in this github .

And the full how-to tutorial, you'll see here .

Source: NusoftHq / Audioec .

  

Using Chrome 46 did not work on my computer. However in firefox 42 it works normally.

    
24.11.2015 / 20:22