录制资源必须具有wav或m4a扩展名

时间:2019-04-29 18:52:59

标签: ios angular typescript ionic-framework

我正在尝试使用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设备上,它运行良好。

0 个答案:

没有答案