Ask HN: What is the best way to start autoplay?
As you know, some browsers prevent 'autoplay' in <audio id="sound" src="track.mp3" autoplay></audio>. I have 2 solutions and need to choose only one:
1) <body onclick="document.getElementById('sound').play();">
VS
2) document.addEventListener('click', musicPlay); function musicPlay() { document.getElementById('sound').play(); }
Thank you.
2 comments
[ 7.3 ms ] story [ 30.0 ms ] threadhttps://stackoverflow.com/ might be better suited for specific programming language questions.