Fix VideoRecorder bug

v2
Mattia Iavarone 7 years ago
parent aa88eb08c6
commit 78c5e4b19c
  1. 3
      cameraview/src/main/java/com/otaliastudios/cameraview/Camera1.java
  2. 4
      cameraview/src/main/java/com/otaliastudios/cameraview/MediaRecorderVideoRecorder.java
  3. 7
      cameraview/src/main/java/com/otaliastudios/cameraview/VideoRecorder.java

@ -205,7 +205,7 @@ class Camera1 extends CameraController implements Camera.PreviewCallback, Camera
mFrameManager.release(); mFrameManager.release();
if (mCamera != null) { if (mCamera != null) {
LOG.i("onStop:", "Clean up.", "Ending video."); LOG.i("onStop:", "Clean up.", "Ending video. mVideoRecorder is null?", mVideoRecorder == null);
if (mVideoRecorder != null) { if (mVideoRecorder != null) {
mVideoRecorder.stop(); mVideoRecorder.stop();
mVideoRecorder = null; mVideoRecorder = null;
@ -655,6 +655,7 @@ class Camera1 extends CameraController implements Camera.PreviewCallback, Camera
@Override @Override
public void run() { public void run() {
mIsTakingVideo = false; mIsTakingVideo = false;
LOG.i("stopVideo", "mVideoRecorder is null?", mVideoRecorder == null);
if (mVideoRecorder != null) { if (mVideoRecorder != null) {
mVideoRecorder.stop(); mVideoRecorder.stop();
mVideoRecorder = null; mVideoRecorder = null;

@ -75,7 +75,7 @@ class MediaRecorderVideoRecorder extends VideoRecorder {
} }
@Override @Override
void stop() { void close() {
if (mMediaRecorder != null) { if (mMediaRecorder != null) {
try { try {
mMediaRecorder.stop(); mMediaRecorder.stop();
@ -85,8 +85,6 @@ class MediaRecorderVideoRecorder extends VideoRecorder {
} }
mMediaRecorder.release(); mMediaRecorder.release();
} }
super.stop();
mProfile = null; mProfile = null;
mMediaRecorder = null; mMediaRecorder = null;
} }

@ -21,11 +21,16 @@ abstract class VideoRecorder {
abstract void start(); abstract void start();
void stop() { final void stop() {
if (mListener != null) {
close();
mListener.onVideoResult(mResult); mListener.onVideoResult(mResult);
mListener = null; mListener = null;
mResult = null; mResult = null;
} }
}
abstract void close();
interface VideoResultListener { interface VideoResultListener {
void onVideoResult(@Nullable VideoResult result); void onVideoResult(@Nullable VideoResult result);

Loading…
Cancel
Save