forked from rDrama/rDrama
dont play music in multiple tabs
parent
63f049f1b6
commit
8ccd8173a3
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue