当前位置:编程学习 > C/C++ >>

第一个dshow的playerdemo

书上的源码是:
 
[cpp]  
#include <iostream>  
#include <dshow.h>  
using namespace std;  
  
int main()  
{  
    cout<<"PlayerDemo"<<endl;  
  
    IGraphBuilder * pGraph = NULL;  
    IMediaControl * pControl = NULL;  
    IMediaEvent * pEvent = NULL;  
  
    HRESULT hr = CoInitialize(NULL);  
    if (FAILED(hr))  
    {  
        printf("ERROR - Could not initialize COM library");  
        return 0;  
    }  
  
    hr = CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER,  
        IID_IGraphBuilder, (void**)&pGraph);  
  
    if (FAILED(hr))  
    {  
        printf("ERROR - Could not create the Filter Graph Manager.");  
        return 0;  
    }  
  
    hr = pGraph->QueryInte易做图ce(IID_IMediaControl, (void**)&pControl);  
    hr = pGraph->QueryInte易做图ce(IID_IMediaEvent, (void**)&pEvent);  
  
    hr = pGraph->RenderFile(L"C:\\DXSDK\\Samples\\Media\\CLOCKTXT.avi", NULL);  
  
    if (SUCCEEDED(hr))  
    {  
        hr = pControl->Run();  
        if (SUCCEEDED(hr))  
        {  
            long evCode;  
            pEvent->WaitForCompletion(INFINITE, &evCode);  
        }  
    }  
  
    pControl->Release();  
    pEvent->Release();  
    pGraph->Release();  
    CoUninitialize();  
    return 0;  
}  
 
linker->input 里面包含Strmbasd.lib库。
 
补充:软件开发 , C++ ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,