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

Update README

This commit is contained in:
Starbeamrainbowlabs 2017-07-31 18:54:27 +01:00
parent 793667c2af
commit f5e2d23da1

View file

@ -1,19 +1,44 @@
# soundbox # soundbox
A super simple JS library for playing sound effects A super simple JS library for playing sound effects and other audio.
* Current size: `1.04kb` Now with button mashing support!
* Current minified size: `0.64kb`
* Current size: `1.2kb`
* Current minified size: `0.78kb`
## To use: ## To use:
### With callbacks
```javascript ```javascript
var soundbox = new SoundBox(); var soundbox = new SoundBox();
soundbox.load("beep", "beep.wav"); soundbox.load("beep", "beep.wav", function() {
console.log("Loaded beep!");
}); // The callback is optional
// later.... // Later....
soundbox.play("beep", function() { soundbox.play("beep", function() {
// do stuff // Do stuff
}); // the callback is optional }); // This callback is also optional
```
### With Promises
```javascript
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"));
``` ```
## Download ## Download
@ -23,7 +48,7 @@ The latest master should be perfectly stable. If you want something that you kno
* [soundbox.min.js](https://raw.githubusercontent.com/sbrl/soundbox/master/soundbox.min.js) * [soundbox.min.js](https://raw.githubusercontent.com/sbrl/soundbox/master/soundbox.min.js)
## License ## License
SoundBox.js is licensed under MIT. SoundBox.js is licensed under MIT:
``` ```
The MIT License (MIT) The MIT License (MIT)