notify the activity at stoping the video recording, fixed third party intents

This commit is contained in:
tibbi 2018-06-14 14:14:57 +02:00
parent 16fdbf8d5a
commit ff33c4f30d
2 changed files with 8 additions and 4 deletions

View File

@ -536,7 +536,7 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener {
} }
fun videoSaved(uri: Uri) { fun videoSaved(uri: Uri) {
setupPreviewImage(mIsInPhotoMode) setupPreviewImage(false)
if (mIsVideoCaptureIntent) { if (mIsVideoCaptureIntent) {
Intent().apply { Intent().apply {
data = uri data = uri
@ -551,7 +551,7 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener {
override fun mediaSaved(path: String) { override fun mediaSaved(path: String) {
rescanPaths(arrayListOf(path)) { rescanPaths(arrayListOf(path)) {
setupPreviewImage(mIsInPhotoMode) setupPreviewImage(true)
Intent(BROADCAST_REFRESH_MEDIA).apply { Intent(BROADCAST_REFRESH_MEDIA).apply {
putExtra(REFRESH_PATH, path) putExtra(REFRESH_PATH, path)
`package` = "com.simplemobiletools.gallery" `package` = "com.simplemobiletools.gallery"

View File

@ -34,6 +34,7 @@ import com.simplemobiletools.camera.interfaces.MyPreview
import com.simplemobiletools.camera.models.FocusArea import com.simplemobiletools.camera.models.FocusArea
import com.simplemobiletools.camera.models.MySize import com.simplemobiletools.camera.models.MySize
import com.simplemobiletools.commons.helpers.isJellyBean1Plus import com.simplemobiletools.commons.helpers.isJellyBean1Plus
import java.io.File
import java.lang.IllegalArgumentException import java.lang.IllegalArgumentException
import java.lang.InterruptedException import java.lang.InterruptedException
import java.lang.Math import java.lang.Math
@ -90,6 +91,7 @@ class PreviewCameraTwo : ViewGroup, TextureView.SurfaceTextureListener, MyPrevie
private var mIsRecording = false private var mIsRecording = false
private var mUseFrontCamera = false private var mUseFrontCamera = false
private var mCameraId = "" private var mCameraId = ""
private var mLastVideoPath = ""
private var mCameraState = STATE_INIT private var mCameraState = STATE_INIT
private var mFlashlightState = FLASH_OFF private var mFlashlightState = FLASH_OFF
@ -786,13 +788,13 @@ class PreviewCameraTwo : ViewGroup, TextureView.SurfaceTextureListener, MyPrevie
private fun setupMediaRecorder() { private fun setupMediaRecorder() {
val videoSize = getCurrentResolution() val videoSize = getCurrentResolution()
val currVideoPath = mActivity.getOutputMediaFile(false) mLastVideoPath = mActivity.getOutputMediaFile(false)
val rotation = mActivity.windowManager.defaultDisplay.rotation val rotation = mActivity.windowManager.defaultDisplay.rotation
mMediaRecorder!!.apply { mMediaRecorder!!.apply {
setAudioSource(MediaRecorder.AudioSource.MIC) setAudioSource(MediaRecorder.AudioSource.MIC)
setVideoSource(MediaRecorder.VideoSource.SURFACE) setVideoSource(MediaRecorder.VideoSource.SURFACE)
setOutputFormat(MediaRecorder.OutputFormat.MPEG_4) setOutputFormat(MediaRecorder.OutputFormat.MPEG_4)
setOutputFile(currVideoPath) setOutputFile(mLastVideoPath)
setVideoEncodingBitRate(10000000) setVideoEncodingBitRate(10000000)
setVideoFrameRate(30) setVideoFrameRate(30)
setVideoSize(videoSize.width, videoSize.height) setVideoSize(videoSize.width, videoSize.height)
@ -813,6 +815,7 @@ class PreviewCameraTwo : ViewGroup, TextureView.SurfaceTextureListener, MyPrevie
if (mActivity.config.isSoundEnabled) { if (mActivity.config.isSoundEnabled) {
mMediaActionSound.play(MediaActionSound.START_VIDEO_RECORDING) mMediaActionSound.play(MediaActionSound.START_VIDEO_RECORDING)
} }
val texture = mTextureView.surfaceTexture val texture = mTextureView.surfaceTexture
texture.setDefaultBufferSize(mPreviewSize!!.width, mPreviewSize!!.height) texture.setDefaultBufferSize(mPreviewSize!!.width, mPreviewSize!!.height)
mPreviewRequestBuilder = mCameraDevice!!.createCaptureRequest(CameraDevice.TEMPLATE_RECORD) mPreviewRequestBuilder = mCameraDevice!!.createCaptureRequest(CameraDevice.TEMPLATE_RECORD)
@ -856,6 +859,7 @@ class PreviewCameraTwo : ViewGroup, TextureView.SurfaceTextureListener, MyPrevie
mIsRecording = false mIsRecording = false
mMediaRecorder!!.stop() mMediaRecorder!!.stop()
mMediaRecorder!!.reset() mMediaRecorder!!.reset()
mActivity.videoSaved(Uri.fromFile(File(mLastVideoPath)))
Thread { Thread {
closeCamera() closeCamera()
openCamera(mTextureView.width, mTextureView.height) openCamera(mTextureView.width, mTextureView.height)