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
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Starbeamrainbowlabs 9a194ffa28 Update README to mention npm package 1 year ago
examplesounds Added missing files... oops! 3 years ago
LICENSE Initial commit 3 years ago
README.md Update README to mention npm package 1 year ago
example.html Refactor to support multiple playbacks at once and Promises 1 year ago
package.json Bump version for v0.2.2 1 year ago
soundbox.js Bump version for v0.2.2 1 year ago
soundbox.min.js Bump version for v0.2.2 1 year ago

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.