logo
On this page

How to monitor the microphone and camera status of users in a room?

2023-03-01
Products / Plugins:Video Call / Audio Call / Live streaming
Platform / Framework:iOS / Android / macOS / Windows

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

Note

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): void

Precautions

Note
  1. When playing streams from CDN addresses, the above callbacks will not be received.
  2. If the user uses custom audio capture, the Mic-related callbacks will not be received.

API Reference

Previous

How to view API comments and documentation in Express Android SDK?

Next

How to set and get ZIM SDK log information?

On this page

Back to top