Module Events
1. Connect Mic Information Change
Description: Connect mic information is obtained via connectMic.getConnectMicInfo(). This event is triggered when the connect mic information changes.
Event: ConnectMicEvents.ConnectMicInfoChange
Callback Parameters: Object object, detailed type description as follows
| Property | Description | Type |
|---|---|---|
connectMicInfo |
Connect mic information | ConnectMicStoreInfo |
Example:
watchCore.connectMic.eventEmitter.on(ConnectMicEvents.ConnectMicInfoChange, () => {
const connectMicInfo = watchCore.connectMic.getConnectMicInfo();
console.log('连麦信息更新', connectMicInfo);
});
2. Connect Mic Network Information Change
Description: Connect mic network status information is obtained via connectMic.getNetworkInfo(). This event is triggered when the connect mic network status information changes.
Event: ConnectMicEvents.NetworkInfoChange
Callback Parameters: Object object, detailed type description as follows
| Property | Description | Type |
|---|---|---|
networkInfo |
Connect mic network information | ConnectMicNetworkInfo |
Example:
watchCore.connectMic.eventEmitter.on(ConnectMicEvents.NetworkInfoChange, () => {
const networkInfo = watchCore.connectMic.getNetworkInfo();
console.log('网络状态改变', networkInfo);
});
3. Instructor Enables Connect Mic Feature
Description: This event is triggered after the instructor enables the connect mic feature. Once enabled, the connect mic functionality will be displayed on the page.
Event: ConnectMicEvents.OpenConnectMic
Callback Parameters: Object object, detailed type description as follows
| Property | Description | Type |
|---|---|---|
type |
Connect mic type | ConnectMicType |
Example:
import { ConnectMicType } from '@polyv/live-watch-sdk';
watchCore.connectMic.eventEmitter.on(ConnectMicEvents.OpenConnectMic, (data) => {
const type = data.type === ConnectMicType.Video ? '视频' : '音频';
toast.info(`讲师开启了${type}连麦,赶快和主讲连麦互动吧~`);
});
4. Instructor Disables Connect Mic Feature
Description: This event is triggered after the instructor disables the connect mic feature.
Event: ConnectMicEvents.CloseConnectMic
Callback Parameters: Object object, detailed type description as follows
| Property | Description | Type |
|---|---|---|
type |
Connect mic type | ConnectMicType |
Example:
import { ConnectMicType } from '@polyv/live-watch-sdk';
watchCore.connectMic.eventEmitter.on(ConnectMicEvents.CloseConnectMic, (data) => {
const type = data.type === ConnectMicType.Video ? '视频' : '音频';
toast.info(`讲师已结束${type}连麦`);
});
5. Connect Mic List Change
Description: When a viewer goes on/off stage or a user stream joins/exits, the connect mic list changes. Use this event to listen for updates to the connect mic user list.
Event: ConnectMicEvents.ConnectMicListChange
Callback Parameters: Object object, detailed type description as follows
| Property | Description | Type |
|---|---|---|
connectMicList |
Connect mic list | ConnectMicItem[] |
Example:
watchCore.connectMic.eventEmitter.on(ConnectMicEvents.ConnectMicListChange, () => {
const connectMicList = watchCore.connectMic.getConnectMicList();
console.log('连麦用户列表更新', connectMicList);
});
6. Instructor Hangs Up Current Connected User
Description: When the instructor hangs up on the currently connected user, the connect mic module will trigger this event.
Event: ConnectMicEvents.TeacherHangUp
Example:
watchCore.connectMic.eventEmitter.on(ConnectMicEvents.TeacherHangUp, () => {
toast.info('讲师已挂断你的连麦');
});
7. Invite to Go On Stage
Description: This event is triggered when the instructor invites a viewer to go on stage.
Event: ConnectMicEvents.InviteConnectMic
Example:
watchCore.connectMic.eventEmitter.on(ConnectMicEvents.InviteConnectMic, () => {
watchCore.connectMic.openInviting();
});
8. Invitation to Go On Stage Reply
Description: This event is triggered when a student accepts or rejects an invitation to go on stage.
Event: ConnectMicEvents.InviteConnectMicAnswer
Example:
watchCore.connectMic.eventEmitter.on(ConnectMicEvents.InviteConnectMic, (data) => {
console.log(`学员是否拒绝上麦:${data.accept}, 拒绝上麦是否是因为操作超时:${data.timeout}`)
});
9. Device Capture Failure
Description: Automatic recovery of media device (camera/microphone) capture fails. This can happen if the camera or microphone interface is loose or occupied by another application. This event is triggered when recovery fails.
Event: ConnectMicEvents.DeviceRecoverFail
Example:
watchCore.connectMic.eventEmitter.on(ConnectMicEvents.DeviceRecoverFail, () => {
toast.error('自动采集失败,请检查设备正常连接后刷新页面重新进入');
});
10. Connect Mic User Limit Reached
Description: When a viewer clicks to accept an invitation to go on stage, the connection may fail because the maximum number of connected users has been reached. Listen for this event and display a prompt on the page.
Event: ConnectMicEvents.ConnectMicOverLimit
Example:
watchCore.connectMic.eventEmitter.on(ConnectMicEvents.ConnectMicOverLimit, () => {
toast.error('连麦失败,连麦人数已到达上限');
});
11. Current Speaker Status Change
Description: This event is triggered when the instructor grants or revokes the speaker permission for the currently connected user.
Event: ConnectMicEvents.CurrentSpeakerStatusChanged
Callback Parameters: Object object, detailed type description as follows
| Property | Description | Type |
|---|---|---|
currentIsSpeaker |
Whether the current user is the speaker | boolean |
Example:
watchCore.connectMic.eventEmitter.on(ConnectMicEvents.CurrentSpeakerStatusChanged, (data) => {
if (data.currentIsSpeaker) {
toast.info('讲师已授予您主讲权限');
} else {
toast.info('讲师已收回您的主讲权限');
}
});
12. Instructor Approves Connect Mic Application
Description: This event is triggered after a viewer applies to connect and the instructor approves the application.
Event: ConnectMicEvents.AllowConnectMicApply
Example:
watchCore.connectMic.eventEmitter.on(ConnectMicEvents.AllowConnectMicApply, (data) => {
toast.success('讲师已同意你的连麦申请');
});
13. Local Stream Initialization Successful
Description: This event is triggered after the instructor approves the connect mic application and the local stream initialization is complete. Once triggered, the local connect mic stream can be pushed.
Event: ConnectMicEvents.LocalStreamInited
Callback Parameters: Object object, detailed type description as follows
| Property | Description | Type |
|---|---|---|
micItem |
Connect mic user node | ConnectMicItem |
Example:
watchCore.connectMic.eventEmitter.on(ConnectMicEvents.LocalStreamInited, () => {
watchCore.connectMic.publishLocalStream({
element: 'NodeElement',
});
});
14. Local Stream Publish Successful
Description: This event is triggered after the local connect mic stream is successfully published. After triggering, the connect mic status becomes ConnectMicStatus.Connected.
Event: ConnectMicEvents.PublishStreamSuccess
Example:
watchCore.connectMic.eventEmitter.on(ConnectMicEvents.PublishStreamSuccess, () => {
toast.success('上麦成功');
const connectMicInfo = watchCore.connectMic.getConnectMicInfo();
console.log('连麦状态', connectMicInfo.connectMicStatus); // ConnectMicStatus.Connected
});
15. Leave Connect Mic Successful
Description: This event is triggered after the local connect mic stream leaves. After triggering, the connect mic status becomes ConnectMicStatus.NotConnect.
Event: ConnectMicEvents.LeaveConnectMicSuccess
Example:
watchCore.connectMic.eventEmitter.on(ConnectMicEvents.LeaveConnectMicSuccess, () => {
toast.success('你已下麦');
const connectMicInfo = watchCore.connectMic.getConnectMicInfo();
console.log('连麦状态', connectMicInfo.connectMicStatus); // ConnectMicStatus.NotConnect
});
16. Remote Connected User Microphone Toggle Change
Event: ConnectMicEvents.RemoteAudioMuteChange
Callback Parameters: Object object, detailed type description as follows
| Property | Description | Type |
|---|---|---|
micItem |
Connect mic user node | ConnectMicItem |
isAudioMuted |
Whether the microphone is muted | boolean |
17. Remote Connected User Camera Toggle Change
Event: ConnectMicEvents.RemoteVideoMuteChange
Callback Parameters: Object object, detailed type description as follows
| Property | Description | Type |
|---|---|---|
micItem |
Connect mic user node | ConnectMicItem |
isVideoMuted |
Whether the camera is turned off | boolean |
18. Local Microphone Toggle Change
Event: ConnectMicEvents.LocalAudioMuteChange
Callback Parameters: Object object, detailed type description as follows
| Property | Description | Type |
|---|---|---|
micItem |
Connect mic user node | ConnectMicItem |
isAudioMuted |
Whether the microphone is muted | boolean |
19. Local Camera Toggle Change
Event: ConnectMicEvents.LocalVideoMuteChange
Callback Parameters: Object object, detailed type description as follows
| Property | Description | Type |
|---|---|---|
micItem |
Connect mic user node | ConnectMicItem |
isVideoMuted |
Whether the camera is turned off | boolean |
20. Switch Primary View
Description: This event is triggered when the instructor switches the primary view.
Event: ConnectMicEvents.SwitchMaster
Callback Parameters: Object object, detailed type description as follows
| Property | Description | Type |
|---|---|---|
currentMaster |
The connect mic user node of the current primary view | ConnectMicItem |
previousMaster |
The previous connect mic user node | ConnectMicItem |
21. Screen Share Information Change
Description: This event is triggered when the screen share information changes.
Event: ConnectMicEvents.ScreenShareInfoChange
Callback Parameters: Object object, detailed type description as follows
| Property | Description | Type |
|---|---|---|
screenInfoChange |
Screen share information | ScreenShareInfo |
Example:
watchCore.connectMic.eventEmitter.on(ConnectMicEvents.ScreenShareInfoChange, () => {
const screenShareInfo = watchCore.connectMic.getScreenShareInfo();
console.log('屏幕共享信息改变', screenShareInfo);
});
22. Screen Share Start
Description: This event is triggered when a viewer starts screen sharing.
Event: ConnectMicEvents.ScreenShareStart
Example:
watchCore.connectMic.eventEmitter.on(ConnectMicEvents.ScreenShareStart, () => {
toast.info('你已进入屏幕共享');
});
23. Screen Share Stop
Description: This event is triggered when a viewer stops screen sharing.
Event: ConnectMicEvents.ScreenShareStop
Example:
watchCore.connectMic.eventEmitter.on(ConnectMicEvents.ScreenShareStart, () => {
toast.info('你已退出屏幕共享');
});
24. Hand-Raise Connect Mic Application Timeout
Description: This event is triggered when a viewer's hand-raise connect mic application times out.
Event: ConnectMicEvents.ApplyTimeOut
Example:
watchCore.connectMic.eventEmitter.on(ConnectMicEvents.ApplyTimeOut, () => {
toast.info('你已申请超时');
});
25. Front/Rear Camera Switch
Description: This event is triggered when switching between the front and rear cameras.
Event: ConnectMicEvents.FacingModeChange
Example:
watchCore.connectMic.eventEmitter.on(ConnectMicEvents.FacingModeChange, () => {
toast.info(watchCore.connectMic.getConnectMicInfo().facingMode);
});
26. User Stream Playback Failure
Description: This event is triggered when user stream playback fails.
Event: ConnectMicEvents.UserStreamPlayFailed
Callback Parameters: Object object, detailed type description as follows
| Property | Description | Type |
|---|---|---|
streamId |
Stream ID | string |
Example:
watchCore.connectMic.eventEmitter.on(ConnectMicEvents.UserStreamPlayFailed, (data) => {
toast.error('用户流播放失败');
});
27. Invitation to Go On Stage Countdown
Description: This event is triggered when the remaining time before automatic rejection changes after receiving an invitation from the instructor. Developers can use this to display a countdown in a custom invitation UI.
Event: ConnectMicEvents.InviteCountDown
Callback Parameters: InviteCountDownData
Example:
watchCore.connectMic.eventEmitter.on(ConnectMicEvents.InviteCountDown, (data) => {
console.log(`剩余 ${data.remain}s / 总 ${data.total}s`);
});
28. Local Audio/Video Toggle Change (Preset / Preview Stage)
Description: This event is triggered when the local camera or microphone toggle changes while not connected (preset / preview stage), for example, when modifying device toggles in the device detection panel. Developers can use this to synchronize the device button states of a custom connect mic panel.
Event: ConnectMicEvents.LocalMuteStatusChange
Callback Parameters: Object object, detailed type description as follows
| Property | Description | Type |
|---|---|---|
video |
Whether the camera is turned off | boolean |
audio |
Whether the microphone is muted | boolean |
Example:
watchCore.connectMic.eventEmitter.on(ConnectMicEvents.LocalMuteStatusChange, (data) => {
console.log('摄像头是否关闭:', data.video, '麦克风是否关闭:', data.audio);
});
