I am using the cordova media plugin to record user voice and storing it in sdcard of a mobile device. Everything is working good, but when recording a new file it is overwriting the file which was previously recorded.
I want to create separate file to be created at each time user record his voice.
Can I get help.
You should change the src file name every time as following...
if(!localStorage.getItem('counter')){
localStorage.setItem("counter",0);
}
var counter = parseInt(localStorage.getItem('counter'));
function recordAudio() {
var src = "myrecording"+counter+".mp3";
var mediaRec = new Media(src,
// success callback
function() {
console.log("recordAudio():Audio Success");
counter++;
localStorage.setItem("counter",counter);
},
// error callback
function(err) {
console.log("recordAudio():Audio Error: "+ err.code);
});
// Record audio
mediaRec.startRecord();
}
Try this it won't override the previous file....happy coding