Disable video capture for legacy camera devices.
This commit is contained in:
parent
1ccce24cf8
commit
5e96832666
1 changed files with 7 additions and 18 deletions
|
@ -227,7 +227,7 @@ public class CameraXFragment extends Fragment implements CameraFragment {
|
||||||
galleryButton.setOnClickListener(v -> controller.onGalleryClicked());
|
galleryButton.setOnClickListener(v -> controller.onGalleryClicked());
|
||||||
countButton.setOnClickListener(v -> controller.onCameraCountButtonClicked());
|
countButton.setOnClickListener(v -> controller.onCameraCountButtonClicked());
|
||||||
|
|
||||||
if (MediaConstraints.isVideoTranscodeAvailable()) {
|
if (isVideoRecordingSupported(requireContext())) {
|
||||||
try {
|
try {
|
||||||
closeVideoFileDescriptor();
|
closeVideoFileDescriptor();
|
||||||
videoFileDescriptor = CameraXVideoCaptureHelper.createFileDescriptor(requireContext());
|
videoFileDescriptor = CameraXVideoCaptureHelper.createFileDescriptor(requireContext());
|
||||||
|
@ -235,13 +235,7 @@ public class CameraXFragment extends Fragment implements CameraFragment {
|
||||||
Animation inAnimation = AnimationUtils.loadAnimation(requireContext(), R.anim.fade_in);
|
Animation inAnimation = AnimationUtils.loadAnimation(requireContext(), R.anim.fade_in);
|
||||||
Animation outAnimation = AnimationUtils.loadAnimation(requireContext(), R.anim.fade_out);
|
Animation outAnimation = AnimationUtils.loadAnimation(requireContext(), R.anim.fade_out);
|
||||||
|
|
||||||
if (CameraXUtil.isMixedModeSupported(requireContext())) {
|
camera.setCaptureMode(CameraXView.CaptureMode.MIXED);
|
||||||
Log.i(TAG, "Device supports mixed mode recording. [" + CameraXUtil.getLowestSupportedHardwareLevel(requireContext()) + "]");
|
|
||||||
camera.setCaptureMode(CameraXView.CaptureMode.MIXED);
|
|
||||||
} else {
|
|
||||||
Log.i(TAG, "Device does not support mixed mode recording, falling back to IMAGE [" + CameraXUtil.getLowestSupportedHardwareLevel(requireContext()) + "]");
|
|
||||||
camera.setCaptureMode(CameraXView.CaptureMode.IMAGE);
|
|
||||||
}
|
|
||||||
|
|
||||||
captureButton.setVideoCaptureListener(new CameraXVideoCaptureHelper(
|
captureButton.setVideoCaptureListener(new CameraXVideoCaptureHelper(
|
||||||
this,
|
this,
|
||||||
|
@ -251,9 +245,6 @@ public class CameraXFragment extends Fragment implements CameraFragment {
|
||||||
new CameraXVideoCaptureHelper.Callback() {
|
new CameraXVideoCaptureHelper.Callback() {
|
||||||
@Override
|
@Override
|
||||||
public void onVideoRecordStarted() {
|
public void onVideoRecordStarted() {
|
||||||
if (camera.getCaptureMode() == CameraXView.CaptureMode.IMAGE) {
|
|
||||||
camera.setCaptureMode(CameraXView.CaptureMode.VIDEO);
|
|
||||||
}
|
|
||||||
hideAndDisableControlsForVideoRecording(captureButton, flashButton, flipButton, outAnimation);
|
hideAndDisableControlsForVideoRecording(captureButton, flashButton, flipButton, outAnimation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -275,12 +266,16 @@ public class CameraXFragment extends Fragment implements CameraFragment {
|
||||||
Log.w(TAG, "Video capture is not supported on this device.", e);
|
Log.w(TAG, "Video capture is not supported on this device.", e);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Log.i(TAG, "Video capture not supported. API: " + Build.VERSION.SDK_INT + ", MFD: " + MemoryFileDescriptor.supported());
|
Log.i(TAG, "Video capture not supported. API: " + Build.VERSION.SDK_INT + ", MFD: " + MemoryFileDescriptor.supported() + ", Camera: " + CameraXUtil.getLowestSupportedHardwareLevel(requireContext()));
|
||||||
}
|
}
|
||||||
|
|
||||||
viewModel.onCameraControlsInitialized();
|
viewModel.onCameraControlsInitialized();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isVideoRecordingSupported(@NonNull Context context) {
|
||||||
|
return MediaConstraints.isVideoTranscodeAvailable() && CameraXUtil.isMixedModeSupported(context);
|
||||||
|
}
|
||||||
|
|
||||||
private void displayVideoRecordingTooltipIfNecessary(CameraButtonView captureButton) {
|
private void displayVideoRecordingTooltipIfNecessary(CameraButtonView captureButton) {
|
||||||
if (shouldDisplayVideoRecordingTooltip()) {
|
if (shouldDisplayVideoRecordingTooltip()) {
|
||||||
int displayRotation = requireActivity().getWindowManager().getDefaultDisplay().getRotation();
|
int displayRotation = requireActivity().getWindowManager().getDefaultDisplay().getRotation();
|
||||||
|
@ -332,12 +327,6 @@ public class CameraXFragment extends Fragment implements CameraFragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onCaptureClicked() {
|
private void onCaptureClicked() {
|
||||||
if (camera.getCaptureMode() == CameraXView.CaptureMode.VIDEO) {
|
|
||||||
camera.setCaptureMode(CameraXView.CaptureMode.IMAGE);
|
|
||||||
Util.runOnMainDelayed(this::onCaptureClicked, 100);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Stopwatch stopwatch = new Stopwatch("Capture");
|
Stopwatch stopwatch = new Stopwatch("Capture");
|
||||||
|
|
||||||
CameraXSelfieFlashHelper flashHelper = new CameraXSelfieFlashHelper(
|
CameraXSelfieFlashHelper flashHelper = new CameraXSelfieFlashHelper(
|
||||||
|
|
Loading…
Add table
Reference in a new issue