This happens because this.currentTime()
is not an integer. It is a Number
containing a floating point value. As you can see in the jsfiddle demo, provided in the documentation, it is unlikely to get a round integer value. So checking for equality is inappropriate in this case. You did not specify what did you want to achieve with your code, but if you want to pause the video after it reaches 2 second in play, you should check if currentTime
is greater than 2, and then set a variable that will ensure you do this only once:
var time_prompts = [], once = true;
time_prompts[0] = 2 //any integer < video duration
$popcorn.on( "timeupdate", function() {
console.log( this.currentTime() );
if (this.currentTime() > time_prompts[0] && once) {
once = false;
this.pause();
console.log(this.paused)
}
});