logo
On this page

Event

ZegoUIKitPrebuiltLiveStreamingService.PK.Event

PKListener

onPKStarted

This callback is triggered when the PK starts.

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

onPKEnded

This callback is triggered when the PK ends.

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

onIncomingPKBattleRequestReceived

This callback is triggered when the host receives a PK battle request.

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

onIncomingPKBattleRequestTimeout

This callback is triggered when a PK request is received, but no response is made before the request times out.

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

onOutgoingPKBattleRequestTimeout

This callback is triggered when a PK battle request is sent but no response is received before the timeout.

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

onIncomingPKBattleRequestCanceled

This callback is triggered when the sender cancels the PK battle request after receiving it.

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

onOutgoingPKBattleRequestAccepted

This callback is triggered when the PK battle request sent by the host is accepted by another host.

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

onOutgoingPKBattleRequestRejected

This callback is triggered when the PK battle request sent by the host is rejected by another host. The rejection reason can be any enumeration of ZegoLiveStreamingPKBattleRejectCode, including HOST_REJECT, USER_NOT_HOST, IN_PK, LIVE_NOT_STARTED, ALREADY_SEND, ALREADY_RECEIVED.

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

onPKUserDisConnected

This callback is triggered when the other host disconnects from the PK battle for more than 5 seconds.

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

onOtherHostCameraOpen

When PK, the callback for the status of other hosts opening or closing the camera.

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

onOtherHostMicrophoneOpen

When PK, the callback for the status of other hosts opening or closing the microphone.

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

onOtherHostMuted

When PK, the callback for receiving the mute status after muting other hosts.

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

ZegoUIKitPrebuiltLiveStreamingService.Common.Event

RoleChangedListener

This callback is triggered when there is a change in the role of the current user.

Prototype
Example
public interface RoleChangedListener {

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

ZegoInRoomMessageListener

This callback is used to listen for room messages. It is triggered when receiving or sending room messages.

Prototype
Example
public interface ZegoInRoomMessageListener {
    // Receive messages sent by others in the room
    void onInRoomMessageReceived(List<ZegoInRoomMessage> messageList);
    // The state of the message sent by oneself changes
    void onInRoomMessageSendingStateChanged(ZegoInRoomMessage inRoomMessage);
}
1
Copied!
ZegoUIKitPrebuiltLiveStreamingService.common.events.addInRoomMessageListener(new ZegoInRoomMessageListener() {
    @Override
    public void onInRoomMessageReceived(List<ZegoInRoomMessage> messageList){
        //...  
    }

    @Override
    public void onInRoomMessageSendingStateChanged(ZegoInRoomMessage inRoomMessage){
        //...  
    }
    //...
});
1
Copied!

ZegoBarrageMessageListener

This callback is triggered when receiving barrage messages in the room.

Prototype
Example
public interface ZegoBarrageMessageListener {

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

ZegoUIKitPrebuiltLiveStreamingConfig

ZegoLiveStreamingEndListener

onLiveStreamingEnded

This callback is triggered when the host ends the live streaming to notify the audience.

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

ZegoLeaveLiveStreamingListener

onLeaveLiveStreaming

This callback is triggered when the user clicks the exit button.

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

ZegoMeRemovedFromRoomListener

onMeRemovedFromRoom

This callback is triggered when the user is kicked out of the room by the server command or the ZegoUIKit.removeUserFromRoom() method.

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