播放视频文件时弹出 DirectShow 视频窗口

发布于 2024-09-30 04:57:45 字数 1411 浏览 1 评论 0原文

我构建了一个在本机 Windows 应用程序 (MFC C++) 中运行的 C# COM 类。 COM 类用于在主应用程序的窗口句柄上显示视频。我正在使用 .NET 互操作来访问我的 C# 应用程序中的 DirectShow。渲染图形后,我看到 ActiveMovie 窗口在它正确定位在窗口中之前弹出。

这是我如何设置图表的示例。我没有包含所有代码,但我认为包含了重要的部分 - 渲染图形并设置窗口所有者和位置。

        _graphBuilder = (IGraphBuilder)new FilgraphManager();

        _sourceFilter = (IBaseFilter)Activator.CreateInstance(Type.GetTypeFromCLSID(CLSID.AsyncReader));
        hr = ((IFileSourceFilter)_sourceFilter).Load(fileName, null);
        DSUtilities.ThrowExceptionForHR(hr);
        hr = _graphBuilder.AddFilter(_sourceFilter, "AsyncReader");
        DSUtilities.ThrowExceptionForHR(hr);

        IPin output = DSUtilities.FindPinByDirection(_sourceFilter, _PinDirection.PINDIR_OUTPUT, 0);

        // add some other filters
        // ...

        _graphBuilder.Render(output);
        _videoWindow = (IVideoWindow)_graphBuilder;

        _videoWindow.WindowStyle = (int)(WindowStyle.Child | WindowStyle.ClipChildren);
        _videoWindow.SetWindowPosition(_viewer.VideoRectangle.Left, _viewer.VideoRectangle.Top, _viewer.VideoRectangle.Width, _viewer.VideoRectangle.Height);
        _videoWindow.Owner = viewer.CanvasHandle.ToInt32();

我相信这个问题与 _graphBuilder.Render() 调用或设置窗口所有者和窗口位置有关。我搞乱了函数调用的顺序,但似乎没有任何帮助。需要注意的一件重要事情是,在调用 IGraphBuilder 上的 Render() 之前,您无法获取 IVideoWindow 接口。我需要摆脱弹出窗口!还有其他人看到这个问题吗?或者有人对造成这种情况的原因有任何想法吗?任何帮助将不胜感激。

谢谢, 担

I've built a C# COM class that is running in a native windows app (MFC C++). The COM class is used to display video on a window handle from the main application. I'm using the .NET interop to access DirectShow in my C# app. After I render the graph I'm seeing the ActiveMovie window pop up before it is correctly positioned in the window.

Here's an example of how I'm setting up my graph. I haven't included all of the code, but I think the important part is included- rendering the graph and setting the window owner and position.

        _graphBuilder = (IGraphBuilder)new FilgraphManager();

        _sourceFilter = (IBaseFilter)Activator.CreateInstance(Type.GetTypeFromCLSID(CLSID.AsyncReader));
        hr = ((IFileSourceFilter)_sourceFilter).Load(fileName, null);
        DSUtilities.ThrowExceptionForHR(hr);
        hr = _graphBuilder.AddFilter(_sourceFilter, "AsyncReader");
        DSUtilities.ThrowExceptionForHR(hr);

        IPin output = DSUtilities.FindPinByDirection(_sourceFilter, _PinDirection.PINDIR_OUTPUT, 0);

        // add some other filters
        // ...

        _graphBuilder.Render(output);
        _videoWindow = (IVideoWindow)_graphBuilder;

        _videoWindow.WindowStyle = (int)(WindowStyle.Child | WindowStyle.ClipChildren);
        _videoWindow.SetWindowPosition(_viewer.VideoRectangle.Left, _viewer.VideoRectangle.Top, _viewer.VideoRectangle.Width, _viewer.VideoRectangle.Height);
        _videoWindow.Owner = viewer.CanvasHandle.ToInt32();

I believe this problem has to do with either the _graphBuilder.Render() call or setting up the window owner and window position. I've messed around with the order of the function calls and nothing seems to help. One important thing to note is that you can't grab the IVideoWindow interface until after you call Render() on the IGraphBuilder. I need to get rid of the pop-up! Has anyone else seen this issue? Or does anyone have any ideas about what's causing it? Any help will be greatly appreciated.

Thanks,
Dan

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

喜你已久 2024-10-07 04:57:45

这一系列的调用对我来说很有效,不会弹出一个窗口:

pGraph->RenderFile(fname, NULL);
pGraph->QueryInterface( IID_IVideoWindow, (void**) &pVidWindow);

pVidWindow->put_Owner((OAHWND)hwnd);
pVidWindow->put_WindowStyle(WS_CHILD | WS_CLIPSIBLINGS);
pVidWindow->SetWindowPosition(0, 0, grc.right, grc.bottom);
pVidWindow->put_MessageDrain( (OAHWND)hwnd );
pVidWindow->put_Visible(OATRUE);

This sequence of calls works for me without popping up a window:

pGraph->RenderFile(fname, NULL);
pGraph->QueryInterface( IID_IVideoWindow, (void**) &pVidWindow);

pVidWindow->put_Owner((OAHWND)hwnd);
pVidWindow->put_WindowStyle(WS_CHILD | WS_CLIPSIBLINGS);
pVidWindow->SetWindowPosition(0, 0, grc.right, grc.bottom);
pVidWindow->put_MessageDrain( (OAHWND)hwnd );
pVidWindow->put_Visible(OATRUE);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文