Does anyone know if @canplaythrough is still a valid listener to use on a `<video /> ` element?
Title! Thanks, and let me know if you have an implementation. I want to play a video only when it is loaded, here is what I have, but it doesn't quite work
6 Replies
Here is a basic implementation that I am trying:
Hi there! From your implementation, it looks like the video can never start to load, because you do not render it (isLoading is true on component load).
Is there a reason you don't want to use the
autoplay
attribute on the <video>
?That definitely helps 👍 And no, no reason specifically, I am not aware of any of its implications here (and all I'm really trying to do is lazy load a video! its really just a "welcome" animation,, so it will get hidden somehow in less than a second or two)
Yeah I see, unfortunately, there is no native way of lazy loading videos. But you could add a short script that listens to the scroll event and when the video is inside the video, start rendering it.
Ended up solving it, by isolating the video into a component that emits once it can play through, and looking back on this, the goal wasnt really lazy loading, but rather making sure that a video can play (and displaying a loading while it can’t) before triggering some css stuffs.
Sounds great 🙂