Interactive live broadcast

9.1 Get XHLiveManager instance and add the XHLiveManagerrDelegate event protocol function.


[[XHClient sharedClient].liveManager addDelegate:self];

/**
Someone has joined the live room to be a broadcaster
@param uid user ID
@param liveID live room ID
@return view for displaying the video of the joiner
*/
- (UIView *)onActorJoined:(NSString *)uid live:(NSString *)liveID
{
}

/**
Someone has left the live room

@param uid user ID
@param liveID live room ID
*/
- (void)onActorLeft:(NSString *)uid live:(NSString *)liveID
{
}
@optional

/**
Room creator received an application to join the live broadcast
@param uid user ID
@param liveID live room ID
*/
- (void)onApplyBroadcast:(NSString *)uid live:(NSString *)liveID
{
}
/**
Applicant receives the reply to join the live broadcast
@param result result
@param liveID live room ID
*/
- (void)onBroadcastResponsed:(XHLiveJoinResult)result live:(NSString *)liveID
{
}

/**
The viewer received an invitation to join the live broadcast
@param uid the user ID who invites you
@param liveID live room ID
*/
- (void)onInviteBroadcast:(NSString *)uid live:(NSString *)liveID
{
}
/**
The room creator received a reply from the user who is being invited
@param result result
@param liveID live room ID
*/
- (void)onInviteResponsed:(XHLiveJoinResult)result live:(NSString *)liveID
{
}

/**
*You are forced to stop live.
@param liveID live room ID
*/
- (void)onCommandToStopPlay:(NSString *)liveID
{
}

/**
Some abnormal conditions may cause the live to go wrong. Please leave the live broadcast after receiving the callback.
@param error error information
@param liveID live room ID
*/
- (void)onLiveError:(NSError *)error live:(NSString *)liveID
{
}

/**
The number of members has changed

@param membersNumber Number of members
*/
- (void)liveMembersNumberUpdated:(NSInteger)membersNumber
{
}
/**
You are kicked
*/
- (void)liveUserKicked
{
}
/**
Receive a message

@param message message
*/
- (void)liveMessageReceived:(NSString *)message fromID:(NSString *)fromID
{
}
/**
Receive a private message

@param message message
@param fromID message sender
*/
- (void)livePrivateMessageReceived:(NSString *)message fromID:(NSString *)fromID
{
}

/**
* Receive real-time data
* @param data data
* @param upId user ID
*/
- (void)onReceiveRealtimeData:(NSString *)data
upId:(NSString *)upId
{
}

9.2 XHLiveManager API Description

/**
Set video parameters

@param config parameters
*/
- (void)setVideoConfig:(XHVideoConfig *)config;

/**
Set callback delegate

@param delegate delegate
*/
- (void)addDelegate:(id<XHLiveManagerDelegate>)delegate;

/**
* Set media type
* @param mediaType type
*/
- (void)setRtcMediaType:(XHRtcMediaTypeEnum) mediaType;


/**
Create a live room

@param liveItem the live room information
@param completion callback
*/
- (void)createLive:(XHLiveItem *)liveItem completion:(void(^)(NSString *liveID, NSError *error))completion;

/**
Start a live room

@param liveID live room ID
@param completion callback
*/
- (void)startLive:(NSString *)liveID completion:(void(^)(NSError *error))completion;

/**
Watch the live room

@param liveID live room ID
@param completion callback
*/
- (void)watchLive:(NSString *)liveID completion:(void(^)(NSError *error))completion;

/**
Audience apply to be a broadcaster

@param toID The creater ID
@param completion callback
*/
- (void)applyToBroadcaster:(NSString *)toID
completion:(void(^)(NSError *error))completion;

/**
The creater agrees to be a broadcaster
@param toID The user who the creater agrees to be a broadcaster
@param completion callback
*/
- (void)agreeApplyToBroadcaster:(NSString *)toID
completion:(void(^)(NSError *error))completion;

/**
The creater refuses someone to be a broadcaster

@param toID The user who the creater refuses to be a broadcaster
@param completion callback
*/
- (void)refuseApplyToBroadcaster:(NSString *)toID
completion:(void(^)(NSError *error))completion;

/**
The creater invites someone to be a broadcaster

@param toID the Invitee ID
@param completion callback
*/
- (void)inviteToBroadcaster:(NSString *)toID
completion:(void(^)(NSError *error))completion;

/**
The audience has agreed to be a broadcaster

@param toID Inviter ID
@param completion callback
*/
- (void)agreeInviteToBroadcaster:(NSString *)toID
completion:(void(^)(NSError *error))completion;

/**
The audience has refused to be a broadcaster

@param toID Inviter ID
@param completion callback
*/
- (void)refuseInviteToBroadcaster:(NSString *)toID
completion:(void(^)(NSError *error))completion;


/**
Stop to be a broadcaster

@param toID someone who will be stopped to be a broadcaster
@param completion callback
*/
- (void)
- :(NSString *)toID
completion:(void(^)(NSError *error))completion;


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

/**
An audience change to be a broadcaster
*/
- (void)changeToBroadcaster;


/**
Leave the live room

@param liveID live room ID
@param completion callback
*/
- (void)leaveLive:(NSString *)liveID completion:(void(^)(NSError *error))completion;

/**
Switch camera direction

@return Camera orientation after switching
*/
- (XHCameraDirection)switchCamera;

/**
Switch to the big video preview

@param view the preview which will be switched
*/
- (void)changeToBig:(UIView *)view;


/**
Switch to the small video preview
@param view the preview which will be switched
*/
- (void)changeToSmall:(UIView *)view;


/**
send a message

@param message message
@param completion callback
*/
- (void)sendMessage:(NSString *)message completion:(void(^)(NSError *error))completion;

/**
send a private message

@param message message
@param toID receiver ID
@param completion callback
*/
- (void)sendMessage:(NSString *)message toID:(NSString *)toID completion:(void(^)(NSError *error))completion;

/**
mute somebody in the live room

@param member the member who is mute
@param seconds mute time
@param liveId live room id
@param completion callback
*/
- (void)muteMember:(NSString *)member
muteSeconds:(NSInteger)seconds
fromLive:(NSString *)liveId
completion:(void(^)(NSError *error))completion;

/**
unmute somebody in the chatroom

@param member the member who is unmute
@param liveId live room id
@param completion callback
*/
- (void)unMuteMember:(NSString *)member
fromLive:(NSString *)liveId
completion:(void(^)(NSError *error))completion;

/**
kick a member

@param member the member who is kicked
@param liveId live room id
@param completion callback
*/
- (void)kickMember:(NSString *)member
fromLive:(NSString *)liveId
completion:(void(^)(NSError *error))completion;