Tone.js/examples/player.html

55 lines
1.5 KiB
HTML
Raw Normal View History

<!DOCTYPE html>
2014-03-15 03:17:18 +00:00
<html>
<head>
<meta charset="utf-8">
2019-01-09 01:21:29 +00:00
<title>Player</title>
2014-09-06 19:35:31 +00:00
2019-01-09 01:21:29 +00:00
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="icon" type="image/png" sizes="174x174" href="./favicon.png">
2020-07-18 00:58:09 +00:00
<script src="https://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/2.4.3/webcomponents-bundle.js"></script>
<link href="https://fonts.googleapis.com/css?family=Material+Icons&display=block" rel="stylesheet"/>
2019-01-09 01:21:29 +00:00
<script src="../build/Tone.js"></script>
2020-07-18 00:58:09 +00:00
<script src="./js/tone-ui.js"></script>
<script src="./js/components.js"></script>
2019-01-09 01:21:29 +00:00
<style type="text/css">
tone-play-toggle {
margin-bottom: 10px;
}
</style>
2014-03-15 03:17:18 +00:00
</head>
<body>
<tone-example label="Player">
2019-01-09 01:21:29 +00:00
<tone-loader></tone-loader>
<div slot="explanation">
2019-01-09 01:21:29 +00:00
Click on the button to play the audio file on loop
using <a href="https://tonejs.github.io/docs/Player">Tone.Player</a>.
</div>
2019-01-09 01:21:29 +00:00
<div id="content">
2019-01-09 01:21:29 +00:00
<tone-play-toggle></tone-play-toggle>
</div>
2019-01-09 01:21:29 +00:00
</tone-example>
<script type="text/javascript">
2020-07-19 00:20:19 +00:00
// the player
const player = new Tone.Player({
url: "https://tonejs.github.io/audio/loop/FWDL.mp3",
loop: true,
loopStart: 0.5,
loopEnd: 0.7,
}).toDestination();
ui({
tone: player,
2020-07-19 00:20:19 +00:00
parent: document.querySelector("#content")
});
2015-06-27 22:02:55 +00:00
2020-07-19 00:20:19 +00:00
// bind the interface
document.querySelector("tone-play-toggle").addEventListener("start", () => player.start());
document.querySelector("tone-play-toggle").addEventListener("stop", () => player.stop());
2014-03-15 03:17:18 +00:00
</script>
2017-03-26 20:39:19 +00:00
2014-03-15 03:17:18 +00:00
</body>
</html>