Skip to content

Instantly share code, notes, and snippets.

@rcguy
Last active August 29, 2015 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rcguy/af34063f5dd8a0acf330 to your computer and use it in GitHub Desktop.
Save rcguy/af34063f5dd8a0acf330 to your computer and use it in GitHub Desktop.
play audio using a button/javascript on an html webpage
<!DOCTYPE html>
<html>
<audio id="audio1" src="audio1.ogg" autobuffer></audio>
<script>
var aid = document.getElementById("audio1");
aid.volume = 0.2;
function EvalSound(soundobj) {
var thissound=document.getElementById(soundobj);
thissound.play();
}
</script>
<div align="center">
<form>
<input type="button" value="Click Me! Click Me!" onClick="EvalSound('audio1')">
</form>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment