javascript
Check if video is stopped or playing Javascript only
var video = document.getElementsByTagName("video");
if (video[0].paused) {
console.log("video is stopped");
//DO SOMETING...
} else {
console.log("video is playing");
//DO SOMETHING...
}
//OR YOU CAN GET video DOM OBJ USING ID
var video = document.getElementById("videoId");
if (video.paused) {
console.log("video is stopped");
//DO SOMETING...
} else {
console.log("video is playing");
//DO SOMETHING...
}
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.
You can get a video DOM element using its tag name or id. We have shown both ways in the code snippet by which you can check if it is playing or paused.
Was this helpful?
Similar Posts
- Videojs check if video is playing
- Check whether a checkbox is checked or not using Javascript only
- Load or preview html to Iframe using Javascript only
- How to make HTTP requests using Javascript Only
- Enter only number field validation redux form
- Check if a variable is null, empty, undefined or false Javascript
- Check if a string is Palindrome or not using Javascript