《在中Visual Studio .NET 2003利用DirectShow播放媒体文件(四).docx》由会员分享,可在线阅读,更多相关《在中Visual Studio .NET 2003利用DirectShow播放媒体文件(四).docx(7页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、在中VisualStudio.NET2003利用DirectShow播放媒体文件(四)/IDC_VW_FRAME控件PictureControl主要作用是控制VedioWindow的显示位置voidCPlayWndDlg:MoveVideoWindow(void)IVideoWindow*pVideoWinow=NULL;if(m_pGraph)m_pGraph->QueryInterface(IID_IVideoWindow,(void*)&pVideoWinow);CRectrc;GetDlgItem(IDC_VW_FRAME)->GetWindowRect(rc);S
2、creenToClient(rc);pVideoWinow->SetWindowPosition(rc.left,rc.top,rc.Width(),rc.Height();pVideoWinow->Release();pVideoWinow=NULL;voidCPlayWndDlg:CleanUp(void)longlevCode;IVideoWindow*pVidWin=NULL;if(!m_pGraph)return;m_pGraph->QueryInterface(IID_IVideoWindow,(void*)&pVidWin);m_pEvent->W
3、aitForCompletion(INFINITE,&levCode);pVidWin->put_Visible(OAFALSE);pVidWin->Release();m_pMediaSeeking->Release();m_pMediaControl->Release();m_pEvent->Release();m_pGraph->Release();m_pMediaSeeking=NULL;m_pMediaControl=NULL;m_pEvent=NULL;m_pGraph=NULL;UpdateData(FALSE);CClientDCdc
4、(GetDlgItem(IDC_VW_FRAME);dc.SetBkColor(RGB(0,0,0);CRectrc;GetDlgItem(IDC_VW_FRAME)->GetClientRect(rc);ClientToScreen(rc);dc.FillRect(rc,CBrush:FromHandle(HBRUSH)GetStockObject(BLACK_BRUSH);Invalidate();BOOLCPlayWndDlg:Stop(void)IVideoWindow*pVidWin=NULL;HRESULThr;if(m_pMediaControl)LONGLONGpos=0
5、;hr=m_pMediaControl->Stop();hr=m_pMediaSeeking->SetPositions(&pos,AM_SEEKING_AbsolutePositioning,&pos,AM_SEEKING_NoPositioning);m_pGraph->QueryInterface(IID_IVideoWindow,(void*)&pVidWin);pVidWin->put_Visible(OAFALSE);m_isPlaying=FALSE;GetDlgItem(IDC_PLAY_BUTTON)->EnableWin
6、dow(TRUE);GetDlgItem(IDC_PAUSE_BUTTON)->EnableWindow(FALSE);pVidWin->Release();longlevCode;m_pEvent->WaitForCompletion(INFINITE,&levCode);m_pMediaControl->Release();returnTRUE;returnFALSE;BOOLCPlayWndDlg:Play(void)/运行IVideoWindow*pVidWin=NULL;if(m_pGraph)m_pGraph->QueryInterface(I
7、ID_IVideoWindow,(void*)&pVidWin);pVidWin->put_Visible(OATRUE);m_pGraph->QueryInterface(IID_IMediaControl,(void*)&m_pMediaControl);m_pMediaControl->Run();m_isPlaying=TRUE;GetDlgItem(IDC_PLAY_BUTTON)->EnableWindow(FALSE);GetDlgItem(IDC_PAUSE_BUTTON)->EnableWindow(TRUE);returnTRUE;returnFALSE;