I inserted the audio in html. But the audio gets started before the entire page loads. I want the audio to be played after the entire page gets loaded.
<audio src="bg.mp3" autoplay="autoplay" loop="loop"></audio>
Can anyone help me in this.
I inserted the audio in html. But the audio gets started before the entire page loads. I want the audio to be played after the entire page gets loaded.
<audio src="bg.mp3" autoplay="autoplay" loop="loop"></audio>
Can anyone help me in this.
You're going to need JavaScript for that. Remove the autoplay
attribute:
<audio id="my_audio" src="bg.mp3" loop="loop"></audio>
and add a script like this:
window.onload = function() {
document.getElementById("my_audio").play();
}
Or if you use jQuery:
$(document).ready(function() {
$("#my_audio").get(0).play();
});
Just Copy and Paste this Code in Body section of your HTML Code.
<audio autoplay>
<source src="song.mp3" type="audio/mpeg">
</audio>
and make sure that your audio file should be in same folder.
I think you must use JS (jQuery) function to do get document ready
$(document).ready(function()
Play an audio file using jQuery when a button is clicked
You have answer here (if I follow you right)
For a repeated tone place the below code
<audio src="./audio/preloader.mp3" autoplay="autoplay" loop="loop"></audio>
and for a single time, remove the loop. Then it should be like this
<audio src="./audio/preloader.mp3" autoplay="autoplay"></audio>