Camera can not be detected! any ideas?

i am programming a microsoft which just likes NetMeeting,and i have a problem now.this question might seem silly to you ,but i am a new jmf_er,so i need your help!
to detect camera ,i wrote the code as follows:
Vector list = CaptureDeviceManager.getDeviceList ( null );
if ( list != null )
for ( int i=0; i<list.size(); i++ )
devInfo = (CaptureDeviceInfo)list.elementAt ( i );
name = devInfo.getName();
System.out.println(name);
if ( name.startsWith ("vfw:") )
System.out.println ("DeviceManager List : " + name );
capDevices.addElement ( new MyCaptureDeviceInfo ( devInfo ) );
but i discovered that there is no name starts with ("vfw:")!and the camera can be detected when i use another microsoft !
i do not know what is wrong ,
any ideas are welcome,thank you!
Regards
Adigan

The ist thing is that ur code is incorrect
the last statment (addElement)is not meant to be here
use the following code..
CaptureDeviceInfo devInfo=null;
Vector list = CaptureDeviceManager.getDeviceList ( null );
  if ( list != null ){
        for ( int i=0; i<list.size(); i++ ){
                          devInfo = (CaptureDeviceInfo)list.elementAt ( i );
                      String name = devInfo.getName();
                      if(name.startsWith ("vfw:")){
                           dExist=true;          
                                                                         break;
     if(dExist==true){
               MediaLocator m = devInfo.getLocator();
                DataSource ds = null;
     try {
          ds=Manager.createDataSource(m);                                Player player = Manager.createRealizedPlayer (ds);
                   player.start();              
                    Component videoScreen= player.getVisualComponent();
          Frame frm=new Frame();
          frm.setBound(100,100,300,300);
          frm.add(videoScreen);
                                          frm.setVisible(true);
     } catch (Exception e) {
else{System.out.println("no device exist");}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

Similar Messages

Maybe you are looking for