Android 视频捕获示例应用程序
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2550743/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Android Video Capture Sample App
提问by Jason
Is there a stand-alone sample code for video capturing in Android ?
Android 中是否有用于视频捕获的独立示例代码?
回答by vanevery
Here is what I provide to my students: Camcorder Source
这是我提供给我的学生的内容:Camcorder Source
回答by Kyle Clegg
Not sure why I didn't think of this sooner. If you're just looking to capture a video so you can take that video and upload it to a server (or do something similar) you can use the native camera app extremely easily using intents.
不知道为什么我没有早点想到这个。如果您只是想捕捉视频以便您可以拍摄该视频并将其上传到服务器(或执行类似操作),您可以使用意图非常轻松地使用本机相机应用程序。
Launch the intent, capture the video, then return to your activity, and access the video via onActivityResult.
启动意图,捕获视频,然后返回到您的活动,并通过 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);
}
}
More at http://developer.android.com/training/camera/videobasics.html
更多信息请访问http://developer.android.com/training/camera/videobasics.html
回答by Longfield
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.
我不知道有一个独立的代码示例,但在Android 相机文档中,在类概述中,有一个非常好的分步过程,向您展示如何录制视频。
I think is nearly as well as a sample code.
我认为几乎和示例代码一样好。