JMF Structure
DataSource (data source)
Interception equipment (Capture Device, including video and audio interception devices)
Viewer (player)
Processor (Processor)
Data formats (format)
Manager (manager)
Directly paste code:
Package B110; Import Java.awt.BorderLayout; Import java.awt.Component; Import java.awt.Dimension; Import Java.awt.Toolkit; Import javax.swing.*; Import javax.media.*; Import Sun.org.mozilla.javascript.internal.Kit; public class Test extends jframe{public static player player = null; private Capturedeviceinfo deviceinfo = null; private Medialocator medialocator = null; Private Component Component = null; Private JPanel mainpanel = null; Private JPanel vediopanel = null; String str1 = "Vfw:logitech USB video camera:0"; String str2 = "Vfw:microsoft WDM Image Capture (WIN32): 0"; Test () {super ("test for the vedio ..."); Init (); private void Init () {Mainpanel = (JPanel) this.getcontentpane (); deviceinfo = Capturedevicemanager.getdevice (STR2); Medialocator = Deviceinfo.getlocator (); try{//using Medialocator to obtain a player player = Manager.createrealizedplayer (medialocator); component = Player.getvisualcomponent (); if (component!= null) {Vediopanel = new JPanel (); Vediopanel.add (component, BorderlAyout. North); Mainpanel.add (Vediopanel); This.pack (); Automatically allocate form size this.setresizable (false); This.setdefaultcloseoperation (Exit_on_close); This.setvisible (TRUE); Player.start (); }}catch (Exception e) {//Todo:handle Exception e.printstacktrace ();}} public static void Main (string[] args) {Test atest = new Test ();}