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

83 lines
2.5 KiB
Markdown
Raw Normal View History

2015-02-17 10:03:09 +00:00
# soundbox
2017-07-31 17:54:27 +00:00
A super simple JS library for playing sound effects and other audio.
2015-02-17 10:13:49 +00:00
2017-07-31 17:54:27 +00:00
Now with button mashing support!
2017-07-31 18:16:47 +00:00
* Current size: `1.4kb`
* Current minified size: `0.74kb`
2015-02-19 20:25:39 +00:00
## To use:
2015-02-17 10:13:49 +00:00
2017-07-31 17:54:27 +00:00
### With callbacks
2015-02-17 10:13:49 +00:00
```javascript
var soundbox = new SoundBox();
2017-07-31 17:54:27 +00:00
soundbox.load("beep", "beep.wav", function() {
console.log("Loaded beep!");
}); // The callback is optional
2015-02-17 10:13:49 +00:00
2017-07-31 17:54:27 +00:00
// Later....
2015-02-19 20:25:39 +00:00
soundbox.play("beep", function() {
2017-07-31 17:54:27 +00:00
// Do stuff
}); // 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"));
2015-02-17 10:13:49 +00:00
```
2015-02-19 20:25:39 +00:00
2017-07-31 17:57:55 +00:00
### Additional Functionality
Get the current version of SoundBox:
```javascript
console.log(`Soundbox is at ${SoundBox.version}`);
```
2015-02-19 20:25:39 +00:00
## Download
2015-02-19 20:35:34 +00:00
The latest master should be perfectly stable. If you want something that you know will work, try the latest [release](https://github.com/sbrl/soundbox/releases).
2015-02-19 20:25:39 +00:00
* [soundbox.js](https://raw.githubusercontent.com/sbrl/soundbox/master/soundbox.js)
2015-02-19 20:27:21 +00:00
* [soundbox.min.js](https://raw.githubusercontent.com/sbrl/soundbox/master/soundbox.min.js)
2015-02-19 20:28:33 +00:00
## License
2017-07-31 17:54:27 +00:00
SoundBox.js is licensed under MIT:
2015-02-19 20:28:33 +00:00
```
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.
```