SoundJS
A cross-browser JavaScript sound loading, playing and layering library primarily designed for browser-based games to have a multi-layering sound API.
Install / Use
/learn @TooTallNate/SoundJSREADME
SoundJS
SoundJS is a library that provides browsers with a JavaScript sound API
that first tries audio files with native HTML5 Audio and falls back to Flash
when necessary.
Specifically, the SoundJS API offers the ability to play the same sound
file more than once at a time, even while the same sound is already playing.
This is also known as multi-layering sounds.
Motivation:
SoundJS is specifically created for the
Simple Game Framework HTML engine. HTML5
Audio is a nice idea, but the spec provides no multi-layering support, meaning
a single <audio> instance can only play it's src once at a time. There's
also the case where no native HTML5 Audio is supported, or the specific file
type is not supported, and that's where Flash can come in behind the scenes.
Features:
- Provides a simple API to load sounds initially, and create play instances when the sound has enough data to start playing or has loaded completely.
- First attempts to use native HTML5 Audio to load and play back the sound.
- Falls back to Flash when HTML5 fails or is not implemented.
- Multi-layering loaded sounds, for multiple bullet shot sounds for example.
- Guarantees cross-browser support for MP3, OGG Vorbis, and uncompressed WAV! H.264 works on HTML5 browsers that support it (no Flash fallback yet).
Example Usage:
var shot = new Sound("shot.mp3");
shot.addEventListener("loaded", function() {
function playShot() {
shot.play();
}
playShot();
setTimeout(playShot, 50);
setTimeout(playShot, 234);
});
View the full API docs for the complete picture.
Building Flash Source and Minimizing JavaScript
A few dependencies are required in order to build the source code into a Flash compatible SWF, and minimize (Compile) the JavaScript source. Make sure that you have installed:
Once the dependencies are met, you can simply run:
./compile
from the root directory. compile is a simple script written in JavaScript
using Node.js as the interpreter. It first uses the Google Compiler web
service to minimize the JavaScript code, then uses the haxe command line
tool to compile the HaXe source into a Flash SWF file.
License
SoundJS incorporates some Flash libraries licensed under the
LGPL license,
SoundJS must be released as LGPL as well.
See the COPYING.LESSER
file for full legal text.
Related Skills
diffs
344.4kUse the diffs tool to produce real, shareable diffs (viewer URL, file artifact, or both) instead of manual edit summaries.
clearshot
Structured screenshot analysis for UI implementation and critique. Analyzes every UI screenshot with a 5×5 spatial grid, full element inventory, and design system extraction — facts and taste together, every time. Escalates to full implementation blueprint when building. Trigger on any digital interface image file (png, jpg, gif, webp — websites, apps, dashboards, mockups, wireframes) or commands like 'analyse this screenshot,' 'rebuild this,' 'match this design,' 'clone this.' Skip for non-UI images (photos, memes, charts) unless the user explicitly wants to build a UI from them. Does NOT trigger on HTML source code, CSS, SVGs, or any code pasted as text.
openpencil
2.0kThe world's first open-source AI-native vector design tool and the first to feature concurrent Agent Teams. Design-as-Code. Turn prompts into UI directly on the live canvas. A modern alternative to Pencil.
ui-ux-pro-max-skill
56.5kAn AI SKILL that provide design intelligence for building professional UI/UX multiple platforms
