mirror of
https://github.com/SimpleMobileTools/Simple-Camera.git
synced 2025-04-01 17:30:11 +02:00
fix some camera state glitches around recording and capturing
This commit is contained in:
parent
13d4f25810
commit
afa5a46303
@ -37,7 +37,9 @@ const val STATE_PICTURE_TAKEN = 2
|
|||||||
const val STATE_WAITING_LOCK = 3
|
const val STATE_WAITING_LOCK = 3
|
||||||
const val STATE_WAITING_PRECAPTURE = 4
|
const val STATE_WAITING_PRECAPTURE = 4
|
||||||
const val STATE_WAITING_NON_PRECAPTURE = 5
|
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 {
|
fun compensateDeviceRotation(orientation: Int, isUsingFrontCamera: Boolean) = when {
|
||||||
orientation == ORIENT_LANDSCAPE_LEFT -> 270
|
orientation == ORIENT_LANDSCAPE_LEFT -> 270
|
||||||
|
@ -681,6 +681,7 @@ class PreviewCameraTwo : ViewGroup, TextureView.SurfaceTextureListener, MyPrevie
|
|||||||
mCaptureSession!!.capture(build(), mCaptureCallback, mBackgroundHandler)
|
mCaptureSession!!.capture(build(), mCaptureCallback, mBackgroundHandler)
|
||||||
}
|
}
|
||||||
} catch (e: CameraAccessException) {
|
} catch (e: CameraAccessException) {
|
||||||
|
mCameraState = STATE_PREVIEW
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -693,6 +694,8 @@ class PreviewCameraTwo : ViewGroup, TextureView.SurfaceTextureListener, MyPrevie
|
|||||||
mCameraState = STATE_PREVIEW
|
mCameraState = STATE_PREVIEW
|
||||||
mCaptureSession!!.setRepeatingRequest(mPreviewRequest, mCaptureCallback, mBackgroundHandler)
|
mCaptureSession!!.setRepeatingRequest(mPreviewRequest, mCaptureCallback, mBackgroundHandler)
|
||||||
} catch (e: CameraAccessException) {
|
} catch (e: CameraAccessException) {
|
||||||
|
} finally {
|
||||||
|
mCameraState = STATE_PREVIEW
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -736,6 +739,7 @@ class PreviewCameraTwo : ViewGroup, TextureView.SurfaceTextureListener, MyPrevie
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun startRecording() {
|
private fun startRecording() {
|
||||||
|
mCameraState = STATE_STARTING_RECORDING
|
||||||
closeCaptureSession()
|
closeCaptureSession()
|
||||||
setupMediaRecorder()
|
setupMediaRecorder()
|
||||||
if (mActivity.config.isSoundEnabled) {
|
if (mActivity.config.isSoundEnabled) {
|
||||||
@ -767,13 +771,16 @@ class PreviewCameraTwo : ViewGroup, TextureView.SurfaceTextureListener, MyPrevie
|
|||||||
mCameraState = STATE_RECORDING
|
mCameraState = STATE_RECORDING
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onConfigureFailed(session: CameraCaptureSession?) {}
|
override fun onConfigureFailed(session: CameraCaptureSession?) {
|
||||||
|
mCameraState = STATE_PREVIEW
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mCameraDevice!!.createCaptureSession(surfaces, captureCallback, mBackgroundHandler)
|
mCameraDevice!!.createCaptureSession(surfaces, captureCallback, mBackgroundHandler)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun stopRecording() {
|
private fun stopRecording() {
|
||||||
|
mCameraState = STATE_STOPING_RECORDING
|
||||||
if (mActivity.config.isSoundEnabled) {
|
if (mActivity.config.isSoundEnabled) {
|
||||||
mMediaActionSound.play(MediaActionSound.STOP_VIDEO_RECORDING)
|
mMediaActionSound.play(MediaActionSound.STOP_VIDEO_RECORDING)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user