mirror of
https://github.com/SimpleMobileTools/Simple-Camera.git
synced 2025-04-15 15:57:25 +02:00
reinitialize the recorder if the device rotation changes while not recording
This commit is contained in:
parent
10282d36ba
commit
fc4bd98e68
@ -54,7 +54,6 @@ class Preview : ViewGroup, SurfaceHolder.Callback, MediaScannerConnection.OnScan
|
|||||||
private var mWasZooming = false
|
private var mWasZooming = false
|
||||||
private var mLastClickX = 0
|
private var mLastClickX = 0
|
||||||
private var mLastClickY = 0
|
private var mLastClickY = 0
|
||||||
private var mInitVideoRotation = 0
|
|
||||||
private var mCurrCameraId = 0
|
private var mCurrCameraId = 0
|
||||||
private var mMaxZoom = 0
|
private var mMaxZoom = 0
|
||||||
}
|
}
|
||||||
@ -366,7 +365,6 @@ class Preview : ViewGroup, SurfaceHolder.Callback, MediaScannerConnection.OnScan
|
|||||||
} catch (e: IOException) {
|
} catch (e: IOException) {
|
||||||
Log.e(TAG, "surfaceCreated IOException " + e.message)
|
Log.e(TAG, "surfaceCreated IOException " + e.message)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun surfaceChanged(holder: SurfaceHolder, format: Int, width: Int, height: Int) {
|
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)
|
mRecorder!!.setPreviewDisplay(mSurfaceHolder.surface)
|
||||||
|
|
||||||
val rotation = getVideoRotation()
|
val rotation = getVideoRotation()
|
||||||
mInitVideoRotation = rotation
|
|
||||||
mRecorder!!.setOrientationHint(rotation)
|
mRecorder!!.setOrientationHint(rotation)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -580,11 +577,14 @@ class Preview : ViewGroup, SurfaceHolder.Callback, MediaScannerConnection.OnScan
|
|||||||
return (deviceRot + previewRot) % 360
|
return (deviceRot + previewRot) % 360
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun startRecording() {
|
fun deviceOrientationChanged() {
|
||||||
if (mInitVideoRotation != getVideoRotation()) {
|
if (mIsVideoMode && !mIsRecording) {
|
||||||
|
mRecorder = null
|
||||||
|
initRecorder()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun startRecording() {
|
||||||
try {
|
try {
|
||||||
mCamera!!.unlock()
|
mCamera!!.unlock()
|
||||||
toggleShutterSound(true)
|
toggleShutterSound(true)
|
||||||
@ -596,7 +596,6 @@ class Preview : ViewGroup, SurfaceHolder.Callback, MediaScannerConnection.OnScan
|
|||||||
Log.e(TAG, "toggleRecording " + e.message)
|
Log.e(TAG, "toggleRecording " + e.message)
|
||||||
releaseCamera()
|
releaseCamera()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun stopRecording() {
|
private fun stopRecording() {
|
||||||
|
@ -498,6 +498,7 @@ class MainActivity : SimpleActivity(), SensorEventListener, PreviewListener, Pho
|
|||||||
else -> 0
|
else -> 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mPreview!!.deviceOrientationChanged()
|
||||||
animateViews(degrees)
|
animateViews(degrees)
|
||||||
mLastHandledOrientation = mOrientation
|
mLastHandledOrientation = mOrientation
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user