M
midier
Unregistered / Unconfirmed
GUEST, unregistred user!
本人编了一个媒体播放的小程序,我想用个标签显示时间值;用了MediaPlayer的
TimeFormat属性,可是标签的始终为‘00:00’?不管我怎么改变Timeformat的属性值,都一样,
如果是设备问题,该怎么做,才能让时间值显示出来? (程序片段)
procedure TForm1.Button1click(Sender:Object);
begin
MediaPlayer1.filename:=OpenDialog1.filename;
MediaPlayer1.DeviceType:=dtAutoSelect;
MediaPlayer1.timeformat:=tfMilliseconds;
MediaPlayer1.open;
MediaPlayer1.play;
Timer1.enabled:=true;
Ttrackbar1.min:=MediaPlayer1.startpos;
Ttrackbar1.max:=MediaPlayer1.length;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
var position:longint;(timeminute,timesecond:为全局变量)
begin
if MediaPlayer1.Mode =mpPlaying then
begin
ttrackBar11.Position :=MediaPlayer1.Position
position:=MediaPlayer1.Position
timeminute:=position div (60*1000);
if timeminute<>0 then
timesecond:=(position-timeminute*(60*1000)) div 1000
else
timesecond:=position div 1000;
Label1.Caption :=format('%.2d',[timeminute])+':'+format('%.2d',[timesecond]);
end else
if MediaPlayer1.NotifyValue =nvSuccessful then
begin
MediaPlayer1.Stop
ttrackBar11.Position :=0;
timer1.Enabled :=false;
end;
end;
比如:<古典名曲-梁祝.mid>的实际播放时间是23秒(windows自带的播放器),跟踪程序得
到Length的值始终是224?
TimeFormat属性,可是标签的始终为‘00:00’?不管我怎么改变Timeformat的属性值,都一样,
如果是设备问题,该怎么做,才能让时间值显示出来? (程序片段)
procedure TForm1.Button1click(Sender:Object);
begin
MediaPlayer1.filename:=OpenDialog1.filename;
MediaPlayer1.DeviceType:=dtAutoSelect;
MediaPlayer1.timeformat:=tfMilliseconds;
MediaPlayer1.open;
MediaPlayer1.play;
Timer1.enabled:=true;
Ttrackbar1.min:=MediaPlayer1.startpos;
Ttrackbar1.max:=MediaPlayer1.length;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
var position:longint;(timeminute,timesecond:为全局变量)
begin
if MediaPlayer1.Mode =mpPlaying then
begin
ttrackBar11.Position :=MediaPlayer1.Position
position:=MediaPlayer1.Position
timeminute:=position div (60*1000);
if timeminute<>0 then
timesecond:=(position-timeminute*(60*1000)) div 1000
else
timesecond:=position div 1000;
Label1.Caption :=format('%.2d',[timeminute])+':'+format('%.2d',[timesecond]);
end else
if MediaPlayer1.NotifyValue =nvSuccessful then
begin
MediaPlayer1.Stop
ttrackBar11.Position :=0;
timer1.Enabled :=false;
end;
end;
比如:<古典名曲-梁祝.mid>的实际播放时间是23秒(windows自带的播放器),跟踪程序得
到Length的值始终是224?