Hello, all,
I'm trying to display the time of an audio file in a lable, so I
Much of this is from the help file, however, this then displays the song (which I know to be precisely 2 minutes long) as 58 hours, 251 minutes and 1 second long. What am I doing wrong?
Any help appreciated.
I'm trying to display the time of an audio file in a lable, so I
Code:
type
HMSRec = record
Hours: byte;
Minutes: byte;
Seconds: byte;
NotUsed: byte;
end;
...
procedure TForm1.FormCreate(Sender: TObject);
var
TheLength: LongInt;
begin
MediaPlayer1.FileName := 'H:\Blur - woohoo.mp3';
MediaPlayer1.Open;
MediaPlayer1.PLay;
{ Set time format - note that some devices don’t support tfHMS }
MediaPlayer1.TimeFormat := tfHMS;
{ Store length of currently loaded media }
TheLength := MediaPlayer1.TrackLength[1];
with HMSRec(TheLength) do { Typecast TheLength as a HMSRec record }
begin
Label1.Caption := IntToStr(Hours); { Display Hours in Label1 }
Label2.Caption := IntToStr(Minutes); { Display Minutes in Label2 }
Label3.Caption := IntToStr(Seconds); { Display Seconds in Label3 }
end;
ShowMessage(IntToStr(THeLength));
end;
Much of this is from the help file, however, this then displays the song (which I know to be precisely 2 minutes long) as 58 hours, 251 minutes and 1 second long. What am I doing wrong?
Any help appreciated.