In HTML5 we can play a audio file using the <audio> tag. It show a simple audio controller in the web page. when we click on the play button of the controller then the specific audio is playing. But we can playing any audio in html automatically just after loding the page or just after refresh the page. We use an <audio> without any controller. and a very simple code in java script or jQuery to playing the audio.
<audio id="tah_audio" src="bg.mp3" loop="loop"></audio>
window.onload = function() {
document.getElementById("tah_audio").play();
}
$(document).ready(function() {
$("#tah_audio").get(0).play();
});
We can also play audio on page load without using any Javascript or JQuery. Only write the following HTML5 code.
<audio autoplay>
<source src="tah.mp3" type="audio/mpeg">
</audio>