Quantcast
Channel: Tell whether video is loaded or not in Javascript - Stack Overflow
Browsing latest articles
Browse All 7 View Live

Answer by Chris Moschini for Tell whether video is loaded or not in Javascript

It's pretty easy for your script to load AFTER the video, if the video is cached. That can make listening to these events unreliable. I resolved this race condition like so:(() => { const video =...

View Article


Answer by samicsc0 for Tell whether video is loaded or not in Javascript

I find other way const video = document.querySelector('video');video.addEventListener('canplaythrough', (event) => { console.log('I think I can play through the entire '+'video without ever having...

View Article

Answer by aye2m for Tell whether video is loaded or not in Javascript

Use onloadeddata event on the video element. It checks whether the video is loaded or not. See this reference for more information.The loadeddata event is fired when the frame at the current playback...

View Article

Answer by Badrush for Tell whether video is loaded or not in Javascript

UPDATE:As others have mentioned, my original solution below does work but it can lead to performance issues and some unpredictability in its behaviour.Therefore I recommend listening to the loadeddata...

View Article

Answer by efaj for Tell whether video is loaded or not in Javascript

To make this into a listener, under normal circumstances, you'll want to listen to the suspend event. It's triggered when download is paused or stopped for any reason, including it's finished.You'll...

View Article


Answer by Šime Vidas for Tell whether video is loaded or not in Javascript

Try this:var video = document.getElementById("video-id-name");if ( video.readyState === 4 ) { // it's loaded}Read here: https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/readyState

View Article

Tell whether video is loaded or not in Javascript

So, I've been using a listener on document.getElementById("video").buffered.lengthto see if it's greater than 0 for when a video's loaded or not. This works for a very small video, and only in Google...

View Article
Browsing latest articles
Browse All 7 View Live