Decision
I created a working example of an accepted answer that uses XHR and reports the progress of the download through the panel.
It is available here.
https://github.com/synthecypher/full-preload
Question
I noticed that when I create a <video> element with sources and call load() , it will load up to about 36%, and then stops if you don't play() , and at that time it will continue to load the rest of the video, which he plays.
However, I want the entire video to be downloaded before it was an element in the timed exercise, and if the Internet connection drops during the exercise, I will have to detect such an event and restart the exercise.
I suppose this is an inline function of HTML5 multimedia elements, but is it possible to override this native functionality?
I tried to load the entire video source as arraybuffer using XMLHttpRequest , which is then converted to blob and set as src of the <source> element in my <video> element.
This does work, but it is not ideal, because I cannot report the progress of the download to the user using the progress bar, since XHR is a synchronous operation and will cause my JavaScript to freeze until an answer is received. I know that XHR2 now has this functionality, but I need to support IE8 + so that is not an option.
Is there a lighter, more elegant solution to my problem that reports progress?
Requirements
- Before playback, you must first download the entire
<video> <source> element. - Need to report progress
source share