Skip to content

Instantly share code, notes, and snippets.

@sasekazu
Created August 17, 2014 11:22
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 sasekazu/9a77044fd29fe90ab3cc to your computer and use it in GitHub Desktop.
Save sasekazu/9a77044fd29fe90ab3cc to your computer and use it in GitHub Desktop.
HTML5 Audio
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>audio test</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script>
$(document).ready(function () {
$("#puyon1Button").click(function () {
console.log("puyon1");
document.getElementById("puyon1").play();
});
$("#nyu1Button").click(function () {
console.log("nyu1");
document.getElementById("nyu1").play();
});
});
</script>
</head>
<body>
<div>
<input id="puyon1Button" value="ぷよん" type="button" />
<input id="nyu1Button" value="ニュッ1" type="button" />
</div>
<audio id="puyon1" preload="auto">
<source src="sound/puyon1.mp3" type="audio/mp3">
<source src="sound/puyon1.ogg" type="audio/ogg">
<source src="sound/puyon1.wav" type="audio/wav">
<p>※ご利用のブラウザでは音声を再生することができません。</p>
</audio>
<audio id="nyu1" preload="auto">
<source src="sound/nyu1.mp3" type="audio/mp3">
<source src="sound/nyu1.ogg" type="audio/ogg">
<source src="sound/nyu1.wav" type="audio/wav">
<p>※ご利用のブラウザでは音声を再生することができません。</p>
</audio>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment