Skip to content

Instantly share code, notes, and snippets.

@rcguy
Last active Aug 29, 2015
Embed
What would you like to do?
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