use*_*196 5 video camera android mediarecorder
Android Dev有一些简单的代码描述如何通过Intents启动摄像机.
现在这很好,如果你只是想启动相机并等待用户按下红色的"REC"按钮.
但我想通过Intent调用摄像机并告诉它以编程方式开始录制.
我该怎么办?我是否在Intent命令中传递某种start()方法?
(如果无法完成,请向我显示一个简单的代码位,可以设置为自动录制视频 - 我一直在网上搜索,但所有关于此问题的代码片段都不起作用)
private static final int CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE = 100;
private Uri fileUri;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// create Intent to take a picture and return control to the calling application
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
fileUri = getOutputMediaFileUri(MEDIA_TYPE_IMAGE); // create a file to save the image
intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); // set the image file name
// start the image capture Intent
startActivityForResult(intent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE);
}
Run Code Online (Sandbox Code Playgroud)
为此,您应该使用MediaRecorder类。
请看一下这个:
http://developer.android.com/reference/android/media/MediaRecorder.html
| 归档时间: |
|
| 查看次数: |
7983 次 |
| 最近记录: |