The Videotaping module captures video recordings of users reading agreements while displaying identification documents. When errors occur, they are thrown as ResponseError objects with specific error codes.
Thrown when the user denies camera permissions or camera access is not available.Code:FadSDK.Errors.Videotaping.NOT_ACCEPT_CAMERA_PERMISSIONWhen it occurs:
User explicitly denies camera permission
Camera permissions blocked by browser or system settings
Camera is already in use by another application
Camera hardware is not available or malfunctioning
Browser doesn’t support camera access (missing MediaDevices API)
How to handle:
try { const LEGEND = 'I, [Name], with date of birth [DOB], with ID number [ID_NUMBER], declare that the information provided is true and accurate.'; const IDENTIFICATIONS = [ { name: FadSDK.Constants.Videotaping.IdsAllowed.ID_MEX_FRONT, title: 'Front of ID' }, { name: FadSDK.Constants.Videotaping.IdsAllowed.ID_MEX_BACK, title: 'Back of ID' } ]; const videotapingResponse = await FAD_SDK.startVideotaping( LEGEND, IDENTIFICATIONS, CONFIGURATION ); if (videotapingResponse.event === FadSDK.Constants.EventModule.MODULE_CLOSED) { console.log('Module closed by user'); return; } // Process videotaping data const videoUrl = URL.createObjectURL(videotapingResponse.data.video); const startSecond = videotapingResponse.data.startSecond; console.log('Videotaping completed'); console.log('Agreement starts at second:', startSecond);} catch (ex) { if (ex.code === FadSDK.Errors.Videotaping.NOT_ACCEPT_CAMERA_PERMISSION) { alert('Camera permission is required to record your statement. Please enable camera access.'); // Provide instructions for enabling camera }}
The Videotaping module requires camera access to record the user reading the agreement while showing their identification documents. Without camera permissions, the module cannot function.
import FadSDK from '@fad-producto/fad-sdk';async function recordVideotaping() { const FAD_SDK = new FadSDK(TOKEN, { environment: FadSDK.getFadEnvironments().UATHA }); try { // Define the agreement text the user will read const LEGEND = ` I, [Full Name], with date of birth [DOB], with ID number [ID_NUMBER] declare that I am [Marital Status], with monthly income of $[Amount], I [do/do not] own a home, I [do/do not] currently have credit cards, and I acknowledge that the information I have provided is true and accurate. `; // Define which ID sides to show during recording const IDENTIFICATIONS = [ { name: FadSDK.Constants.Videotaping.IdsAllowed.ID_MEX_FRONT, title: 'Front of ID' }, { name: FadSDK.Constants.Videotaping.IdsAllowed.ID_MEX_BACK, title: 'Back of ID' } ]; const videotapingResponse = await FAD_SDK.startVideotaping( LEGEND, IDENTIFICATIONS, CONFIGURATION ); // Check if user closed the module if (videotapingResponse.event === FadSDK.Constants.EventModule.MODULE_CLOSED) { console.log('User closed the videotaping module'); return; } // Process successful videotaping capture console.log('Videotaping completed successfully'); // Create URL for video playback const videoUrl = URL.createObjectURL(videotapingResponse.data.video); const startSecond = videotapingResponse.data.startSecond; // Display video const videoElement = document.getElementById('video-id') as HTMLVideoElement; const downloadLink = document.getElementById('download-link') as HTMLAnchorElement; const startSecondDisplay = document.getElementById('startSecond'); videoElement.src = videoUrl; downloadLink.href = videoUrl; downloadLink.download = 'videotaping-agreement.webm'; startSecondDisplay.innerHTML = `Agreement starts at: ${startSecond}s`; console.log('Videotaping ready for playback'); console.log('User statement begins at second:', startSecond); } catch (ex) { console.error('Videotaping error:', ex); if (ex.code === FadSDK.Errors.Videotaping.NOT_ACCEPT_CAMERA_PERMISSION) { alert('Camera access is required to record your statement with ID verification. Please enable camera permissions and try again.'); // Show instructions for enabling camera showCameraPermissionInstructions(); } else { // Handle unexpected errors console.error('Unexpected error:', ex); alert(`An error occurred: ${ex.message}`); } } finally { FAD_SDK.end(); }}function showCameraPermissionInstructions() { const instructions = ` To enable camera access: 1. Click the camera icon in your browser's address bar 2. Select 'Allow' for camera access 3. Reload the page and try again `; console.log(instructions);}
interface VideotapingResponse { data: { video: Blob; // Complete video recording startSecond: number; // Timestamp (in seconds) when user starts reading the agreement duration?: number; // Total duration of the recording in seconds timestamp?: string; // ISO timestamp of when recording was completed }; event: string; // Event type (PROCESS_COMPLETED, MODULE_CLOSED)}
The startSecond field indicates when the user begins reading the agreement text. This is useful for verification purposes and for skipping to the relevant part of the video.
Check camera permissions before starting the module:
async function checkCameraAccess(): Promise<boolean> { try { const stream = await navigator.mediaDevices.getUserMedia({ video: true, audio: false }); // Stop all tracks immediately stream.getTracks().forEach(track => track.stop()); return true; } catch (error) { console.error('Camera access check failed:', error); return false; }}async function initVideotaping() { const hasCamera = await checkCameraAccess(); if (!hasCamera) { alert('Please enable camera access to record your statement with ID verification'); showCameraPermissionInstructions(); return; } // Proceed with videotaping await recordVideotaping();}
Browser-Specific Instructions
Provide platform-specific guidance:
function getCameraInstructions(): string { const userAgent = navigator.userAgent.toLowerCase(); if (userAgent.includes('chrome')) { return 'Click the camera icon in the address bar and select "Allow"'; } else if (userAgent.includes('firefox')) { return 'Click the permissions icon and enable camera access'; } else if (userAgent.includes('safari')) { return 'Go to Safari > Settings > Camera and allow access for this website'; } else if (userAgent.includes('edge')) { return 'Click the lock icon in the address bar and enable camera'; } return 'Please enable camera permissions in your browser settings';}
Permission State Detection
Query current permission state:
async function getCameraPermissionState(): Promise<PermissionState> { try { const result = await navigator.permissions.query({ name: 'camera' as PermissionName }); return result.state; // 'granted', 'denied', or 'prompt' } catch (error) { console.error('Permission query not supported:', error); return 'prompt'; }}async function handleVideotaping() { const state = await getCameraPermissionState(); if (state === 'denied') { alert('Camera access is blocked. Please update your browser settings.'); showCameraPermissionInstructions(); return; } else if (state === 'prompt') { // Show explanation before requesting permission showCameraPermissionRationale(); } await recordVideotaping();}function showCameraPermissionRationale() { alert('We need camera access to record you reading the agreement while showing your ID. This ensures the authenticity and legal validity of your consent.');}
The Videotaping module can be closed by the user at any time:
if (videotapingResponse.event === FadSDK.Constants.EventModule.MODULE_CLOSED) { // User cancelled the videotaping process console.log('Videotaping cancelled by user'); // Handle cancellation gracefully - allow restart or exit}
Module closure is not an error condition - it’s a normal user action. Handle it gracefully by allowing users to restart or exit the flow.