|
@@ -103,7 +103,7 @@ typedef NS_ENUM(NSInteger, MICSTATUS) {
|
|
|
|
|
|
@property (nonatomic, assign) BOOL isImConnected;
|
|
|
|
|
|
-/// 主讲人是否在房间
|
|
|
+/// 老师是否在房间
|
|
|
@property (nonatomic, assign) BOOL isCreaterInRoom;
|
|
|
|
|
|
@property (nonatomic, assign) BOOL isCreaterVideoEnable;
|
|
@@ -149,6 +149,8 @@ typedef NS_ENUM(NSInteger, MICSTATUS) {
|
|
|
|
|
|
@property (nonatomic, strong) LiveApplyingView *applyingView; // 申请中
|
|
|
|
|
|
+@property (nonatomic, assign) BOOL isPauseLive;
|
|
|
+
|
|
|
@end
|
|
|
|
|
|
// 用于记录点赞消息连续点击的次数
|
|
@@ -169,7 +171,7 @@ static int clickPraiseBtnTimes = 0;
|
|
|
self.enableSeat = YES;
|
|
|
self.enableLike = YES;
|
|
|
self.micStatus = MICSTATUS_NOMAL;
|
|
|
- self.isCreaterInRoom = NO; // 默认主讲人不在房间
|
|
|
+ self.isCreaterInRoom = NO; // 默认老师不在房间
|
|
|
self.isImConnected = [USER_MANAGER checkIMConnected];
|
|
|
self.isCloseRoom = NO;
|
|
|
self.isOtherLogin = NO;
|
|
@@ -234,15 +236,26 @@ static int clickPraiseBtnTimes = 0;
|
|
|
[joinChatroomMessage setMsgId:[RCIM sharedRCIM].currentUserInfo.userId];
|
|
|
MJWeakSelf;
|
|
|
[self sendMessage:joinChatroomMessage displayMessage:NO callback:^(BOOL success) {
|
|
|
- NSString *contentString = [NSString stringWithFormat:@"%@ 进入直播间",UserDefault(NicknameKey)];
|
|
|
- [weakSelf showAnimationView:YES showMessag:contentString];
|
|
|
- [weakSelf joinRTCRoom];
|
|
|
+ [weakSelf showEnterMessageAndJoinRTCRoom];
|
|
|
}];
|
|
|
} error:^(RCErrorCode status) {
|
|
|
NSLog(@"error code %zd" ,status);
|
|
|
}];
|
|
|
}
|
|
|
|
|
|
+- (void)showEnterMessageAndJoinRTCRoom {
|
|
|
+
|
|
|
+ NSString *contentString = [NSString stringWithFormat:@"%@ 进入直播间",UserDefault(NicknameKey)];
|
|
|
+ [self showAnimationView:YES showMessag:contentString];
|
|
|
+ [self joinRTCRoom];
|
|
|
+}
|
|
|
+
|
|
|
+- (void)leaveRTCRoomCallback:(void(^)(BOOL success))callback {
|
|
|
+ [[RCRTCEngine sharedInstance] leaveRoom:^(BOOL isSuccess, RCRTCCode code) {
|
|
|
+ callback(isSuccess);
|
|
|
+ }];
|
|
|
+}
|
|
|
+
|
|
|
- (void)joinRTCRoom {
|
|
|
|
|
|
// 如果当前加入了房间 只刷新或者退出
|
|
@@ -731,7 +744,7 @@ static int clickPraiseBtnTimes = 0;
|
|
|
// 渲染主播的流 优先显示主播的共享流
|
|
|
KSLiveStreamVideo *mainVideo = nil;
|
|
|
for (KSLiveStreamVideo *videoSource in steamArray) {
|
|
|
- if ([videoSource.userId isEqualToString:self.createrId]) { // 主屏只渲染主讲人
|
|
|
+ if ([videoSource.userId isEqualToString:self.createrId]) { // 主屏只渲染老师
|
|
|
if ([videoSource.streamTag isEqualToString:@"screenshare"]) { // 如果是共享流
|
|
|
if (![self.videoView.streamId isEqualToString:videoSource.streamId]) { // 主屏渲染不同 则重新渲染
|
|
|
mainVideo = videoSource;
|
|
@@ -823,10 +836,14 @@ static int clickPraiseBtnTimes = 0;
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
// 创建并设置远端视频预览视图
|
|
|
for (RCRTCInputStream *stream in streams) {
|
|
|
+ if ([stream.userId isEqualToString:self.createrId]) {
|
|
|
+ self.isPauseLive = NO;
|
|
|
+ }
|
|
|
if (stream.mediaType == RTCMediaTypeVideo) {
|
|
|
- if ([stream.userId isEqualToString:self.createrId]) { // 只渲染主讲人的流
|
|
|
+ if ([stream.userId isEqualToString:self.createrId]) { // 只渲染老师的流
|
|
|
self.isCreaterVideoEnable = YES;
|
|
|
[self setupRemoteViewWithStream:stream];
|
|
|
}
|
|
@@ -944,7 +961,7 @@ static int clickPraiseBtnTimes = 0;
|
|
|
if ([user.userId isEqualToString:self.createrId]) { // 当主播重新进入房间需要重置连麦状态
|
|
|
self.isCreaterInRoom = YES;
|
|
|
// 重置连麦状态
|
|
|
- [self resetMicWaitToNomal];
|
|
|
+// [self resetMicWaitToNomal];
|
|
|
// 刷新顶部视图
|
|
|
}
|
|
|
else {
|
|
@@ -956,11 +973,13 @@ static int clickPraiseBtnTimes = 0;
|
|
|
// 主播离开房间 (观众接收)
|
|
|
- (void)didLeaveUser:(RCRTCRemoteUser *)user {
|
|
|
[self removeRemoteVideoWithUserId:user.userId]; // 移除对应的视频
|
|
|
- if ([user.userId isEqualToString:self.createrId]) { // 如果是主讲人
|
|
|
+ if ([user.userId isEqualToString:self.createrId]) { // 如果是老师
|
|
|
+
|
|
|
self.isCreaterInRoom = NO;
|
|
|
[self resetMicWaitToNomal];
|
|
|
[self tipsTeacherLeaveRoom];
|
|
|
[self clearVideoView];
|
|
|
+ [self hideTipsView];
|
|
|
[self showEmptyViewDisplay:NO];
|
|
|
}
|
|
|
else {
|
|
@@ -1005,7 +1024,7 @@ static int clickPraiseBtnTimes = 0;
|
|
|
}
|
|
|
|
|
|
- (void)tipsTeacherLeaveRoom {
|
|
|
- [self MBPShow:@"主讲人已离开房间"];
|
|
|
+ [self MBPShow:@"老师已离开房间"];
|
|
|
}
|
|
|
|
|
|
|
|
@@ -1043,13 +1062,9 @@ static int clickPraiseBtnTimes = 0;
|
|
|
[self MBPShow:@"聊天消息需在40个字以内哦"];
|
|
|
return;
|
|
|
}
|
|
|
-// if (self.enableChat) {
|
|
|
- self.lastSendMsgTime = currentInterval;
|
|
|
- [self touristSendMessage:text];
|
|
|
-// }
|
|
|
-// else {
|
|
|
-// [self setDefaultBottomViewStatus];
|
|
|
-// }
|
|
|
+ self.lastSendMsgTime = currentInterval;
|
|
|
+ [self touristSendMessage:text];
|
|
|
+
|
|
|
}
|
|
|
|
|
|
- (void)touristSendMessage:(NSString *)text {
|
|
@@ -1063,8 +1078,7 @@ static int clickPraiseBtnTimes = 0;
|
|
|
|
|
|
#pragma mark ---- RTC
|
|
|
- (void)joinLiveRoom {
|
|
|
-// self.liveRoleType = RCRTCLiveRoleTypeAudience;
|
|
|
-// self.micStatus = MICSTATUS_NOMAL;
|
|
|
+
|
|
|
// 1.配置房间
|
|
|
RCRTCRoomConfig *config = [[RCRTCRoomConfig alloc] init];
|
|
|
config.roomType = RCRTCRoomTypeLive;
|
|
@@ -1076,8 +1090,6 @@ static int clickPraiseBtnTimes = 0;
|
|
|
__strong typeof(weakSelf) strongSelf = weakSelf;
|
|
|
if (code == RCRTCCodeSignalServerNotConnect || code == RCRTCCodeParameterError || code == RCRTCCodeNotInRTCRoom || code == RCRTCCodeRTCTokenIsNull || code == RCRTCCodeHttpTimeoutError || code == RCRTCCodeHttpError || code == RCRTCCodeVoIPNotAvailable) {
|
|
|
NSLog(@"%@",[NSString stringWithFormat:@"加入失败 code %ld",code]);
|
|
|
-// [strongSelf MBPShow:@"加入直播间失败"];
|
|
|
-// [strongSelf.navigationController dismissViewControllerAnimated:YES completion:nil];
|
|
|
}
|
|
|
else { // 加入直播间成功
|
|
|
[strongSelf notiferJoinSuccessToServiceCallback:^{
|
|
@@ -1191,7 +1203,7 @@ static int clickPraiseBtnTimes = 0;
|
|
|
NSString *descMessage = @"";
|
|
|
if (isPublish) {
|
|
|
imageName = @"liveVideo_close";
|
|
|
- descMessage = @"主讲人已关闭画面!";
|
|
|
+ descMessage = @"老师已关闭画面!";
|
|
|
}
|
|
|
else {
|
|
|
imageName = @"liveroom_empty";
|
|
@@ -1303,10 +1315,7 @@ static int clickPraiseBtnTimes = 0;
|
|
|
if (rcMessage) {
|
|
|
// 👍🏻消息
|
|
|
if ([rcMessage.content isMemberOfClass:[KSLiveChatroomLike class]]) {
|
|
|
- KSLiveChatroomLike *likeMessage = (KSLiveChatroomLike *)rcMessage.content;
|
|
|
- // 统计点赞数量
|
|
|
- // __blockSelf.likeCount += likeMessage.counts;
|
|
|
- // [__blockSelf countLikeMessageCount];
|
|
|
+ return;
|
|
|
}
|
|
|
else if ([rcMessage.content isMemberOfClass:[RCChatroomLikeCount class]]) {
|
|
|
RCChatroomLikeCount *likeCountMessage = (RCChatroomLikeCount *)rcMessage.content;
|
|
@@ -1319,9 +1328,9 @@ static int clickPraiseBtnTimes = 0;
|
|
|
if ([rcMessage.senderUserId isEqualToString:UserDefault(UIDKey)]) {
|
|
|
return;
|
|
|
}
|
|
|
- if ([rcMessage.senderUserId isEqual:self.createrId]) { // 如果是老师 重置连麦申请状态
|
|
|
- [__blockSelf resetMicWaitToNomal];
|
|
|
- }
|
|
|
+// if ([rcMessage.senderUserId isEqual:self.createrId]) { // 如果是老师 重置连麦申请状态
|
|
|
+// [__blockSelf resetMicWaitToNomal];
|
|
|
+// }
|
|
|
|
|
|
RCUserInfo *userInfo = rcMessage.content.senderUserInfo;
|
|
|
NSString *userName = [userInfo.name stringByAppendingString:@""];
|
|
@@ -1352,17 +1361,6 @@ static int clickPraiseBtnTimes = 0;
|
|
|
[__blockSelf countMemberCount];
|
|
|
return;
|
|
|
}
|
|
|
- // // 禁言控制
|
|
|
- // else if ([rcMessage.content isMemberOfClass:[RCChatroomChatBan class]]) {
|
|
|
- // RCChatroomChatBan *banMessage = (RCChatroomChatBan *)rcMessage.content;
|
|
|
- // if (banMessage.chatBan) { // 禁止发言
|
|
|
- // __blockSelf.enableChat = NO;
|
|
|
- // }
|
|
|
- // else { // 开启发言
|
|
|
- // __blockSelf.enableChat = YES;
|
|
|
- // }
|
|
|
- // [__blockSelf insertMessage:rcMessage userInfo:notification.userInfo];
|
|
|
- // }
|
|
|
// 连麦控制消息
|
|
|
else if ([rcMessage.content isMemberOfClass:[RCChatroomSeatsControl class]]) {
|
|
|
RCChatroomSeatsControl *seatControlMessage = (RCChatroomSeatsControl *)rcMessage.content;
|
|
@@ -1390,17 +1388,17 @@ static int clickPraiseBtnTimes = 0;
|
|
|
// 刷新麦序
|
|
|
return;
|
|
|
}
|
|
|
- if (seatApplyMessage.type == SEATHANDLE_INVITE) { // 主讲人发起申请
|
|
|
+ if (seatApplyMessage.type == SEATHANDLE_INVITE) { // 老师发起申请
|
|
|
NSString *titles = [NSString stringWithFormat:@"%@邀请您连麦",[NSString returnNoNullStringWithString:seatApplyMessage.teacherName]];
|
|
|
[__blockSelf showInviteAlertMessage:titles];
|
|
|
}
|
|
|
- else if (seatApplyMessage.type == SEATHANDLE_DISINVITE) { // 主讲人撤回邀请
|
|
|
- [__blockSelf MBPShow:@"主讲人撤回了连麦邀请"];
|
|
|
+ else if (seatApplyMessage.type == SEATHANDLE_DISINVITE) { // 老师撤回邀请
|
|
|
+ [__blockSelf MBPShow:@"老师撤回了连麦邀请"];
|
|
|
if (__blockSelf.alertView && __blockSelf.alertView.isShow) {
|
|
|
[__blockSelf.alertView dismissAlertView];
|
|
|
}
|
|
|
}
|
|
|
- else if (seatApplyMessage.type == SEATHANDLE_KICKSEAT) { // 主讲人将麦上观众抱下麦
|
|
|
+ else if (seatApplyMessage.type == SEATHANDLE_KICKSEAT) { // 老师将麦上观众抱下麦
|
|
|
[__blockSelf kickSeatWithMessage:@"您已被抱下麦"];
|
|
|
}
|
|
|
[__blockSelf hideApplyingView];
|
|
@@ -1412,15 +1410,16 @@ static int clickPraiseBtnTimes = 0;
|
|
|
if (![seatResponseMessage.audienceId isEqualToString:UserDefault(UIDKey)]) { // 只处理和自己相关的消息
|
|
|
return;
|
|
|
}
|
|
|
- if (seatResponseMessage.type == SEATRESPONSE_TEACHERAPPROVE) { //
|
|
|
+ if (seatResponseMessage.type == SEATRESPONSE_TEACHERAPPROVE && __blockSelf.micStatus == MICSTATUS_WAITING) { //
|
|
|
+ [__blockSelf hideApplyingView];
|
|
|
[__blockSelf connectHostWithStatus:YES];
|
|
|
+ [__blockSelf insertMessage:rcMessage userInfo:notification.userInfo];
|
|
|
}
|
|
|
else if (seatResponseMessage.type == SEATRESPONSE_TEACHERREJECT) {
|
|
|
- [__blockSelf MBPShow:@"主讲人拒绝了您的连麦申请"];
|
|
|
+ [__blockSelf MBPShow:@"老师拒绝了您的连麦申请"];
|
|
|
__blockSelf.micStatus = MICSTATUS_NOMAL;
|
|
|
+ [__blockSelf insertMessage:rcMessage userInfo:notification.userInfo];
|
|
|
}
|
|
|
- [__blockSelf hideApplyingView];
|
|
|
- [__blockSelf insertMessage:rcMessage userInfo:notification.userInfo];
|
|
|
}
|
|
|
else if ([rcMessage.content isMemberOfClass:[KSLiveChatroomDownSeat class]]) { // 成员下麦消息
|
|
|
return;
|
|
@@ -1442,8 +1441,9 @@ static int clickPraiseBtnTimes = 0;
|
|
|
else if ([rcMessage.content isMemberOfClass:[RCTextMessage class]]) {
|
|
|
[__blockSelf insertMessage:rcMessage userInfo:notification.userInfo];
|
|
|
}
|
|
|
- else if ([rcMessage.content isMemberOfClass:[KSRCPauseLiveMessage class]]) { // 主讲人暂停直播
|
|
|
- [__blockSelf MBPShow:@"主讲人已暂停直播"];
|
|
|
+ else if ([rcMessage.content isMemberOfClass:[KSRCPauseLiveMessage class]]) { // 老师暂停直播
|
|
|
+ __blockSelf.isPauseLive = YES;
|
|
|
+ [__blockSelf MBPShow:@"老师已暂停直播"];
|
|
|
if (__blockSelf.micStatus == MICSTATUS_WAITING) {
|
|
|
[__blockSelf sendSeatMessageApply:NO];
|
|
|
}
|
|
@@ -1481,7 +1481,7 @@ static int clickPraiseBtnTimes = 0;
|
|
|
}
|
|
|
else if ([rcMessage.content isMemberOfClass:[KSRejectAllSeatMessage class]]) { // 拒绝所有连麦申请
|
|
|
if (__blockSelf.micStatus == MICSTATUS_WAITING) {
|
|
|
- [__blockSelf MBPShow:@"主讲人拒绝了您的连麦申请"];
|
|
|
+ [__blockSelf MBPShow:@"老师拒绝了您的连麦申请"];
|
|
|
// 处理连麦状态
|
|
|
__blockSelf.micStatus = MICSTATUS_NOMAL;
|
|
|
[__blockSelf insertMessage:rcMessage userInfo:notification.userInfo];
|
|
@@ -1934,13 +1934,10 @@ static int clickPraiseBtnTimes = 0;
|
|
|
[self MBPShow:@"您已被老师禁言"];
|
|
|
return;
|
|
|
}
|
|
|
-// if (self.enableChat) { // 判断是否全员禁言
|
|
|
- [_inputBar setHidden:NO];
|
|
|
- [_inputBar setInputBarStatus:KSBottomBarStatusKeyboard];
|
|
|
-// }
|
|
|
-// else {
|
|
|
-// [self MBPShow:@"老师关闭聊天"];
|
|
|
-// }
|
|
|
+
|
|
|
+ [_inputBar setHidden:NO];
|
|
|
+ [_inputBar setInputBarStatus:KSBottomBarStatusKeyboard];
|
|
|
+
|
|
|
}
|
|
|
break;
|
|
|
case LIVEROOMACTION_SEAT: // // 连麦按钮
|
|
@@ -1966,10 +1963,13 @@ static int clickPraiseBtnTimes = 0;
|
|
|
return;
|
|
|
}
|
|
|
if (self.isCreaterInRoom == NO) {
|
|
|
- [self MBPShow:@"主讲人不在直播间"];
|
|
|
+ [self MBPShow:@"老师不在直播间"];
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (self.isPauseLive == YES) {
|
|
|
+ [self MBPShow:@"老师暂停中,暂时无法接受邀请"];
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
if (self.enableSeat) {
|
|
|
// 显示弹窗
|
|
|
[self displaySeatApplyView];
|
|
@@ -1991,7 +1991,7 @@ static int clickPraiseBtnTimes = 0;
|
|
|
[self praiseBtnPressed];
|
|
|
}
|
|
|
else {
|
|
|
- [self MBPShow:@"主讲人不在直播间"];
|
|
|
+ [self MBPShow:@"老师不在直播间"];
|
|
|
}
|
|
|
}
|
|
|
break;
|