我正在尝试使用cordova本机插件录制音频,但调试器会向我显示此错误
“录制资源必须具有wav或m4a扩展名”
。 如何更改文件的扩展名?
我的代码:
startRecord() {
if (this.platform.is('ios')) {
this.fileName = 'Record'+ (this.counter = this.counter + 1);
this.filePath = this.file.documentsDirectory.replace(/file:\/\//g, '') + this.fileName;
this.audio = this.media.create(this.filePath);
} else if (this.platform.is('android')) {
this.fileName = 'Record'+ (this.counter = this.counter + 1);
this.filePath = this.file.externalDataDirectory.replace(/file:\/\//g, '') + this.fileName;
this.audio = this.media.create(this.filePath);
}
this.audio.startRecord();
this.recording = true;
}
PS:在Android设备上,它运行良好。