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?