I am using netbeans IDE 7.1.1 I'm making the application capture an image from a webcam, but my problem is that when I run that application first time it gives me proper output but when I run the same application again, it gives me this error:
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)
can anyone tell me why this is happening?
my code is:
/* Grab the default web cam*/
MediaLocator ml = new MediaLocator("vfw://0");
/* Create my data source */
DataSource ds = Manager.createDataSource(ml);
requestFormatResolution(ds);
/* Create & start my player */
Player p = Manager.createRealizedPlayer(ds);
p.start();
Component videoScreen = p.getVisualComponent();