//mpVideoPlayer->setControl( "{D1EB6D20-8923-11d0-9D97-00A0C90A43CB}" );
mpVideoPlayer
->setGeometry
( QRect( 15,
46,
551,
341 ) );
//mpVideoPlayer->queryInterface( IID_IVideoWindow, &pVW );
mpVideoPlayer = new QAxWidget( mpFrame );
//mpVideoPlayer->setControl( "{D1EB6D20-8923-11d0-9D97-00A0C90A43CB}" );
mpVideoPlayer->setGeometry( QRect( 15, 46, 551, 341 ) );
//mpVideoPlayer->queryInterface( IID_IVideoWindow, &pVW );
To copy to clipboard, switch view to plain text mode
USES_CONVERSION;
WCHAR wFile[MAX_PATH];
HRESULT hr;
if (!szFile)
return E_POINTER;
// Clear open dialog remnants before calling RenderFile()
UpdateWindow(ghApp);
// Convert filename to wide character string
wcsncpy(wFile, T2W(szFile), NUMELMS(wFile)-1);
wFile[MAX_PATH-1] = 0;
// Get the interface for DirectShow's GraphBuilder
JIF(CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER,
IID_IGraphBuilder, (void **)&pGB));
if(SUCCEEDED(hr))
{
// 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));
// Is this an audio-only file (no video component)?
CheckVisibility();
// Have the graph signal event via window callbacks for performance
JIF(pME->SetNotifyWindow((OAHWND)ghApp, WM_GRAPHNOTIFY, 0));
if (!g_bAudioOnly)
{
// Setup the video window
JIF(pVW->put_Owner((OAHWND)ghApp));
JIF(pVW->put_WindowStyle(WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN));
JIF(InitVideoWindow(1, 1));
GetFrameStepInterface();
}
else
{
// Initialize the default player size and enable playback menu items
JIF(InitPlayerWindow());
}
// Complete window initialization
ShowWindow(ghApp, SW_SHOWNORMAL);
UpdateWindow(ghApp);
SetForegroundWindow(ghApp);
g_bFullscreen = FALSE;
g_PlaybackRate = 1.0;
UpdateMainTitle();
#ifdef REGISTER_FILTERGRAPH
hr = AddGraphToRot(pGB, &g_dwGraphRegister);
if (FAILED(hr))
{
Msg(TEXT("Failed to register filter graph with ROT! hr=0x%x"), hr);
g_dwGraphRegister = 0;
}
#endif
// Run the graph to play the media file
JIF(pMC->Run());
g_psCurrent=Running;
SetFocus(ghApp);
}
return hr;
USES_CONVERSION;
WCHAR wFile[MAX_PATH];
HRESULT hr;
if (!szFile)
return E_POINTER;
// Clear open dialog remnants before calling RenderFile()
UpdateWindow(ghApp);
// Convert filename to wide character string
wcsncpy(wFile, T2W(szFile), NUMELMS(wFile)-1);
wFile[MAX_PATH-1] = 0;
// Get the interface for DirectShow's GraphBuilder
JIF(CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER,
IID_IGraphBuilder, (void **)&pGB));
if(SUCCEEDED(hr))
{
// 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));
// Is this an audio-only file (no video component)?
CheckVisibility();
// Have the graph signal event via window callbacks for performance
JIF(pME->SetNotifyWindow((OAHWND)ghApp, WM_GRAPHNOTIFY, 0));
if (!g_bAudioOnly)
{
// Setup the video window
JIF(pVW->put_Owner((OAHWND)ghApp));
JIF(pVW->put_WindowStyle(WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN));
JIF(InitVideoWindow(1, 1));
GetFrameStepInterface();
}
else
{
// Initialize the default player size and enable playback menu items
JIF(InitPlayerWindow());
}
// Complete window initialization
ShowWindow(ghApp, SW_SHOWNORMAL);
UpdateWindow(ghApp);
SetForegroundWindow(ghApp);
g_bFullscreen = FALSE;
g_PlaybackRate = 1.0;
UpdateMainTitle();
#ifdef REGISTER_FILTERGRAPH
hr = AddGraphToRot(pGB, &g_dwGraphRegister);
if (FAILED(hr))
{
Msg(TEXT("Failed to register filter graph with ROT! hr=0x%x"), hr);
g_dwGraphRegister = 0;
}
#endif
// Run the graph to play the media file
JIF(pMC->Run());
g_psCurrent=Running;
SetFocus(ghApp);
}
return hr;
To copy to clipboard, switch view to plain text mode
Bookmarks