在android系统中点击开始视频捕捉 [英] Starting video capture on one click in android

查看:135
本文介绍了在android系统中点击开始视频捕捉的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要开始摄像头,并自动启动通过单击Android游戏刚刚录制。我有code键启动相机,但我不知道如何下手的视频自动捕获。请帮忙。
在code我有启动摄像机 -

I want to start camera and also to automatically start recording just by clicking an app in android. I have the code to start the camera but I do not know how to start auto capture of the video. Please help. the code I have for launching camera-

@Override 
protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState); 
   setContentView(R.layout.activity_c1_main);
   Intent intent = new Intent("android.media.action.VIDEO_CAPTURE");
   StartActivityForResult(intent,CAPTURE_VIDEO_ACTIVITY);
}

我发现了大约view.performclick但不知道如何使用相机

I found about view.performclick but do not know how to use for camera

推荐答案

使用MediaRecorder用于这一目的。尽管这将需要更多的工作,但会给你更多的控制。按照此链接 HTTP://android-er.blogspot。 TW / 2011/04 /启动录像-using.html 。既然你不reuire任何按钮点击记录,开始在镜头前保持延迟。像这样做

Use MediaRecorder for this purpose. Though it will require more work but will give you much more control. Follow this link http://android-er.blogspot.tw/2011/04/start-video-recording-using.html. Since you don't reuire any button click for recording, keep a delay before starting the camera. Do it like this

myButton.setPressed(true); //you won't click the button
myButton.invalidate();
myButton.postDelayed(new Runnable() {  
    public void run() {      
         myButton.setPressed(false); 
         myButton.invalidate();
         releaseCamera();   //release camera from preview before MediaRecorder starts
        if(!prepareMediaRecorder()){
            Toast.makeText(AndroidVideoCapture.this,"could not prepare MediaRecorder",Toast.LENGTH_LONG).show();
            finish();
        }
        mediaRecorder.start();
    }
},5000); //causes delay of 5 seconds befor recording starts

这篇关于在android系统中点击开始视频捕捉的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