Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

audio cotrol #17

Open
wants to merge 1 commit into
base: gh-pages
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions css/bootstrap.min.css

Large diffs are not rendered by default.

Binary file modified css/nyan.css
Binary file not shown.
Binary file added fonts/glyphicons-halflings-regular.eot
Binary file not shown.
288 changes: 288 additions & 0 deletions fonts/glyphicons-halflings-regular.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added fonts/glyphicons-halflings-regular.ttf
Binary file not shown.
Binary file added fonts/glyphicons-halflings-regular.woff
Binary file not shown.
Binary file added fonts/glyphicons-halflings-regular.woff2
Binary file not shown.
10 changes: 7 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@
<head>
<meta charset="UTF-8">
<title>Nyan Cat - HTML5+CSS3+JS</title>
<link href="css/bootstrap.min.css" rel="stylesheet">

<link rel="stylesheet" href="css/nyan.css"/>
</head>
<body>
<a id="audio-button" class="btn btn-default audio-button" alt="toggle audio" onclick="toggleAudio()">
<span id="audio-button-icon" class="glyphicon glyphicon glyphicon glyphicon-volume-up" aria-hidden="true"></span>
</a>
<div class="sparks-combo">
<div class="spark"></div>
<div class="spark"></div>
Expand Down Expand Up @@ -39,14 +43,14 @@
<span>My Github Repo</span>
</a>

<audio autoplay="true" loop="true">
<audio id="nyan-sound" autoplay loop>
<source src="audio/nyan-cat.ogg" type="audio/ogg" />
<source src="audio/nyan-cat.mp3" type="audio/mpeg" />
</audio>

<!-- Libs -->
<script src="//code.jquery.com/jquery-1.10.1.min.js"></script>
<script src="//code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script src="http://code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
<!-- Nyan Stuff -->
<script src="js/nyan.js"></script>
</body>
Expand Down
23 changes: 22 additions & 1 deletion js/nyan.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,25 @@ $(function() {
var timer = setInterval(function () {
nyancat.cycleFrames();
}, 70);
});
});

function toggleAudio() {
var audio = $("#nyan-sound")[0];
if (audio.paused) {
audio.play();
toggleAudioIcon()
} else {
audio.pause();
toggleAudioIcon()
}
}

function toggleAudioIcon() {
if ($('#audio-button-icon').hasClass('glyphicon-volume-off')) {
$('#audio-button-icon').removeClass('glyphicon-volume-off');
$('#audio-button-icon').addClass('glyphicon-volume-up');
} else {
$('#audio-button-icon').removeClass('glyphicon-volume-up');
$('#audio-button-icon').addClass('glyphicon-volume-off');
}
}