Created
April 25, 2018 12:57
-
-
Save albach/33f878acce557f69a778d65db6ca889e to your computer and use it in GitHub Desktop.
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
<!-- === HTML AUDIO --> | |
<audio id="cAudio"> | |
<source src="../static/media/c_note.mp3" type="audio/mpeg"></source> | |
<source src="../static/media/c_note.ogg" type="audio/ogg"></source> | |
<source src="../static/media/c_note.wav" type="audio/wav"></source> | |
</audio> | |
<a id="c" href="">Click me!</a> | |
<script type="text/javascript"> | |
// === JS AUDIO | |
// This controls the button for the c note. | |
// This variable calls the cNote audio element in the HTML. | |
var cNote = document.getElementById('cAudio'); | |
// This turns our <div id= "c"> into a button that plays our audio file when the box is pressed. | |
$('#c').on("mousedown", function(){ | |
// This is a property that scrubs the audio file back to its start. | |
cNote.currentTime = 0; | |
// This plays the audio file. | |
cNote.play(); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment