I'm trying to limit video play within range of number that user specified.
User specified a start frame and an end frame like this.
frameInputEnd: 300
frameInputStart: 50
i recalculate those input into seconds like this
this.startDuration = (((1000 / this.fpsCount) * this.rangeFrame.frameInputStart) / 1000).toFixed(2);
this.endDuration = ((1000 / this.fpsCount) * this.rangeFrame.frameInputEnd) / 1000;
and set the currentTime = this.startDuration. That way user can have duration start on the frame which they have specified. I want to add an event where the video has reach the currentTime that is equal to frameInputEnd here's what i did
this.videoPlayer.nativeElement.ontimeupdate = (e: any) => {
this.whatFps = `${Math.ceil(e.target.currentTime * this.fpsCount)} / ${this.totalFrame}`;
if(this.videoPlayer.nativeElement.currentTime.toFixed(2) == Number(this.endDuration).toFixed(2)){
this.pause()
}
}
i add .toFixed(2) since the frameInputEnd is equal to 12.50 seconds. but the currentTime never match to 12.50 seconds, either it's 12.51 or 12.52 the video never stopped automatically.
Does anyone knows a batter way to achieve this?
try to use >= instead of ==