How do I use jQuery to pause or stop html5 video?

Please try this link: http://demo.missionfamily.org/vendors/new-factor-29

Towards the middle of the page click on tab: Video & Allegati
Click to play video
Then click on another tab, the video is still playing.

How do I use jQuery to pause/stop this video when I click on another tab?

thanks in advance
badwolfffAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

badwolfffAuthor Commented:
by the way I am using video.js
Julian HansenCommented:
The basics are as follows

var video = document.getElementById('vidoeid');

video.pause();
video.play();

Open in new window


The following sample demonstrates the concept - source code below and in the sample
http://www.marcorpsa.com/ee/t939.html
<!doctype html>
<html>
<head>
<title>Test</title>
<link href="css/bootstrap.css" rel="stylesheet" />
<style type="text/css">
</style>
</head>
<body>
<div class="container">
  <div>
    <video id="thevideo" src="http://sample-videos.com/video/mp4/720/big_buck_bunny_720p_10mb.mp4"></video>
  </div>
  <button class="video-control" data-action="play">Play</button>
  <button class="video-control" data-action="pause" disabled>Pause</button>

<h4>Source Code</h4>
<iframe src="t939s.html" style="width: 100%; border: 0; padding: 0; margin: 0; height: 400px"></iframe>
</div>
<script src="http://code.jquery.com/jquery.js"></script>

<!-- Latest compiled and minified JavaScript -->
<script src="js/bootstrap.js"></script>
<script type="text/javascript">
$(function() {
  $('.video-control').click(function(e) {
    e.preventDefault();
    var video = document.getElementById('thevideo');
    var action = $(this).data('action');
    $('.video-control').prop('disabled',false);
    if (action == 'play') {
      video.play();
      $(this).prop('disabled',true);
    }
    else if (action == 'pause') {
      video.pause();
      $(this).prop('disabled', true);
    }
  });
});
</script>
</body>
</html>

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
jQuery

From novice to tech pro — start learning today.