[J2ME]手机拍摄视频

[J2ME]手机拍摄视频

1、手机拍摄视频
 1
 2        this.setFullScreenMode(true );
 3        try 
{
 4            p = Manager.createPlayer("capture://video"
);
 5
            p.realize();
 6            vc = (VideoControl) p.getControl("VideoControl"
);
 7            if (vc != null
{
 8                vc.initDisplayMode(VideoControl.USE_DIRECT_VIDEO, this
); 
 9//                vc.setDisplaySize(128,160);

10            }

11            vc.setVisible(true); //设置可见
12            p.start();//开始拍摄
13        }
 catch (Exception e) {}
14    

没有办法修改保存目录,只能在默认的保存路径里读取。

2.手机实现录音功能:
 1public void run() {
 2  Player player = Manager.createPlayer("capture://audio"
);
 3  player.realize();//播放器出始化

 4 
 5  RecordControl rc = (RecordControl)player.getControl("RecordControl"
);
 6  rc.setRecordLocation("file://test.wav"
);
 7
    
 8  rc.startRecord();//開始錄音

 9  player.start();//播放器開始運作
10                
11  Thread.sleep(3000);//錄製3秒

12  rc.stopRecord();
13  rc.commit();//結束錄音

14                
15  player.close();//關閉播放器

16}

17
18

3.如果想实现拍照功能,只需调用一个方法即可。
byte[] pngImage = vc.getSnapshot(null);

你可能感兴趣的:([J2ME]手机拍摄视频)