I have a few mp3 soundclips to play at certain events on my HTML5 app. There's no tag, the script creates Audio objects at the beginning (one for each mp3) and loads the files. When I have to play a sound, I simply call play() on one of these objects.
This works fine in a Chrome desktop, but is very inconsistent in my iPod touch, eventually some sounds stop playing and I even get error alerts.
Here's a small script I set up to see the problem, it's hosted at soundtest.staticloud.com including the 3 audio files so you can check it out on an iPhone/whatever.
var snd = [];
window.onload = function() {
for(var i = 0; i < 3; i++) {
snd[i] = new Audio("snd" + i + ".mp3");
snd[i].load();
}
}
function sound(n) {
snd[n-1].play();
}
Am I doing something wrong?