From 04c9cc23ff333ff4ef836ec9c2d75707e592f144 Mon Sep 17 00:00:00 2001 From: shohara Date: Thu, 30 Aug 2018 19:37:24 +0900 Subject: [PATCH] Prevent mode change on capturing --- .../java/com/theta360/pluginsample/CameraFragment.java | 5 +++-- .../main/java/com/theta360/pluginsample/MainActivity.java | 8 ++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/plugin/src/main/java/com/theta360/pluginsample/CameraFragment.java b/plugin/src/main/java/com/theta360/pluginsample/CameraFragment.java index cb6802a..4ff05f4 100644 --- a/plugin/src/main/java/com/theta360/pluginsample/CameraFragment.java +++ b/plugin/src/main/java/com/theta360/pluginsample/CameraFragment.java @@ -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 @@ -253,7 +255,6 @@ public boolean takeVideo() { mCamera.setParameters(mParameters); - mMediaRecorder = new MediaRecorder(); mCamera.unlock(); mMediaRecorder.setCamera(mCamera); diff --git a/plugin/src/main/java/com/theta360/pluginsample/MainActivity.java b/plugin/src/main/java/com/theta360/pluginsample/MainActivity.java index 4133c03..1f6d118 100644 --- a/plugin/src/main/java/com/theta360/pluginsample/MainActivity.java +++ b/plugin/src/main/java/com/theta360/pluginsample/MainActivity.java @@ -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(); } @@ -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(); @@ -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 } }