Recent

Author Topic: Current position of the progress bar  (Read 916 times)

Pe3s

  • Hero Member
  • *****
  • Posts: 533
Current position of the progress bar
« on: May 15, 2022, 10:34:07 am »
Hi, how can I calculate the current position of the progress bar if I know the length of a music track or movie?

Thaddy

  • Hero Member
  • *****
  • Posts: 14157
  • Probably until I exterminate Putin.
Re: Current position of the progress bar
« Reply #1 on: May 15, 2022, 10:43:47 am »
scale to 100%, position is at  X% (very simple 12 year old math)
Specialize a type, not a var.

Pe3s

  • Hero Member
  • *****
  • Posts: 533
Re: Current position of the progress bar
« Reply #2 on: May 15, 2022, 11:30:55 am »
Code: Pascal  [Select][+][-]
  1. pbar.value:= pbar.ClientWidth * duration ?????

bytebites

  • Hero Member
  • *****
  • Posts: 624
Re: Current position of the progress bar
« Reply #3 on: May 15, 2022, 11:54:48 am »
Code: Pascal  [Select][+][-]
  1. ProgressBar1.Min:=0;
  2. ProgressBar1.Max:=100;
  3.  
  4.  
  5. ProgressBar1.Position:=trunc(music.position/duration*100);
  6. Application.ProcessMessages;

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: Current position of the progress bar
« Reply #4 on: May 15, 2022, 07:14:31 pm »
scale to 100%, position is at  X% (very simple 12 year old math)
@Thaddy
Sometimes your advice is negated by the way you belittle the questioner. Suppose the questioner is a refugee who has had no formal education at primary or teenage level?
If you can't resist adding a snide comment to complete your advice I feel it would be better that you not offer any response.

440bx

  • Hero Member
  • *****
  • Posts: 3921
Re: Current position of the progress bar
« Reply #5 on: May 15, 2022, 09:13:45 pm »
@Thaddy,

I have to concur with @howardpc and, FYI, putting people down doesn't make you look good, on the contrary.

(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

 

TinyPortal © 2005-2018