I am going to record audio on android device. This is code.
curr_playing_file: MediaObject;
recordaudio(){
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 "Cannot read property 'stopRecord' of undefined " error. Media object has function of "stopRecord()". But I couldn't know the reason of this error. Please give me advice. Thanks.