使用 JMF 从网络摄像头流式传输视频会导致 Windows 7 切换到基本主题

发布于 2024-12-20 17:57:10 字数 816 浏览 1 评论 0原文

我的 Java 程序打开网络摄像头流并将捕获的视频流式传输到 Swing 组件,但当我启动它时,它会导致 Windows 切换到基本主题。这是我的代码的摘录:

String str1 = "vfw:Logitech USB Video Camera:0";
String str2 = "vfw:Microsoft WDM Image Capture (Win32):0";

captureDeviceInfo = CaptureDeviceManager.getDevice(str2);
Format[] formats = captureDeviceInfo.getFormats();
for (Format format : formats) {
    System.out.println(format);
}
mediaLocator = captureDeviceInfo.getLocator();
try {
    player = Manager.createRealizedPlayer(mediaLocator);
    player.start();
    Component comp;

    if ((comp = player.getVisualComponent()) != null) {
        playerPanel.add(comp);
        add(playerPanel, BorderLayout.NORTH);

    }

如果我注释掉将 comp 添加到playerPanel 的行,它不会切换到基本主题,所以我认为这就是出错的地方。据我了解,JMF 不再维护,并且可能与 Windows 7 Aero 主题不完全兼容。但仍然有办法解决这个问题吗?为什么会切换?

My Java program that opens up a webcam stream and streams the captured video to a Swing component works, but when I launch it, it causes Windows to switch to the Basic theme. This is an excerpt from my code:

String str1 = "vfw:Logitech USB Video Camera:0";
String str2 = "vfw:Microsoft WDM Image Capture (Win32):0";

captureDeviceInfo = CaptureDeviceManager.getDevice(str2);
Format[] formats = captureDeviceInfo.getFormats();
for (Format format : formats) {
    System.out.println(format);
}
mediaLocator = captureDeviceInfo.getLocator();
try {
    player = Manager.createRealizedPlayer(mediaLocator);
    player.start();
    Component comp;

    if ((comp = player.getVisualComponent()) != null) {
        playerPanel.add(comp);
        add(playerPanel, BorderLayout.NORTH);

    }

If I comment out the line where the I add comp to playerPanel, it doesn't switch to the basic theme, so I assume that's where it goes wrong. From what I understand JMF is not maintained anymore and probably isn't fully compatible with Windows 7 Aero Theme. But still, is there a way to fix this? Why does it switch?

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

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

发布评论

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

评论(3

爱情眠于流年 2024-12-27 17:57:10

既然您说只有当您将组件添加到播放器面板时(因此当视频可见时)才会发生这种情况,我认为这可能与我曾经遇到的 Media Player Classic 问题有关。

来自 http://www.codecguide.com/faq_mpc.htm

问:玩游戏时 Aero 被禁用,桌面变成基本模式
MPC 中的文件

答:如果您选择了错误的视频,则可能会发生这种情况
MPC 选项中的渲染器。 Aero 与 Overlay 不兼容
混合器。 [...]

播放器组件可能使用此 Overlay Mixer 来显示视频。尝试看看是否可以改变它。

Since you said that it only happens when you add the component to the player panel (so when the video is visible), I think it might be related to an issue I once had with Media Player Classic.

From http://www.codecguide.com/faq_mpc.htm:

Q: Aero gets disabled and my desktop turns to basic mode when playing
a file in MPC

A: This can happen if you selected the wrong video
renderer in MPC options. Aero is not compatible with the Overlay
Mixer. [...]

Probably the player component uses this Overlay Mixer to display the video. Try to find out if you can change it.

笑看君怀她人 2024-12-27 17:57:10

好的,这个问题的答案是安装网络摄像头驱动程序。我使用的是 Logitech QuickCam Pro 9000,因此我刚刚从 Logitech 网站下载了驱动程序。显然,如果您使用 Windows 提供的通用网络摄像头驱动程序,您可以获得我之前描述的行为。

Okay so, the answer to this one was to install the webcam drivers. I'm using a Logitech QuickCam Pro 9000, so I just downloaded the driver from Logitech's website. Apparently if you use the generic webcam driver that Windows provides you can get the behavior I described earlier.

护你周全 2024-12-27 17:57:10

要解决该问题,请在构造函数中添加以下内容:

Manager.setHint(Manager.LIGHTWEIGHT_RENDERER, Boolean.TRUE);

您的问题仅仅是由于 Swing 是轻量级的并且默认渲染目标是重量级组件。

To solve the problem, add the following in your constructor:

Manager.setHint(Manager.LIGHTWEIGHT_RENDERER, Boolean.TRUE);

Your problem is simply due to the fact that Swing is lightweight and the default rendering targets heavyweight components.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文