我用panel.handle获取视频回放,如果第一次就播放这个文件,没问题,如果先播放别的,再播放它就有问题,显示不出来。等点停止,panel.repaint时就会闪一下就没有了,为什么啊?

解决方案 »

  1.   

    回放没问题吧
    TPanel是标准的win32控件。
      

  2.   

    directshow网络上有测试的程序,我试过没出现你那样的问题
      

  3.   

    directshow(dspack)以前我做过好像也没什么问题啊?
      

  4.   

    我根据海康的例子做的,人家的就没问题啊,可是我看了,除了我两个回调函数没调,剩下都一样啊,回调函数例子去掉也没什么问题啊?难道是我都调用同一个panel.handle,没释放,第二个就调用这个了?还是我需要panel.repaint?panel.refresh?,form.repaint,form.refresh?我都写了啊,不管用啊
      

  5.   

    有例子,人家的例子没问题,我在前面加了一句showmessage就可以显示了,可是真正运行的时候不能有这句啊,还有两段视频,只不过服务器不一样,为什么一个怎么都能播放的了,一个在别的播放完它就不能播放了啊,要是不加showmessage,它会在最后一秒的时候闪出来显示一下
      

  6.   

    我把代码贴一下,哪位帮我看看吧?
    这个F_Play是开始按钮
    procedure TFrmplayback.F_Play;
    var
     fileselpos             :integer;    
     csFileName             :pchar;
     csIP,csTemp, sTemp1    :String;
     nPos                   :integer;
     boolreturn:boolean;
    begin if(m_locFileList.Selected = nil) then
    begin
    showMessage('请选择要播放的文件!');
    exit;
    end;
    //PlayM4_SetFileRefCallBack(USED_PORT,FileRefDone,(DWORD)this);
    csFileName := pchar(m_locFileList.Selected.caption);
    if(Length(csFileName)=0) then
    exit;
    csTemp:=csFileName; while(Pos('\',csTemp)>0) do
    begin
    csIP:=Rightstr(csTemp,Length(csTemp)-nPos);
        //showmessage(csIP);
    csTemp:=csIP;
    nPos:=pos('\',csTemp);
    end;
    nPos:=pos('_',csTemp);
    csIP:=Leftstr(csTemp,nPos-1);
    m_csIP:=csIP;
    if(PlayM4_OpenFile(USED_PORT,csFileName)=false) then  //调用PlayM4_OpenFile
    begin
    showmessage('open file failed!');
    exit;
    end;
    sTemp1 := m_locFileList.Selected.Caption;
    iSelChannel := midstr(sTemp1,pos('_',sTemp1)+1,2);
      m_iTotalSeconds:=0;
    m_iTotalSeconds:=PlayM4_GetFileTime(USED_PORT); //调用PlayM4_GetFileTime if(m_iTotalSeconds<=0) then
    begin
    boolreturn:=PlayM4_CloseFile(USED_PORT);
    showmessage('文件大小为0!');
    exit;
    end;
    boolreturn:=PlayM4_SetDisplayCallBack(USED_PORT,DisplayCBFun);//调用PlayM4_SetDisplayCallBack
    if((PlayM4_Play(USED_PORT,Frmplayback.Panel1.Handle))=FALSE) then  //调用PlayM4_Play
    begin
           err:=PlayM4_GetLastError(USED_PORT);
        if  err=NET_DVR_PASSWORD_ERROR then
          showmessage('用户名密码错误')
        else
          showmessage(inttostr(err));
        boolreturn:=PlayM4_CloseFile(USED_PORT);
    end;
      F_Sound(TRUE); //调用F_Sound
    end;
    procedure TFrmplayback.F_Sound(bSound: boolean);
    var boolreturn:boolean;
    begin if(bSound) then
    begin
    m_bSound:=PlayM4_PlaySound(USED_PORT);
    boolreturn:=PlayM4_SetVolume(USED_PORT,32767);
    end
    else
    begin
    boolreturn:=PlayM4_StopSound();
    m_bSound:=FALSE;
    end;
    end;
    以下为停止按钮
        f_pause;
    boolreturn:=PlayM4_Stop(USED_PORT);
    boolreturn:=PlayM4_CloseFile(USED_PORT);
        F_Sound(false);
        
    procedure TFrmplayback.F_Pause;
    begin    
      if(PlayM4_Pause(USED_PORT, not m_bPause)) then
    begin
    m_bPause:=not m_bPause;
    end
    else
    begin
    //TRACE("PAUSE ERROR!");
        showmessage('PAUSE ERROR!');
    end;
    end;
      

  7.   

    播放不同回路视频时需要不同的port