I have a video element where I want to compare it's current time to a variable with upto 2 decimal values.
$(video1).on('timeupdate', function(){
var currentTime = Math.round(this.currentTime);
var durationNum = Math.round(this.duration);
var formattedCurrentTime = secondsToHms(currentTime);
var formattedDurationTime = secondsToHms(durationNum)
onTrackedVideoFram(formattedCurrentTime, formattedDurationTime)
if(currentTime >10){ $(".box1, .box2").hide(); }
if(currentTime == choiceHeart){
console.log("HERE");
video1[0].pause();
}
this is from a tutorial file so the only way I know how to get the timeupdate to return a value is through that math.round function which returns rounded whole number.
BUT, I want to trigger an event, like pause the video at, say, 2.5 minutes (or 2 minutes 15 frames - by After effects 30 fps standards)****
The way I could do is create a variable early in the document like this :
var triggerEvent = 2.5;
So how do I get to understand that 2.5 means to return this value in 2 minutes and half minutes and it should pause the video at 2 & a half minutes?
PS :
In order to pause the video I plan to use an if loop :
if(currentTime == triggerEvent){
video1[0].pause();
}
here video1 is referencing to a variable which points to the div which holds the video.
currentTime
of the video is in units of seconds. If you want to pause at 2.5 minutes, just docurrentTime >= 2.5 * 60
?timeupdate
does not dispatch linearly