最近想搞搞语音和视屏,想用第三方包JMF,但是jmf的api全是英文,真的看不懂,第一次接触jmf,对立面间的类,方法等一点不熟,如何获取本地声音(某个人说的话,描述的不准确),如何将获得的声音发送出去,如何获取视屏等,希望大家发点资料,发电jmf实例(资料最好是中文的,英文看不懂)下面链接还有个问题,一直没有解决,有会的吼一下吧jmf

解决方案 »

  1.   

    package jmf;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{   
                // 利用Medialocator 获取一个player   
                player = Manager.createRealizedPlayer(mediaLocator);   
                component = player.getVisualComponent();   
                if (component != null){   
                    vedioPanel = new JPanel();   
                    vedioPanel.add(component, BorderLayout.NORTH);   
                    mainPanel.add(vedioPanel);   
                       
                    this.pack();    // 自动分配窗体大小   
                    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();   
        }   
    }  package jmf;import java.awt.Component;
    import java.awt.Rectangle;import javax.media.CaptureDeviceInfo;
    import javax.media.CaptureDeviceManager;
    import javax.media.Manager;
    import javax.media.MediaLocator;
    import javax.media.Player;
    import javax.swing.Box;
    import javax.swing.JFrame;
    import javax.swing.UIManager;
    import javax.swing.UnsupportedLookAndFeelException;public class SampCam extends JFrame {
        /**
         * 
         */
        private static final long serialVersionUID = 1211056605389924001L;
        private static Player player = null;
        private CaptureDeviceInfo device = null;
        private MediaLocator locator = null;
        boolean proportion = true;
        String str1 = "vfw:Logitech USB Video Cam:0";
        String str2 = "vfw:Microsoft WDM Image Capture (Win32):0";
        Component component1;    public SampCam() {
            super("摄像机");
            try {
                UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());// 与操作系统风格一致
            } catch (ClassNotFoundException e1) {
                e1.printStackTrace();
            } catch (InstantiationException e1) {
                e1.printStackTrace();
            } catch (IllegalAccessException e1) {
                e1.printStackTrace();
            } catch (UnsupportedLookAndFeelException e1) {
                e1.printStackTrace();
            }
            try {
                jbInit();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }    public static void main(String[] args) {
            new SampCam();
        }    private void jbInit() throws Exception {
            component1 = Box.createGlue();
            // =====================初始化设备===================//
            component1.addNotify();
            device = CaptureDeviceManager.getDevice(str2);
            locator = device.getLocator();
            try {
                player = Manager.createRealizedPlayer(locator);
                player.start();
                if ((component1 = player.getVisualComponent()) != null) {
                    this.getContentPane().add(component1, "Center");
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
            component1.setBounds(new Rectangle(0,0, 250, 280));
            this.setSize(380, 300);
            this.setVisible(true);
        }
    }
      

  2.   

    Jmf摄像头程序。不推荐多媒体用jmf去做。不看英文文档永远提升不了自己!基本的处理 javax下有