如何使用DSpack在打开一个Avi文件的时候, 控制开始播放的时刻, 我按照很多方法试过, 无论怎样指定CurrPos, 开始播放的时候都是跳到开始位置才播放!

解决方案 »

  1.   

    高手帮忙:http://topic.csdn.net/u/20100510/09/50a51ee4-acd1-4254-88c3-c8c0b390f42f.html
      

  2.   

    我试过了,IMediaSeeking.setPosition 只能在文件已经打开后操作才可以!!
    论坛上的帖子已经有过类似的解决方法,而且有效的,
    但是,我想要的效果是打开文件的同时跳到指定的时间!!
    无论怎么操作都要跳到起始位置!!
      

  3.   

    可能楼主要的效果比较完美?先打开再定位,可能第一个画面会停留一下再跳到指定的位置是吧?
    如果不行那两个视频同时播放,只是切换videoWindow的前后位置呢?
      

  4.   

    //==============================================================================
    // 改变当前播放的视频, aCurrPos,aStopPos本别代表重新载入的视频的起始播放位置
    // 为 0 时代表从当前播放的视频的当前位置开始播放新的视频
    //==============================================================================
    procedure TfrmVideo.ChangeCurrVideo(aVideoName: string = ''; aCurrPos: Int64 = 0; aStopPos: Int64 = 0; aVideoIndex: Integer = -1);
    var
      CurrPos, StopPos: Int64;
      MediaSeeking: IMediaSeeking;
    begin
      Timer.OnTimer:= nil;
      Timer.Enabled:= False;
      if not FilterGraph.Active then
        FilterGraph.Active:= True;
      if (aCurrPos = 0) and (aStopPos = 0) then
      begin
        FilterGraph.QueryInterface(IID_IMediaSeeking, MediaSeeking);
        MediaSeeking.GetPositions(CurrPos, StopPos);
        aCurrPos:= CurrPos;
        aStopPos:= StopPos;
      end;  if ((aVideoName <> '') or (aVideoIndex > 0)) and ((aVideoName <> CurrVideo) and (aVideoIndex <> CurrIndex)) then
      begin
        if aVideoName = '' then
          aVideoName:= CurrVideo;
        if aVideoIndex < 0 then
          aVideoIndex:= CurrIndex;    FilterGraph.ClearGraph;
        FilterGraph.RenderFile(VideoInfo.TimePath[aVideoIndex].Path + aVideoName + '.avi');
        FilterGraph.Play;
        CurrVideo:= aVideoName;
        CurrIndex:= aVideoIndex;
      end;  FCurrPos:= aCurrPos;
      FStopPos:= aStopPos;
      Self.Caption:= FCapion + FormatDateTime('hh:mm:ss', VideoInfo.TimePath[CurrIndex].Time);  // 这种方式真变态? SetPositions 必须用事件激活? 为什么呢?
      // 想办法改变这种方式
      Timer.Enabled:= True;
      Timer.OnTimer:= TimerTimer;
    end;timer的OnTimer中位IMediaSeeking.setPosition 
    本来在一个窗体中师可以的,把改变视频位置的代码放在其他时间中“触发”还勉强可以工作,
    可在MDI方式下就不行了
      

  5.   

    大体看明白了,试试在你的FilterGraph的OnDSEvent事件里当是EC_CLOCK_CHANGED事件时执行你的setposition
      

  6.   

    procedure TFormPlayWin.FilterGraphDSEvent(sender: TComponent; Event,
      Param1, Param2: Integer);
    begin
      //log.Lines.Add(GetEventCodeDef(event));
      if event = EC_CLOCK_CHANGED then
        MediaSeeking.SetPosition
    end;
      

  7.   

    试过了,还是不行阿!!是不是DSpack的固有问题呀,上面的代码你试过工作怎么样的效果阿?
      

  8.   

    我试过了没有问题
    你把你怎么做的发上来看看setposition部分