0

I'm trying to define this filename,because the filename always shows an error if I run the code.

Here is my code so far:

function createDownloadLink(blob) {
    
    var url = URL.createObjectURL(blob);
    var au = document.createElement('audio');
    var li = document.createElement('li');
    var link = document.createElement('a');

    //name of .wav file to use during upload and download (without extendion)
    var filename = new Date().toISOString();

    //add controls to the <audio> element
    au.controls = true;
    au.src = url;

    //save to disk link
    link.href = url;
    link.download = filename+".wav"; //download forces the browser to donwload the file using the  filename
    link.innerHTML = "Download to Local";

    //add the new audio element to li
    li.appendChild(au);
    
    //add the filename to the li
    li.appendChild(document.createTextNode(filename+".wav "))

    //add the save to disk link to li
    li.appendChild(link);
    
    //upload link
    var upload = document.createElement('a');
    upload.href="#";
    upload.innerHTML = "Upload";
    upload.addEventListener("click", function(event){
         uploadRecordedFile(blob,filename);
    })
    li.appendChild(document.createTextNode (" "))//add a space in between
    //li.appendChild(upload)//add the upload link to li

    //add the li element to the ol
    recordingsList.appendChild(li);
    
    uploadRecordedFile(blobfilename);
}

The uploadRecordedFile(blobfilename) is not define

I'm designing a recorder where if you click the stop button,the recording would save as a json file.

  • Is there a specific reason for it to be a json file? Also, have you [tried this](https://stackoverflow.com/questions/16413063/html5-record-audio-to-file)? – FiddlingAway Dec 31 '22 at 18:56

0 Answers0