[EDIT: using a simplified test page without Javascript etc.]
I've got a webpage that contains four audio files. These files are served as HTML5 <audio>
with .mp3 files, which should play in Safari. (I've had no trouble with .ogg files in Firefox and Chrome.)
Each time I reload the page, between one and three of the files load properly, and the rest fail to load -- although they don't give an error, and the 'loading' message disappears; it's as if they're loading with a size of 0B. Which files work and which don't seems completely random: I've seen each of them load and each of them fail more than once.
How can I make all these files load properly?
I was having a similar issue with files not loading and came up with this solution. It seems that HTML5 audio/video can "stall", meaning that is just stops loading. Luckily, there's a "stall" event that fires when this happens. What I did was listen for this event and when/if it fires, just try to force the audio to load again.
Example using jQuery:
// the event is 'onstalled' - 'stalled' in the jquery case
$("audio").bind("stalled", function() {
var audio = this;
audio.load();
// Threw in these two lines for good measure.
audio.play();
audio.pause();
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With