Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the play event on a video html5 element?

I have a video html5 tag embedded on page. I need to trigger an action when the user clicks the "Play Button". But I can't find how to bind that to my action. Is there an event for what I need? I'm using jQuery...

Thanks!

like image 392
Andres Avatar asked Oct 01 '12 20:10

Andres


People also ask

How do you know if a video is playing in HTML?

To detect if it's playing use the video. onplaying event to detect it's now loaded and playing e.g. video. onplaying = function() { console. log('Video is now loaded and playing'); } .

What is play in HTML?

HTML Audio/Video DOM play() Method The play() method starts playing the current audio or video. Tip: Use the pause() method to pause the current audio/video.

What is input event in HTML?

The input event fires when the value of an <input> , <select> , or <textarea> element has been changed. The event also applies to elements with contenteditable enabled, and to any element when designMode is turned on. In the case of contenteditable and designMode , the event target is the editing host.


1 Answers

Does this W3C demo page help? http://www.w3.org/2010/05/video/mediaevents.html It appears the play event is simply 'play'.

For example:

$('video').bind('play', function (e) {
    // do something
});

or

$('video').on('play', function (e) {
    // do something
});
like image 152
Stephen Booher Avatar answered Oct 08 '22 02:10

Stephen Booher