How to monitor the microphone and camera status of users in a room?
Introduction
In certain scenarios, developers need to monitor the microphone and camera status of users in a room to determine whether the remote stream publishing device is working properly, and to preliminarily understand the reason for device problems based on the corresponding state code.
Implementation Method
Before implementing the device status monitoring feature, please ensure that you have implemented the basic real-time audio and video functionality. For details, please refer to: Quick Start - Implementation Process
ZEGO Express SDK provides two callbacks onRemoteMicStateUpdate and onRemoteCameraStateUpdate to monitor the status changes of remote camera and microphone through this callback.
Sample Code
// Objective-C
- (void)onRemoteMicStateUpdate:(ZegoRemoteDeviceState) state streamID:(NSString *) streamID;
- (void)onRemoteCameraStateUpdate:(ZegoRemoteDeviceState) state streamID:(NSString *) streamID;// Java
public void onRemoteMicStateUpdate (String streamID, ZegoRemoteDeviceState state);
public void onRemoteCameraStateUpdate (String streamID, ZegoRemoteDeviceState state);// cpp
public:
void onRemoteMicStateUpdate(std::string streamID, ZegoRemoteDeviceState state) override;
void onRemoteCameraStateUpdate(std::string streamID, ZegoRemoteDeviceState state) override;// dart
ZegoExpressEngine.onRemoteMicStateUpdate = (String streamID, ZegoRemoteDeviceState state) {
//
};
ZegoExpressEngine.onRemoteCameraStateUpdate= (String streamID, ZegoRemoteDeviceState state) {
//
};// c#
public delegate void OnRemoteMicStateUpdate(string streamID, ZegoRemoteDeviceState state);
public delegate void OnRemoteCameraStateUpdate(string streamID, ZegoRemoteDeviceState state);// TypeScript
onRemoteMicStateUpdate?(streamID: string, state: zego.ZegoRemoteDeviceState): void
onRemoteCameraStateUpdate?(streamID: string, state: zego.ZegoRemoteDeviceState): voidPrecautions
- When playing streams from CDN addresses, the above callbacks will not be received.
- If the user uses custom audio capture, the Mic-related callbacks will not be received.
