made looping and autoplay in js

This commit is contained in:
Garrett Finucane 2014-07-07 10:55:12 -04:00
parent 5b3e6b9187
commit e4edf9901e
2 changed files with 8 additions and 2 deletions

View file

@ -65,10 +65,10 @@
</p>
</div>
<div onClick="showHelp()" id="openSideBar"><i class="fa fa-info-circle fa-lg"></i><span id ='helpText'> <i class="fa fa-arrow-left"><b> Help</b></i></span></div>
<audio id="intro" autoplay>
<audio id="intro">
<source src="sounds/intro.ogg" type="audio/ogg">
</audio >
<audio id="loop" loop >
<audio id="loop" >
<source src="sounds/loop.ogg" type="audio/ogg">
</audio>
<div id="overlay" class="faded"></div>

View file

@ -172,10 +172,16 @@ function hideUIElements() {
$('#startBtn').hide();
}
function loadListeners(){
document.getElementById('intro').play();
document.getElementById('intro').addEventListener('ended', function(){
this.pause();
toggleAudio();
}, false);
document.getElementById('loop').addEventListener('ended', function(){
this.currentTime = 0;
this.play();
}, false);
}
function toggleAudio(){
var loopAudio = document.getElementById("loop");