A Web Audio Library Designed For Games – jWebAudio

jWebAudio is a web audio library designed for games, with both standard and jQuery versions. You can find almost everything you need to control audio in web games with jWebAudio, which provides functions like fade in and fade out, loop, multishot for short sound effects like gun shotting and etc.



A Web Audio Library Designed For Games - jWebAudio

Basic Usage:

Include the latest jQuery javascript library and jWebAudio script on your web page.

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript" src="../build/jquery.jWebAudio.js"></script>

Create a container for the plugin.

<div id="demo"></div>

The javascript.

$(document).ready(function() {
    /* Create sound with url.
     * Note that sound is not actually loaded yet. So it is 
     * recommended that you create all sounds that will be used
     * later and load them when necessary. If the sound is not
     * loaded when play, it will automatically load.
     * Each element div can contain at most one sound.
     * You may set those divs to be invisible if you wish.
    $('#div1').jWebAudio('addSoundSource', {
        'url': 'resource/a.ogg',
        'preLoad': true,
        'callback': function() {

    /* Which has the same effect as the following. */
    $('#div1').jWebAudio('addSoundSource', {
        'url': 'resource/a.ogg'
    $('#div1').jWebAudio('load', function() {

    /* jWebAudio maintains chainability as jQuery does.
     * So you may call the above functions in this way
     * and will get all the same results.
     * $('#div1').jWebAudio('addSoundSource', {
     *     'url': 'resource/a.ogg'
     * }).jWebAudio('load', function() {
     *     $('#div1').jWebAudio('play');
     * });

You Might Be Interested In: