OSDN Git Service

ムービーの撮影機能を搭載。
authorMRSa <mrsa@myad.jp>
Sat, 15 Apr 2017 13:29:02 +0000 (22:29 +0900)
committerMRSa <mrsa@myad.jp>
Sat, 15 Apr 2017 13:29:02 +0000 (22:29 +0900)
wear/src/main/java/jp/sfjp/gokigen/a01c/liveview/FeatureDispatcher.java
wear/src/main/java/jp/sfjp/gokigen/a01c/liveview/ICameraFeatureDispatcher.java
wear/src/main/java/jp/sfjp/gokigen/a01c/liveview/OlyCameraLiveViewOnTouchListener.java
wear/src/main/java/jp/sfjp/gokigen/a01c/olycamerawrapper/IOlyCameraCoordinator.java
wear/src/main/java/jp/sfjp/gokigen/a01c/olycamerawrapper/OlyCameraCoordinator.java
wear/src/main/java/jp/sfjp/gokigen/a01c/olycamerawrapper/takepicture/AutoFocusControl.java [moved from wear/src/main/java/jp/sfjp/gokigen/a01c/olycamerawrapper/AutoFocusControl.java with 94% similarity]
wear/src/main/java/jp/sfjp/gokigen/a01c/olycamerawrapper/takepicture/MovieRecordingControl.java [new file with mode: 0644]
wear/src/main/java/jp/sfjp/gokigen/a01c/olycamerawrapper/takepicture/SingleShotControl.java [moved from wear/src/main/java/jp/sfjp/gokigen/a01c/olycamerawrapper/SingleShotControl.java with 91% similarity]
wear/src/main/res/values-ja/strings.xml
wear/src/main/res/values/strings.xml

index 28a6679..623a6b6 100644 (file)
@@ -117,6 +117,10 @@ public class FeatureDispatcher implements ICameraFeatureDispatcher
                 // 撮影モードの変更(逆順)
                 changeTakeModeReverse();
                 break;
+            case ICameraFeatureDispatcher.FEATURE_CONTROL_MOVIE:
+                // 動画の撮影・撮影終了
+                movieControl();
+                break;
         }
 
         // コマンド実行完了後、ぶるぶるさせる
@@ -174,7 +178,7 @@ public class FeatureDispatcher implements ICameraFeatureDispatcher
 
     /**
      *   撮影モードの変更指示
-     *   (P > A > S > M > ART > iAuto > ...)
+     *   (P > A > S > M > ART > movie > iAuto > ...)
      */
     private void changeTakeMode()
     {
@@ -205,11 +209,14 @@ public class FeatureDispatcher implements ICameraFeatureDispatcher
                 break;
 
             case "ART":
+                targetMode =  targetMode + "/movie>";
+                break;
+
+            case "Movie":
                 targetMode =  targetMode + "/iAuto>";
                 break;
 
             case "iAuto":
-            case "movie":
             default:
                 targetMode =  targetMode + "/P>";
                 break;
@@ -225,7 +232,7 @@ public class FeatureDispatcher implements ICameraFeatureDispatcher
 
     /**
      *   撮影モードの変更指示
-     *   (iAuto < P < A < S < M < ART < iAuto < ...)
+     *   (iAuto < P < A < S < M < ART < movie < iAuto < ...)
      */
     private void changeTakeModeReverse()
     {
@@ -258,11 +265,12 @@ public class FeatureDispatcher implements ICameraFeatureDispatcher
             case "ART":
                 targetMode =  targetMode + "/M>";
                 break;
-
+            case "Movie":
+                targetMode =  targetMode + "/ART>";
+                break;
             case "iAuto":
-            case "movie":
             default:
-                targetMode =  targetMode + "/ART>";
+                targetMode =  targetMode + "/movie>";
                 break;
         }
         Log.v(TAG, "changeTakeMode() " + targetMode);
@@ -273,10 +281,9 @@ public class FeatureDispatcher implements ICameraFeatureDispatcher
         //camera.updateTakeMode();
     }
 
-
     /**
      *   シャッターボタンが押された!
-     *   ï¼\88ç\8f¾å\9c¨ã\81¯ã\80\81é\80£ç¶\9aæ\92®å½±ã\83¢ã\83¼ã\83\89ã\82\84ã\83 ã\83¼ã\83\93ã\83¼æ\92®å½±ã\81«ã\81¤ã\81\84ã\81¦ã\81¯ã\81¾ã\81 é\9d\9e対å¿\9cï¼\89
+     *   (現在は、連続撮影モードについてはまだ非対応)
      */
     private void pushShutterButton()
     {
@@ -285,6 +292,15 @@ public class FeatureDispatcher implements ICameraFeatureDispatcher
     }
 
     /**
+     *   動画の撮影・停止を行う
+     *
+     */
+    private void movieControl()
+    {
+        camera.movieControl();
+    }
+
+    /**
      *   グリッド表示の ON/OFFを切り替える
      *
      */
@@ -294,7 +310,6 @@ public class FeatureDispatcher implements ICameraFeatureDispatcher
         updateGridStatusButton(objectId);
     }
 
-
     /**
      *  デジタル水準器の ON/OFFを切り替える
      *
@@ -430,7 +445,6 @@ public class FeatureDispatcher implements ICameraFeatureDispatcher
         propertyProxy.updateCameraPropertyUp(IOlyCameraProperty.ART_FILTER);
     }
 
-
     /**
      *   設定画面を開く
      *
index 3a7ffe0..8628088 100644 (file)
@@ -72,6 +72,7 @@ interface ICameraFeatureDispatcher
     int FEATURE_ART_FILTER_UP = 15;
     int FEATURE_TOGGLE_SHOW_LEVEL_GAUGE = 16;
     int FEATURE_CHANGE_TAKEMODE_REVERSE = 17;
+    int FEATURE_CONTROL_MOVIE = 18;
 
     // エリアタッチ時の機能(featureNumber)
     int FEATURE_AREA_ACTION_NONE = 100;
index bb7ad02..1a0ba6c 100644 (file)
@@ -217,7 +217,7 @@ public class OlyCameraLiveViewOnTouchListener  implements View.OnClickListener,
                 preference_action_id = preference_action_id + ICameraFeatureDispatcher.MODE_IAUTO;
                 break;
 
-            case "movie":
+            case "Movie":
                 preference_action_id = preference_action_id + ICameraFeatureDispatcher.MODE_MOVIE;
                 break;
 
@@ -272,7 +272,7 @@ public class OlyCameraLiveViewOnTouchListener  implements View.OnClickListener,
                 preference_action_id = preference_action_id + ICameraFeatureDispatcher.MODE_IAUTO;
                 break;
 
-            case "movie":
+            case "Movie":
                 preference_action_id = preference_action_id + ICameraFeatureDispatcher.MODE_MOVIE;
                 break;
 
@@ -326,7 +326,7 @@ public class OlyCameraLiveViewOnTouchListener  implements View.OnClickListener,
                 preference_action_id = preference_action_id + ICameraFeatureDispatcher.MODE_IAUTO;
                 break;
 
-            case "movie":
+            case "Movie":
                 preference_action_id = preference_action_id + ICameraFeatureDispatcher.MODE_MOVIE;
                 break;
 
@@ -381,7 +381,7 @@ public class OlyCameraLiveViewOnTouchListener  implements View.OnClickListener,
                 defaultAction = ICameraFeatureDispatcher.FEATURE_ACTION_NONE;
                 break;
 
-            case "movie":
+            case "Movie":
                 preference_action_id = preference_action_id + ICameraFeatureDispatcher.MODE_MOVIE;
                 defaultAction =  (isLongClick) ? ICameraFeatureDispatcher.FEATURE_EXPOSURE_BIAS_DOWN : ICameraFeatureDispatcher.FEATURE_EXPOSURE_BIAS_DOWN;
                 break;
@@ -437,7 +437,7 @@ public class OlyCameraLiveViewOnTouchListener  implements View.OnClickListener,
                 defaultAction = ICameraFeatureDispatcher.FEATURE_ACTION_NONE;
                 break;
 
-            case "movie":
+            case "Movie":
                 preference_action_id = preference_action_id + ICameraFeatureDispatcher.MODE_MOVIE;
                 defaultAction =  (isLongClick) ? ICameraFeatureDispatcher.FEATURE_EXPOSURE_BIAS_UP : ICameraFeatureDispatcher.FEATURE_EXPOSURE_BIAS_UP;
                 break;
@@ -483,17 +483,17 @@ public class OlyCameraLiveViewOnTouchListener  implements View.OnClickListener,
                 preference_action_id = preference_action_id + ICameraFeatureDispatcher.MODE_ART;
                 break;
 
-            case "iAuto":
-                preference_action_id = preference_action_id + ICameraFeatureDispatcher.MODE_IAUTO;
-                break;
-
-            case "movie":
+            case "Movie":
                 preference_action_id = preference_action_id + ICameraFeatureDispatcher.MODE_MOVIE;
+                defaultAction = ICameraFeatureDispatcher.FEATURE_CONTROL_MOVIE;
                 break;
 
+            case "iAuto":
             default:
+                preference_action_id = preference_action_id + ICameraFeatureDispatcher.MODE_IAUTO;
                 break;
         }
+        Log.v(TAG, "SHUTTER : " + takeMode);
         return (dispatcher.dispatchAction(IShowInformation.BUTTON_6, preferences.getInt(preference_action_id, defaultAction)));
     }
 
@@ -538,7 +538,7 @@ public class OlyCameraLiveViewOnTouchListener  implements View.OnClickListener,
                 preference_action_id = preference_action_id + ICameraFeatureDispatcher.MODE_IAUTO;
                 break;
 
-            case "movie":
+            case "Movie":
                 preference_action_id = preference_action_id + ICameraFeatureDispatcher.MODE_MOVIE;
                 break;
 
@@ -587,7 +587,7 @@ public class OlyCameraLiveViewOnTouchListener  implements View.OnClickListener,
                 preference_action_id = preference_action_id + ICameraFeatureDispatcher.MODE_IAUTO;
                 break;
 
-            case "movie":
+            case "Movie":
                 preference_action_id = preference_action_id + ICameraFeatureDispatcher.MODE_MOVIE;
                 break;
 
@@ -636,7 +636,7 @@ public class OlyCameraLiveViewOnTouchListener  implements View.OnClickListener,
                 preference_action_id = preference_action_id + ICameraFeatureDispatcher.MODE_IAUTO;
                 break;
 
-            case "movie":
+            case "Movie":
                 preference_action_id = preference_action_id + ICameraFeatureDispatcher.MODE_MOVIE;
                 break;
 
index b7032db..81bc6ac 100644 (file)
@@ -27,6 +27,9 @@ public interface IOlyCameraCoordinator
     /** シングル撮影機能の実行 **/
     void singleShot();
 
