This is the method I use to automatically play the audio on the page when I open it
- Creating
iframe
with empty audio:
<iframe src="assets/music/silence.mp3" allow="autoplay" id="audio" style="display:none"></iframe>
You can use this sound: silence
- Add audio tag with your original sound:
<audio id="player" preload="auto" autoplay loop>
<source src="assets/music/loop.mp3" type="audio/mp3">
</audio>
I found this solution on stackoverflow
This is my examples (they have a background sound):