17

在 Android 中是否有用于视频捕获的独立示例代码?

4

4 回答 4

23

以下是我提供给我的学生的内容:Camcorder Source

于 2010-08-27T15:48:51.930 回答
3

不知道为什么我没有早点想到这个。如果您只是想捕捉视频,以便可以拍摄该视频并将其上传到服务器(或执行类似操作),您可以使用意图非常轻松地使用本机相机应用程序。

启动意图,捕获视频,然后返回到您的活动,并通过 onActivityResult 访问视频。

// Setup a result flag for your video capture
int ACTION_TAKE_VIDEO = 100;

// Launch an intent to capture video from MediaStore
Intent takeVideoIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
startActivityForResult(takeVideoIntent, ACTION_TAKE_VIDEO);

// Obtain the file path to the video in onActivityResult
public void onActivityResult(int requestCode, int resultCode, Intent data) {

if (resultCode == RESULT_OK) {

    if (requestCode == ACTION_TAKE_VIDEO) {

        Uri videoUri = data.getData();
        String filePath = getPath(videoUri);
        Log.d("LOGCAT", "Video path is: " + filePath);
    }
}

更多信息请访问http://developer.android.com/training/camera/videobasics.html

于 2013-02-04T08:24:44.220 回答
2

I found a good solution from here

于 2011-08-25T13:40:16.570 回答
0

I am not aware of a stand-alone code sample, but in the Android camera documentation, in the Class overview, there is a very nice step by step procedure that shows you how to record video.

I think is nearly as well as a sample code.

于 2010-08-26T09:23:12.803 回答