1
0
Fork 0
mirror of https://github.com/sbrl/soundbox.git synced 2018-01-10 21:33:43 +00:00
A super simple JS library for playing sound effects - this is a read-only backup mirror of the main Github repository https://github.com/sbrl/soundbox
Find a file
2017-07-31 18:57:55 +01:00
examplesounds Added missing files... oops! 2015-02-19 20:21:07 +00:00
example.html Refactor to support multiple playbacks at once and Promises 2017-07-31 18:41:32 +01:00
LICENSE Initial commit 2015-02-17 10:03:09 +00:00
README.md Add version number to library. 2017-07-31 18:57:55 +01:00
soundbox.js Add version number to library. 2017-07-31 18:57:55 +01:00
soundbox.min.js Update minified version 2017-07-31 18:54:09 +01:00

soundbox

A super simple JS library for playing sound effects and other audio.

Now with button mashing support!

  • Current size: 1.2kb
  • Current minified size: 0.78kb

To use:

With callbacks

var soundbox = new SoundBox();
soundbox.load("beep", "beep.wav", function() {
    console.log("Loaded beep!");
}); // The callback is optional

// Later....
soundbox.play("beep", function() {
	// Do stuff
}); // This callback is also optional

With Promises

var soundbox = new SoundBox();
soundbox.load("beep-a", "beep-a.wav")
    .then(
        () => console.log("Loaded beep a!"),
        () => console.error("Failed to load keep a :-(")
    );
soundbox.load("beep-b", "beep-b.wav");
soundbox.load("beep-c", "beep-c.wav");
soundbox.load("victory", "victory.mp3");

soundbox.play("beep-a")
    .then(() => soundbox.play("beep-b"))
    .then(() => soundbox.play("beep-c"))
    .then(() => soundbox.play("victory"));

Additional Functionality

Get the current version of SoundBox:

console.log(`Soundbox is at ${SoundBox.version}`);

Download

The latest master should be perfectly stable. If you want something that you know will work, try the latest release.

License

SoundBox.js is licensed under MIT:

The MIT License (MIT)

Copyright (c) 2015 Starbeamrainbowlabs

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.