99常识网

vs2012浣跨敤瑙嗛鏁欑▼(vs2008视频教程)

admin 355

1、这是简化代码,我这有完整的,如果要和我说下#includeclassPlayCore{public:PlayCore(void);virtual~PlayCore(void);boolSetFile(wchar_t*file_name);boolPlay();boolStop();boolPause();private:bool_IsLoadFile;IGraphBuilder*pGraph;IMediaControl*pControl;IMediaEvent*pEvent;};PlayCore::PlayCore(void){this->_IsLoadFile=false;//InitializetheCOMlibrary.HRESULThr=CoInitialize(NULL);if(FAILED(hr)){#ifdef_CONSOLEprintf("error-CouldnotinitializeCOMlibrary");#elseMessageBox(NULL,L"error-CouldnotinitializeCOMlibrary",L"Error",MB_OK);#endif}//Createthefiltergraphmanagerandqueryforinterinterfaces.hr=CoCreateInstance(CLSID_FilterGraph,NULL,CLSCTX_INPROC_SERVER,IID_IGraphBuilder,(void**)&pGraph);if(FAILED(hr)){#ifdef_CONSOLEprintf("error-CouldnotcreatetheFilterGraphManager.");#elseMessageBox(NULL,L"error-ConldnotcreatetheFilterGraphManager.",L"Error",MB_OK);#endif}hr=pGraph->QueryInterface(IID_IMediaControl,(void**)&pControl);hr=pGraph->QueryInterface(IID_IMediaEvent,(void**)&pEvent);}PlayCore::~PlayCore(void){this->pControl->Release();this->pEvent->Release();this->pGraph->Release();CoUninitialize();}boolPlayCore::SetFile(wchar_t*file_name){//Buildthegraph.HRESULThr=pGraph->RenderFile(file_name,NULL);if(SUCCEEDED(hr)){this->_IsLoadFile=true;returntrue;}returnfalse;}boolPlayCore::Play(){if(!this->_IsLoadFile)returnfalse;//Runthegraph.HRESULThr=pControl->Run();if(SUCCEEDED(hr)){//Waitforcompletion.longevCode;pEvent->WaitForCompletion(1000,&evCode);//Note:DonotuseINFINITEinarealapplication,//becauseitcanblockindefinitely.}}boolPlayCore::Pause(){pControl->Pause();returntrue;}boolPlayCore::Stop(){pControl->Stop();returntrue;}。

以上就是【vs2012浣跨敤瑙嗛鏁欑▼,vs2008视频教程】相关内容。

vs2012浣跨敤瑙嗛鏁欑▼(vs2008视频教程)