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:
/** Reference on MainCamera peripheral. */
private var cameraRef: Ref<MainCamera>? = null
/** Monitors and prints auto record setting. */
fun monitorAutoRecord(drone: Drone) {
cameraRef = drone.getPeripheral(MainCamera::class.java) { camera ->
// called on main thread when the camera peripheral changes
// get auto record settings
camera?.autoRecord()?.run {
if (isAvailable) {
// get setting value
val autoRecord = isEnabled
print("Current value: $autoRecord")
} else {
// auto record setting is not available
print("Auto record is not available")
}
}
}
}
Example of output:
Current value: true
Sample code to modify auto record setting:
/** Sets auto record setting. */
fun setVideoMode(drone: Drone, autoRecord: Boolean) {
drone.getPeripheral(MainCamera::class.java)?.run {
// set setting value
autoRecord().isEnabled = autoRecord
}
}
Camera 2#
Photo mode is configured with parameter Camera2Params.autoRecordMode
.
Sample code to monitor auto record mode:
/** Reference on MainCamera peripheral. */
private var cameraRef: Ref<MainCamera>? = null
/** Monitors and prints auto record mode. */
fun monitorAutoRecordMode(drone: Drone) {
cameraRef = drone.getPeripheral(MainCamera::class.java) { camera ->
// called on main thread when the camera peripheral changes
camera?.run {
// get configuration parameter
config[Camera.Config.AUTO_RECORD_MODE].run {
if (supportedValues(onlyCurrent = true).isEmpty()) {
// parameter value is not relevant
// if there is not supported values in current configuration
println("No supported value in current configuration")
} else {
// print parameter value
println("Current value: $value")
}
}
}
}
}
Example of output:
Current value: RECORD_FLIGHT
Sample code to modify video mode:
/** Sets auto record mode. */
fun setAutoRecordMode(drone: Drone, mode: Camera.AutoRecordMode) {
drone.getPeripheral(MainCamera::class.java)?.run {
// create configuration editor, starting from current configuration
val editor = camera.config.edit(fromScratch = false)
// get configuration parameter
editor[Camera.Config.AUTO_RECORD_MODE].let { configParam ->
// change parameter value,
// and unset other parameters conflicting with this new value
configParam.value = mode
// 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 retrieved by calling configParam.supportedValues(onlyCurrent = false)
.