Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save minakshi-sharma/9c328ac1664a5b31f5401e63cec6c58a to your computer and use it in GitHub Desktop.
Save minakshi-sharma/9c328ac1664a5b31f5401e63cec6c58a to your computer and use it in GitHub Desktop.
Add background music to the webpage
<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