Skip to main content

Method Signature

FAD_SDK.startVideotaping(
  legend: string,
  identifications: Identification[],
  configuration?: Configuration
): Promise<VideotapingResponse>

Description

The startVideotaping() method initiates the videotaping module, which records the user reading specific text while presenting their identification documents to the camera. This combines video agreement with ID verification in a single recording.

Parameters

legend
string
required
The text that the user must read aloud during the recording. This text will be displayed on screen for the user to follow.Example: “I, John Doe, with ID number 123456, declare that the information I have provided is true and accurate.”
identifications
Identification[]
required
Array of identification documents to be presented during recording
configuration
Configuration
Optional configuration object for customizing the module’s behavior and appearance

Returns

VideotapingResponse
Promise<object>
A promise that resolves with the videotaping module response

Code Example

import FadSDK from '@fad-producto/fad-sdk';

const TOKEN = 'YOUR_FAD_TOKEN';

const CONFIGURATION = {
  allowClose: true,
  views: {
    instructions: true,
    preview: true,
  },
  timer: {
    recording: { min: 5, max: 40 },
    faceUndetected: 5,
  },
  customization: {
    fadCustomization: {
      colors: {
        primary: '#0066CC',
      },
      buttons: {
        primary: {
          backgroundColor: '#0066CC',
          labelColor: '#ffffff',
        },
      },
    },
    moduleCustomization: {
      legends: {
        buttonRecord: 'Start recording',
        buttonFinish: 'Finish',
        recording: 'Recording',
        focusface: 'Frame your face within the guide',
      },
      legendsInstructions: {
        title: 'Video with ID',
        subtitle: 'Read the agreement and present your ID',
        buttonNext: 'Continue',
      },
      legendsPreview: {
        title: 'Video with ID',
        buttonRetry: 'Record again',
        buttonNext: 'Confirm recording',
      },
    },
  },
};

async function captureVideotaping() {
  const options = {
    environment: FadSDK.getFadEnvironments().UATHA
  };

  const FAD_SDK = new FadSDK(TOKEN, options);
  
  try {
    const LEGEND = 'I, John Doe, born on June 20, with voter ID number: 123456789, ' +
      'declare that I am Single, with monthly income of $15,667.21, ' +
      'I have my own house or apartment, I currently have credit cards, ' +
      'and I acknowledge that the information I have provided is truthful.';

    const IDENTIFICATIONS = [
      { 
        name: FadSDK.Constants.Videotaping.IdsAllowed.ID_MEX_FRONT, 
        title: 'Front' 
      },
      { 
        name: FadSDK.Constants.Videotaping.IdsAllowed.ID_MEX_BACK, 
        title: 'Back' 
      },
    ];

    const videotapingResponse = await FAD_SDK.startVideotaping(
      LEGEND,
      IDENTIFICATIONS,
      CONFIGURATION
    );

    if (videotapingResponse.event === FadSDK.Constants.EventModule.MODULE_CLOSED) {
      console.log('Module closed by the user');
      return;
    }

    // Process the results
    console.log('Videotaping completed successfully');

    // Create URL for the video blob
    const videoUrl = URL.createObjectURL(videotapingResponse.data.video);
    const startSecond = videotapingResponse.data.startSecond;
    
    console.log('Video URL:', videoUrl);
    console.log('Agreement starts at second:', startSecond);

    // Display in HTML video element
    // document.getElementById('video-id').src = videoUrl;
    // document.getElementById('startSecond').textContent = startSecond;

  } catch (error) {
    if (error.code === FadSDK.Errors.Videotaping.NOT_ACCEPT_CAMERA_PERMISSION) {
      console.error('Camera permission not granted');
    } else {
      console.error('Error:', error);
    }
  } finally {
    FAD_SDK.end();
  }
}

Error Handling

The method may throw errors that can be identified using FadSDK.Errors.Videotaping:
  • NOT_ACCEPT_CAMERA_PERMISSION - Camera permission was not granted
See the Videotaping Error Codes page for a complete list of error codes.
The videotaping module requires both camera and microphone permissions to function properly.
The startSecond value indicates when the user begins reading the agreement in the video, which is useful for verification purposes.
Always call FAD_SDK.end() in a finally block to properly clean up resources after the module completes or fails.

Build docs developers (and LLMs) love