import { onMounted, ref } from 'vue';
const recorderManager = uni.getRecorderManager();
console.log(recorderManager)
// 用于存储当前声音分贝值
const decibelValue = ref(null);
// 开始录音
const startRecord = () => {
recorderManager.start({
detectDecibel: true
});
console.log('开始录音');
};
// 停止录音
const stopRecord = () => {
recorderManager.stop();
console.log('停止录音');
};
// 监听声音分贝变化事件
recorderManager.onDecibelChange((res) => {
decibelValue.value = res.dB;
});
// 监听录音停止事件
recorderManager.onStop(() => {
decibelValue.value = null;
});