Simple Web Audio API wrapper.
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');
});
Not supported in Internet Explorer. See caniuse.com.
Load SpecRunner.html
in a browser window.