简体   繁体   English

DJI Gimbal - 按下时如何从硬件按钮获取回调

[英]DJI Gimbal - how to get callbacks from hardware buttons when pressed

I'm working on a camera app using Android Camera2 SDK which has button for start/stop recording, and a zoom functionality.我正在使用 Android Camera2 SDK 开发一个相机应用程序,该应用程序具有开始/停止录制按钮和缩放功能。 I've integrated the DJI mobile SDK and I did the registration with the API key generated from the developer account.我已经集成了 DJI 移动 SDK,并使用从开发者帐户生成的 API 密钥进行了注册。 When I start the app, I receive a REGISTRATION_SUCCESS from DJISDKManager.SDKManagerCallback()#onRegister() and the Gimbal is connected through Bluetooth to the phone.当我启动应用程序时,我从DJISDKManager.SDKManagerCallback()#onRegister()收到REGISTRATION_SUCCESS并且云台通过蓝牙连接到手机。

Now the issue is, how can I intercept the hardware button press events from the Gimbal ?现在的问题是,如何拦截云台的硬件按钮按下事件? For example if I press the hardware record button of the Gimbal, the camera app starts recording.例如,如果我按下云台的硬件录制按钮,相机应用程序开始录制。

I tried something like this, but it doesn't work.我尝试过这样的事情,但它不起作用。 I couldn't find any documentation about how to receive callbacks when hardware buttons are pressed.我找不到任何有关在按下硬件按钮时如何接收回调的文档。

OSMOMobileHandheldController osmoMobileHandheldController = new OSMOMobileHandheldController();
    osmoMobileHandheldController.setHardwareStateCallback(hardwareState -> {

        switch (hardwareState.getRecordAndShutterButtons()) {
            case IDLE: {
                Log.e(TAG, "getRecordAndShutterButtons IDLE");
                break;
            }
            case RECORD_CLICK: {
                Log.e(TAG, "getRecordAndShutterButtons RECORD_CLICK");
                break;
            }
            case SHUTTER_CLICK: {
                Log.e(TAG, "getRecordAndShutterButtons SHUTTER_CLICK");
                break;
            }
            case SHUTTER_LONG_CLICK: {
                Log.e(TAG, "getRecordAndShutterButtons SHUTTER_LONG_CLICK");
                break;
            }
            default: {
                Log.e(TAG, "getRecordAndShutterButtons UNKNOWN");
            }
        }
        
        switch (hardwareState.getZoomState()) {
            case IDLE: {
                Log.e(TAG, "getZoomState IDLE");
                break;
            }
            case ZOOM_IN: {
                Log.e(TAG, "getZoomState ZOOM_IN");
                break;
            }
            case ZOOM_OUT: {
                Log.e(TAG, "getZoomState ZOOM_OUT");
                break;
            }
            default: {
                Log.e(TAG, "getTriggerButton UNKNOWN");
            }
        }

    });

You can't just create an object.你不能只创建一个对象。 You must call the sdk to get the correct instance.您必须调用 sdk 才能获得正确的实例。 You have only created an object that is not connected to anything.您只创建了一个没有连接到任何东西的对象。

https://developer.dji.com/api-reference/android-api/Components/SDKManager/DJISDKManager.html#djisdkmanager_product_inline https://developer.dji.com/api-reference/android-api/Components/SDKManager/DJISDKManager.html#djisdkmanager_product_inline

So something like: DJISDKManager.getInstance().getProduct().getHandheld() will get you an object that is connected to the api所以像: DJISDKManager.getInstance().getProduct().getHandheld() 会给你一个连接到 api 的对象

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM