pull/1/head
Dylan McIntyre 8 years ago
parent 0a2a94245c
commit 743c3fdee8
  1. 43
      camerakit/src/main/api16/com/flurgle/camerakit/Camera1.java

@ -2,8 +2,11 @@ package com.flurgle.camerakit;
import android.graphics.YuvImage; import android.graphics.YuvImage;
import android.hardware.Camera; import android.hardware.Camera;
import android.media.CamcorderProfile;
import android.media.MediaRecorder;
import android.view.SurfaceHolder; import android.view.SurfaceHolder;
import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
@ -27,6 +30,8 @@ public class Camera1 extends CameraImpl {
private Camera.CameraInfo mCameraInfo; private Camera.CameraInfo mCameraInfo;
private Size mPreviewSize; private Size mPreviewSize;
private Size mCaptureSize; private Size mCaptureSize;
private MediaRecorder mMediaRecorder;
private File mVideoFile;
private int mDisplayOrientation; private int mDisplayOrientation;
@ -58,6 +63,7 @@ public class Camera1 extends CameraImpl {
}); });
mCameraInfo = new Camera.CameraInfo(); mCameraInfo = new Camera.CameraInfo();
} }
// CameraImpl: // CameraImpl:
@ -200,12 +206,16 @@ public class Camera1 extends CameraImpl {
@Override @Override
void startVideo() { void startVideo() {
initMediaRecorder();
prepareMediaRecorder();
mMediaRecorder.start();
} }
@Override @Override
void endVideo() { void endVideo() {
mMediaRecorder.stop();
mMediaRecorder = null;
mCameraListener.onVideoTaken(mVideoFile);
} }
@Override @Override
@ -368,4 +378,33 @@ public class Camera1 extends CameraImpl {
return output; return output;
} }
private void initMediaRecorder() {
mMediaRecorder = new MediaRecorder();
mCamera.unlock();
mMediaRecorder.setCamera(mCamera);
mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
mMediaRecorder.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_480P));
mVideoFile = new File(mPreview.getView().getContext().getExternalFilesDir(null), "video.mp4");
mMediaRecorder.setOutputFile(mVideoFile.getAbsolutePath());
mMediaRecorder.setMaxDuration(20000);
mMediaRecorder.setMaxFileSize(5000000);
mMediaRecorder.setOrientationHint(mCameraInfo.orientation);
}
private void prepareMediaRecorder() {
// mMediaRecorder.setPreviewDisplay(mPreview.getSurface());
try {
mMediaRecorder.prepare();
} catch (IllegalStateException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
} }

Loading…
Cancel
Save