mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-22 07:03:53 +08:00
update: 拨号成功后开启自动录音
This commit is contained in:
@@ -83,6 +83,12 @@ if (document.readyState === 'loading') {
|
||||
document.addEventListener('DOMContentLoaded', () => app.init());
|
||||
} else {
|
||||
app.init();
|
||||
window.addEventListener('beforeunload', () => {
|
||||
// 销毁定时器
|
||||
if (app.uiController && app.uiController.wsTimer) {
|
||||
clearInterval(app.uiController.wsTimer);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export default app;
|
||||
|
||||
@@ -11,6 +11,7 @@ class UIController {
|
||||
this.visualizerCanvas = null;
|
||||
this.visualizerContext = null;
|
||||
this.audioStatsTimer = null;
|
||||
this.wsTimer = null;
|
||||
this.currentBackgroundIndex = 0;
|
||||
this.backgroundImages = ['1.png', '2.png', '3.png'];
|
||||
|
||||
@@ -331,6 +332,20 @@ class UIController {
|
||||
this.addChatMessage('配置已保存', false);
|
||||
}
|
||||
|
||||
// 拨号成功后直接开始录音
|
||||
dialAndRecord() {
|
||||
const recordBtn = document.getElementById('recordBtn');
|
||||
const wsHandler = getWebSocketHandler();
|
||||
this.wsTimer = setInterval(() => {
|
||||
if (wsHandler.isConnected() && wsHandler.websocket.onopen) {
|
||||
clearInterval(this.wsTimer);
|
||||
this.wsTimer = null;
|
||||
recordBtn.click();
|
||||
return;
|
||||
}
|
||||
}, 500);
|
||||
}
|
||||
|
||||
// 处理连接按钮点击
|
||||
async handleConnect() {
|
||||
console.log('handleConnect called');
|
||||
@@ -415,6 +430,8 @@ class UIController {
|
||||
dialBtn.disabled = false;
|
||||
dialBtn.querySelector('.btn-text').textContent = '挂断';
|
||||
dialBtn.classList.add('dial-active');
|
||||
|
||||
this.dialAndRecord();
|
||||
}
|
||||
|
||||
this.hideModal('settingsModal');
|
||||
|
||||
Reference in New Issue
Block a user