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:39 +00:00
co-authored by Claude Sonnet 4.6
parent ce4209068f
commit d8f4cc97c6
2 changed files with 19 additions and 0 deletions
+18
View File
@@ -345,6 +345,7 @@ function handleMessage(msg) {
show('results-screen');
}
else if (msg.type === 'podium') {
stopBGM();
stopGame();
showPodium(msg.leaderboard);
}
@@ -367,6 +368,7 @@ document.getElementById('join-btn').addEventListener('click', () => {
}
myDept = dept;
const displayName = `${fn} ${ln}`;
startBGM();
ws.send(JSON.stringify({type: 'join', name: `${fn} ${ln}`, dept, display: displayName}));
});
@@ -749,6 +751,21 @@ function hexToRgb(hex) {
return `${r},${g},${b}`;
}
// ── BACKGROUND MUSIC ─────────────────────────────────────────────────────────
const bgm = document.getElementById('bgm');
let bgmStarted = false;
function startBGM() {
if (bgmStarted) return;
bgmStarted = true;
bgm.volume = 0.35;
bgm.play().catch(() => {});
}
function stopBGM() {
bgm.pause();
bgm.currentTime = 0;
bgmStarted = false;
}
connectWS();
function exitGame() {
@@ -758,5 +775,6 @@ function exitGame() {
connectWS();
}
</script>
<audio id="bgm" src="/static/music.mp3" loop preload="auto"></audio>
</body>
</html>