Well, i have an issue on recording media audio on iOS. i can start recording but when i call stopRecord function it doesn’t stop. It creates my a file in the specified path of 0 kb.
In Android it works perfectly. Please help.
plguins:
<plugin name="cordova-plugin-media" spec="5.0.2" />
<plugin name="cordova-plugin-file" spec="6.0.1" />
Code
constructor(private media: Media, public plt: Platform, private file: File, public alrtCtrl: AlertController) { }
startRecord(){
this.fileName = 'record'+ new Date().getDate()+new Date().getMonth()+new Date().getFullYear()+new Date().getHours()+new Date().getMinutes()+new Date().getSeconds()+'.mp3';
if(this.plt.is('ios')){
this.file.createFile(this.file.tempDirectory, this.fileName,true).then(() => {
this.filePath = this.file.tempDirectory;
this.audio = this.media.create(this.filePath.replace(/^file:\/\//, '') + this.fileName);
this.audio.startRecord();
})
}else if (this.plt.is('android')){
this.audio = this.media.create(this.file.externalDataDirectory + this.fileName);
this.filePath = this.file.externalDataDirectory
this.audio.startRecord();
}
}
stopRecord(){
this.audio.stopRecord();
this.file.readAsDataURL(this.filePath,this.fileName).then((base64Audio) => {
this.base64 = base64Audio // **it only returns data:audio/mpeg;base64,**
})
}
}