From f5e2d23da1e04adca4a0091fed06fe2eeeecf9a2 Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Mon, 31 Jul 2017 18:54:27 +0100 Subject: [PATCH] Update README --- README.md | 41 +++++++++++++++++++++++++++++++++-------- 1 file changed, 33 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 5061293..da1cdda 100644 --- a/README.md +++ b/README.md @@ -1,19 +1,44 @@ # 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` - * Current minified size: `0.64kb` +Now with button mashing support! + + * Current size: `1.2kb` + * Current minified size: `0.78kb` ## To use: +### With callbacks + ```javascript 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() { - // do stuff -}); // the callback is optional + // 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")); ``` ## 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) ## License -SoundBox.js is licensed under MIT. +SoundBox.js is licensed under MIT: ``` The MIT License (MIT)