diff --git a/app/src/main/kotlin/com/simplemobiletools/camera/Preview.kt b/app/src/main/kotlin/com/simplemobiletools/camera/Preview.kt index 9477e84e..6c011f4f 100644 --- a/app/src/main/kotlin/com/simplemobiletools/camera/Preview.kt +++ b/app/src/main/kotlin/com/simplemobiletools/camera/Preview.kt @@ -54,7 +54,6 @@ class Preview : ViewGroup, SurfaceHolder.Callback, MediaScannerConnection.OnScan private var mWasZooming = false private var mLastClickX = 0 private var mLastClickY = 0 - private var mInitVideoRotation = 0 private var mCurrCameraId = 0 private var mMaxZoom = 0 } @@ -366,7 +365,6 @@ class Preview : ViewGroup, SurfaceHolder.Callback, MediaScannerConnection.OnScan } catch (e: IOException) { Log.e(TAG, "surfaceCreated IOException " + e.message) } - } override fun surfaceChanged(holder: SurfaceHolder, format: Int, width: Int, height: Int) { @@ -517,7 +515,6 @@ class Preview : ViewGroup, SurfaceHolder.Callback, MediaScannerConnection.OnScan mRecorder!!.setPreviewDisplay(mSurfaceHolder.surface) val rotation = getVideoRotation() - mInitVideoRotation = rotation mRecorder!!.setOrientationHint(rotation) try { @@ -580,11 +577,14 @@ class Preview : ViewGroup, SurfaceHolder.Callback, MediaScannerConnection.OnScan return (deviceRot + previewRot) % 360 } - private fun startRecording() { - if (mInitVideoRotation != getVideoRotation()) { - + fun deviceOrientationChanged() { + if (mIsVideoMode && !mIsRecording) { + mRecorder = null + initRecorder() } + } + private fun startRecording() { try { mCamera!!.unlock() toggleShutterSound(true) @@ -596,7 +596,6 @@ class Preview : ViewGroup, SurfaceHolder.Callback, MediaScannerConnection.OnScan Log.e(TAG, "toggleRecording " + e.message) releaseCamera() } - } private fun stopRecording() { diff --git a/app/src/main/kotlin/com/simplemobiletools/camera/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/camera/activities/MainActivity.kt index 7d24b5df..6364b22e 100644 --- a/app/src/main/kotlin/com/simplemobiletools/camera/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/camera/activities/MainActivity.kt @@ -498,6 +498,7 @@ class MainActivity : SimpleActivity(), SensorEventListener, PreviewListener, Pho else -> 0 } + mPreview!!.deviceOrientationChanged() animateViews(degrees) mLastHandledOrientation = mOrientation }