javascript

Videojs check if video is playing

var videoObj = videojs("video_id");

if (!videoObj.paused()) {
    console.log("Video is playing");
} else {
    console.log("Video is paused");
}

//USING .paused() function of videojs

To check whether a video is playing or not you can use .paused() method if you are using Videojs library in your project. The method will return false if the video is in play mode and return true if it is paused.

As in the above code snippet, we have wrapped the function inside the if-else condition and we are logging if the video is playing or not. You can write your code inside those conditions if you have any requirements.

Also, we have initialized Videojs object in our videoObj variable that will contain all the properties and methods related to Videojs player.

Was this helpful?