Using Media plugin as voice recorder


#1

Hello, I want to make a voice record for chat. I using this plugin but when I testing it, it show error.

start = 0
mp3file: MediaObject = this.media.create(this.file.dataDirectory+'recording.mp3')
  constructor(public navCtrl: NavController, 
  public navParams: NavParams, 
  private media: Media, private file: File) {
 
  } 
  rec(){ 
    console.log(this.file.dataDirectory+'recording.mp3');
    if(this.start == 0){
      console.log('rec')
       this.mp3file.startRecord();
      this.start = 1
    }else{
      console.log('stop rec')
      this.mp3file.stopRecord();
      console.log(this.file)
    }
  }

This is the error I got, when “this.mp3file.stopRecord();” called


#2

Solved


#3

Hi Chungtheng. Can you help me how can to pause and restore recording audio