用timer控件
//显示播放或录制的时间
procedure tform1.shownowtimeorframe;
var
nowtime,alltime:LongInt;
minutes,seconds:integer;
begin
//if showformat=timeformat then
// begin
with mediaplayer1do
begin
timeformat:=tfmilliseconds;
nowtime:=position;
alltime:=length;
minutes:=nowtime div 60000;
seconds:=(nowtime-60000*minutes) div 1000;
label1.Caption:=inttostr(minutes)+'分'+inttostr(seconds)+'秒';
minutes:=alltime div 60000;
seconds:=(alltime-60000*minutes) div 1000;
label2.Caption:=inttostr(minutes)+'分'+inttostr(seconds)+'秒';
end;
end;
//改变滑动条位置及显示的时间
procedure TForm1.Timer1Timer(Sender: TObject);
begin
if mediaplayer1.Mode=mpplaying then
begin
shownowtimeorframe;
trackbar1.Position:=mediaplayer1.Position div 1000;BtOPen.Enabled:=true;
end;
if mediaplayer1.Mode=mprecording then
begin
shownowtimeorframe;
trackbar1.Position:=mediaplayer1.Position div 1000;
end;
if mediaplayer1.Mode=mpstopped then
shownowtimeorframe;
end;