求教一个关于jmf的DataSource类问题
public class TestCapture {
public void capture() {
Vector v = CaptureDeviceManager.getDeviceList();
Iterator it = v.listIterator();
CaptureDeviceInfo cdi = null;
MediaLocator ml = null;
Player p = null;
while(it.hasNext()) {
cdi = (CaptureDeviceInfo)it.next();
if(cdi.getName().startsWith("vfw:")) {
ml = cdi.getLocator();
try {
DataSource ds = Manager.createDataSource(ml);//这里出错
try {
p = Manager.createPlayer(ds);
JFrame jf = new JFrame();
jf.add(p.getVisualComponent());
jf.setVisible(true);
} catch (NoPlayerException e) {
e.printStackTrace();
}
p.start();
} catch (NoDataSourceException e) {
e.printStackTrace();
} catch (
IOException e) {
e.printStackTrace();
}
}
}
}
public static void main(String args[]) {
new TestCapture().capture();
}
}
代码如上,报了下面的错:
java.io.IOException: Could not connect to capture device
javax.media.NoDataSourceException: Error instantiating class: com.sun.media.protocol.vfw.DataSource : java.io.IOException: Could not connect to capture device
at javax.media.Manager.createDataSource(Manager.java:1012)
at TestCapture.capture(TestCapture.java:29)
at TestCapture.main(TestCapture.java:63)
相关的包都已经引进,局部变量Player p 用Manager.createPalyer(ml);创建就完全没问题,能看到图像,但为什么就是创建不了DataSource呢?网上关于jmf的资料少,找了半天都没找到原因,求教高手!!!
------解决方案--------------------
我也有同样的错误