diff --git a/app/src/main/kotlin/com/simplemobiletools/camera/helpers/Constants.kt b/app/src/main/kotlin/com/simplemobiletools/camera/helpers/Constants.kt index f8fc0600..84e88e33 100644 --- a/app/src/main/kotlin/com/simplemobiletools/camera/helpers/Constants.kt +++ b/app/src/main/kotlin/com/simplemobiletools/camera/helpers/Constants.kt @@ -37,7 +37,9 @@ const val STATE_PICTURE_TAKEN = 2 const val STATE_WAITING_LOCK = 3 const val STATE_WAITING_PRECAPTURE = 4 const val STATE_WAITING_NON_PRECAPTURE = 5 -const val STATE_RECORDING = 6 +const val STATE_STARTING_RECORDING = 6 +const val STATE_STOPING_RECORDING = 7 +const val STATE_RECORDING = 8 fun compensateDeviceRotation(orientation: Int, isUsingFrontCamera: Boolean) = when { orientation == ORIENT_LANDSCAPE_LEFT -> 270 diff --git a/app/src/main/kotlin/com/simplemobiletools/camera/views/PreviewCameraTwo.kt b/app/src/main/kotlin/com/simplemobiletools/camera/views/PreviewCameraTwo.kt index 01290e68..550ef9ad 100644 --- a/app/src/main/kotlin/com/simplemobiletools/camera/views/PreviewCameraTwo.kt +++ b/app/src/main/kotlin/com/simplemobiletools/camera/views/PreviewCameraTwo.kt @@ -681,6 +681,7 @@ class PreviewCameraTwo : ViewGroup, TextureView.SurfaceTextureListener, MyPrevie mCaptureSession!!.capture(build(), mCaptureCallback, mBackgroundHandler) } } catch (e: CameraAccessException) { + mCameraState = STATE_PREVIEW } } @@ -693,6 +694,8 @@ class PreviewCameraTwo : ViewGroup, TextureView.SurfaceTextureListener, MyPrevie mCameraState = STATE_PREVIEW mCaptureSession!!.setRepeatingRequest(mPreviewRequest, mCaptureCallback, mBackgroundHandler) } catch (e: CameraAccessException) { + } finally { + mCameraState = STATE_PREVIEW } } @@ -736,6 +739,7 @@ class PreviewCameraTwo : ViewGroup, TextureView.SurfaceTextureListener, MyPrevie } private fun startRecording() { + mCameraState = STATE_STARTING_RECORDING closeCaptureSession() setupMediaRecorder() if (mActivity.config.isSoundEnabled) { @@ -767,13 +771,16 @@ class PreviewCameraTwo : ViewGroup, TextureView.SurfaceTextureListener, MyPrevie mCameraState = STATE_RECORDING } - override fun onConfigureFailed(session: CameraCaptureSession?) {} + override fun onConfigureFailed(session: CameraCaptureSession?) { + mCameraState = STATE_PREVIEW + } } mCameraDevice!!.createCaptureSession(surfaces, captureCallback, mBackgroundHandler) } private fun stopRecording() { + mCameraState = STATE_STOPING_RECORDING if (mActivity.config.isSoundEnabled) { mMediaActionSound.play(MediaActionSound.STOP_VIDEO_RECORDING) }