我正在尝试在 java 应用程序中使用我的 cam,但我得到了一些错误,这是我的代码。很简单有人告诉我我的代码有什么问题:
import java.util.Vector;
import javax.media.CaptureDeviceInfo;
import javax.media.CaptureDeviceManager;
import javax.media.Manager;
import javax.media.MediaLocator;
import javax.media.Player;
import javax.swing.JFrame;
public class Main extends JFrame {
public Main(){
super("Jcam");
try {
Vector v = CaptureDeviceManager.getDeviceList(null);
CaptureDeviceInfo cam = null;
for(int i=0;i<v.size();i++)
{
CaptureDeviceInfo dev = (CaptureDeviceInfo) v.elementAt(i);
if(dev.getName().startsWith("vfw"))
{
cam = dev;
break;
}
System.out.println(dev.getName());
}
if (cam == null){ System.exit(0); }
MediaLocator ml = cam.getLocator();
Player p = Manager.createRealizedPlayer(ml);
add(p.getVisualComponent());
p.start();
} catch (Exception e) {
}
setSize(700, 700);
setVisible(true);
}
/**
* @param args
*/
public static void main(String[] args) {
new Main();
}
这是日志
Exception in thread "VFW Request Thread" java.lang.UnsatisfiedLinkError: JMFSecurityManager: java.lang.UnsatisfiedLinkError: no jmvfw in java.library.path
at com.sun.media.JMFSecurityManager.loadLibrary(JMFSecurityManager.java:206)
at com.sun.media.protocol.vfw.VFWCapture.<clinit>(VFWCapture.java:19)
at com.sun.media.protocol.vfw.VFWSourceStream.doConnect(VFWSourceStream.java:241)
at com.sun.media.protocol.vfw.VFWSourceStream.run(VFWSourceStream.java:763)
at java.lang.Thread.run(Unknown Source)