This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

hi,

I making a program using the mpegdll.dll, it has a .length property, to display the time, but it is in milliseconds. I tried converting it to Minutes and seconds but had no luck, can anyone show me how to do it. Currently I have this

T := ((MPEG1.Length div 1000) div 60);

I := IntToStr(T);

Label3.Caption := I

Now the time I get is rounded like say 4 minutes, how do I get the seconds too, and how to format the label so it is displayed like this 0:00 (Minutes:Seconds). I'm not even sure my calculation is correct so please show the full procedure.

Thanks

I making a program using the mpegdll.dll, it has a .length property, to display the time, but it is in milliseconds. I tried converting it to Minutes and seconds but had no luck, can anyone show me how to do it. Currently I have this

T := ((MPEG1.Length div 1000) div 60);

I := IntToStr(T);

Label3.Caption := I

Now the time I get is rounded like say 4 minutes, how do I get the seconds too, and how to format the label so it is displayed like this 0:00 (Minutes:Seconds). I'm not even sure my calculation is correct so please show the full procedure.

Thanks

We could do it like this :

T := ((MPEG1.Length / 1000) / 60);

label3.Caption := IntToStr(Trunc(T)) + ':'+IntToStr(Frac(T));

Regards, Zif.

A sample would help.

Thanks

T is double? Correct?

S is String? Correct?

To translate T to string you must use FloatToStr....

OR to get minutes ... You need :

IntToStr(Trunc(T)) ---> Trunc gets the integer value of T;

to get minutes :

Frac(T) ---> gets the fractional part of T....

So if you got 2 values after comma --->

var seconds : string;

seconds := Trunc(Frac(T)*100);

Label3.Caption := IntToStr(Trunc(T)) + ':'+IntToStr(Trunc(Frac(T)

ok here is the full code

Var

T : Double;

Begin

T := ((MPEG1.length /1000) /60);

Label3.Caption := IntToStr(Trunc(T))+':'+ IntToStr(Frac(T)*100); =>> here I get Incompatible types Integer and Real.

Any ideas

See Frac returns a real value.... So, we do this :

If frac(T) is 0.32 ---> * 100 --> 32 ---> change to integer ---> Trunc(32)

This is the code --> IntToStr(Trunc(Frac(T)*100

Regards, Zif.

maybe this is all you need. Drop a TButton, a TLabel and a TEdit on a blank form and put this in the buttons OnClick handler. Now you can test the format of milliseconds to HH:MM:SS:FF.

procedure TForm1.Button1Click(Sender

// frames in 25 fps (PAL), can also be 30 (NTSC)

const FPS = 30;

var H, M, S, F, MS : Integer;

begin

MS := StrToInt(Edit1.Text);

H := (((MS div 1000) div 60) div 60) mod 60;

M := ((MS div 1000) div 60) mod 60;

S := (MS div 1000) mod 60;

F := ((MS mod 1000) * FPS) div 1000;

Label1.Caption := Format('%.2d:%.2d:%.2d-%.2

end;

This function outputs *very* fast.

Slash/d003303

When reading this thread, I just wanted to say that IntToStr is rather slow and using and rounding lots of floats doesn't help either...

I guess the fastest/shortest way of doing this is:

Label1.Caption:=Format('%d

This doesn't display hours, but I think that's ok... few Mpegs will last more than one hour and even then, something like "87 minutes" is quite normal for movies...

P.S.: d003303, what does H := (((MS div 1000) div 60) div 60) mod 60; do? Are you a workaholic and your day "only" has 60 hours? *bg*

ZifNab's a workaholic as well... his minute has 100 seconds!

hellfire: If you used ZifNab's code, you should change IntToStr(Trunc(Frac(T)*100

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.

If you use div you will always get an integer; It rounds everything so you can assign the result to an integer.

Use / and you get a float or double ---> if you need numbers after comma, just take this float minus the integer part of it and you got it!

Regards ZiF.