(1) procedure TForm1.Button1Click(Sender: TObject); var TheLength,h,m,s,x:integer; hh,mm,ss:String; begin MediaPlayer1.Open(); // Set time format - note that some devices don't support tfHMS MediaPlayer1.TimeFormat := tfMilliseconds ; // Store length of currently loaded media TheLength := MediaPlayer1.Length; // display hours in hh h:= TheLength div (1000*60*60); x := TheLength-h*1000*60*60; if (h<10) then hh :='0'+IntToStr(h) else hh := IntToStr(h); // display minutes in mm TheLength := x; m:= TheLength div(1000*60); x :=TheLength-m*1000*60; if (m<10)then mm :='0'+IntToStr(m) else mm := IntToStr(m); // display the seconds in ss TheLength := x; s:= TheLength div(1000*60); if (s<10)then ss :='0'+IntToStr(s) else ss := IntToStr(s); Label1.Caption := hh+':'+mm+':'+ss; end; (2) 将THELENGTH设为MediaPlayer1.Position,其余不变即可获取当前时间。
var
Min, Sec: Byte;
Len: Longint;
begin
if CurrentTrack <> OldTrack then
begin
Len := mpCDPlayer.TrackLength[mci_Tmsf_Track(mpCDPlayer.Position)];
Min := mci_msf_Minute(Len);//最长分钟
Sec := mci_msf_Second(Len);//最长秒数
ggTrackDone.MaxValue := (60 * Min) + Sec;
LblTrackLen.Caption := Format(MSFormatStr, [m, s]);
end;
OldTrack := CurrentTrack;
end;2.......
m := mci_Tmsf_Minute(mpCDPlayer.Position);//当前分钟
s := mci_Tmsf_Second(mpCDPlayer.Position);//当前秒数
====================================delphi 5 开发指南
var
Min, Sec: Byte;
Len: Longint;
begin
Len := mpCDPlayer.TrackLength[mci_Tmsf_Track(mpCDPlayer.Position)];
Min := mci_msf_Minute(Len);//最长分钟
Sec := mci_msf_Second(Len);//最长秒数
end;那是一个完整的例子,你按照需要自己做。另外,<delphi 5 开发指南 >讲的比较详细,你找来看看
邮件发送给: [email protected]
procedure TForm1.Button1Click(Sender: TObject);
var TheLength,h,m,s,x:integer;
hh,mm,ss:String;
begin
MediaPlayer1.Open();
// Set time format - note that some devices don't support tfHMS
MediaPlayer1.TimeFormat := tfMilliseconds ;
// Store length of currently loaded media
TheLength := MediaPlayer1.Length;
// display hours in hh
h:= TheLength div (1000*60*60);
x := TheLength-h*1000*60*60;
if (h<10) then hh :='0'+IntToStr(h)
else hh := IntToStr(h); // display minutes in mm
TheLength := x;
m:= TheLength div(1000*60);
x :=TheLength-m*1000*60;
if (m<10)then mm :='0'+IntToStr(m)
else mm := IntToStr(m); // display the seconds in ss
TheLength := x;
s:= TheLength div(1000*60);
if (s<10)then ss :='0'+IntToStr(s)
else ss := IntToStr(s);
Label1.Caption := hh+':'+mm+':'+ss;
end;
(2)
将THELENGTH设为MediaPlayer1.Position,其余不变即可获取当前时间。