怎样获取一首曲子的播放时间长度呢?

解决方案 »

  1.   

    if Self.OpenDialog1.Execute then
    begin
       Self.MediaPlayer1.FileName := Self.OpenDialog1.FileName;
       Self.MediaPlayer1.Open;
       Self.MediaPlayer1.TimeFormat := tfMilliseconds;
       ShowMessage(IntToStr(Self.MediaPlayer1.Length DIV 1000));
    end;TimeFormat 用于指定时间的格式,由四个字节的整数组成,取值及含义:
     tfMilliseconds : 四个字节为一个变量以毫秒为单位
     tfHMS          : 时、分、秒、未用
     tfMSF          : 分、秒、Frames、未用
     tfFrames       : 四个字节为一个变量以帧为单位
     tfSMPTE24      : 以 24-Frame 计数:时、分、秒、Frames
     tfSMPTE25      : 以 25-Frame 计数:时、分、秒、Frames
     tfSMPTE30      : 以 30-Frame 计数:时、分、秒、Frames
     tfSMPTE30Drop  : 以 30-Drop-Frame 计数:时、分、秒、Frames
     tfBytes        : 时间按字节存储四字节整数
     tfSamples      : 时间按Samples存储四字节整数
     tfTMSF         : 轨道、分、秒、Frames