3

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?

vrutberg
  • 1,981
  • 1
  • 20
  • 28

3 Answers3

0

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.

Olofu Mark
  • 19
  • 1
0

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.

Community
  • 1
  • 1
Sorin
  • 1,965
  • 2
  • 12
  • 18
  • Okay, so I've tried this code on another computer and it works without having to switch to the basic theme. Could this have something to do with display drivers? – vrutberg Dec 13 '11 at 12:47
0

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.

vrutberg
  • 1,981
  • 1
  • 20
  • 28