人气:16
大家好,小帝来为大家解答以上问题。vs2012浣跨敤瑙嗛鏁欑▼,vs2008视频教程这个很多人还不知道,现在让我们一起来看看吧!
1、这是简化代码,我这有完整的,如果要和我说下#include 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; }。
以上就是【vs2012浣跨敤瑙嗛鏁欑▼,vs2008视频教程】相关内容。
声明: 本站所有文章来自互联网搜索结果, 如果侵犯到你的权益 请提供版权证明来信告知,我们会在3个工作日之内删除 本站为非赢利性网站 不接受任何赞助和广告
Copyright 2005-2021 http://kt.pingguodj.com 酷头网 客服邮箱:s2s2s2-s@outlook.com