#Autoplay when page loads
14 messages · Page 1 of 1 (latest)
window.onload =
function auto() {
musicContainer.classList.add('play');
playBtn.querySelector('i.fas').classList.remove('fa-play');
playBtn.querySelector('i.fas').classList.add('fa-pause');
audio.play();
audio.volume = 0.3;
}
i tried this
but dint work
the idea is that this starts autoplaying
this is the css code
Not sure if this is your issue, but many browsers block autoplay because users don't want things to just start playing and making noise on load. Something to consider.
let me do a quick test
im gonna try this code
// Call playSong() when the page loads
window.addEventListener('load', playSong);
bcs its a loading screen so it can work i guess
There's also rules on when it's allowed in chrome for example. But I don't remember the criteria
for a loading screen in a game
i think i got it working