ios - Cordova 媒体插件 ios“无法使用 AVAudioRecorder 代码开始录制:1”
问题描述
这个问题之前被问过,但它接受的答案不起作用。问题是我无法使用 cordova/ionic 2 应用程序在 ios 上录制音频,我尝试了 ionic native 失败且没有错误,现在尝试给出错误的 cordova-media-plugin:"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);
});
推荐阅读
- spring - SingleConnectionDataSource 现在关闭新实例
- angular - 使用高图/高图悬停在工具提示上时如何显示同一属性的多个值
- powershell - 使用查询或 Powershell 在 SSAS 实例上识别具有管理访问权限的登录
- python - conda报错:环境不一致,请仔细查看打包方案
- javascript - 如何将变量作为字符串传递以定位要由 d3 读取的文件
- c# - 如何在 C# 中将 Dicom 转换为 BMP 图像?
- groovy - 检索地图列表中的第一张地图groovy
- java - 更改我的正则表达式后在线程“main”java.lang.NullPointerException 中获取异常
- sql - SQL 返回逗号分隔列表 - 指定的修剪长度大于当前 LOB 值的长度
- graphql - 使用 Apollo Server 嵌套的每字段解析器