Capturing Videos

OzCapsula (SDK v8.22 and newer)

circle-exclamation

To start recording, use startActivityForResult:

Kotlin
val sessionToken: String = getSessionToken()
val captureRequest = CaptureRequest(
    listOf(
        AnalysisProfile(
            Analysis.Type.QUALITY,
            listOf(MediaRequest.ActionMedia(OzAction.Blank)),
        )
    )
)
val intent = OzLivenessSDK.createStartIntent(captureRequest, sessionToken)
startActivityForResult(intent, REQUEST_LIVENESS_CONTAINER)

To obtain the captured video, use onActivityResult:

Kotlin
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
    super.onActivityResult(requestCode, resultCode, data)
    if (requestCode == REQUEST_LIVENESS_CONTAINER) {
        when (resultCode) {
            OzLivenessResultCode.SUCCESS -> runAnalysis(OzLivenessSDK.getContainerFromIntent(data))
            OzLivenessResultCode.USER_CLOSED_LIVENESS -> { /* user closed the screen */ }
            else -> {
                val errorMessage = OzLivenessSDK.getErrorFromIntent(data)
                /* show error */
            }
        }
    }
}

If you use fragment, please refer to the example below. LivenessFragment is the Fragmentarrow-up-right representation of the Liveness screen UI.

SDK 8.21 and older

To start recording, use thestartActivityForResult method:

actions – a list of user actions while recording video.

For Fragment, use the code below. LivenessFragment is the Fragmentarrow-up-right representation of the Liveness screen UI.

circle-exclamation

To obtain the captured video, use theonActivityResult method:

  • sdkMediaResult – an object with video capturing results for interactions with Oz API (a list of the OzAbstractMedia objects),

  • sdkErrorString – description of errors, if any.

circle-info

If you use our SDK just for capturing videos, omit the Checking Liveness and Face Biometry step.

If a user closes the capturing screen manually, resultCode receives the Activity.RESULT_CANCELED value.

Code example:

Last updated

Was this helpful?