> For the complete documentation index, see [llms.txt](https://docs.facephi.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.facephi.com/docs.facephi-en/sdks/sdk-mobile/android-sdk/componentes-modulos/video-grabacion.md).

# Video recording - Videorecording

## Introduction <a href="#id-1-introduccion" id="id-1-introduccion"></a>

Screen recording is performed with the ***VideoRecording Component***.

This component captures the device screen in the background. It is primarily intended for recording the onboarding process.

***

## Dependency <a href="#id-2-dependencia" id="id-2-dependencia"></a>

The component-specific dependency is:

```
implementation "com.facephi.androidsdk:video_recording_component:$version"
```

***

## Available Controllers <a href="#id-3-controladores-disponibles" id="id-3-controladores-disponibles"></a>

| **Controller**               | **Description**                              |
| ---------------------------- | -------------------------------------------- |
| VideoRecordingController     | Main video recording controller.             |
| StopVideoRecordingController | Controller for stopping the video recording. |

***

***

## Simplified Launch <a href="#id-4-lanzamiento-simplificado" id="id-4-lanzamiento-simplificado"></a>

Once the SDK has been initialized and a new operation has been created, the component can be launched. You can use any of its controllers to execute its functionality.

### Starting the capture <a href="#id-41-lanzamiento-de-la-captura" id="id-41-lanzamiento-de-la-captura"></a>

To start screen recording:

```kotlin
val response = SDKController.launch(
    VideoRecordingController(
        VideoRecordingConfigurationData(...)
    )
)

when (response) {
    is SdkResult.Error   -> Napier.d("ERROR - ${response.error.name}")
    is SdkResult.Success -> response.data
}

```

### Stopping the capture <a href="#id-42-detener-la-captura" id="id-42-detener-la-captura"></a>

To stop screen recording:

```kotlin
val response = SDKController.launch(StopVideoRecordingController())

when (response) {
    is SdkResult.Error   -> Napier.d("ERROR - ${response.error.name}")
    is SdkResult.Success -> Napier.d("APP: VIDEO RECORDING STATE (stop): ${response.data.state.name}")
}

```

### Receiving errors <a href="#id-61-recepcion-de-errores" id="id-61-recepcion-de-errores"></a>

Errors are returned as a 'VideoRecordingError' object.

List of errors:

* `CANCEL_BY_USER` (`VRC_000`): The user canceled the process
* `COMPONENT_LICENSE_ERROR` (`VRC_002`): The component license is invalid
* `EMPTY_LICENSE` (`VRC_003`): The license string is empty
* `FLOW_ERROR` (`VRC_759`): Error in the flow process
* `INITIALIZATION_ERROR` (`VRC_004`): Initialization error
* `INTERNAL_ERROR` (`VRC_758`): Internal error
* `OPERATION_NOT_CREATED` (`VRC_006`): There is no operation in progress
* `NETWORK_CONNECTION` (`VRC_750`): Internet connection error
* `PERMISSION_ERROR` (`VRC_751`): The user denied the required permissions. With `enableAudio=true` this also covers denial or dismissal of the microphone permission and denial of the `MediaProjection`.
* `SOCKET_ERROR` (`VRC_752`): Error connecting to the services
* `UNKNOWN_ERROR` (`VRC_753`): Unknown error
* `VIDEO_CALL_ACTIVE_ERROR` (`VRC_754`): Cannot start because a video call is active
* `VIDEO_ERROR` (`VRC_755`): Error processing the video
* `VIDEO_RECORDING_ACTIVE_ERROR` (`VRC_756`): Cannot start because video recording is in progress
* `FETCH_DATA_ERROR` (`VRC_757`): Error retrieving the result

### Receiving the successful result - *data* <a href="#id-62-recepcion-del-resultado-correcto-data" id="id-62-recepcion-del-resultado-correcto-data"></a>

On success, the `data` field contains a `VideoRecordingResult`.

* `state`: Recording state. `SHARING` indicates that recording has started, and `FINISH` indicates that it has stopped successfully.

## Advanced information

This section provides additional information about the component.

### Advanced component configuration <a href="#id-51-configuracion-avanzada-del-componente" id="id-51-configuracion-avanzada-del-componente"></a>

To launch the current component, create a *VideoRecordingConfigurationData* object, which will configure the component's controller.

All the fields that are part of this class are detailed below.

> Note: *VideoRecordingConfigurationData* is the class developers use to launch *VideoRecordingController*. The *FVideoRecordingConfigurationData* (same fields, but with `enableAudio` set to `true`) is used for launching via streams (*FVideoRecordingController*, configuration serialized as JSON); it is not used for direct integration with controllers.

The fields `url`, `apiKey` and `tenantId` usually **do not need to be provided** since they are populated internally using the License in use.

These fields are usually provided **only** when the **server** is **On-Premise**.

#### **url**

Path to the video socket (`String?`, default `null`)

#### **apiKey**

ApiKey required to connect to the video socket (`String?`, default `null`)

#### **tenantId**

Tenant identifier that refers to the current client, required to connect to the video service (`String?`, default `null`).

#### **enableAudio**

Enables audio capture during screen recording. Default `false`. When set to `true`, Android requests `RECORD_AUDIO` before the `MediaProjection`permission; if the user denies or closes the permission screen, `VRC_PERMISSION_ERROR` is returned and recording does not start.

\ <br>
