-
problem with camera code
java.util.NoSuchElementException is coming in my code
package ankur;
import java.awt.Component;
import java.awt.Frame;
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.media.format.YUVFormat;
/**
*
* @author Ankur
*/
public class Main {
/**
* @param args the command line arguments
*/
CaptureDeviceInfo device;
MediaLocator ml=null;
Player player=null;
Component videoScreen=null;
public static void main(String[] args) {
// TODO code application logic here
new Main();
}
Main() {
try
{
//gets a list of devices which support the given videoformat
Vector deviceList = CaptureDeviceManager.getDeviceList(new YUVFormat());
device = (CaptureDeviceInfo) deviceList.firstElement();
ml = device.getLocator();
player = Manager.createRealizedPlayer(ml);
player.start();
videoScreen = player.getVisualComponent();
Frame frm=new Frame();
frm.setBounds(10,10,300,300);
frm.add(videoScreen);
frm.setVisible(true);
}
catch(Exception e)
{
System.out.println(e);
}
}
}
-
You'll want to do printStackTrace(), and then tell us where it's being thrown from...