hassle-free, cross-plattform, two-command wrapper to preload and play sound files
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
CONTRIBUTING.md
LICENSE.md
README.md
bower.json
simpleSound.js
simpleSound.min.js

README.md

simpleSound

Latest Version Bower Software License

Hassle-free cross-plattform JavaScript audio preloading and playback.

Summary

simpleSound is a small wrapper designed to handle the preloading and playback of sound files. It uses the Web Audio API for playback, but falls back on HTML5 audio tags when necessary. Same goes for audio file formats, it will fall back to ogg files if MP3 support is not available.

It also overcomes the arbitrary requirement of iOS WebKit, which only allows sound files to be triggered on an explicit user action. This makes independent playback possible, like it's used for HTML5 games.

It does not utilize jQuery or any other third party plugins, this is a simple standalone script.

Install

Via Bower

$ bower install simplesound-js --save

Usage

You will need to have both .ogg and .mp3 versions of every sound file, in the same folder.

Then just call simpleSound.load('filename_without_extension') to preload the sound and simpleSound.play('filename_without_extension') to play the sound. It's that easy!

Contributing

Please see CONTRIBUTING for details.

Credits

License

The MIT License (MIT). Please see License File for more information.