Closed websanova closed 7 years ago
Howdy!
With HTML5, the UA is pretty much entirely in control of the HTTP request/response sequence and amount/order of bytes downloaded. You can specify preload
and similar on the native HTML5 <audio>
or Audio()
objects, but it makes little difference from what I've found and is N/A on mobile devices. By default, HTML5 clients will request partials/byte ranges if the server supports them.
In effect, the only case where a client will "pre-load" 100% of the file is if you were to request it via XHR or similar other "progressive" single-request download beforehand - which is these days considered an anti-pattern anyhow, since the point of HTML5 is to be efficient and allow users to seek arbitrarily within audio files that may be many hours long. (Consider video, i.e., seeking on YouTube; same sort of argument, even though audio is of course a lower bitrate.)
In SM2's case, I fire "onload" and friends when the UA indicates the canplay
event or similar via HTML5. There is also canplaythrough
, which is the UA's best guess at "I can play this sound completely from this point onward, without having to stop playback to buffer."
A little more here on how HTML5 clients request audio. http://www.schillmania.com/projects/soundmanager2/doc/technotes/#client-requests
I should add, feel free to reopen this if you've found a bug, etc. ;)
Hey, great little library, works like a charm so far.
I'm just wondering though. it seems to always load the song at about 28% when I check
bytesLoaded
. inside ofwhileloading
. Before that it just shows0
constantly. Is there anyway to get data before that or is it just a browser/html5 thing?