Click here to Skip to main content
15,919,028 members
Please Sign up or sign in to vote.
3.00/5 (5 votes)
See more:
How can I play flv files in MFC 6.0 dialog application. Inform me if there is an activeX control for that purpose or any other way.
Posted

There is a way.
To use DirectShow filters.
DirectX SDK has one program named Graph Edit C:\DXSDK\Bin\DXUtils\graphedt.exe .
You can use it to understand, what is going on when you play movies.

Here are some classes you need and some code from existing program.

All you need is to add Flv filters, connect them and select the window.

Here is the base.

C++
// DirectShow interfaces
IGraphBuilder *pGB = NULL;
IMediaControl *pMC = NULL;
IMediaEventEx *pME = NULL;
IVideoWindow  *pVW = NULL;
IBasicAudio   *pBA = NULL;
IBasicVideo   *pBV = NULL;
IMediaSeeking *pMS = NULL;
IMediaPosition *pMP = NULL;
IVideoFrameStep *pFS = NULL;


<pre lang="xml">// add file source
        CComPtr<IBaseFilter> pSource;
        JIF(pGB->AddSourceFilter(wFile, L"Source", &pSource));
        CComPtr<IPin> pSrcPin;
        JIF(pSource->FindPin(L"Output", &pSrcPin));

        // add my video renderer
        CComPtr<IBaseFilter> pRendererFilter;
        JIF(pRendererFilter.CoCreateInstance(CLSID_StereoRendererLR, NULL, CLSCTX_INPROC_SERVER));
        JIF(pGB->AddFilter(pRendererFilter, L"Stereo Renderer LR"));
        //CComPtr<IPin> pDestPin;
        //JIF(pRendererFilter->FindPin(L"In", &pDestPin));

        // add directsound renderer
        CComPtr<IBaseFilter> pDirectSound;
        JIF(pDirectSound.CoCreateInstance(CLSID_DSoundRender, NULL, CLSCTX_INPROC_SERVER));
        JIF(pGB->AddFilter(pDirectSound, L"DirectSound"));

        // render graph without adding new renderers
        CComPtr<IFilterGraph2> pFG2;
        JIF(pGB->QueryInterface(IID_IFilterGraph2, (void **)&pFG2));
        JIF(pFG2->RenderEx(pSrcPin, AM_RENDEREX_RENDERTOEXISTINGRENDERERS, NULL));



        // ************************
        // Have the graph builder construct its the appropriate graph automatically
        //JIF(pGB->RenderFile(wFile, NULL));



        // QueryInterface for DirectShow interfaces
        JIF(pGB->QueryInterface(IID_IMediaControl, (void **)&pMC));
        JIF(pGB->QueryInterface(IID_IMediaEventEx, (void **)&pME));
        JIF(pGB->QueryInterface(IID_IMediaSeeking, (void **)&pMS));
        JIF(pGB->QueryInterface(IID_IMediaPosition, (void **)&pMP));

        // Query for video interfaces, which may not be relevant for audio files
        JIF(pGB->QueryInterface(IID_IVideoWindow, (void **)&pVW));
        JIF(pGB->QueryInterface(IID_IBasicVideo, (void **)&pBV));

        // Query for audio interfaces, which may not be relevant for video-only files
        JIF(pGB->QueryInterface(IID_IBasicAudio, (void **)&pBA));


 
Share this answer
 
A simple Google search for "flv files" will yield lots of useful information.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900