Hello,
I'm trying to play a video file from a C# application (although the same
occurs with a win32 application) with the following code:
Type ComFilterGraph = Type.GetTypeFromCLSID(Clsid.FilterGraph);
Object CoClass = Activator.CreateInstance(ComFilterGraph);
if (CoClass != null)
{
int hr;
_GraphBuilder = CoClass as IGraphBuilder;
_MediaControl = CoClass as IMediaControl;
_VideoWindow = CoClass as IVideoWindow;
// build the graph
hr = _GraphBuilder.RenderFile(_ClipFile, null);
//Set the video window
hr = _VideoWindow.put_Owner(panel1.Handle);
hr = _VideoWindow.put_WindowStyle(WS_CHILD | WS_CLIPSIBLINGS);
hr = _VideoWindow.SetWindowPosition(0, 0, panel1.Width, panel1.Height);
hr = _MediaControl.Run();
}
I cannot get perfect results, most of the time the call to RenderFile
returns VFW_E_CANNOT_RENDER.
I got some AVI files where either the sound or the video is played (same
behaviour in media player).
In summary I was not able to play any *.wmv or *.mpg files. On the desktop,
the same code is able to play DIVX files !
Any information is welcome, thanks in advance.
DK