Created
April 21, 2020 11:50
-
-
Save minakshi-sharma/9c328ac1664a5b31f5401e63cec6c58a to your computer and use it in GitHub Desktop.
Add background music to the webpage
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<p><audio id="loop-limited" controls="controls" autoplay style="width: 6em;height:20px;"><source src="http://www.chakdhoom.com/wp-content/uploads/2017/01/chak-1-AudioTrimmer.com_.mp3" type="audio/ogg" /><source src="http://www.chakdhoom.com/wp-content/uploads/2017/01/chak-1-AudioTrimmer.com_.mp3" type="audio/mpeg" /></audio><br /> | |
<script> | |
var loopLimit = 5; | |
var loopCounter = 0; | |
document.getElementById('loop-limited').addEventListener('ended', function(){if (loopCounter < loopLimit){this.currentTime = 0;this.play();loopCounter++;} | |
}, false);</script></p> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment