Background music

How do I make background music on my site (page)?

You can use the audio (and optionally also source) tag(s) for that purpose. Here’s an example of using only the audio tag:

<audio autoplay loop src="yourfile.mp3"></audio>

and here’s another example of using both the audio and source tags together:

<audio autoplay loop>
     <source src="yourfile.mp3" type="audio/mp3">

Put only one of these inside your body tag, overwriting yourfile.mp3 with your MP3 file path or URL or, if it doesn’t work for you, use the code @anon19508339 sent, overwriting music-path-goes-here with your MP3 file path or URL.


Due the new chrome policy, The auto-music play got disabled, Which cannot be played automatically.
But there’s still a way to play it non-automatically( only by clicking at free area), By using these inside body tag:

<audio id='music' loop="loop" preload="none" src="music-path-goes-here"></audio>
<div style='position: absolute; z-index: -99; width: 100%; height: 100%' onclick='document.getElementById("music").play();' ontouchstart='document.getElementById("music").play();'>Play</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.