feat: add background music support and static files mount

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-04 03:42:34 +00:00
co-authored by Claude Sonnet 4.6
parent fb6a280e85
commit ffbf75e60d
3 changed files with 23 additions and 0 deletions
+20
View File
@@ -660,6 +660,7 @@ function handle(msg) {
else showRoundResults(msg);
}
else if (msg.type === 'podium') {
stopBGM();
showPodium(msg.leaderboard);
}
}
@@ -685,6 +686,7 @@ document.getElementById('join-btn').addEventListener('click', () => {
}
const display = `${fn} ${ln}`;
startBGM();
ws.send(JSON.stringify({type: 'join', name: display, dept, display}));
});
@@ -787,6 +789,23 @@ function showPodium(lb) {
// ── INIT ──────────────────────────────────────────────────────────────────────
// ── BACKGROUND MUSIC ─────────────────────────────────────────────────────────
let bgmStarted = false;
function startBGM() {
const bgm = document.getElementById('bgm');
if (bgmStarted) return;
bgmStarted = true;
bgm.volume = 0.20;
bgm.play().catch(() => {});
}
function stopBGM() {
const bgm = document.getElementById('bgm');
bgm.pause();
bgm.currentTime = 0;
bgmStarted = false;
}
window.addEventListener('resize', () => { if (grid) { setupCanvas(); drawGrid(); }});
connectWS();
</script>
@@ -800,5 +819,6 @@ connectWS();
</div>
</div>
<audio id="bgm" src="/static/music.mp3" loop preload="auto"></audio>
</body>
</html>