Tone.js/examples/player.html

62 lines
1.2 KiB
HTML
Raw Normal View History

2014-03-15 03:17:18 +00:00
<html>
<head>
<title>Basic Player</title>
<link rel="stylesheet" type="text/css" href="../style/GUI.css">
<script src="http://code.jquery.com/jquery-2.1.0.min.js"></script>
2014-03-16 17:33:56 +00:00
<script type="text/javascript" src="../src/core/Tone.js"></script>
2014-04-05 00:24:19 +00:00
<script type="text/javascript" src="../src/component/Player.js"></script>
2014-03-15 03:17:18 +00:00
</head>
<body>
<style type="text/css">
#Trigger {
2014-03-15 03:30:00 +00:00
margin-left: -50px;
margin-top: -50px;
2014-03-15 03:17:18 +00:00
width: 100px;
height: 100px;
position: absolute;
top: 50%;
left: 50%;
background-color: blue;
2014-03-15 03:30:00 +00:00
}
#Trigger:after {
font-family: monospace;
position: absolute;
width: 100%;
content: "loop";
2014-03-15 03:17:18 +00:00
color: white;
text-align: center;
line-height: 100px;
}
2014-03-15 03:30:00 +00:00
#Trigger:active {
background-color: white;
color: black;
}
#Trigger:active:after {
content: "stop";
color: black;
}
2014-03-15 03:17:18 +00:00
</style>
2014-03-15 03:30:00 +00:00
<div id='Trigger'></div>
2014-03-15 03:17:18 +00:00
<script type="text/javascript">
2014-03-16 17:33:56 +00:00
var player = new Tone.Player("../audio/casio/A1.mp3");
2014-03-15 03:17:18 +00:00
player.toMaster();
2014-03-15 03:30:00 +00:00
//once it's loaded, add the event triggers
2014-03-15 03:17:18 +00:00
player.load(function(){
2014-03-15 03:30:00 +00:00
$("#Trigger").mousedown(function(e){
player.loop(0, 0, .5);
2014-03-15 03:17:18 +00:00
});
2014-03-15 03:30:00 +00:00
$("#Trigger").mouseup(function(e){
2014-03-15 03:17:18 +00:00
player.stop();
});
});
</script>
</body>
</html>