script to check if a video is playing and not restart

筅森魡賤 提交于 2020-01-07 12:35:40

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/10679184/script-to-check-if-a-video-is-playing-and-not-restart

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!