logo
当前页

Event

ZegoUIKitPrebuiltLiveStreamingService.PK.Event

PKListener

onPKStarted

当 PK 连麦开始时,将触发此回调。

  • 函数原型:

    Untitled
    void onPKStarted();
    
    1
    Copied!
  • 示例:

    Untitled
    ZegoUIKitPrebuiltLiveStreamingService.pk.events.addPKListener(new PKListener() {
        @Override
        public void onPKStarted() {
            //...  
        }
    //...
    });
    
    1
    Copied!

onPKEnded

当 PK 连麦结束时,将触发此回调。

  • 函数原型:

    Untitled
    void onPKEnded();
    
    1
    Copied!
  • 示例:

    Untitled
    ZegoUIKitPrebuiltLiveStreamingService.pk.events.addPKListener(new PKListener() {
        @Override
        public void onPKEnded() {
            //...  
        }
        //...
    });
    
    1
    Copied!

onIncomingPKBattleRequestReceived

当主播接收到PK战斗请求时,将触发此回调。

  • 函数原型:

    Untitled
    void onIncomingPKBattleRequestReceived(String requestID, ZegoUIKitUser anotherHostUser,String anotherHostLiveID, String customData);
    
    1
    Copied!
  • 示例:

    Untitled
    ZegoUIKitPrebuiltLiveStreamingService.pk.events.addPKListener(new PKListener() {
        @Override
        public void onIncomingPKBattleRequestReceived(String requestID, ZegoUIKitUser anotherHostUser,String anotherHostLiveID, String customData) {
            //...  
        }
        //...
    });
    
    1
    Copied!

onIncomingPKBattleRequestTimeout

当接收到 PK 连麦请求,且在请求超时之前没有回复时,将触发此回调。

  • 函数原型:

    Untitled
    void onIncomingPKBattleRequestTimeout(String requestID, ZegoUIKitUser anotherHostUser);
    
    1
    Copied!
  • 示例:

    Untitled
    ZegoUIKitPrebuiltLiveStreamingService.pk.events.addPKListener(new PKListener() {
        @Override
        public void onIncomingPKBattleRequestTimeout(String requestID, ZegoUIKitUser anotherHostUser) {
            //...  
        }
        //...
    });
    
    1
    Copied!

onOutgoingPKBattleRequestTimeout

当发送 PK 连麦请求后,在超时之前未收到响应时,将触发此回调。

  • 函数原型:

    Untitled
    void onOutgoingPKBattleRequestTimeout(String requestID, ZegoUIKitUser anotherHostUser);
    
    1
    Copied!
  • 示例:

    Untitled
    ZegoUIKitPrebuiltLiveStreamingService.pk.events.addPKListener(new PKListener() {
        @Override
        public void onOutgoingPKBattleRequestTimeout(String requestID, ZegoUIKitUser anotherHostUser) {
            //...  
        }
        //...
    });
    
    1
    Copied!

onIncomingPKBattleRequestCanceled

当接收到 PK 连麦请求后,发送者取消请求时,将触发此回调。

  • 函数原型:

    Untitled
    void onIncomingPKBattleRequestCanceled(String requestID, ZegoUIKitUser anotherHostUser, String customData);
    
    1
    Copied!
  • 示例:

    Untitled
    ZegoUIKitPrebuiltLiveStreamingService.pk.events.addPKListener(new PKListener() {
        @Override
        public void onIncomingPKBattleRequestCanceled(String requestID, ZegoUIKitUser anotherHostUser, String customData) {
            //...  
        }
        //...
    });
    
    1
    Copied!

onOutgoingPKBattleRequestAccepted

当发送 PK 战斗请求后,另一主播接受请求时,将触发此回调。

  • 函数原型:

    Untitled
    void onOutgoingPKBattleRequestAccepted(String requestID, ZegoUIKitUser anotherHostUser);
    
    1
    Copied!
  • 示例:

    Untitled
    ZegoUIKitPrebuiltLiveStreamingService.pk.events.addPKListener(new PKListener() {
        @Override
        public void onOutgoingPKBattleRequestAccepted(String requestID, ZegoUIKitUser anotherHostUser) {
            //...  
        }
        //...
    });
    
    1
    Copied!

onOutgoingPKBattleRequestRejected

当发送 PK 连麦请求后,另一主播拒绝请求时,将触发此回调。拒绝原因可以是 ZegoLiveStreamingPKBattleRejectCode 任意枚举,包括 HOST_REJECTUSER_NOT_HOSTIN_PKLIVE_NOT_STARTEDALREADY_SENDALREADY_RECEIVED

  • 函数原型:

    Untitled
    void onOutgoingPKBattleRequestRejected(int reason, ZegoUIKitUser anotherHostUser);
    
    1
    Copied!
  • 示例:

    Untitled
    ZegoUIKitPrebuiltLiveStreamingService.pk.events.addPKListener(new PKListener() {
        @Override
        public void onOutgoingPKBattleRequestRejected(int reason, ZegoUIKitUser anotherHostUser) {
            //...  
        }
        //...
    });
    
    1
    Copied!

onPKUserDisConnected

当您正在 PK 连麦中,另一主播断开连接超过 5 秒时,将触发此回调。

  • 函数原型:

    Untitled
    void onPKUserDisConnected(String userID, boolean disconnected);
    
    1
    Copied!
  • 示例:

    Untitled
    ZegoUIKitPrebuiltLiveStreamingService.pk.events.addPKListener(new PKListener() {
        @Override
        public void onPKUserDisConnected(String userID, boolean disconnected) {
            //...  
        }
        //...
    });
    
    1
    Copied!

onOtherHostCameraOpen

PK的时候,其他主播打开或者关闭摄像头的状态回调

  • 函数原型:

    Untitled
    void onOtherHostCameraOpen(String userID, boolean open);
    
    1
    Copied!
  • 示例:

    Untitled
    ZegoUIKitPrebuiltLiveStreamingService.pk.events.addPKListener(new PKListener() {
        @Override
        public void onOtherHostCameraOpen(String userID, boolean open) {
            //...  
        }
        //...
    });
    
    1
    Copied!

onOtherHostMicrophoneOpen

PK的时候,其他主播打开或者关闭麦克风的状态回调

  • 函数原型:

    Untitled
    void onOtherHostMicrophoneOpen(String userID, boolean open);
    
    1
    Copied!
  • 示例:

    Untitled
    ZegoUIKitPrebuiltLiveStreamingService.pk.events.addPKListener(new PKListener() {
        @Override
        public void onOtherHostMicrophoneOpen(String userID, boolean open) {
            //...  
        }
        //...
    });
    
    1
    Copied!

onOtherHostMuted

PK的时候,自己把其他主播静音后收到的回调

  • 函数原型:

    Untitled
    void onOtherHostMuted(String userID, boolean muted);
    
    1
    Copied!
  • 示例:

    Untitled
    ZegoUIKitPrebuiltLiveStreamingService.pk.events.addPKListener(new PKListener() {
        @Override
        public void onOtherHostMuted(String userID, boolean muted) {
            //...  
        }
        //...
    });
    
    1
    Copied!

ZegoUIKitPrebuiltLiveStreamingService.Common.Event

RoleChangedListener

当自己的角色发生变化的时候,会触发此回调

  • 函数原型:

    Untitled
    public interface RoleChangedListener {
    
        void onRoleChanged(ZegoLiveStreamingRole liveStreamingRole);
    }
    
    
    1
    Copied!
  • 示例:

    Untitled
    ZegoUIKitPrebuiltLiveStreamingService.common.events.addRoleChangedListener(new RoleChangedListener() {
        @Override
        public void onRoleChanged(ZegoLiveStreamingRole liveStreamingRole){
            //...  
        }
        //...
    });
    
    1
    Copied!

ZegoInRoomMessageListener

房间内消息的相关回调监听。收到房间内消息或者发送房间内消息的时候会触发此回调

  • 函数原型:

    Untitled
    public interface ZegoInRoomMessageListener {
        // 收到房间内别人发的消息
        void onInRoomMessageReceived(List<ZegoInRoomMessage> messageList);
        // 自己发送的消息状态变更
        void onInRoomMessageSendingStateChanged(ZegoInRoomMessage inRoomMessage);
    }
    
    
    1
    Copied!
  • 示例:

    Untitled
    ZegoUIKitPrebuiltLiveStreamingService.common.events.addInRoomMessageListener(new ZegoInRoomMessageListener() {
        @Override
        public void onInRoomMessageReceived(List<ZegoInRoomMessage> messageList){
            //...  
        }
    
        @Override
        public void onInRoomMessageSendingStateChanged(ZegoInRoomMessage inRoomMessage){
            //...  
        }
        //...
    });
    
    1
    Copied!

ZegoBarrageMessageListener

收到房间内弹幕消息的时候,会触发此回调

  • 函数原型:

    Untitled
    public interface ZegoBarrageMessageListener {
    
        void onIMRecvBarrageMessage(String roomID, ArrayList<ZegoBarrageMessageInfo> messageList);
    }
    
    
    1
    Copied!
  • 示例:

    Untitled
    ZegoUIKitPrebuiltLiveStreamingService.common.events.addBarrageMessageListener(new ZegoBarrageMessageListener() {
        @Override
        public void onIMRecvBarrageMessage(String roomID, ArrayList<ZegoBarrageMessageInfo> messageList){
            //...  
        }
        //...
    });
    
    1
    Copied!

ZegoUIKitPrebuiltLiveStreamingConfig

ZegoLiveStreamingEndListener

onLiveStreamingEnded

当主播结束直播时,将触发此回调,用于通知观众。

  • 函数原型:

    Untitled
    void onLiveStreamingEnded();
    
    1
    Copied!
  • 示例:

    Untitled
    ZegoUIKitPrebuiltLiveStreamingConfig config;
    //...
    config.zegoLiveStreamingEndListener = new ZegoLiveStreamingEndListener() {
        @Override
        public void onLiveStreamingEnded() {
        
        }
    };
    
    1
    Copied!

ZegoLeaveLiveStreamingListener

onLeaveLiveStreaming

当用户点击退出按钮时,将触发此回调。

  • 函数原型:

    Untitled
    void onLeaveLiveStreaming();
    
    1
    Copied!
  • 示例:

    Untitled
    ZegoUIKitPrebuiltLiveStreamingConfig config;
    //...
    config.leaveLiveStreamingListener = new ZegoLeaveLiveStreamingListener() {
        @Override
        public void onLeaveLiveStreaming() {
        
        }
    };
    
    1
    Copied!

ZegoMeRemovedFromRoomListener

onMeRemovedFromRoom

当自己被服务器命令或ZegoUIKit.removeUserFromRoom()方法踢出房间时,将触发此回调。

  • 函数原型:

    Untitled
    void onMeRemovedFromRoom();
    
    1
    Copied!
  • 示例:

    Untitled
    ZegoUIKitPrebuiltLiveStreamingConfig config;
    //...
    config.removedFromRoomListener = new ZegoMeRemovedFromRoomListener() {
        @Override
        public void onMeRemovedFromRoom() {
        
        }
    };
    
    1
    Copied!

Previous

API

Next

Config