有没有一个适用于安卓的视频捕获独立示例代码?
启动意图,捕获视频,然后返回到您的活动,并通过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);
}
}
Camcorder -> onKeyDown :: KeyEvent.KEYCODE_DPAD_CENTER
更改为KEYCODE_SEARCH
。这样,按下搜索键就可以开启和关闭录制。另请注意,当您停止录制时,Camcorder Activity会调用finish()
来关闭应用程序。 - JoJo