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