Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
161 views
Welcome To Ask or Share your Answers For Others

1 Answer

To prevent clicking from doing anything to the video you can do this:

$("video").click(function(e) {
   e.preventDefault();
   return false;
});

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;
   }
});

Let me know if you're not using jQuery and I'll update my answer to use getElementsByTagName.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...