> 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/ios-sdk/modulos/video-grabacion.md).

# Video recording - Videorecording

This component requires iOS 13 or later.

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

The *Component* covered in this document is called the ***VideoRecording Component***. It captures the device screen in the background. It is primarily intended for recording the onboarding process.

The [Simplified Launch](https://docs.facephi.com/docs.facephi-en/sdks/sdk-mobile/ios-sdk/inicializacion/lanzamiento-simplificado.md) section describes the steps required for basic SDK integration. This section provides information about launching this component.

## Dependencies

To avoid conflicts and compatibility issues, if you want to install the component in a project that contains an older version of the Facephi libraries (*Widgets*), they must be completely removed before installing the ***SDKMobile***.

### CocoaPods

* Currently, FacePhi libraries are distributed remotely through various dependency managers, in this case CocoaPods. The **required** dependencies that must be installed beforehand (by adding them to the project's Podfile) are:

```swift
  pod 'FPHISDKMainComponent', '~> $VERSION'
```

* To install the Selphi component, add the following entry to the application's Podfile:

```swift
  pod 'FPHISDKVideoRecordingComponent', '~> $VERSION'
```

### SPM

* The required dependencies that must be installed beforehand are:

```sh
//HTTPS
https://github.com/facephi-clienters/SDK-SdkPackage-SPM.git
//SSH
git@github.com:facephi-clienters/SDK-SdkPackage-SPM.git
```

* To install the SELPHI component, add the following entry to the project's modules:

```swift
//HTTPS
https://github.com/facephi-clienters/SDK-VideoRecording-SPM.git
//SSH
git@github.com:facephi-clienters/SDK-VideoRecording-SPM.git
```

## Permissions

In the client application where the components will be integrated, the following entry must be added to the **Info.plist** file when the recording includes audio:

```
Microphone access must be allowed (NSMicrophoneUsageDescription - Privacy - Microphone Usage Description)
```

{% hint style="info" %}
Microphone permission is only required if you enable **`enableAudio`** in **`VideoRecordingConfigurationData`**. By default, **`enableAudio`** it **`false`** and the recording does not capture audio.
{% endhint %}

## Available Controllers

| **Controller**           | **Description**                 |
| ------------------------ | ------------------------------- |
| VideoRecordingController | Main video recording controller |

## Simplified Launch

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.

### Controller declaration

```swift
private var videoRecordingController: VideoRecordingController?
```

### Starting the capture

To start screen recording:

```swift
public func launchVideoRecording(viewController: UIViewController) {
    let data = VideoRecordingConfigurationData()
    let videoRecordingController = VideoRecordingController(
        data: data,
        viewController: viewController,
        output: {
            print("videoRecordingController output: \($0.errorType)")
        })
    SDKController.shared.launch(controller: videoRecordingController)
    self.videoRecordingController = videoRecordingController
}
```

### Stopping the capture

To stop screen recording:

```swift
public func stopVideoRecording() {
    self.videoRecordingController?.stopVideoRecording()
}
```

### 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:

* VRC\_EMPTY\_LICENSE: The license string is empty
* VRC\_INITIALIZATION\_ERROR: Initialization error
* VRC\_OPERATION\_NOT\_CREATED: There is no operation in progress
* VRC\_NETWORK\_CONNECTION: Internet connection error
* VRC\_PERMISSION\_ERROR: The user has denied the permissions
* VRC\_SOCKET\_ERROR: Error connecting to the services
* VRC\_UNKNOWN\_ERROR: Unknown error
* VRC\_VIDEO\_CALL\_ACTIVE: Cannot start because a Video Call is active
* VRC\_VIDEO\_ERROR: Error processing the video
* VRC\_VIDEO\_RECORDING\_ACTIVE: Cannot start because the Video Recording process is active

## 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.

The fields included in the configuration usually **do not need to be provided** because 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

#### **apiKey**

API key required to connect to the video socket

#### **tenantId**

Tenant identifier that refers to the current client, required to connect to the video service.

#### **enableAudio**

Flag to configure whether the video recording includes audio. Defaults to `false`.

{% hint style="info" %}
If **`enableAudio`** is **`true`**, you must declare microphone permission in **Info.plist** (see the [Permissions section](#permisos)).
{% endhint %}
