在没有载入文件之前要获取文件播放时间,注意是要在没有载入之前。

解决方案 »

  1.   

    可以在没载入之前知道视频文件的大小,一定也可以在没载入前知道长度的。要不 winamp 和 wmp 怎么做?
      

  2.   

    WINAMP也是载入后才知道的.
    因为媒体文件都有特定的格式,比如MP3最后128字节装载了关于这个文件的一些信息,我想大概是利用了STREAM来读取并显示给用户.
      

  3.   

    procedure TFormDVDPlayer.FilterGraphDVDCurrentHMSFTime(sender: TObject;
      HMSFTimeCode: tagDVD_HMSF_TIMECODE; TimeCode: tagDVD_TIMECODE);
    var
      ttt : tagDVD_HMSF_TIMECODE;
      fps : ULONG;
    begin
      with HMSFTimeCode do
        StatusBar.Panels.Items[0].Text :=
          format('%d:%d:%d',[bHours, bMinutes ,bSeconds]);
      with FilterGraph as IDvdInfo2 do GetTotalTitleTime(ttt, fps);
      Edit1.Text := format('%d:%d:%d',[ttt.bHours, ttt.bMinutes ,ttt.bSeconds]);
      if BeginPlay then
      begin
        if StrToTime(format('%d:%d:%d',[HMSFTimeCode.bHours, HMSFTimeCode.bMinutes ,HMSFTimeCode.bSeconds]))>StrToTime(format('%d:%d:%d',[ttt.bHours, ttt.bMinutes ,ttt.bSeconds]))-2 then
        begin
          MessageDlg('影片播放完毕', mtWarning, [mbOK], 0);
          FilterGraph.Stop;
          FilterGraph.ClearGraph;
        end;
      end;
    end;