mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-31 03:43:57 +08:00
update: 录音按钮新增防抖
This commit is contained in:
@@ -168,7 +168,13 @@ class UIController {
|
|||||||
// Record button
|
// Record button
|
||||||
const recordBtn = document.getElementById('recordBtn');
|
const recordBtn = document.getElementById('recordBtn');
|
||||||
if (recordBtn) {
|
if (recordBtn) {
|
||||||
|
let recordTimer = null;
|
||||||
recordBtn.addEventListener('click', () => {
|
recordBtn.addEventListener('click', () => {
|
||||||
|
if (recordTimer) {
|
||||||
|
clearTimeout(recordTimer);
|
||||||
|
recordTimer = null;
|
||||||
|
}
|
||||||
|
recordTimer = setTimeout(() => {
|
||||||
const audioRecorder = getAudioRecorder();
|
const audioRecorder = getAudioRecorder();
|
||||||
if (audioRecorder.isRecording) {
|
if (audioRecorder.isRecording) {
|
||||||
audioRecorder.stop();
|
audioRecorder.stop();
|
||||||
@@ -185,6 +191,7 @@ class UIController {
|
|||||||
audioRecorder.start();
|
audioRecorder.start();
|
||||||
}, 100);
|
}, 100);
|
||||||
}
|
}
|
||||||
|
}, 300);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user