IONIC-native-media issue. Cannot read property 'stopRecord' of undefined

This is my code
curr_playing_file: MediaObject;

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’);
catch (e) {
console.log(‘record error’);
setTimeout(function () {
try {
console.log(‘stop recording’);
//stop recording
if (this.curr_playing_file == undefined)
console.log(‘dont stop’);
catch (error) {
}, 10000);

I get this error.
IONIC-native-media issue. Cannot read property ‘stopRecord’ of undefined

Please help.

Please edit your post, it is not very readable at the moment.
Use the </> button above the input field to format your code, command line output or error message (select the text first, then click the button or wrap it in ``` manually). Check the preview if it looks better. This will make sure your text is readable and if it recognizes the programming language it also automatically adds code syntax highlighting. Thanks.