Use pause instead of mute

This commit is contained in:
Christian Semmler 2025-07-19 09:17:38 -07:00
parent 7c4a858767
commit 553a714591
No known key found for this signature in database
GPG Key ID: 086DAA1360BEEE5C
2 changed files with 9 additions and 9 deletions

16
app.js
View File

@ -30,22 +30,22 @@ document.addEventListener('DOMContentLoaded', function () {
// --- Sound Toggle --- // --- Sound Toggle ---
function updateSoundEmojiState() { function updateSoundEmojiState() {
soundToggleEmoji.textContent = audio.muted ? '🔇' : '🔊'; soundToggleEmoji.textContent = audio.paused ? '🔇' : '🔊';
soundToggleEmoji.title = audio.muted ? 'Unmute Audio' : 'Mute Audio'; soundToggleEmoji.title = audio.paused ? 'Play Audio' : 'Pause Audio';
} }
if (audio && soundToggleEmoji) { if (audio && soundToggleEmoji) {
updateSoundEmojiState(); updateSoundEmojiState();
soundToggleEmoji.addEventListener('click', function () { soundToggleEmoji.addEventListener('click', function () {
audio.muted = !audio.muted; if (audio.paused) {
if (!audio.muted) {
audio.currentTime = 0; audio.currentTime = 0;
audio.play(); audio.play();
} else {
audio.pause();
} }
updateSoundEmojiState();
}); });
audio.addEventListener('volumechange', updateSoundEmojiState); audio.addEventListener('play', updateSoundEmojiState);
audio.addEventListener('pause', updateSoundEmojiState);
} }
// --- Control Image Hover --- // --- Control Image Hover ---
@ -68,7 +68,7 @@ document.addEventListener('DOMContentLoaded', function () {
runGameButton.addEventListener('click', function () { runGameButton.addEventListener('click', function () {
if (!Module.running) return; if (!Module.running) return;
audio.muted = true; audio.pause();
updateSoundEmojiState(); updateSoundEmojiState();
this.src = this.dataset.on; this.src = this.dataset.on;

View File

@ -43,7 +43,7 @@
<div id="top-content"> <div id="top-content">
<div class="video-container"> <div class="video-container">
<img id="install-video" width="260" height="260" src="install.webp" alt="Install Game"> <img id="install-video" width="260" height="260" src="install.webp" alt="Install Game">
<audio id="install-audio" loop muted preload="none"> <audio id="install-audio" loop preload="none">
<source src="install.mp3" type="audio/mpeg"> <source src="install.mp3" type="audio/mpeg">
Your browser does not support the audio tag. Your browser does not support the audio tag.
</audio> </audio>