代码:
// 开始录制对应的流程
async startRecordingProcess() {
if (this.avRecorder != undefined) {
await this.avRecorder.release();
this.avRecorder = undefined;
}
// 1.创建录制实例
this.avRecorder = await media.createAVRecorder();
this.setAudioRecorderCallback();
// 2.获取录制文件fd赋予avConfig里的url;参考FilePicker文档
this.avConfig = this.createNewAudioFile()
// 3.配置录制参数完成准备工作
await this.avRecorder.prepare(this.avConfig.config);
// 4.开始录制
await this.avRecorder.start();
}
但是AVRecorder不可以监听收到音频的音量大小,如果想获取音量的大小,只能使用AudioCapturer。