I am using a very basic HTML5 audio script and I would simply like the song to loop. How can I accomplish this? Thanks in advance!
$(".play").click(function(){
var snd = new Audio("bells.mp3");
snd.play();
});
I am using a very basic HTML5 audio script and I would simply like the song to loop. How can I accomplish this? Thanks in advance!
$(".play").click(function(){
var snd = new Audio("bells.mp3");
snd.play();
});
Specify the loop attribute in your HTML mark-up
<audio loop>
<source src="bells.mp3" type="audio/mpeg">
<audio>
No JavaScript needed
Set the loop
property to true
$(".play").click(function(){
var snd = new Audio("bells.mp3");
snd.loop = true;
snd.play();
});