Overview
This article outlines the process for monitoring host presence during live sessions. This feature ensures that hosts are actively visible on video and supports moderation actions like issuing warnings or ending sessions when absence is detected.
Prerequisites
- A valid Agora project with the necessary access tokens.
- Basic undestanding of Agora callbacks
Issue Description
There is a need for real-time face detection to ensure that the host is actively present on video during sessions. The system continuously verifies whether the host is visible on camera; if absence is detected, it triggers alert callbacks to enable appropriate actions such as issuing warnings or automatically terminating the session. This helps maintain authenticity, accountability, and a consistent user experience.
Resolution Steps
We recommend using the enableFaceDetection API to detect faces. Once enabled, the SDK triggers the onFacePositionChanged callback to report face information for the local user. When the face moves out of the camera view, the callback is immediately triggered on the client side. By checking the the numFaces value in callback, you can determine whether a face is present — a value of 0 indicates that no human face is detected.
Please find the relevant documentation:
-
enableFaceDetection: https://api-ref.agora.io/en/video-sdk/react-native/4.x/API/class_irtcengine.html#api_irtcengine_enablefacedetectionCode Snippett:
abstract enableFaceDetection(enabled: boolean): number; -
onFacePositionChanged: https://api-ref.agora.io/en/video-sdk/react-native/4.x/API/class_irtcengineeventhandler.html#callback_irtcengineeventhandler_onfacepositionchanged
Based on the callback response, you can take appropriate action — for example, display a warning popup informing the user that if their face is not detected on camera within the next 5 seconds, the channel will be ended.