哪里有vc编写视频播放器实例教程或者源码,我用vs2008

比较紧急,能播放一般格式的视频,可以实现播放器的基本功能,最好是directshow编程... 比较紧急,能播放一般格式的视频,可以实现播放器的基本功能,最好是directshow编程 展开
 我来答
手机用户38041
2014-07-02 · TA获得超过743个赞
知道答主
回答量:121
采纳率:0%
帮助的人:121万
展开全部
这是简化代码,我这有完整的,如果要和我说下 #include <Dshow.h> class PlayCore { public: PlayCore(void); virtual ~PlayCore(void); bool SetFile(wchar_t * file_name); bool Play(); bool Stop(); bool Pause(); private: bool _IsLoadFile; IGraphBuilder *pGraph; IMediaControl *pControl; IMediaEvent *pEvent; }; PlayCore::PlayCore(void) { this->_IsLoadFile = false; // Initialize the COM library. HRESULT hr = CoInitialize(NULL); if(FAILED(hr)) { #ifdef _CONSOLE printf("error - Could not initialize COM library"); #else MessageBox(NULL,L"error - Could not initialize COM library",L"Error",MB_OK); #endif } //Create the filter graph manager and query for inter interfaces. hr = CoCreateInstance(CLSID_FilterGraph,NULL,CLSCTX_INPROC_SERVER, IID_IGraphBuilder,(void **)&pGraph); if(FAILED(hr)) { #ifdef _CONSOLE printf("error - Could not create the Filter Graph Manager."); #else MessageBox(NULL,L"error - Conld not create the Filter Graph Manager.",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(); } bool PlayCore::SetFile(wchar_t *file_name) { //Build the graph. HRESULT hr = pGraph->RenderFile(file_name,NULL); if(SUCCEEDED(hr)) { this->_IsLoadFile = true; return true; } return false; } bool PlayCore::Play() { if(! this->_IsLoadFile) return false; //Run the graph. HRESULT hr = pControl->Run(); if(SUCCEEDED(hr)) { //Wait for completion. long evCode; pEvent->WaitForCompletion(1000,&evCode); //Note: Do not use INFINITE in a real application, //because it can block indefinitely. } } bool PlayCore::Pause() { pControl->Pause(); return true; } bool PlayCore::Stop() { pControl->Stop(); return true; }
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式