4 Replies Latest reply: Feb 10, 2012 10:35 AM by 916640 RSS

    Player Exception quick Help

    916640
      Hi
      i have a code to see through the webcam
      import javax.media.Manager;
      import javax.media.MediaLocator;
      import javax.media.Player;
      import javax.swing.*;
      import java.awt.Component;
       
      public class SwingCapture {
           public static void main(String[] args) {
           
                otro perro=new otro();
                perro.show();
                perro.proceso();
           }
      }
      class otro extends JFrame{
           JLabel Imagen;
           otro(){
                Imagen=new JLabel();
                Imagen.setBounds(30,40,20,20);
                add(Imagen);
                setBounds(400,400,400,400);
                setLayout( null ); // use a BorderLayou      
                setTitle("Prueba de Camara Web");
           }
           public void proceso(){
                     Manager.setHint( Manager.LIGHTWEIGHT_RENDERER, true );
                try{
                     MediaLocator ml = new MediaLocator("vfw://0");
                     Player p = Manager.createRealizedPlayer(ml);
       
                     Component video = p.getVisualComponent();
       
                     video.setBounds(20,30,600,600);
                     if ( video != null ){
                          // add video to the component
                      add( video);
                     }
       
       
                     p.start();
                }catch(Exception e){
                     e.printStackTrace();
                }
           }
      }
      but it throw the next exception
      javax.media.NoPlayerException: Cannot find a Player for :vfw://0
           at javax.media.Manager.createPlayerForContent(Manager.java:1412)
           at javax.media.Manager.createPlayer(Manager.java:417)
           at javax.media.Manager.createRealizedPlayer(Manager.java:553)
           at ratatouille.otro.proceso(SwingCapture.java:31)
           at ratatouille.SwingCapture.main(SwingCapture.java:14)
      where is the error?
      Thanks...


      PD:sorry for my bad english

      Edited by: 913637 on 09-feb-2012 20:39

      Edited by: RockBytes on 10-feb-2012 7:47