Interactive live broadcast

9.1 Get an XHLiveManager instance and add a live event listener

XHLiveManager liveManager = XHClient.getInstance().getLiveManager(this);
liveManager.addListener(new IXHLiveManagerListener() {
@Override
public void onActorJoined(String liveID, String actorID) {
// Someone has joined the live room
}

@Override
public void onActorLeft(String liveID, String actorID) {
//Someone has left the live room
}

@Override
public void onApplyBroadcast(String liveID, String applyUserID) {
//Room creator received an application to join the live room
}

@Override
public void onApplyResponsed(String liveID, XHConstants.XHLiveJoinResult result) {
//Applicant receives the reply to join the live broadcast
}

@Override
public void onInviteBroadcast(String liveID, String applyUserID) {
// The viewer received an invitation to join the live stream
}

@Override
public void onInviteResponsed(String liveID, XHConstants.XHLiveJoinResult result) {
// The room creator received a reply from the user who is being invited
}

@Override
public void onLiveError(String liveID, String error) {
// Some abnormal conditions may cause the live to go wrong
}

@Override
public void onMembersUpdated(int membersNumber) {
//he number of members has changed
}

@Override
public void onSelfKicked() {
// You are kicked You are kicked
}

@Override
public void onSelfMuted(int seconds) {
//You are muted
}

@Override
public void onCommandToStopPlay(String liveID) {
//You are forced to stop live.
}

@Override
public void onReceivedMessage(XHIMMessage message) {
// Receive a message
}

@Override
public void onReceivePrivateMessage(XHIMMessage message) {
// Receive a private message
}

@Override
public void onReceiveRealtimeData(byte[] data, String upId) {
//Receive real-time data
}
});

9.2 XHLiveManager API Description

/**
* Add the live event listener
* @param liveManagerListener IXHLiveManagerListener Receive live event related events
*/
void addListener(IXHLiveManagerListener liveManagerListener);

/**
* Set the media type
* @param mediaTypeEnum Audio and video exist at the same time, or only one of them is turned on.
*/
void setRtcMediaType(XHConstants.XHRtcMediaTypeEnum mediaTypeEnum);

/**
* Create a live room
* @param liveItem XHLiveItem Specify the Live name and type
* @param callback Result callback
*/
void createLive(XHLiveItem liveItem,IXHResultCallback callback);

/**
* start a live room
* @param liveID live room ID
* @param callback Result callback. The sessionid will be returned upon success, which is used for query of recording records on the server.
*/
void startLive(String liveID,IXHResultCallback callback);

/**
* watch the live room
* @param liveID live room ID
* @param callback Result callback
*/
void watchLive(String liveID,IXHResultCallback callback);

/**
* A view that specifies the display for the meeting participants
* @param userID User ID
* @param player StarPlayer for displaying the view
* @param isBig Set whether to display a large image of the anchor
*/
void attachPlayerView(String userID,StarPlayer player,Boolean isBig);

/**
* Audience apply to be an broadcaster
* @param toID The broadcaster ID
*/
void applyToBroadcaster(String toID);

/**
* The creater agrees to be a broadcaster
* @param toID the user who the creater agrees to be a broadcaster
*/
void agreeApplyToBroadcaster(String toID);

/**
* The creater refuses to be a broadcaster
* @param toID the user who the creater agrees to be a broadcaster
*/
void refuseApplyToBroadcaster(String toID);

/**
* the creater invites someone to be a broadcaster
* @param toID the Invitee ID
*/
void inviteToBroadcaster(String toID);

/**
* The audience has agreed to be a broadcaster
* @param toID Inviter ID
*/
void agreeInviteToBroadcaster(String toID);

/**
* The audience has refused to be a broadcaster
* @param toID Inviter ID
*/
void refuseInviteToBroadcaster(String toID);

/**
* stop to be a broadcaster
* @param toID someone who will be stopped to be a broadcaster
*/
void commandToAudience (String toID);

/**
* A broadcaster changes to be an audience
*/
void changeToAudience(IXHResultCallback callback);

/**
* A broadcaster changes to be an audience
* @param callback Result callback. The sessionid will be returned upon success, which is used for query of recording records on the server.
*/
void changeToBroadcaster(IXHResultCallback callback);

/**
* Leave the live room
* @param callback result callback
*/
void leaveLive(IXHResultCallback callback);

/**
* Switch camera direction
*/
void switchCamera();

/**
* Switch camera direction
* @param cameraId Specified camera ID
*/
void switchCamera(int cameraId);

/**
* Switch to the big video preview
* @param userID Switch to the large image of the user ID
*/
void changeToBig(String userID);

/**
* Switch to the small video preview
* @param userID Switch to the small image of the user ID
*/
void changeToSmall(String userID);

/**
* Dynamically switch audio:the audio can be switched at any time during the live broadcast, and the status is automatically reset after the live broadcast ends.
*/
void setAudioEnable(Boolean enable);

/**
* Dynamically switch video:the video can be switched at any time during the live broadcast, and the status is automatically reset after the live broadcast ends.
*/
void setVideoEnable(Boolean enable);

/**
* send a message
* @param message message
* @param callback Result callback
* @return Return the sent message object
*/
XHIMMessage sendMessage(String message, IXHResultCallback callback);

/**
* Send a private message
* Private messages can only be received by the target user
* @param message message
* @param toID Target user ID
* @param callback Result callback
* @return Return the sent message object
*/
XHIMMessage sendPrivateMessage(String toID, String message, IXHResultCallback callback);

/**
* mute somebody in the live room
* @param memberID the member who is mute
* @param muteSeconds mute time
* @param callback Result callback
*/
void muteMember(String memberID, int muteSeconds, IXHResultCallback callback);

/**
* unmute somebody in the live room
* @param memberID the member who is unmute
* @param callback Result callback
*/
void unMuteMember(String memberID,IXHResultCallback callback);

/**
* kick out users in the live room
* @param memberID the member who is being kicked out
* @param callback Result callback
*/
void kickMember(String memberID, IXHResultCallback callback);


/**
* Push RTMP stream
* @param rtmpurl Push address
* @param callback Result callback
*/
void pushRtmp(String rtmpurl,IXHResultCallback callback);

/**
* Stop pushing RTMP stream
* @param callback Result callback
*/
void stopPushRtmp(IXHResultCallback callback);


/**
* Set recorder
* @param recorder
*/
void setRecorder(IXHRecorder recorder);

/**
* Switch recorder
* @param recorder
*/
void resetRecorder(IXHRecorder recorder);

/**
* Send the real-time data
* @param data data array
*/
void sendRealtimeData(byte[] data);