科尔多瓦媒体插件ios "Failed to start recording using AVAudioRecorder code:1"



这个问题以前被问过,但它被接受的答案不起作用。问题是,我无法使用cordova/ionic 2应用程序在ios上录制音频,我尝试了ionic原生程序,但没有错误,现在尝试了cordova媒体插件,但出现了错误:"Failed to start recording using AVAudioRecorder code:1".这是我的代码

this.file.createFile(this.dir, this.filename, true).then(f => {
this.m = new (<any>window).Media(this.dir + this.filename,function(e){alert('Success');},
function(e){alert('failed'+JSON.stringify(e));});
this.m.startRecord();
}).catch(e=>alert(JSON.stringify(e)));

this.dir的值为tempDirectory,文件名为.wav,结果与mp3 相同

请帮忙,谢谢

这可能是一个许可证问题,因为在这个插件的旧版本(cordova 3.0(上,代码1是:

缺少Android权限

为了确保您有记录的权限,您可以使用此插件

一个例子:

cordova.plugins.diagnostic.isMicrophoneAuthorized(function(authorized){
if (authorized) {
// Do something
} else {
// Do something else
}
}, function(error){
console.error(error);
});

相关内容

最新更新