Currently I'm making web based voice recorder which will upload the recorded audio to the server. Before upload it to server, the user need to record audio & input few fields such as audio name etc.
I'm using RecordJs from MattDiamond https://github.com/mattdiamond/Recorderjs. When a user clicks on the stop recording button, an audio player will appear and user can play it. If the user decided to use it, they will click a button to use that audio and it will be an input value to a file type input field. The code is shown as below:
var url;
function stopRecording() {
mediaStream.stop();
rec.stop();
rec.exportWAV(function(e) {
rec.clear();
//Recorder.forceDownload(e, "test.wav");
url = Recorder.getAudioUrl(e, "audio.wav");
document.getElementById("audioPlayer").src = url;
document.getElementById("audioPlayer").style.display = "";
});
}
function setInputFile() {
document.getElementById("filename").value = url;
}
So far, I managed to capture the audio and play the recorded audio from my browser but I stuck at next step which is to set the recorded audio as a value to the input field. Using document.getElementById("filename").value = url; give an error. Could please anyone in the forum give any suggestion how to set it?