Open Kjos opened 6 years ago
Maybe we should just remove the whole preload logic for audio and video, letting it stream as normal?
If you set timeout to 1 you may get that error once but for me videos still work once you get through user gesture click to play etc.
I thought that if you didn't want to wait you can stop putting your videos within a-assets, but that was a long time ago and maybe that has changed since then.
Description:
Currently setting timeout to 1 will cause a WebGL error for video about non-power of two textures, because the texture isn't loaded yet. onloadeddata should at least be called once before play and resolve() can be called on first onloadeddata callback.
Next to that, the buffer might never reach 100% of the video length, and thus the user might have to wait -say- 2.5 seconds out of 3 seconds (when timeout = 3). This is expected behaviour because most browsers only buffer a very small portion of the video. Also this is very browser dependent and will lead to different behaviours across browsers.
An alternative could be to update the timeout when onprogress is called, with -say- 1 second instead. Each progress call grants another 1s timeout. This way the user only waits a max of 1 second after buffer loading ends. But this could also behave differently across browsers.
What usually is done to fix the buffer loading ending early, is to play through the entire audio/video first, which will ensure the entire clip is loaded in cache. However, with cubemap videos the filesize will be so large it might very well be cleared from cache again anyway.
It's probably better to at least disable timeout functionality by default (instead of 3000ms). Right now, most browsers will wait 3 seconds while actual loading ends very early.