1
0
Fork 0
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
Go to file
Starbeamrainbowlabs 9a194ffa28 Update README to mention npm package 2017-07-31 20:06:29 +01:00
examplesounds Added missing files... oops! 2015-02-19 20:21:07 +00:00
LICENSE Initial commit 2015-02-17 10:03:09 +00:00
README.md Update README to mention npm package 2017-07-31 20:06:29 +01:00
example.html Refactor to support multiple playbacks at once and Promises 2017-07-31 18:41:32 +01:00
package.json Bump version for v0.2.2 2017-07-31 19:27:33 +01:00
soundbox.js Bump version for v0.2.2 2017-07-31 19:27:33 +01:00
soundbox.min.js Bump version for v0.2.2 2017-07-31 19:27:33 +01:00

README.md

soundbox

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

Now with button mashing support!

  • Current size: 1.4kb
  • Current minified size: 0.74kb

Demo

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.

soundbox is also available via npm here: sound-box - To install it simply type npm install sound-box.

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.