Tone.js/examples/player.html

33 lines
655 B
HTML
Raw Normal View History

2014-03-15 03:17:18 +00:00
<html>
<head>
<title>Basic Player</title>
2014-06-19 17:38:21 +00:00
<script type="text/javascript" src="../Tone.js"></script>
2014-03-15 03:17:18 +00:00
</head>
<body>
<button>trigger</button>
<div id='loading'>loading...</button>
2014-03-15 03:17:18 +00:00
<script type="text/javascript">
2014-04-06 00:47:59 +00:00
2014-06-16 23:38:13 +00:00
var player = new Tone.Player("./audio/casio/A1.mp3");
2014-04-06 00:47:59 +00:00
//connect it to the output
player.toMaster();
//once it's loaded, add the event triggers
player.load(function(){
document.querySelector('#loading').remove();
});
2014-04-06 00:47:59 +00:00
var button = document.querySelector('button');
2014-04-06 00:47:59 +00:00
button.onmousedown = function(){
player.loop(0, .1, .11);
};
2014-03-15 03:17:18 +00:00
button.onmouseup = function(){
player.stop();
}
2014-06-20 01:48:16 +00:00
2014-03-15 03:17:18 +00:00
</script>
</body>
</html>