изменение текущего времени, тест 1

This commit is contained in:
2026-05-25 13:49:40 +03:00
parent 3738538d23
commit 508d209377
3 changed files with 46 additions and 1 deletions

View File

@@ -3761,4 +3761,49 @@ function buildChannelValue(matchId) {
if (hasMatch) return "match";
return "";
}
function setClockSeconds(newSeconds) {
const wasRunning = !!timerId;
if (timerId) {
clearInterval(timerId);
timerId = null;
}
pausedAccumulatedSeconds = Math.max(0, Number(newSeconds) || 0);
matchClockSeconds = pausedAccumulatedSeconds;
if (wasRunning) {
periodStartedAt = Date.now();
timerId = setInterval(() => {
updateTimerUI();
saveMatchState();
}, 1000);
} else {
periodStartedAt = null;
}
updateTimerUI();
saveMatchState();
syncClockToVmix(matchClockSeconds, wasRunning);
}
async function syncClockToVmix(seconds, shouldRun) {
const h = String(Math.floor(seconds / 3600)).padStart(2, "0");
const m = String(Math.floor((seconds % 3600) / 60)).padStart(2, "0");
const s = String(seconds % 60).padStart(2, "0");
const value = `${h}:${m}:${s}`;
const commands = [
vmixCmd("Function=SetCountdown&Input=ВЕРХНИЙ СЧЕТ&SelectedName=Таймер.Text&Value=02:00:00"),
vmixCmd(`Function=ChangeCountdown&Input=ВЕРХНИЙ СЧЕТ&SelectedName=Таймер.Text&Value=${value}`),
vmixCmd(
shouldRun
? "Function=StartCountdown&Input=ВЕРХНИЙ СЧЕТ&SelectedName=Таймер.Text"
: "Function=PauseCountdown&Input=ВЕРХНИЙ СЧЕТ&SelectedName=Таймер.Text"
)
];
await sendDirectVmixCommands(commands);
}