+    /** ムービー撮影機能の実行(開始・終了) **/
+    void movieControl();
+
     /** 撮影確認画像の設定 **/
     void setRecViewMode(boolean isRecViewMode);
 
index 7924863..1a12a90 100644 (file)
@@ -14,6 +14,9 @@ import jp.sfjp.gokigen.a01c.IShowInformation;
 import jp.sfjp.gokigen.a01c.R;
 import jp.sfjp.gokigen.a01c.liveview.IAutoFocusFrameDisplay;
 import jp.sfjp.gokigen.a01c.liveview.ICameraStatusReceiver;
+import jp.sfjp.gokigen.a01c.olycamerawrapper.takepicture.AutoFocusControl;
+import jp.sfjp.gokigen.a01c.olycamerawrapper.takepicture.MovieRecordingControl;
+import jp.sfjp.gokigen.a01c.olycamerawrapper.takepicture.SingleShotControl;
 import jp.sfjp.gokigen.a01c.preference.ICameraPropertyAccessor;
 
 /**
@@ -38,6 +41,7 @@ public class OlyCameraCoordinator implements IOlyCameraCoordinator, IIndicatorCo
     // 本クラスの配下のカメラ制御クラス群
     private final AutoFocusControl autoFocus;
     private final SingleShotControl singleShot;
+    private final MovieRecordingControl movieControl;
     private final OlyCameraPropertyProxy propertyProxy;
     private final LoadSaveCameraProperties loadSaveCameraProperties;
     private final OlyCameraConnection cameraConnection;
@@ -65,7 +69,8 @@ public class OlyCameraCoordinator implements IOlyCameraCoordinator, IIndicatorCo
 
         // 本クラスの配下のカメラ制御クラス群の設定
         autoFocus = new AutoFocusControl(camera, focusFrameDisplay, this); // AF制御
-        singleShot = new SingleShotControl(camera, focusFrameDisplay, this, showInformation);  // 撮影
+        singleShot = new SingleShotControl(camera, focusFrameDisplay, this, showInformation);  // 1枚撮影
+        movieControl = new MovieRecordingControl(context, camera, showInformation); // ムービー撮影
         propertyProxy = new OlyCameraPropertyProxy(camera); // カメラプロパティ
         cameraStatusDisplay = new CameraStatusDisplay(propertyProxy, showInformation);  // 画面表示
         this.levelMeter = new LevelMeterHolder(showInformation, android.support.v7.preference.PreferenceManager.getDefaultSharedPreferences(context).getBoolean(ICameraPropertyAccessor.SHOW_LEVEL_GAUGE_STATUS, false));  // デジタル水準器
@@ -191,6 +196,15 @@ public class OlyCameraCoordinator implements IOlyCameraCoordinator, IIndicatorCo
     }
 
     /**
+     *   ムービーの撮影・停止
+     */
+    @Override
+    public void movieControl()
+    {
+        movieControl.movieControl();
+    }
+
+    /**
      *   撮影確認画像を生成するか設定する
      *
      */
