This is my code
curr_playing_file: MediaObject;
record(){
var nItem = localStorage.getItem(‘recordvoiceNum’);
var numstr = 0;
if (nItem == null) {
numstr = 1;
}
else {
var numstr = parseInt(nItem, 10);
numstr = numstr + 1;
}
//Create media file
this.curfilename = ‘audio’ + numstr + ‘.3gp’;
this.curr_playing_file = this.createAudioFile(this.curfilename);
localStorage.setItem(‘recordvoiceNum’, numstr.toString());
try {
console.log(‘start Recording’);
if (this.curr_playing_file == undefined)
console.log(‘dont start’);
this.curr_playing_file.startRecord();
}
catch (e) {
console.log(‘record error’);
console.log(e.message);
}
setTimeout(function () {
try {
console.log(‘stop recording’);
//stop recording
if (this.curr_playing_file == undefined)
console.log(‘dont stop’);
this.curr_playing_file.stopRecord();
}
catch (error) {
console.log(‘stoperror’);
console.log(error.message);
}
}, 10000);
}
I get this error.
IONIC-native-media issue. Cannot read property ‘stopRecord’ of undefined
Please help.