我在2000环境下用mediaplay取mp3的时间长度就准确,但取mid和wav的长度就不准,这是怎么会事???请各位英雄出手相救啊!
在用midaplay取mid文件时,长度和取mp3的长度差的太多,怎么也弄不好,超级郁闷!!!还请各位指点迷津啊!

解决方案 »

  1.   

    谢谢楼上的各位,现在就是算不出mediaplayer1.Length在取mid音乐时,取的长度和时间的对应关系,但mp3和wav都非常准确,昨晚查以前的下大富翁上也有个类似的问题,但楼主没说怎么做好的就把贴子给结了,超级失望落寞中,想我堂堂七尺汉子连这么个小问题都搞不定,实在是无颜以对。。呜呜,自刎乌江算了
    begin
      mediaplayer1.timeformat:=tfMilliseconds;
      if  opendialog1.Execute then
        edit3.Text:=opendialog1.FileName;
      if opendialog1.FileName='' then  exit;
      button3.Enabled:=true;
      mediaplayer1.FileName:=opendialog1.FileName;
      mediaplayer1.Open;
     // mediaplayer1.Show;
      showmessage(inttostr(mediaplayer1.Length));
     if UpperCase(DelFileName(mediaplayer1.FileName))='MID' then
     begin
       label8.Caption:=SecToMin(Trunc(mediaplayer1.Length * 60 / 312));
     end
     else
      label8.Caption:=SecToMin(mediaplayer1.Length div 1000);
      DateTimePicker2.Time := StrToTime(label8.Caption);
      SetEnable(true);
      checkbox1.Checked:=true;
      mediaplayer1.Close;
    end;
      

  2.   

    大富翁上的同样问题问题的标题是: 请教一个非常简单的问题,关于 MEDIAPLAYER 的时间 (100分 )
     
    来自:白河愁 时间:2001-10-9 10:38:00 ID:662529 为什么我用 MEDIAPLAYER.length 得到一个 MIDI 的长度居然会比一个不到一秒
    的 WAV 文件短?怎么才能得到正确的长度呢? 
    来自:小人物 时间:2001-10-9 10:43:00 ID:662535 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抰 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; 
    来自:白河愁 时间:2001-10-9 12:08:00 ID:662713 这个是DELPHI里的例子吧?都是不行的,那个5分多钟的MIDI比那个不到一秒的WAV短多了。 
    来自:LeeChange 时间:2001-10-9 16:45:00 ID:663248 看一下TimeFormat 
    来自:白河愁 时间:2001-10-9 21:49:00 ID:663715 上面不是设置了TIME FORMAT 吗?就是不行。 
    来自:leejames 时间:2001-10-11 16:59:00 ID:666987 我用过这个东东,tfHMS好象有真不行,我用豪秒换算就可以,你试试看 
    来自:白河愁 时间:2002-4-22 0:54:00 ID:1059153 已经KO了,请斑竹删贴并把分给回我吧。 
    来自:杭彦彤 时间:2002-4-22 8:37:00 ID:1059275 去delphi专区那发帖子,问题一般能解决
     
      

  3.   

    MediaPlayer1.TimeFormat := tfHMS;这个可以不?
      

  4.   

    //try
      MediaPlayer.TimeFormat := tfFrames;
      ShowMessage('Number of frames = ' +
        IntToStr(MediaPlayer .Length));
      MediaPlayer .TimeFormat := tfMilliseconds;
      ShowMessage('Number of milliseconds = ' +
                  IntToStr(MediaPlayer .Length));
      

  5.   

    佩服 zswangII(伴水清清)(职业清洁工) 真乃高手高手之高高手!!!