fix some camera state glitches around recording and capturing

This commit is contained in:
tibbi 2018-06-08 22:38:02 +02:00
parent 13d4f25810
commit afa5a46303
2 changed files with 11 additions and 2 deletions

View File

@ -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

View File

@ -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)
}