mute unmute and audio

This commit is contained in:
Garrett Finucane 2014-07-05 17:18:23 -04:00
parent 838c707018
commit 311e2ef734
4 changed files with 25 additions and 8 deletions

View file

@ -7,7 +7,7 @@
<link rel="stylesheet" type="text/css" href="style/style.css">
<link rel="stylesheet" href="style/fa/css/font-awesome.min.css">
</head>
<body onload="playTunes()">
<body onload="toggleAudio()">
<canvas id="canvas"></canvas>
<div id='devtools' style='z-index:3;display:none;position:absolute;left:50%;width:400px;height:400px;top:50%;margin-top:-200px;margin-left:-200px;'>
<h2 id = 'clickToExit' style = 'background-color:#fff;color:#000'>Click to exit</h2>
@ -67,12 +67,13 @@
<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></span></div>
<audio id="intro">
<source src="sounds/intro.ogg" type="audio/ogg">
</audio id="loop">
<audio id="loop" loop>
</audio >
<audio id="loop" autoplay loop="loop">
<source src="sounds/loop.ogg" type="audio/ogg">
</audio>
<div id="overlay" class="faded"></div>
<div id = 'pauseBtn'><i class="fa fa-pause fa-2x"></i></div>
<div id = 'volumeBtn'><i class="fa fa-volume-up fa-2x"></i></div>
<div id = 'restartBtn'><i class="fa fa-refresh fa-2x"></i></div>
</body>
</html>

View file

@ -104,7 +104,15 @@ $(document).ready(function(){
return false;
});
$("#volumeBtn").on('touchstart mousedown', function() {
if (toggleAudio()) {
$("#volumeBtn").html('<i class="fa fa-volume-off fa-2x"></i>');
} else {
$("#volumeBtn").html('<i class="fa fa-volume-up fa-2x"></i>');
}
return false;
});
$("#restartBtn").on('touchstart mousedown', function() {
if (gameState==2 || gameState==1 || importing == 1) {
init(1);

View file

@ -172,10 +172,11 @@ function hideUIElements() {
$('#restartBtn').hide();
$('#startBtn').hide();
}
function playTunes(){
var introAudio = document.getElementById("loop");
introAudio.play();
function toggleAudio(){
var loopAudio = document.getElementById("loop");
if(loopAudio.paused) loopAudio.play();
else loopAudio.pause()
return loopAudio.paused
}
function init(b) {

View file

@ -59,7 +59,14 @@ button:focus {
color:#000;
cursor:pointer;
}
#volumeBtn {
position: absolute;
top: 2px;
right: 4px;
z-index: 3000;
color:#000;
cursor:pointer;
}
#pauseBtn {
position: absolute;
margin-bottom: 3px;