Event
ZegoUIKitPrebuiltLiveStreamingService.PK.Event
PKListener
onPKStarted
当 PK 连麦开始时,将触发此回调。
-
函数原型:
Untitledvoid onPKStarted();
1 -
示例:
UntitledZegoUIKitPrebuiltLiveStreamingService.pk.events.addPKListener(new PKListener() { @Override public void onPKStarted() { //... } //... });
1
onPKEnded
当 PK 连麦结束时,将触发此回调。
-
函数原型:
Untitledvoid onPKEnded();
1 -
示例:
UntitledZegoUIKitPrebuiltLiveStreamingService.pk.events.addPKListener(new PKListener() { @Override public void onPKEnded() { //... } //... });
1
onIncomingPKBattleRequestReceived
当主播接收到PK战斗请求时,将触发此回调。
-
函数原型:
Untitledvoid onIncomingPKBattleRequestReceived(String requestID, ZegoUIKitUser anotherHostUser,String anotherHostLiveID, String customData);
1 -
示例:
UntitledZegoUIKitPrebuiltLiveStreamingService.pk.events.addPKListener(new PKListener() { @Override public void onIncomingPKBattleRequestReceived(String requestID, ZegoUIKitUser anotherHostUser,String anotherHostLiveID, String customData) { //... } //... });
1
onIncomingPKBattleRequestTimeout
当接收到 PK 连麦请求,且在请求超时之前没有回复时,将触发此回调。
-
函数原型:
Untitledvoid onIncomingPKBattleRequestTimeout(String requestID, ZegoUIKitUser anotherHostUser);
1 -
示例:
UntitledZegoUIKitPrebuiltLiveStreamingService.pk.events.addPKListener(new PKListener() { @Override public void onIncomingPKBattleRequestTimeout(String requestID, ZegoUIKitUser anotherHostUser) { //... } //... });
1
onOutgoingPKBattleRequestTimeout
当发送 PK 连麦请求后,在超时之前未收到响应时,将触发此回调。
-
函数原型:
Untitledvoid onOutgoingPKBattleRequestTimeout(String requestID, ZegoUIKitUser anotherHostUser);
1 -
示例:
UntitledZegoUIKitPrebuiltLiveStreamingService.pk.events.addPKListener(new PKListener() { @Override public void onOutgoingPKBattleRequestTimeout(String requestID, ZegoUIKitUser anotherHostUser) { //... } //... });
1
onIncomingPKBattleRequestCanceled
当接收到 PK 连麦请求后,发送者取消请求时,将触发此回调。
-
函数原型:
Untitledvoid onIncomingPKBattleRequestCanceled(String requestID, ZegoUIKitUser anotherHostUser, String customData);
1 -
示例:
UntitledZegoUIKitPrebuiltLiveStreamingService.pk.events.addPKListener(new PKListener() { @Override public void onIncomingPKBattleRequestCanceled(String requestID, ZegoUIKitUser anotherHostUser, String customData) { //... } //... });
1
onOutgoingPKBattleRequestAccepted
当发送 PK 战斗请求后,另一主播接受请求时,将触发此回调。
-
函数原型:
Untitledvoid onOutgoingPKBattleRequestAccepted(String requestID, ZegoUIKitUser anotherHostUser);
1 -
示例:
UntitledZegoUIKitPrebuiltLiveStreamingService.pk.events.addPKListener(new PKListener() { @Override public void onOutgoingPKBattleRequestAccepted(String requestID, ZegoUIKitUser anotherHostUser) { //... } //... });
1
onOutgoingPKBattleRequestRejected
当发送 PK 连麦请求后,另一主播拒绝请求时,将触发此回调。拒绝原因可以是 ZegoLiveStreamingPKBattleRejectCode
任意枚举,包括 HOST_REJECT
、USER_NOT_HOST
、IN_PK
、LIVE_NOT_STARTED
、ALREADY_SEND
、ALREADY_RECEIVED
。
-
函数原型:
Untitledvoid onOutgoingPKBattleRequestRejected(int reason, ZegoUIKitUser anotherHostUser);
1 -
示例:
UntitledZegoUIKitPrebuiltLiveStreamingService.pk.events.addPKListener(new PKListener() { @Override public void onOutgoingPKBattleRequestRejected(int reason, ZegoUIKitUser anotherHostUser) { //... } //... });
1
onPKUserDisConnected
当您正在 PK 连麦中,另一主播断开连接超过 5 秒时,将触发此回调。
-
函数原型:
Untitledvoid onPKUserDisConnected(String userID, boolean disconnected);
1 -
示例:
UntitledZegoUIKitPrebuiltLiveStreamingService.pk.events.addPKListener(new PKListener() { @Override public void onPKUserDisConnected(String userID, boolean disconnected) { //... } //... });
1
onOtherHostCameraOpen
PK的时候,其他主播打开或者关闭摄像头的状态回调
-
函数原型:
Untitledvoid onOtherHostCameraOpen(String userID, boolean open);
1 -
示例:
UntitledZegoUIKitPrebuiltLiveStreamingService.pk.events.addPKListener(new PKListener() { @Override public void onOtherHostCameraOpen(String userID, boolean open) { //... } //... });
1
onOtherHostMicrophoneOpen
PK的时候,其他主播打开或者关闭麦克风的状态回调
-
函数原型:
Untitledvoid onOtherHostMicrophoneOpen(String userID, boolean open);
1 -
示例:
UntitledZegoUIKitPrebuiltLiveStreamingService.pk.events.addPKListener(new PKListener() { @Override public void onOtherHostMicrophoneOpen(String userID, boolean open) { //... } //... });
1
onOtherHostMuted
PK的时候,自己把其他主播静音后收到的回调
-
函数原型:
Untitledvoid onOtherHostMuted(String userID, boolean muted);
1 -
示例:
UntitledZegoUIKitPrebuiltLiveStreamingService.pk.events.addPKListener(new PKListener() { @Override public void onOtherHostMuted(String userID, boolean muted) { //... } //... });
1
ZegoUIKitPrebuiltLiveStreamingService.Common.Event
RoleChangedListener
当自己的角色发生变化的时候,会触发此回调
-
函数原型:
Untitledpublic interface RoleChangedListener { void onRoleChanged(ZegoLiveStreamingRole liveStreamingRole); }
1 -
示例:
UntitledZegoUIKitPrebuiltLiveStreamingService.common.events.addRoleChangedListener(new RoleChangedListener() { @Override public void onRoleChanged(ZegoLiveStreamingRole liveStreamingRole){ //... } //... });
1
ZegoInRoomMessageListener
房间内消息的相关回调监听。收到房间内消息或者发送房间内消息的时候会触发此回调
-
函数原型:
Untitledpublic interface ZegoInRoomMessageListener { // 收到房间内别人发的消息 void onInRoomMessageReceived(List<ZegoInRoomMessage> messageList); // 自己发送的消息状态变更 void onInRoomMessageSendingStateChanged(ZegoInRoomMessage inRoomMessage); }
1 -
示例:
UntitledZegoUIKitPrebuiltLiveStreamingService.common.events.addInRoomMessageListener(new ZegoInRoomMessageListener() { @Override public void onInRoomMessageReceived(List<ZegoInRoomMessage> messageList){ //... } @Override public void onInRoomMessageSendingStateChanged(ZegoInRoomMessage inRoomMessage){ //... } //... });
1
ZegoBarrageMessageListener
收到房间内弹幕消息的时候,会触发此回调
-
函数原型:
Untitledpublic interface ZegoBarrageMessageListener { void onIMRecvBarrageMessage(String roomID, ArrayList<ZegoBarrageMessageInfo> messageList); }
1 -
示例:
UntitledZegoUIKitPrebuiltLiveStreamingService.common.events.addBarrageMessageListener(new ZegoBarrageMessageListener() { @Override public void onIMRecvBarrageMessage(String roomID, ArrayList<ZegoBarrageMessageInfo> messageList){ //... } //... });
1
ZegoUIKitPrebuiltLiveStreamingConfig
ZegoLiveStreamingEndListener
onLiveStreamingEnded
当主播结束直播时,将触发此回调,用于通知观众。
-
函数原型:
Untitledvoid onLiveStreamingEnded();
1 -
示例:
UntitledZegoUIKitPrebuiltLiveStreamingConfig config; //... config.zegoLiveStreamingEndListener = new ZegoLiveStreamingEndListener() { @Override public void onLiveStreamingEnded() { } };
1
ZegoLeaveLiveStreamingListener
onLeaveLiveStreaming
当用户点击退出按钮时,将触发此回调。
-
函数原型:
Untitledvoid onLeaveLiveStreaming();
1 -
示例:
UntitledZegoUIKitPrebuiltLiveStreamingConfig config; //... config.leaveLiveStreamingListener = new ZegoLeaveLiveStreamingListener() { @Override public void onLeaveLiveStreaming() { } };
1
ZegoMeRemovedFromRoomListener
onMeRemovedFromRoom
当自己被服务器命令或ZegoUIKit.removeUserFromRoom()方法踢出房间时,将触发此回调。
-
函数原型:
Untitledvoid onMeRemovedFromRoom();
1 -
示例:
UntitledZegoUIKitPrebuiltLiveStreamingConfig config; //... config.removedFromRoomListener = new ZegoMeRemovedFromRoomListener() { @Override public void onMeRemovedFromRoom() { } };
1