Connected Microphone User List
This document primarily describes the connected microphone user list and the API documentation for node ConnectMicItem.
1. Connected Microphone List
1.1 Get Connected Microphone List
How viewers watch the streams of connected microphone users:
- When a viewer is not connected to the microphone, they watch via a mixed stream;
- After a viewer connects to the microphone, they watch via an RTC stream;
When a viewer goes on stage or a connected microphone user's stream joins, the ConnectMicEvents.ConnectMicDataChange event is triggered. Developers can obtain the connected microphone user list through the event's micDatas or getMicDatas method.
API Method: getMicDatas(): ConnectMicItemData[]
Return Value Description: ConnectMicItemData[] type
Example:
watchCore.connectMic.eventEmitter.on(ConnectMicEvents.ConnectMicDataChange, () => {
const micDatas = watchCore.connectMic.getMicDatas();
console.log('连麦用户列表', micDatas);
});
1.2 Connected Microphone Node Data
Interface: ConnectMicItemData
| Property Name | Description | Type |
|---|---|---|
userId |
User ID | string |
nickname |
User Nickname | string |
avatar |
User Avatar | string |
userType |
User Type | ChatUserType |
isLocal |
Is Local Stream Push | boolean |
isMaster |
Is Main Speaker | boolean |
currentVolume |
Current Volume (0 ~ 1) | number |
isAudioMuted |
Is Microphone Muted | boolean |
isVideoMuted |
Is Camera Disabled | boolean |
pusherAttributes |
Push Stream Parameters | PusherAttributes |
playerAttributes |
Pull Stream Parameters | PlayerAttributes |
2. Connected Microphone Data Event
When the connected microphone list changes, the ConnectMicEvents.ConnectMicDataChange connected microphone list modification event is triggered. Scenarios include: going on/off stage, changes in the microphone and camera status of connected microphone users, volume changes, etc. After obtaining the new connected microphone list data, developers need to reassign the pusherAttributes or playerAttributes in the data to <live-pusher> or <live-player>. For details, refer to the <connect-mic-player> component in the demo.
