0

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?

Nata2ha Mayan2
  • 474
  • 1
  • 10
  • 23
  • Natasha, what have you tried so far? It's much much easier to get help from this community 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 May 21 '12 at 03: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 May 21 '12 at 04:56
  • This was in Matt's answer: http://www.w3.org/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 May 21 '12 at 05:00
  • `if( $('video').paused == true ) { /* Do what you want when not playing */ } else { /* vid playing */ }` – jamesmortensen May 21 '12 at 05:03

1 Answers1

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.

Community
  • 1
  • 1
Matt Wonlaw
  • 12,146
  • 5
  • 42
  • 44
  • just wondering, but this did help me fix it (thnks), is `getElementsByTagName` javascript and not jquery? I don't use it much either way, that's why I would like to know :) – Nata2ha Mayan2 May 24 '12 at 23:12
  • `getElementsByTagName` is implemented directly by the browser and is always available to your javascript, whether you are using jQuery or not. jQuery uses the `getElementsByTagName`, `getElementById`, etc. methods under the covers. – Matt Wonlaw May 25 '12 at 16:12