35 lines
690 B
JavaScript
35 lines
690 B
JavaScript
// Audio Manager - Handles background music only
|
|
|
|
class AudioManager {
|
|
constructor() {
|
|
this.bgMusic = document.getElementById('bg-music');
|
|
if (this.bgMusic) {
|
|
this.bgMusic.volume = 0.5;
|
|
}
|
|
}
|
|
|
|
playLobby() {
|
|
// No lobby music
|
|
}
|
|
|
|
playGame() {
|
|
if (!this.bgMusic) return;
|
|
this.bgMusic.src = '/audio/tetris_theme_og.mp3';
|
|
this.bgMusic.loop = true;
|
|
this.bgMusic.play().catch(e => console.log('Audio autoplay blocked:', e));
|
|
}
|
|
|
|
playGameOver() {
|
|
// No game over music
|
|
}
|
|
|
|
stop() {
|
|
if (!this.bgMusic) return;
|
|
this.bgMusic.pause();
|
|
this.bgMusic.currentTime = 0;
|
|
}
|
|
}
|
|
|
|
// Initialize audio manager
|
|
const audio = new AudioManager();
|