用于检查视频是否正在播放而不重启的脚本 [英] script to check if a video is playing and not restart
问题描述
好吧,这是笨拙的,但我正在寻找的是一个脚本,检查,如果正在播放视频,则点击,如果是,则不要再开始播放。
这是一个页面中有六个拇指在一个阵列中,每个都播放一个视频,你不应该重新启动视频(这意味着它的行为就像它没有被选中)
我怎么会能够做到这一点吗?
Okay, that's phrased awkwardly, but what I'm looking for is a script that checks, onclick if a video is playing, and if it is, don't start playing it again.
It's for a page that has six thumbs in an array that each play a video, and you're not supposed to be able to restart the video(which means its acting like its not selected)
how would I be able to do this?
推荐答案
为防止点击对视频做任何事情,你可以这样做:
To prevent clicking from doing anything to the video you can do this:
$("video").click(function(e) {
e.preventDefault();
return false;
});
要确定视频是否正在播放,您可以阅读上一个问题:
< a href =https://stackoverflow.com/questions/8599076/detect-if-html5-video-element-is-playing>检测是否正在播放HTML5视频元素
To determine if the video is playing or not you can read this previous question: Detect if HTML5 Video element is playing
因此,您需要阅读该内容,然后执行以下操作:
So you'll want to read that and then do something like:
$("video").click(function(e) {
if (videoStatus === "playing") {
e.preventDefault();
return false;
}
});
如果您不使用jQuery,请告诉我,我会更新我的回答以使用 getElementsByTagName
。
Let me know if you're not using jQuery and I'll update my answer to use getElementsByTagName
.
这篇关于用于检查视频是否正在播放而不重启的脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!