Tone.js/examples/player.html

36 lines
No EOL
798 B
HTML

<html>
<head>
<title>Basic Player</title>
<script src="http://code.jquery.com/jquery-2.1.0.min.js"></script>
<script type="text/javascript" src="../Tone.js"></script>
<link rel="stylesheet" type="text/css" href="exampleStyle.css">
</head>
<body>
<div>press and hold the button to play a 10ms grain from the audio file</div>
<br>
<button>start</button>
<div id='loading'>loading...</button>
<script type="text/javascript">
var player = new Tone.Player("./audio/casio/A1.mp3", function(){
$("#loading").remove();
});
//connect it to the output
player.toMaster();
$("button").mousedown(function(){
player.loop(0, .1, .11);
$(this).text("stop");
});
$("button").mouseup(function(){
player.stop();
$(this).text("start");
});
</script>
</body>
</html>