Auto record#

The “auto record” setting is used to enable or disable automatic recording. When automatic recording is enabled, the video recording starts when the drone takes off and stops after landing.

Camera 1#

Sample code to monitor auto record setting:

/// Keep reference on MainCamera peripheral to get notified of changes.
private var cameraRef: Ref<MainCamera>?

/// Monitors and prints auto record setting.
func monitorAutoRecord(drone: Drone) {
    cameraRef = drone.getPeripheral(Peripherals.mainCamera) { camera in
        // called on main thread when the camera peripheral changes
        if let camera = camera {
            if let autoRecordSetting = camera.autoRecordSetting {
                // get setting value
                let autoRecord = autoRecordSetting.value
                print("Current value is: \(autoRecord)")
            } else {
                // auto record setting is not available
                print("Auto record is not supported")
            }
        }
    }
}

Example of output:

Current value is: true

Sample code to modify auto record setting:

/// Sets auto record setting.
func setVideoMode(drone: Drone, autoRecord: Bool) {
    if let camera = drone.getPeripheral(Peripherals.mainCamera) {
        // set setting value
        camera.autoRecordSetting?.value = autoRecord
    }
}

Camera 2#

Photo mode is configured with parameter Camera2Params.autoRecordMode.

Sample code to monitor auto record mode:

/// Keep reference on MainCamera2 peripheral to get notified of changes.
private var cameraRef: Ref<MainCamera2>?

/// Monitors and prints auto record mode.
func monitorAutoRecord(drone: Drone) {
    cameraRef = drone.getPeripheral(Peripherals.mainCamera2) { camera in
        // called on main thread when the camera peripheral changes
        if let camera = camera {
            // get configuration parameter
            if let configParam = camera.config[Camera2Params.autoRecordMode] {
                if configParam.currentSupportedValues.isEmpty {
                    // parameter value is not relevant
                    // if there is not supported values in current configuration
                    print("No supported value in current configuration")
                } else {
                    // get parameter value
                    let autoRecord = configParam.value
                    print("Current value is: \(autoRecord)")
                }
            }
        }
    }
}

Example of output:

Current value is: recordFlight

Sample code to modify video mode:

/// Sets auto record mode.
func setAutoRecord(drone: Drone, autoRecord: Camera2AutoRecordMode) {
    if let camera = drone.getPeripheral(Peripherals.mainCamera2) {
        // create configuration editor, starting from current configuration
        let editor = camera.config.edit(fromScratch: false)
        // retrieve configuration parameter
        if let configParam = editor[Camera2Params.autoRecordMode] {
            // change parameter value,
            // and unset other parameters conflicting with this new value
            configParam.value = autoRecord
            // complete configuration, by setting missing parameters values
            editor.autoComplete()
            // send new configuration to drone
            editor.commit()
        }
    }
}

Trying to change the parameter value to an unsupported value has no effect. Values supported by the camera are provided by the parameter field configParam.overallSupportedValues.