Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detecting HTML5 video play/pause state with jQuery

I'm building a jQuery slideshow which will feature an HTML5 video player on one of the slides. Is there any way to get the jQuery slideshow to pause from its otherwise automatically running state, when it detects that the video is playing, besides a "slideshow play/pause" button?

like image 308
Jules Avatar asked Aug 19 '12 14:08

Jules


People also ask

How do I know if a video is paused in jquery?

You can use the . paused() method in javascript to check whether a video is playing or not. It will return true if the video is playing and return false if the video is not playing.

How do you add a pause button to a video in HTML?

this. play() : this. pause();" .


2 Answers

You can check if the video is paused used the paused property:

$("#videoID").get(0).paused;

You can pause a video using the pause() method:

$("#videoID").get(0).pause();

You can then resume the playback of the video using the play() method:

$("#videoID").get(0).play();
like image 185
jeff Avatar answered Sep 19 '22 10:09

jeff


var video = $('video');

var videoElement = video.get(0);

if (!videoElement.paused) {} 

One way of doing it using Jquery

like image 38
Luke Robertson Avatar answered Sep 19 '22 10:09

Luke Robertson