MarseyWorld/files/assets/events/shared/js/music.js

20 lines
494 B
JavaScript
Raw Normal View History

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