englercj / resource-loader

A middleware-style generic resource loader built with web games in mind.
http://englercj.github.io/resource-loader/
MIT License
424 stars 77 forks source link

How to check for video progress? #153

Open MirrorTM opened 3 years ago

MirrorTM commented 3 years ago

when loading a video i wish to wait until its fully loaded , however the loader doesnt report progress by onProgress.. how to manage this? cant find any documentation

englercj commented 3 years ago

I don't think we report individual resource load progress for anything that isn't XHR currently. PR welcome.

You'd need to implement it in here: https://github.com/englercj/resource-loader/blob/master/src/load_strategies/MediaElementLoadStrategy.ts You can see how it works for XHR in here: https://github.com/englercj/resource-loader/blob/master/src/load_strategies/XhrLoadStrategy.ts Here are the relevant MDN docs: https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/progress_event

englercj commented 3 years ago

Oh actually, we don't report anything after "canplaythrough" because we consider that "done". The best thing to do here is probably create your own video element and use that. You can even pass it into resource loader if you want, depending on what you're actually doing.