Make sound with loop at HTML5

Loop Method 1

Use pure html5 tag like this,

Loop Method 1
Use html5 and javascript like this,

<
document.getElementById('audio_2').addEventListener('ended', function(){
 this.currentTime = 0;
}, false);

Loop Method 3
Uses two JavaScript functions and two audio elements with the same source to alternate playback duties.


	
document.getElementById('audio_3').addEventListener('ended', function(){
	this.currentTime = 0;
	this.pause();
	document.getElementById('audio_4').play();
	}, false);
	 
	document.getElementById('audio_4').addEventListener('ended', function(){
	this.currentTime = 0;
	this.pause();
	document.getElementById('audio_3').play();
	}, false);

Reference:
http://forestmist.org/tag/javascript/

Posted in Java Script

Leave a Reply