/sona

Web Audio API wrapper

Primary LanguageJavaScriptMIT LicenseMIT

Sona

Simple Web Audio API wrapper.

Usage

var sona = new Sona([
    { url: 'assets/sample.mp3', id: 'sample' },
    { url: 'assets/test.mp3', id: 'test' },
    { url: 'assets/example.mp3', id: 'example' }
]);

sona.load(function () {
	// All sounds have loaded when this callback is executed

    // Play a sound once at default volume
    sona.play('sample');

    // Play a looping sound
    sona.loop('example');

    // Get volume of sound
    sona.getVolume('sample');	// == 1

    // Change volume to 50%
    sona.setVolume('sample', 0.5);

    // Stop the loop
    sona.stop('sample');
});

Compatibility

Not supported in Internet Explorer. See caniuse.com.

Specs

Load SpecRunner.html in a browser window.