$(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() { $('#div1').jWebAudio('play'); } }); /* Which has the same effect as the following. */ /* $('#div1').jWebAudio('addSoundSource', { 'url': 'resource/a.ogg' }); $('#div1').jWebAudio('load', function() { $('#div1').jWebAudio('play'); }); */ /* 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'); * }); */ });