javascript - script to check if a video is playing and not restart - Stack Overflow

Okay, that's phrased awkwardly, but what I'm looking for is a script that checks, onclick if

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?

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?

Share Improve this question asked May 21, 2012 at 3:24 Nata2ha Mayan2Nata2ha Mayan2 4841 gold badge10 silver badges24 bronze badges 4
  • Natasha, what have you tried so far? It's much much easier to get help from this munity if you give us a place to start, like showing research you've done in the form of your own code, explaining what you've tried, what didn't work and why, etc, etc. Otherwise, you're asking everyone to lift dead weight, which is really hard even for the strongest programmers. Consider editing your question and including this additional info. Good luck! – jamesmortensen Commented May 21, 2012 at 3:28
  • @jmort253 sorry, I should have put what I've done. Really, I've looked for it, but since I'm not sure how to phrase it, I haven't had any luck and haven't tried to much yet. I was hoping I could just get pointed in a general direction, really – Nata2ha Mayan2 Commented May 21, 2012 at 4:56
  • This was in Matt's answer: w3/2010/05/video/mediaevents.html Check it out. It shows all the events and properties while the video is playing. "Paused" looks like one you could use to determine if the vid is playing as it's true whenever the video isn't playing. – jamesmortensen Commented May 21, 2012 at 5:00
  • if( $('video').paused == true ) { /* Do what you want when not playing */ } else { /* vid playing */ } – jamesmortensen Commented May 21, 2012 at 5:03
Add a ment  | 

1 Answer 1

Reset to default 5

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.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745340676a4623312.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信