JMF capture technology (video)

  JMF capture technology (video) 

  Capture video code 

  Class CaptureVideo extends Frame implements ControllerListener ( 

  Private CaptureDeviceInfo infor; 

  Private MediaLocator mediaLocator; 

  Private String url = "vfw: Microsoft WDM Image Capture (Win32):    0 "  ;

  Private Component com; 

  Private Panel panel; 

  MediaPlayer player; 

  Public CaptureVideo () ( 

  Infor = CaptureDeviceManager.getDevice (url); 

  MediaLocator = infor.getLocator (); 

  ) 

  Public void paly () ( 

  Try ( 

  Player = Manager.createPlayer (mediaLocator) / / use mediaLocator create Player 

  Player.addControllerListener (this); 

  Player.realize (); 

  ) Catch (NoPlayerException e) ( 

  / / TODO automatically generated catch block 

  E.printStackTrace (); 

  ) Catch (IOException e) ( 

  / / TODO automatically generated catch block 

  E.printStackTrace (); 

  ) 

  Public void createComponent () ( 

  SetTitle (the "video signal"); 

  AddWindowListener (new WinClose ()); 

  SetBounds (100,100,200,200); 

  Panel = new Panel (); 

  If ((= com player.getVisualComponent ())! = Null) ( 

  Panel.add (com); 

  ) 

  Add (panel); 

  SetVisible (true); 

  ) 

  Public synchronized void controllerUpdate (ControllerEvent arg0) ( 

  / / TODO Automatic Generation stubs 

  If (arg0 instanceof RealizeCompleteEvent) ( 

  System.out.println ( "realized"); 

  CreateComponent (); / / players will be added to the Panel on 

  Player.prefetch (); 

  ) 

  If (arg0 instanceof PrefetchCompleteEvent) ( 

  Player.start (); 

  System.out.println ( "prefetched"); 

  ) 

  ) 

  ) 

  (Public class test 
  Public static void main () ( 

  CaptureVideo video = new CaptureVideo (); 

  Video.player (); 

  ) 

  ) 

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • Facebook
  • DotNetKicks
  • DZone
  • Netvouz
  • Propeller

Tags: ,

Releated Java Articles

Comments

Leave a Reply