var a = document.querySelector('audio'),
bc = document.querySelector('#buttons'),
audiosprite = {
'all': [ 0, 7 ];
'boing': [ 0, 1.3 ],
'boomtchack': [ 2, 2.5 ],
'peng': [ 4, 5 ]
},
end = 0;
a.addEventListener('loadeddata', function(ev) {
for (var i in audiosprite) {
bc.innerHTML += '<button onclick="play(\'' +
i + '\')">' + i + '</button>';
}
}, false);
a.addEventListener('timeupdate', function(ev) {
if (a.currentTime > end) { a.pause(); }
},false);
function play(sound) {
if ( audiosprite[sound] ) {
a.currentTime = audiosprite[sound][0];
end = audiosprite[sound][1];
a.play();
}
}