@@ -1,4 +1,4 @@
-package jp.sfjp.gokigen.a01c.olycamerawrapper;
+package jp.sfjp.gokigen.a01c.olycamerawrapper.takepicture;
 
 import android.graphics.PointF;
 import android.graphics.RectF;
@@ -7,6 +7,7 @@ import jp.co.olympus.camerakit.OLYCamera;
 import jp.co.olympus.camerakit.OLYCameraAutoFocusResult;
 import jp.co.olympus.camerakit.OLYCameraKitException;
 import jp.sfjp.gokigen.a01c.liveview.IAutoFocusFrameDisplay;
+import jp.sfjp.gokigen.a01c.olycamerawrapper.IIndicatorControl;
 
 /**
  *   オートフォーカス制御クラス
@@ -16,7 +17,7 @@ import jp.sfjp.gokigen.a01c.liveview.IAutoFocusFrameDisplay;
  *     3. unlockAutoFocus() で AF-Unlock を実行
  *
  */
-class AutoFocusControl implements OLYCamera.TakePictureCallback
+public class AutoFocusControl implements OLYCamera.TakePictureCallback
 {
     private final OLYCamera camera;
     private final IIndicatorControl indicator;
@@ -27,7 +28,7 @@ class AutoFocusControl implements OLYCamera.TakePictureCallback
      *   コンストラクタ
      *
      */
-    AutoFocusControl(OLYCamera camera, IAutoFocusFrameDisplay focusFrameDrawer, IIndicatorControl indicator)
+    public AutoFocusControl(OLYCamera camera, IAutoFocusFrameDisplay focusFrameDrawer, IIndicatorControl indicator)
     {
         this.camera = camera;
         this.indicator = indicator;
@@ -40,7 +41,7 @@ class AutoFocusControl implements OLYCamera.TakePictureCallback
      * @param point  ターゲットAF点
      *
      */
-    boolean lockAutoFocus(PointF point)
+    public boolean lockAutoFocus(PointF point)
     {
         if (camera.isTakingPicture() || camera.isRecordingVideo())
         {
@@ -83,7 +84,7 @@ class AutoFocusControl implements OLYCamera.TakePictureCallback
      *   AF-Lを解除する
      *
      */
-    void unlockAutoFocus()
+    public void unlockAutoFocus()
     {
         if (camera.isTakingPicture() || camera.isRecordingVideo())
         {
diff --git a/wear/src/main/java/jp/sfjp/gokigen/a01c/olycamerawrapper/takepicture/MovieRecordingControl.java b/wear/src/main/java/jp/sfjp/gokigen/a01c/olycamerawrapper/takepicture/MovieRecordingControl.java
new file mode 100644 (file)
index 0000000..fe1b609
--- /dev/null
@@ -0,0 +1,97 @@
+package jp.sfjp.gokigen.a01c.olycamerawrapper.takepicture;
+
+import android.content.Context;
+import android.graphics.Color;
+import android.util.Log;
+import android.widget.Toast;
+
+import java.util.HashMap;
+
+import jp.co.olympus.camerakit.OLYCamera;
+import jp.co.olympus.camerakit.OLYCameraKitException;
+import jp.sfjp.gokigen.a01c.IShowInformation;
+import jp.sfjp.gokigen.a01c.R;
+
+/**
+ *   ビデオ撮影の開始・終了制御クラス。
+ *
+ */
+public class MovieRecordingControl implements OLYCamera.CompletedCallback
+{
+    private final String TAG = toString();
+    private final Context context;
+    private final OLYCamera camera;
+    private final IShowInformation statusDrawer;
+
+    /**
+     *   コンストラクタ
+     *
+     */
+    public MovieRecordingControl(Context context, OLYCamera camera, IShowInformation statusDrawer)
+    {
+        this.context = context;
+        this.camera = camera;
+        this.statusDrawer = statusDrawer;
+    }
+
+    /**
+     *   動画撮影の開始と終了
+     *
+     */
+    public void movieControl()
+    {
+        try
+        {
+            if (camera.isTakingPicture())
+            {
+                // スチル撮影中の場合は、何もしない(モード異常なので)
+                Log.v(TAG, "NOW TAKING PICTURE(STILL) : COMMAND IGNORED");
+                return;
+            }
+            if (!camera.isRecordingVideo())
+            {
+                // ムービー撮影の開始指示
+                camera.startRecordingVideo(new HashMap<String, Object>(), this);
+                statusDrawer.setMessage(IShowInformation.AREA_9, Color.RED, context.getString(R.string.video_recording));
+            }
+            else
+            {
+                // ムービー撮影の終了指示
+                camera.stopRecordingVideo(this);
+                statusDrawer.setMessage(IShowInformation.AREA_9, Color.WHITE, "");
+            }
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
+    }
+
+    /**
+     *   処理完了
+     *
+     */
+    @Override
+    public void onCompleted()
+    {
+        // 撮影終了をバイブレータで知らせる
+        statusDrawer.vibrate(IShowInformation.VIBRATE_PATTERN_SIMPLE_MIDDLE);
+    }
+
+    /**
+     *   エラー発生
+     *
+     * @param e 例外情報
+     */
+    @Override
+    public void onErrorOccurred(OLYCameraKitException e)
+    {
+        // 撮影失敗をバイブレータで知らせる
+        statusDrawer.vibrate(IShowInformation.VIBRATE_PATTERN_SIMPLE_SHORT);
+        {
+            // 撮影失敗の表示をToastで行う
+            Toast.makeText(context, R.string.video_failure, Toast.LENGTH_SHORT).show();
+        }
+        e.printStackTrace();
+    }
+}
@@ -1,4 +1,4 @@
-package jp.sfjp.gokigen.a01c.olycamerawrapper;
+package jp.sfjp.gokigen.a01c.olycamerawrapper.takepicture;
 
 import android.graphics.RectF;
 import android.util.Log;
@@ -8,13 +8,14 @@ import jp.co.olympus.camerakit.OLYCamera;
 import jp.co.olympus.camerakit.OLYCameraAutoFocusResult;
 import jp.sfjp.gokigen.a01c.IShowInformation;
 import jp.sfjp.gokigen.a01c.liveview.IAutoFocusFrameDisplay;
+import jp.sfjp.gokigen.a01c.olycamerawrapper.IIndicatorControl;
 
 /**
  *   一枚撮影用のクラス
  *
  * Created by MRSa on 2016/06/18.
  */
-class SingleShotControl implements OLYCamera.TakePictureCallback
+public class SingleShotControl implements OLYCamera.TakePictureCallback
 {
     private final String TAG = toString();
     //private final Context context;
@@ -27,7 +28,7 @@ class SingleShotControl implements OLYCamera.TakePictureCallback
      *  コンストラクタ
      *
      */
-    SingleShotControl(OLYCamera camera, IAutoFocusFrameDisplay frameInfo, IIndicatorControl indicator, IShowInformation statusDrawer)
+    public SingleShotControl(OLYCamera camera, IAutoFocusFrameDisplay frameInfo, IIndicatorControl indicator, IShowInformation statusDrawer)
     {
         //this.context = context;
         this.camera = camera;
@@ -40,7 +41,7 @@ class SingleShotControl implements OLYCamera.TakePictureCallback
      *   1枚撮影する
      *
      */
-    void singleShot()
+    public void singleShot()
     {
         try
         {
index 948741d..f9f83c0 100644 (file)
@@ -40,5 +40,7 @@
 
     <string name="shoot_camera">撮影!</string>
     <string name="shoot_camera_failure">失敗です&#8230;</string>
+    <string name="video_recording">&#9679;REC</string>
+    <string name="video_failure">失敗です&#8230;</string>
     <string name="message_none">---</string>
 </resources>
index 7be6739..40c215d 100644 (file)
@@ -39,5 +39,7 @@
 
     <string name="shoot_camera">Capture!</string>
     <string name="shoot_camera_failure">FAILED!</string>
+    <string name="video_recording">&#9679;REC</string>
+    <string name="video_failure">FAILED!</string>
     <string name="message_none">---</string>
 </resources>