【发布时间】:2021-10-10 05:58:49
【问题描述】:
我已经安装了插件并检查了所有需要的权限,但仍然在媒体插件上收到错误代码 1。
我还添加了<application android:requestLegacyExternalStorage="true" /> 到<edit-config>。
版本
- ionic-native/app-version: "^5.33.1"
- 电容器/cli:“^2.4.8”
- 电容器/机器人:“^2.4.6”
- cordova-plugin-media: "^5.0.3"
- @ionic-native/file: "^5.34.0"
代码示例:
startRecording() {
if (this.platform.is('ios')) {
this.fileName = 'record' + new Date().getDate() + new Date().getMonth() + new Date().getFullYear() + new Date().getHours() + new Date().getMinutes() + new Date().getSeconds() + '.mp3';
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' + new Date().getDate() + new Date().getMonth() + new Date().getFullYear() + new Date().getHours() + new Date().getMinutes() + new Date().getSeconds() + '.mp3';
this.filePath = this.file.externalDataDirectory + this.fileName;
this.audio = this.media.create(this.filePath);
}
this.audio.onStatusUpdate.subscribe(status => {
console.log("status", status)
});
this.audio.onSuccess.subscribe(() => {
console.log("success")
});
this.audio.onError.subscribe(error => {
console.log("error", error)
});
this.audio.startRecord();
this.recording = true;
}
【问题讨论】:
标签: android angular ionic-framework capacitor recorder