Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

99
Views
Stop video automatically when certain time is set typescript

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?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

try to use >= instead of ==

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!