Saturday, June 1, 2024
 Popular · Latest · Hot · Upcoming
188
rated 0 times [  190] [ 2]  / answers: 1 / hits: 26367  / 9 Years ago, wed, december 30, 2015, 12:00:00

I've written a small jquery code to override HTML 5 play function. However, I am not able to check if a video is playing or not.
Here is my jquery code



$(video).click(function() {
var video = $(#myvideo).get(0);
video.play();
$(.play).css(display, none);
return false;
});
$(#myvideo).bind(pause ended, function() {
$(.play).css(display, block);
});


Just give me simple tips to show a div with class=pause(I have CSS for it) when the video is paused and pause the video as well.


More From » jquery

 Answers
217

You'd use the paused property to check if the video is paused.

If it's not paused, it's playing



$(video).click(function() {
var video = $(#myvideo).get(0);

if ( video.paused ) {
video.play();
$(.play).hide();
$(.pause).show();
} else {
video.pause();
$(.play).show();
$(.pause).hide();
}

return false;
});

[#63892] Monday, December 28, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jenamackennac

Total Points: 304
Total Questions: 110
Total Answers: 107

Location: Ecuador
Member since Thu, Jun 4, 2020
4 Years ago
jenamackennac questions
Fri, Feb 18, 22, 00:00, 2 Years ago
Wed, Apr 21, 21, 00:00, 3 Years ago
Thu, Apr 1, 21, 00:00, 3 Years ago
Tue, Feb 2, 21, 00:00, 3 Years ago
;