int hr;
long[] p = new long[1];
hr = Com.CoCreateInstance(Com.CLSID_FilterGraph, 0L, Com.CLSCTX_ALL, Com.IID_IGraphBuilder, p);
if (Com.FAILED(hr))
throw new ComException(hr);
graphBuilder = new IGraphBuilder(p[0]);
hr = graphBuilder.RenderFile(path, "");
if (Com.FAILED(hr))
throw new ComException(hr);
hr = graphBuilder.QueryInterface(Com.IID_IMediaControl, p);
if (Com.FAILED(hr))
throw new ComException(hr);
mediaControl = new IMediaControl(p[0]);
hr = graphBuilder.QueryInterface(Com.IID_IMediaSeeking, p);
if (Com.FAILED(hr))
throw new ComException(hr);
mediaSeeking = new IMediaSeeking(p[0]);
hr = graphBuilder.QueryInterface(Com.IID_IVideoWindow, p);
if (Com.FAILED(hr))
throw new ComException(hr);
// determine video size:
final IVideoWindow videoWindow = new IVideoWindow(p[0]);
{
long[] width = new long[1];
hr = videoWindow.get_Width(width);
if (Com.FAILED(hr))
throw new ComException(hr);
//logger.fine("width: " + width[0]);
long[] height = new long[1];
hr = videoWindow.get_Height(height);
if (Com.FAILED(hr))
throw new ComException(hr);
//logger.fine("height: " + height[0]);
videoSize = new Dimension((int) width[0], (int) height[0]);
}