From d8f4cc97c6d02a8ea4888dcc01061c40f8386c05 Mon Sep 17 00:00:00 2001 From: Carlos Lugo Date: Thu, 4 Jun 2026 03:42:39 +0000 Subject: [PATCH] feat: add background music support and static files mount Co-Authored-By: Claude Sonnet 4.6 --- docker-compose.yml | 1 + templates/player.html | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/docker-compose.yml b/docker-compose.yml index 4805338..87b424c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,6 +3,7 @@ services: build: . volumes: - quiz-data:/data + - ./static:/app/static environment: - DB_PATH=/data/quiz.db restart: unless-stopped diff --git a/templates/player.html b/templates/player.html index a7e2dd5..93ac62f 100644 --- a/templates/player.html +++ b/templates/player.html @@ -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(); } + \ No newline at end of file