Record a video while user performs a scan
MobbScan offers you the possibility to record an unattended video of the user while performing the verification process.
Configuration
Before adding the unattended video to your application, you should modify the following:
configure an extra dependency in your
build.gradleconfiguration file (dependencies section).dependencies { ... implementation 'com.twilio:video-android:7.6.1' ... }Add required permission in the
AndroidManifest.xmlof your project:<!-- Required to record audio --> <uses-permission android:name="android.permission.RECORD_AUDIO" />
Adding the recording process
MobbScan provides you with a default activity that will open a new
MobbScanAPI.getInstance().startUnattendedVideo(scanId) { result, resultData, error ->
// Your finished listener code here
}
MobbScanAPI.getInstance().startUnattendedVideo(scanId, new VideoUnattendedFinishedListener() {
@Override
public void onFinished(VideoUnattendedResult result, MobbScanVideoDetectionResultData resultData, MobbScanAPIError error) {
// Your finished listener code here...
}
});
Configuring timeout
This process depends on the user to scan the document in order to finish recording the video. In order to keep the video between some time and size limits, the unattended video process has a timeout.
This timeout is by default set at 3 minutes.
If you want to change this value, you can use the following method call instead of the regular one:
MobbScanAPI.getInstance().startUnattendedVideo(scanId, YOUR_TIMEOUT_IN_SECONDS) { result, resultData, error ->
// Your finished listener code here
}
MobbScanAPI.getInstance().startUnattendedVideo(scanId, YOUR_TIMEOUT_IN_SECONDS, new VideoUnattendedFinishedListener() {
@Override
public void onFinished(VideoUnattendedResult result, MobbScanVideoDetectionResultData resultData, MobbScanAPIError error) {
// Your finished listener code here...
}
});
NOTE: The timeout should be between 1 and 5 minutes. Otherwise, the SDK will throw an
IllegalStateException.
Customizing the recording UI
Customize default UI
You can customize the colors, sizes and font family of the default UI overriding the values of the following files:
colors.xml:
<color name="unattended_spinner_color">#FF3D6B</color>
<color name="unattended_action_title_color">#FFFFFF</color>
<color name="unattended_countdown_color">#FFFFFF</color>
<color name="unattended_configure_background_color">#FFFFFF</color>
<color name="unattended_configure_title_color">#2C2B2B</color>
<color name="background_default_color">#95000000</color>
<color name="rectangle_default_color">#FFFFFF</color>
<color name="rectangle_detect_color">#3FC336</color>
<color name="text_color">#FFFFFF</color>
<color name="mrz_text_green">#ADFF2F</color>
<color name="face_overlay_color">#80FFFFFF</color>
<color name="face_outline_color">#FFFFFF</color>
<color name="face_progress_color">#55D672</color>
<color name="face_recording_color">#E0263B</color>
dimens.xml:
<dimen name="unattended_action_text_size">18sp</dimen>
<dimen name="unattended_countdown_text_size">40sp</dimen>
<dimen name="unattended_configure_title_text_size">18sp</dimen>
<dimen name="rectangle_detector_border_size">4dp</dimen>
<dimen name="face_detector_border_size">10dp</dimen>
styles.xml:
<style name="UnattendedVideoTheme" parent="@android:style/Theme.NoTitleBar.Fullscreen">
<item name="android:fontFamily">sans-serif-light</item>
<item name="unattended_configure_service_bg">@color/unattended_configure_background_color</item>
<item name="unattended_configure_service_text_size">@dimen/unattended_configure_title_text_size</item>
<item name="unattended_configure_service_text_color">@color/unattended_configure_title_color</item>
<item name="unattended_detection_bg">@color/background_default_color</item>
<item name="unattended_detection_rectangle_base_color">@color/rectangle_default_color</item>
<item name="unattended_detection_rectangle_detected_color">@color/rectangle_detect_color</item>
<item name="unattended_detection_action_text_size">@dimen/unattended_action_text_size</item>
<item name="unattended_detection_action_text_color">@color/unattended_action_title_color</item>
<item name="unattended_detection_countdown_text_size">@dimen/unattended_countdown_text_size</item>
<item name="unattended_detection_countdown_text_color">@color/unattended_countdown_color</item>
</style>
Show or hide the back button
You can control whether the default unattended activity shows the toolbar back button through MobbScanConfiguration.
If you do not know how to use this object, please refer to configure detection process for more information.
val mobbScanConfiguration = MobbScanConfiguration()
mobbScanConfiguration.setBackButtonVisible(true)
MobbScanAPI.getInstance().initAPI(YOUR_LICENSE, YOUR_CONTEXT, LICENSE_LISTENER, mobbScanConfiguration)
MobbScanConfiguration mobbScanConfiguration = new MobbScanConfiguration();
mobbScanConfiguration.setBackButtonVisible(true);
MobbScanAPI.getInstance().initAPI(YOUR_LICENSE, YOUR_CONTEXT, LICENSE_LISTENER, mobbScanConfiguration);
Setting setBackButtonVisible(true) shows the back button in the toolbar of the default unattended activity. Pressing it triggers the same cancellation flow as the standard back action.
If you also want to control whether pressing the back button shows a confirmation dialog or exits immediately, use setCancellationDialogEnabled(boolean) in the same MobbScanConfiguration instance. See Configure the detection process.
If you want to customize the back button color or the cancellation dialog button colors used in the unattended flow, see Customize MobbScan Default Interfaces.
