判断视频是否在Javascript中加载 [英] Tell whether video is loaded or not in Javascript
本文介绍了判断视频是否在Javascript中加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
因此,我一直在使用
$ b
So, I've been using a listener on
document.getElementById("video").buffered.length
查看它是否大于 0
一个视频的加载与否。这适用于非常小的视频,仅适用于Google Chrome。它根本不适用于Firefox。任何想法如何让这个工作?
to 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 Chrome. It doesn't work in Firefox at all. Any ideas for how to get this to work?
我基本上要等到加载3个单独的视频才能采取具体行动,我该怎么做?
I essentially want to wait till 3 seperate videos are loaded to take a specific action, how do I go about this?
推荐答案
试试这个:
Try this:
var video = document.getElementById("video-id-name");
if ( video.readyState === 4 ) {
// it's loaded
}
请阅读此处: https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/readyState
这篇关于判断视频是否在Javascript中加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文