1
0
Fork 0
mirror of https://github.com/sbrl/soundbox.git synced 2018-01-10 21:33:43 +00:00
soundbox/example.html

67 lines
1.5 KiB
HTML
Raw Permalink Normal View History

2015-02-19 20:21:07 +00:00
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>SoundBox.js Example</title>
</head>
<body>
<h1>SoundBox.js Example</h1>
<p>All sounds from <a href="http://www.bfxr.net/" target="_blank">Bfxr</a>.</p>
<button onclick="play_sound_1();">Play Sound 1</button>
<button onclick="play_sound_2();">Play Sound 2</button>
<button onclick="play_sound_3();">Play Sound 3</button>
<br />
2015-02-19 20:21:07 +00:00
<button onclick="play_multiple_sounds();">Play Multiple Sounds</button>
<button onclick="play_multiple_sounds_promise();">Play Multiple Sounds with Promises</button>
2015-02-19 20:21:07 +00:00
<!----------->
<style>
body { font-family: sans-serif; }
</style>
<script src="soundbox.js"></script>
2015-02-19 20:21:07 +00:00
<script>
window.addEventListener("load", function(event) {
window.soundbox = new SoundBox();
soundbox.load("beep1", "examplesounds/beep1.wav");
soundbox.load("beep2", "examplesounds/beep2.wav");
soundbox.load("beep3", "examplesounds/beep3.wav");
});
function play_sound_1()
{
soundbox.play("beep1");
}
function play_sound_2()
{
soundbox.play("beep2");
}
function play_sound_3()
{
soundbox.play("beep3");
}
function play_multiple_sounds()
{
soundbox.play("beep1", function() {
soundbox.play("beep2", function() {
soundbox.play("beep3");
});
});
}
function play_multiple_sounds_promise()
{
window.soundbox.play("beep1")
.then(() => window.soundbox.play("beep2"))
.then(() => window.soundbox.play("beep3"));
}
2015-02-19 20:21:07 +00:00
</script>
</body>
</html>