Polyv Help Center

Help Center

Module Events

Updated: 2024-10-10 17:27:10

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. Instructor Enables Connect Mic Feature

Description: This event is triggered after the instructor enables the connect mic feature. Once enabled, the connect mic feature 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-miniprogram-sdk';
watchCore.connectMic.eventEmitter.on(ConnectMicEvents.OpenConnectMic, (data) => {
  const type = data.type === ConnectMicType.Video ? '视频' : '音频';
  toast.info(`讲师开启了${type}连麦,赶快和主播连麦互动吧~`);
});

3. 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-miniprogram-sdk';
watchCore.connectMic.eventEmitter.on(ConnectMicEvents.CloseConnectMic, (data) => {
  const type = data.type === ConnectMicType.Video ? '视频' : '音频';
  toast.info(`讲师已结束${type}连麦`);
});

4. Connect Mic Status Update

Event: ConnectMicEvents.ConnectMicStatusChange

Callback Parameters: Object object, detailed type description as follows

Property Description Type
connectMicStatus Connect mic status update ConnectMicStatus

5. Connect Mic List Modification

Description: When a viewer goes on/off stage or a user stream joins/exits, the connect mic list changes. Listen for updates to the connect mic user list through this event.

Event: ConnectMicEvents.ConnectMicDataChange

Callback Parameters: Object object, detailed type description as follows

Property Description Type
micDatas Connect mic list ConnectMicItemData[]

Example:

watchCore.connectMic.eventEmitter.on(ConnectMicEvents.ConnectMicDataChange, () => {
  const connectMicList = watchCore.connectMic.getMicDatas();
  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. Connect Mic User Limit Reached

Description: When a viewer clicks to accept an invitation to go on stage, the connection may fail because the user limit 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('连麦失败,连麦人数已到达上限');
});

8. Current Speaker Status Changed

Description: This event is triggered when the instructor grants/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('讲师已收回您的主讲权限');
  }
});

9. Instructor Approves Connect Mic Request

Description: This event is triggered when a viewer requests to connect and the instructor approves the request.

Event: ConnectMicEvents.AllowConnectMicApply

Example:

watchCore.connectMic.eventEmitter.on(ConnectMicEvents.AllowConnectMicApply, (data) => {
  toast.success('讲师已同意你的连麦申请');
});

10. Remote Connected User Microphone Toggle Changed

Event: ConnectMicEvents.RemoteAudioMuteChange

Callback Parameters: Object object, detailed type description as follows

Property Description Type
isAudioMuted Whether the microphone is muted boolean

11. Remote Connected User Camera Toggle Changed

Event: ConnectMicEvents.RemoteVideoMuteChange

Callback Parameters: Object object, detailed type description as follows

Property Description Type
isVideoMuted Whether the camera is turned off boolean

12. Local Microphone Toggle Changed

Event: ConnectMicEvents.LocalAudioMuteChange

Callback Parameters: Object object, detailed type description as follows

Property Description Type
isAudioMuted Whether the microphone is muted boolean

13. Local Camera Toggle Changed

Event: ConnectMicEvents.LocalVideoMuteChange

Callback Parameters: Object object, detailed type description as follows

Property Description Type
isVideoMuted Whether the camera is turned off boolean

14. 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.conncetMicStatus); // ConnectMicStatus.NotConnect
});
联系客服,在线咨询
在线咨询