benerin sound leaderboard

This commit is contained in:
Nathan 2025-12-19 02:27:47 +07:00
parent d79d21b222
commit 6511e5d59a
2 changed files with 16 additions and 4 deletions

View File

@ -129,7 +129,7 @@ body {
} }
.table-header { .table-header {
background: rgba(255, 255, 255, 0.617); background: rgba(255, 255, 255, 0.442);
font-weight: bold; font-weight: bold;
border-radius: 15px 15px 0 0; border-radius: 15px 15px 0 0;
text-transform: uppercase; text-transform: uppercase;
@ -232,7 +232,7 @@ body {
.col-date { .col-date {
font-size: 0.8rem; font-size: 0.8rem;
color: #888; color: #313131;
text-align: right; text-align: right;
} }

View File

@ -12,15 +12,27 @@ const lbAudio = document.getElementById("lbAudio");
let isLbPlaying = true; let isLbPlaying = true;
if (lbMusicBtn && lbAudio) { if (lbMusicBtn && lbAudio) {
// --- TAMBAHAN: Coba play langsung saat load ---
lbAudio.play().then(() => {
// Jika browser mengizinkan, set icon jadi nyala
lbMusicBtn.innerHTML = "🔊";
isLbPlaying = true;
}).catch(error => {
// Jika browser memblokir (Autoplay Policy), set ke mute dulu
console.log("Autoplay dicegah browser, menunggu interaksi user.");
lbMusicBtn.innerHTML = "🔇";
isLbPlaying = false; // Ubah state jadi false biar klik berikutnya nge-play
});
// ----------------------------------------------
lbMusicBtn.addEventListener("click", () => { lbMusicBtn.addEventListener("click", () => {
if (isLbPlaying) { if (isLbPlaying) {
lbAudio.pause(); lbAudio.pause();
lbMusicBtn.innerHTML = "🔇"; lbMusicBtn.innerHTML = "🔇";
isLbPlaying = false; isLbPlaying = false;
} else { } else {
// Memulai musik
lbAudio.play().catch(error => { lbAudio.play().catch(error => {
console.log("Autoplay dicegah browser, klik manual diperlukan."); console.log("Gagal memutar audio:", error);
}); });
lbMusicBtn.innerHTML = "🔊"; lbMusicBtn.innerHTML = "🔊";
isLbPlaying = true; isLbPlaying = true;