全屏视频捕获 android
full screen on video capture android
我需要全屏视频捕获,但我无法do.I正在发布我的code.please帮助我
public void startRecordingVideo() {
if (getActivity().getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_FRONT)) {
Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
File mediaFile = new File(
Environment.getExternalStorageDirectory().getAbsolutePath() + "/myvideo.mp4");
videoUri = Uri.fromFile(mediaFile);
intent.putExtra(MediaStore.EXTRA_OUTPUT, videoUri);
startActivityForResult(intent, VIDEO_CAPTURE);
} else {
Toast.makeText(this.getActivity(), "No camera on device", Toast.LENGTH_LONG).show();
}
}
来自 Android MediaStore 文档,
EXTRA_FULL_SCREEN
The name of an Intent-extra used to control the UI of a ViewImage.
This is a boolean property that overrides the activity's default
fullscreen state.
还有一种情况是由于相机分辨率而导致填充,在我的情况下,如果我使用 320*240,它会提供相同的填充,但如果我使用 1280*720 或更高它没有显示任何填充和适合全屏。
为此,您还可以使用 MediaStore.EXTRA_VIDEO_QUALITY
参数来设置视频质量。
所以在你的情况下尝试这样使用,
public void startRecordingVideo() {
if (getActivity().getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_FRONT)) {
Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
File mediaFile = new File(
Environment.getExternalStorageDirectory().getAbsolutePath() + "/myvideo.mp4");
videoUri = Uri.fromFile(mediaFile);
intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1);
intent.putExtra(MediaStore.EXTRA_FULL_SCREEN , true);
intent.putExtra(MediaStore.EXTRA_OUTPUT, videoUri);
startActivityForResult(intent, VIDEO_CAPTURE);
} else {
Toast.makeText(this.getActivity(), "No camera on device", Toast.LENGTH_LONG).show();
}
}
public void startRecordingVideo() {
if (getActivity().getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_FRONT)) {
Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
File mediaFile = new File(
Environment.getExternalStorageDirectory().getAbsolutePath() + "/myvideo.mp4");
videoUri = Uri.fromFile(mediaFile);
intent.putExtra(MediaStore.EXTRA_OUTPUT, videoUri);
startActivityForResult(intent, VIDEO_CAPTURE);
} else {
Toast.makeText(this.getActivity(), "No camera on device", Toast.LENGTH_LONG).show();
}
}
来自 Android MediaStore 文档,
EXTRA_FULL_SCREEN
The name of an Intent-extra used to control the UI of a ViewImage. This is a boolean property that overrides the activity's default fullscreen state.
还有一种情况是由于相机分辨率而导致填充,在我的情况下,如果我使用 320*240,它会提供相同的填充,但如果我使用 1280*720 或更高它没有显示任何填充和适合全屏。
为此,您还可以使用 MediaStore.EXTRA_VIDEO_QUALITY
参数来设置视频质量。
所以在你的情况下尝试这样使用,
public void startRecordingVideo() {
if (getActivity().getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_FRONT)) {
Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
File mediaFile = new File(
Environment.getExternalStorageDirectory().getAbsolutePath() + "/myvideo.mp4");
videoUri = Uri.fromFile(mediaFile);
intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1);
intent.putExtra(MediaStore.EXTRA_FULL_SCREEN , true);
intent.putExtra(MediaStore.EXTRA_OUTPUT, videoUri);
startActivityForResult(intent, VIDEO_CAPTURE);
} else {
Toast.makeText(this.getActivity(), "No camera on device", Toast.LENGTH_LONG).show();
}
}