Skip to content

Commit

Permalink
Prevent mode change on capturing
Browse files Browse the repository at this point in the history
  • Loading branch information
shohara committed Aug 30, 2018
1 parent ae399d8 commit 04c9cc2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -230,13 +230,15 @@ public void takePicture() {
}
}

public boolean isMediaRecorder() {
public boolean isMediaRecorderNull() {
return mMediaRecorder == null;
}

public boolean takeVideo() {
boolean result = true;
if (mMediaRecorder == null) {
mMediaRecorder = new MediaRecorder();

mAudioManager.setParameters("RicUseBFormat=true");
mAudioManager.setParameters("RicMicSelect=RicMicSelectAuto");
mAudioManager
Expand All @@ -253,7 +255,6 @@ public boolean takeVideo() {

mCamera.setParameters(mParameters);

mMediaRecorder = new MediaRecorder();
mCamera.unlock();

mMediaRecorder.setCamera(mCamera);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ public void onKeyUp(int keyCode, KeyEvent event) {
if (keyCode == KeyReceiver.KEYCODE_MEDIA_RECORD) {
Fragment fragment = getSupportFragmentManager().findFragmentById(R.id.fragment);
if (fragment != null && fragment instanceof CameraFragment) {
if (((CameraFragment) fragment).isMediaRecorder()) {
// not recording video
if (((CameraFragment) fragment).isMediaRecorderNull() && !(((CameraFragment) fragment).isCapturing())) {
// not recording video or capturing still
isVideo = !isVideo;
updateLED();
}
Expand Down Expand Up @@ -123,7 +123,7 @@ private boolean takeVideo() {
Fragment fragment = getSupportFragmentManager().findFragmentById(R.id.fragment);
if (fragment != null && fragment instanceof CameraFragment) {

if (((CameraFragment) fragment).isMediaRecorder()) {
if (((CameraFragment) fragment).isMediaRecorderNull()) {
// start recording
if (!(((CameraFragment) fragment).isCapturing())) {
notificationAudioMovStart();
Expand Down Expand Up @@ -156,7 +156,7 @@ private void endProcess() {
if (!isEnded) {
Fragment fragment = getSupportFragmentManager().findFragmentById(R.id.fragment);
if (fragment != null && fragment instanceof CameraFragment) {
if (!((CameraFragment) fragment).isMediaRecorder()) {
if (!((CameraFragment) fragment).isMediaRecorderNull()) {
takeVideo(); // stop recording
}
}
Expand Down

0 comments on commit 04c9cc2

Please sign in to comment.