fix: Web Client — добавлена функция updateRmsMeter
Проблема: updateRmsMeter is not defined Решение: - Добавлена функция updateRmsMeter(level) - Добавлены DOM элементы rmsFill, rmsValue - Добавлена переменная rmsTimeout Теперь audio-level события обрабатываются корректно
This commit is contained in:
@@ -361,6 +361,7 @@
|
||||
let analyser = null;
|
||||
let source = null;
|
||||
let mediaStream = null;
|
||||
let rmsTimeout = null;
|
||||
|
||||
const canvas = document.getElementById('audioCanvas');
|
||||
const ctx = canvas.getContext('2d');
|
||||
@@ -383,6 +384,8 @@
|
||||
const haStatusSpan = document.getElementById('haStatus');
|
||||
const liveVolSpan = document.getElementById('liveVol');
|
||||
const eventFeedDiv = document.getElementById('eventFeed');
|
||||
const rmsFill = document.getElementById('rmsFill');
|
||||
const rmsValue = document.getElementById('rmsValue');
|
||||
|
||||
function addEventToLog(message, type = 'info') {
|
||||
const time = new Date().toLocaleTimeString('ru-RU', {hour:'2-digit', minute:'2-digit', second:'2-digit'});
|
||||
@@ -416,6 +419,20 @@
|
||||
}
|
||||
}
|
||||
|
||||
// Update RMS meter
|
||||
function updateRmsMeter(level) {
|
||||
const percent = Math.min(100, Math.max(0, level * 100));
|
||||
rmsFill.style.width = percent + '%';
|
||||
rmsValue.textContent = level.toFixed(2);
|
||||
|
||||
// Reset after 1 second of no audio
|
||||
clearTimeout(rmsTimeout);
|
||||
rmsTimeout = setTimeout(() => {
|
||||
rmsFill.style.width = '0%';
|
||||
rmsValue.textContent = '0.00';
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
function sendCommand(command, payload = {}) {
|
||||
if(!ws || ws.readyState !== WebSocket.OPEN) {
|
||||
addEventToLog(`❌ Не удалось отправить: ${command} — нет соединения`);
|
||||
|
||||
Reference in New Issue
Block a user