在使用AVRecorder录音时,需要同时获取声音的音量。目前只找到获取设备媒体的音量,这不符合需求。请问有别的方式获取吗?
setInterval(() => {
let audioManager = audio.getAudioManager();
let audioVolumeManager: audio.AudioVolumeManager = audioManager.getVolumeManager();
let groupId: number = audio.DEFAULT_VOLUME_GROUP_ID;
audioVolumeManager.getVolumeGroupManager(groupId, (err: BusinessError, value: audio.AudioVolumeGroupManager) => {
if (err) {
console.error(`[audio] Failed to obtain the volume group infos list. ${err}`);
return;
}
value.getVolume(audio.AudioVolumeType.MEDIA, (err: BusinessError, value: number) => {
if (err) {
console.error(`[audio] Failed to obtain the volume. ${err}`);
return;
}
console.info('[audio] volume ' + value);
});
console.info('[audio] Callback invoked to indicate that the volume group infos list is obtained.');
});
}, 300)
AVRecorder暂不支持监听收到音频音量大小,可以使用AudioCapturer,提供音频采集的相关接口,使用getVolume获取音量的大小。