Here is what I suggest you do and why:
function videoSeek(){
var video = document.getElementById("IDofVideo"); //Get video player
//stuff happens here...
var currentsec = Math.floor(Math.random() * 4) + 1; //Gives you # between 1 and 4.
if(currentsec == 3){
video.pause();
console.log("STOP");
}
}
First, I don't know what your variable vid
is or how you got it so I'm showing you how I would set it.
Second, the random number you have should definitely be changed, like @johnkork stated. I don't know the range of numbers you need so I just did an example of 1-4.
Third, the if statement must use either ==
or ===
for comparison like @Fildor stated. Here is a good article explaining why Which equals operator (== vs ===) should be used in JavaScript comparisons?
And last, assuming vid
was properly set and everything, your .pause();
call should work.
I don't really see what you are trying to accomplish with this, so having a goal would help display what you need to do. Hopefully this helps.