Tag <video> controlling by javascript

Asked

Viewed 369 times

4

How do I so that when I click on the video it starts uploading, because I’m not getting if anyone can help thank you.

Here’s the code snippet from the video:

<div class="video">
   <video class="video" loop controls tabindex="0">
      <source src="video/nome_do_video.mp4"/>
   </video>
</div>

1 answer

4


The method name is play(), however, you should access it from the DOM tree because it is not a Jquery method but a DOM Object method.

jQuery( document ).ready(function($) {
    $('video.video').click(function() {
        $(this).get(0).paused ? $(this).get(0).play() : $(this).get(0).pause();
    });
});

In this script, if the video is paused, the action of play(), otherwise it shall be paused.

  • Thank you guy helped me a lot

  • guy just a question like I do to kind of have a buffer for it starts only after the video load at least 15% ?

  • in google, search so "Html5 video buffer before playing"

  • thank you very much.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.