Skip to content

Instantly share code, notes, and snippets.

@dnoyes
Created February 23, 2012 03:00
Show Gist options
  • Save dnoyes/1889579 to your computer and use it in GitHub Desktop.
Save dnoyes/1889579 to your computer and use it in GitHub Desktop.
html5 audio
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
var a = new Audio();
var sources = [
'http://www.pacdv.com/sounds/fart-sounds/fart-2.wav',
'http://www.pacdv.com/sounds/fart-sounds/fart-3.wav',
'http://www.pacdv.com/sounds/fart-sounds/fart-8.wav'];
function playFart() {
var i = Math.floor(Math.random()*sources.length);
a.pause();
a.src = sources[i];
a.startTime = 0;
a.play();
}
</script>
<style>
.container {width:400px; height:400px; background-color:red;}
</style>
</head>
<body>
<div class="container" onmouseover="playFart();">poop</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment