1
我從網絡攝像頭捕獲流,並想在視頻圖像上繪製一些東西。我試着在下面的例子中,問題是無論我如何安排組件,其他組件都始終在後臺。 有沒有辦法解決這個問題?通過JMF組件繪畫
public class SwingCapture extends JPanel {
private static final long serialVersionUID = -1284686239737730338L;
private static Player player = null;
public static final int WIDTH = 640;
public static final int HEIGHT = 480;
private MediaLocator ml = null;
public SwingCapture()
{
setLayout(null);
setSize(WIDTH, HEIGHT);
ml = new MediaLocator("vfw:Microsoft WDM Image Capture (Win32):0");
try {
player = Manager.createRealizedPlayer(ml);
player.start();
Component comp = null;
if ((comp = player.getVisualComponent()) != null) {
add(comp);
comp.setBounds(0, 0, 640, 480);
}
add(Canvas.getInstance());
Canvas.getInstance().setBounds(0, 0, 640, 480);
}
catch (Exception e)
{
e.printStackTrace();
}
}
public static void playerclose() {
player.close();
player.deallocate();
}
}