thinkpixellab / PxLoader

PxLoader is a simple JavasScript library for creating preloaders and resource downloaders for HTML5 apps.
http://thinkpixellab.com/pxloader
1.11k stars 173 forks source link

Full preload video #61

Closed kevingobert closed 6 years ago

kevingobert commented 7 years ago

I have to load a lot of videos. PXLoader could help me do that. For now, video continues to load but the addCompletionListener() function is already running. While reading, I realized that this is the browser that managed if the video could be played. But I 'd like the video is fully charged for not having buffering after the loader.

Is it possible to force the full load media ? Thank you

joelfillmore commented 7 years ago

We're setting preload="auto" which means that the entire video could be loaded, but its up to each browser to determine exactly how much of the video they will load before firing the event indicating it can be played. Usually its just enough so that video can begin playing and buffer remaining data during playback given the current transfer rate. I'm not aware of a way to force the browser to load the entire video.

If you really need the entire video, one possible solution would be Media Source Extensions to HTML5 video. It's possible to manually fetch the data, build a source buffer, and attach that to a video element.

Here is an article detailing how you could use that method to build a DASH compatible player: https://msdn.microsoft.com/en-us/library/dn551368%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396

kevingobert commented 7 years ago

Thank you for your reply. The worries, if I test with a bad connection the video stops after a few seconds. The buffering time is the same with a fast or slow connection so when the connection is slow after 3sec the video stops.

I was testing the Laoder with the function data ( xhr ). It then loads the file completely but when using the video cuts off every 3 seconds.