通知
本站点除 Legacy 产品与方案外,已迁移至 声网新文档中心 ,当前页面不再维护
Documentation
All
Console 官网 Community Technical support

How can I listen for the status of a user's microphone and camera?

Type: Integration issues    Platform: Android / iOS / macOS / Web / Windows / Unity / Cocos Creator / 微信小程序 / Electron / React Native / Flutter / RESTful / Flutter2   Last Updated: 2022/09/14 23:05:56

Introduction

When using the Agora RTC SDK to implement a real-time call or interactive streaming, to listen for the status of a user's microphone and camera in a channel, you can use the Agora RTM SDK.

Implementation

You can use the following functions of the Agora RTM SDK to listen for the status of a user's microphone and camera in a channel:

  • User attributes: Listen for the status of a specified user's microphone and camera by adding user attributes.
  • Channel attributes: Listen for the status of all users' microphones and cameras in a specified channel by adding channel attributes.

Listen for user attributes

  1. After joining a channel, call addOrUpdateLocalUserAttributes to add or update the attributes of the local user's microphone and camera.
  2. Call getUserAttributesByKeys to get the attributes of a specified user's microphone and camera, which can be used to show the microphone and camera status.

Listen for channel attributes

  1. (This step is for Linux/Windows C++ only, skip to step 2 when using other platforms.) After joining a channel, call createChannelAttribute to create and return an IRtmChannelAttribute instance.
After getting the microphone and camera status, call release to release the IRtmChannelAttribute instance.
  1. Call addOrUpdateChannelAttributes to add or update the attributes of all users' microphones and cameras in a specified channel.

  2. Call getChannelAttributesByKeys to get the attributes of all users' microphones and cameras in a specified channel, which can be used to show the microphone and camera status.

Reference

Refer to the following documents for detailed integration guide and API reference: