I'm developing a local server that will stream a user's audio files so they can access them via web browsers using the HTML5 audio object. Since these files are on the user's computer, I expect the files to be buffered completely when they are loaded, but for certain large files, the songs get buffered part of the way, then stop, and resume buffering some time later.
My question is: how can I force the audio object to buffer the entire song at once? Can I do this from javascript, do I have to set an attribute on the audio object, or is there anything else I can do?
autobuffer: If this attribute is used, the audio will begin buffering automtically, even if the playback isn't automatic. controls: This attribute allows the user to control audio playback, volume, seeking and pause or resume playback.
This is done by using the loop attribute of the <audio> tag. It is used to restart the audio again and again after loading the web page.
The preload attribute specifies if and how the author thinks that the audio file should be loaded when the page loads. The preload attribute allows the author to provide a hint to the browser about what he/she thinks will lead to the best user experience. This attribute may be ignored in some instances.
The solution I found was this:
function load() {
a.play();
setTimeout("a.pause()", 10);
}
Play the file and pause it 10ms later, then the browser will buffer the entire song.
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