Removing source in audio controller?

Hi

Is there a way to remove the source of the Appery audio controller through JavaScript? I’ve created an audio recording app via the Cordova MediaRecorder plugin - code works, but right now if users hit the record button again, the audio controller still plays the same source. Is it possible to add a line in the record button to clear off any assigned sources in AudioPlayer before recording new audio? Thanks.

document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
console.log("device ready to go.");
console.log(navigator.mediaDevices.getUserMedia);
}

navigator.mediaDevices.getUserMedia({
'audio': true
}).then(function(mediastream) {
var options = { mimeType : 'audio/wav'};
var mediaRecorder = new MediaRecorder(mediastream, options);

//start recording

Appery("RecordAudioButton").click(function() {
mediaRecorder.start();
console.log(mediaRecorder.state);
console.log("recorder started");

});

//stop recording

Appery("StopRecord").click(function() {
mediaRecorder.stop();
console.log(mediaRecorder.state);
console.log("recorder stopped");

});

//play recording

mediaRecorder.ondataavailable = function(blob) {
var audioURL = mediaRecorder.src;
if(device.platform === 'iOS') { // iOS ; cordova-plugin-device required for this check
Appery("audioPlayer").attr("src", audioURL);
} else {
var recordedChunks = [];
recordedChunks.push(blob.data);
audioURL.src = URL.createObjectURL(new Blob(recordedChunks)); // Android device
}
};

});
1 person has
this question
+1
Reply