forked from rDrama/rDrama
1
0
Fork 0

dont play music in multiple tabs

master
Aevann 2023-10-17 22:35:00 +03:00
parent 63f049f1b6
commit 8ccd8173a3
2 changed files with 85 additions and 67 deletions

View File

@ -1,7 +1,17 @@
if (localStorage.getItem("music_playing") != 'true') {
const audio = document.getElementById('event-song');
audio.addEventListener('play', () => {
localStorage.setItem("music_playing", true);
})
window.addEventListener('beforeunload', () => {
localStorage.setItem("music_playing", false);
})
audio.play();
document.addEventListener('click', () => {
if (audio.paused) audio.play();
}, {once : true});
prepare_to_pause(audio)
}

View File

@ -1,6 +1,15 @@
let u_username = document.getElementById('u_username')
if (localStorage.getItem("music_playing") != 'true') {
const audio = document.getElementById('profile-song')
audio.addEventListener('play', () => {
localStorage.setItem("music_playing", true);
})
window.addEventListener('beforeunload', () => {
localStorage.setItem("music_playing", false);
})
let u_username = document.getElementById('u_username')
const anthem_button = document.getElementById('toggle-anthem')
const anthem_button_mobile = document.getElementById('toggle-anthem-mobile')
@ -22,8 +31,6 @@ function pause_audio(audio) {
if (u_username)
{
u_username = u_username.innerHTML
function toggle() {
if (audio.paused) {
play_audio(audio);
@ -77,3 +84,4 @@ else
prepare_to_pause(audio)
}
}
}