请自己在本论坛中搜!!应该有的 很多
先声明以下是转载(thedream)的^^
//用getlength得到的就是总长度(单位是毫秒吧,0.001秒),当前播放时间也就一样啦
<br />unit Unit1;
<br />
<br />interface
<br />
<br />uses
<br />  Windows, Messages, SysUtils, Classes, Graphics, 
<br />
<br />Controls, Forms, Dialogs,
<br />  StdCtrls, OleCtrls, RealAudioObjects_TLB;
<br />
<br />type
<br />  TForm1 = class(TForm)
<br />    RealAudio1: TRealAudio;
<br />    Button1: TButton;
<br />    Button2: TButton;
<br />    procedure Button1Click(Sender: TObject);
<br />    procedure Button2Click(Sender: TObject);
<br />  private
<br />    { Private declarations }
<br />  public
<br />    { Public declarations }
<br />  end;
<br />
<br />var
<br />  Form1: TForm1;
<br />
<br />implementation
<br />
<br />{$R *.DFM}
<br />procedure GetTotalTime(var RealAudio1: TRealAudio; var 
<br />
<br />vMin,vSecond:Integer);
<br />var
<br />  temp:integer;
<br />begin
<br />  temp:=round(realaudio1.GetLength/1000);//&Icirc;&Ograve;&Otilde;&acirc;&Agrave;&iuml;&Ouml;&raquo;&frac34;&laquo;&Egrave;·&micro;
<br />
<br />&frac12;&Atilde;&euml;
<br />  vMin:=temp div 60;
<br />  vSecond:=temp - vMin*60;
<br />end;
<br />
<br />procedure TForm1.Button1Click(Sender: TObject);
<br />begin
<br />realaudio1.SetSource('C:\1222\jacky06.mp3');
<br />realaudio1.DoPlay;
<br />end;
<br />
<br />procedure TForm1.Button2Click(Sender: TObject);
<br />var
<br />  ff,mm:integer;
<br />begin
<br />  GetTotalTime(realaudio1,ff,mm);
<br />  showmessage(inttostr(ff)+'·&Ouml;'+inttostr(mm)+'&Atilde;&euml;');
<br />
<br />end;
<br />
<br />end.
<br />

解决方案 »

  1.   

    设定MediaPlayer1.TimeFormat := tfHMS;type  HMSRec = record
        Hours: byte;
        Minutes: byte;
        Seconds: byte;
        NotUsed: byte;  end;procedure TForm1.Button1Click(Sender: TObject);var
      TheLength: LongInt;
    begin  { Set time format - note that some devices don’t support tfHMS }  MediaPlayer1.TimeFormat := tfHMS;
      { Store length of currently loaded media }
      TheLength := MediaPlayer1.Length;
      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;
    end;
      

  2.   

    //---------------时间转换函数----------//
    function msTominSec(t: integer): string;
    var min,sec: integer;
        s1,s2: string;
    begin
      sec:=t div 1000;
      min:=sec div 60;
      sec:=(sec-min*60);
      if min > 9 then s1:=intToStr(min)
      else s1:='0' + intToStr(min);
      if sec>9 then s2:=intToStr(sec)
      else s2:='0' + intToStr(sec);
      Result:=s1 + ':' +s2;
    end;
    //---------歌曲总长-----------//
      label2.Caption := ''+ msToMinSec(mp.Length) + '';
    //-------时间变化-----------//
    label1.Caption := msToMinSec(mp.Position);//在Timer1Timer过程中,你的明白