|
@@ -14,7 +14,7 @@
|
|
|
#import "KSChatroomMessageCenter.h"
|
|
|
#import <RongIMKit/RongIMKit.h>
|
|
|
#import "KSChatroomTextCell.h"
|
|
|
-#import "KSNormalAlertView.h"
|
|
|
+
|
|
|
#import "KSLiveStreamVideo.h"
|
|
|
#import "SeatContentView.h"
|
|
|
#import "LiveroomTimeManager.h"
|
|
@@ -31,6 +31,10 @@
|
|
|
#import "KSLiveEndView.h"
|
|
|
#import "LiveAnimationView.h"
|
|
|
|
|
|
+#import "LiveRoomAlertView.h"
|
|
|
+#import "LiveApplyView.h"
|
|
|
+#import "LiveApplyingView.h"
|
|
|
+
|
|
|
#define AUTOHIDE_TIME (10.0f)
|
|
|
|
|
|
#define PACKAGE_LOST (0.30f)
|
|
@@ -67,7 +71,7 @@ typedef NS_ENUM(NSInteger, MICSTATUS) {
|
|
|
// 连麦状态
|
|
|
@property (nonatomic, assign) MICSTATUS micStatus;
|
|
|
/// 提示窗
|
|
|
-@property (nonatomic, strong) KSNormalAlertView *alertView;
|
|
|
+@property (nonatomic, strong) LiveRoomAlertView *alertView;
|
|
|
/// 连麦的视图
|
|
|
@property (nonatomic, strong) SeatContentView *seatContainer;
|
|
|
// 聊天UI
|
|
@@ -141,6 +145,10 @@ typedef NS_ENUM(NSInteger, MICSTATUS) {
|
|
|
|
|
|
@property (nonatomic, assign) BOOL isOtherLogin; // 是否被顶掉
|
|
|
|
|
|
+@property (nonatomic, strong) LiveApplyView *applyView; // 未申请
|
|
|
+
|
|
|
+@property (nonatomic, strong) LiveApplyingView *applyingView; // 申请中
|
|
|
+
|
|
|
@end
|
|
|
|
|
|
// 用于记录点赞消息连续点击的次数
|
|
@@ -236,12 +244,13 @@ static int clickPraiseBtnTimes = 0;
|
|
|
}
|
|
|
|
|
|
- (void)joinRTCRoom {
|
|
|
+
|
|
|
+ // 如果当前加入了房间 只刷新或者退出
|
|
|
if (self.room && self.liveRoleType == RCRTCLiveRoleTypeBroadcaster) {
|
|
|
[self connectHostWithStatus:NO];
|
|
|
}
|
|
|
else {
|
|
|
[self setRoleType];
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -438,7 +447,8 @@ static int clickPraiseBtnTimes = 0;
|
|
|
if (self.hasShowSuspendView) {
|
|
|
KSLiveStreamVideo *mainVideo = nil;
|
|
|
if (self.videoView.streamId) {
|
|
|
- for (KSLiveStreamVideo *streamVideo in self.streamVideos) {
|
|
|
+ NSMutableArray *steamArray = [self.streamVideos mutableCopy];
|
|
|
+ for (KSLiveStreamVideo *streamVideo in steamArray) {
|
|
|
if ([streamVideo.streamId isEqualToString:self.videoView.streamId]) {
|
|
|
mainVideo = streamVideo;
|
|
|
break;
|
|
@@ -533,6 +543,8 @@ static int clickPraiseBtnTimes = 0;
|
|
|
}
|
|
|
|
|
|
- (void)setRoleType {
|
|
|
+ self.micStatus = MICSTATUS_NOMAL;
|
|
|
+ [self hideApplyingView];
|
|
|
// 1.设置切换听筒为扬声器
|
|
|
[self.engine setDefaultAudioRouteToSpeaker:YES];
|
|
|
// 2.加入RTC房间
|
|
@@ -541,6 +553,7 @@ static int clickPraiseBtnTimes = 0;
|
|
|
|
|
|
// 观众上下麦
|
|
|
- (void)connectHostWithStatus:(BOOL)isConnect {
|
|
|
+
|
|
|
// 转换中,不再处理转换身份
|
|
|
if (self.isTransferRole) {
|
|
|
return;
|
|
@@ -588,6 +601,7 @@ static int clickPraiseBtnTimes = 0;
|
|
|
});
|
|
|
|
|
|
} onFailed:^(RCRTCCode code) {
|
|
|
+
|
|
|
NSLog(@"------- up error code %ld", code);
|
|
|
weakSelf.isTransferRole = NO;
|
|
|
dispatch_main_async_safe(^{
|
|
@@ -604,7 +618,6 @@ static int clickPraiseBtnTimes = 0;
|
|
|
weakSelf.micStatus = MICSTATUS_NOMAL;
|
|
|
[weakSelf renderSeatView];
|
|
|
}
|
|
|
-
|
|
|
});
|
|
|
|
|
|
} onKicked:^{
|
|
@@ -662,7 +675,6 @@ static int clickPraiseBtnTimes = 0;
|
|
|
}
|
|
|
// 刷新麦位状态
|
|
|
[weakSelf renderSeatView];
|
|
|
-
|
|
|
});
|
|
|
|
|
|
} onKicked:^{
|
|
@@ -713,7 +725,9 @@ static int clickPraiseBtnTimes = 0;
|
|
|
// 更新视图
|
|
|
- (void)updateVideoViewContainer {
|
|
|
NSMutableArray *steamArray = [self.streamVideos mutableCopy];
|
|
|
- if (self.streamVideos.count > 0) {
|
|
|
+
|
|
|
+ if (steamArray.count > 0) {
|
|
|
+
|
|
|
// 渲染主播的流 优先显示主播的共享流
|
|
|
KSLiveStreamVideo *mainVideo = nil;
|
|
|
for (KSLiveStreamVideo *videoSource in steamArray) {
|
|
@@ -973,7 +987,9 @@ static int clickPraiseBtnTimes = 0;
|
|
|
|
|
|
- (void)resetConnectionStatus {
|
|
|
if (self.micStatus == MICSTATUS_CONNECTING) {
|
|
|
- [self connectHostWithStatus:NO];
|
|
|
+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0f * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
|
+ [self connectHostWithStatus:NO];
|
|
|
+ });
|
|
|
}
|
|
|
else {
|
|
|
[self removeSeatContainer];
|
|
@@ -1046,6 +1062,8 @@ 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;
|
|
@@ -1143,7 +1161,7 @@ static int clickPraiseBtnTimes = 0;
|
|
|
self.alertView = nil;
|
|
|
}
|
|
|
MJWeakSelf;
|
|
|
- self.alertView = [KSNormalAlertView ks_showAlertWithTitle:tipsMessage leftTitle:@"取消" rightTitle:@"确定" inView:self.view cancel:^{
|
|
|
+ self.alertView = [LiveRoomAlertView liveroomAlertWithTitle:tipsMessage leftButtonTitle:@"取消" rightTitle:@"确定" inView:self.view cancel:^{
|
|
|
weakSelf.micStatus = MICSTATUS_NOMAL;
|
|
|
[weakSelf sendSeatResponseMessage:NO];
|
|
|
} confirm:^{
|
|
@@ -1349,7 +1367,14 @@ static int clickPraiseBtnTimes = 0;
|
|
|
RCChatroomSeatsControl *seatControlMessage = (RCChatroomSeatsControl *)rcMessage.content;
|
|
|
if (seatControlMessage.seatBan) { // 禁止连麦
|
|
|
__blockSelf.enableSeat = NO;
|
|
|
- __blockSelf.micStatus = MICSTATUS_NOMAL;
|
|
|
+
|
|
|
+ // 未连麦情况下才重置
|
|
|
+ if (__blockSelf.micStatus != MICSTATUS_CONNECTING) {
|
|
|
+ __blockSelf.micStatus = MICSTATUS_NOMAL;
|
|
|
+ }
|
|
|
+
|
|
|
+ [__blockSelf hideApplyView];
|
|
|
+ [__blockSelf hideApplyingView];
|
|
|
}
|
|
|
else { // 开启连麦
|
|
|
__blockSelf.enableSeat = YES;
|
|
@@ -1377,6 +1402,7 @@ static int clickPraiseBtnTimes = 0;
|
|
|
else if (seatApplyMessage.type == SEATHANDLE_KICKSEAT) { // 主讲人将麦上观众抱下麦
|
|
|
[__blockSelf kickSeatWithMessage:@"您已被抱下麦"];
|
|
|
}
|
|
|
+ [__blockSelf hideApplyingView];
|
|
|
[__blockSelf insertMessage:rcMessage userInfo:notification.userInfo];
|
|
|
}
|
|
|
// 连麦回复消息(暂不处理)
|
|
@@ -1392,6 +1418,8 @@ static int clickPraiseBtnTimes = 0;
|
|
|
[__blockSelf MBPShow:@"主讲人拒绝了您的连麦申请"];
|
|
|
__blockSelf.micStatus = MICSTATUS_NOMAL;
|
|
|
}
|
|
|
+ [__blockSelf hideApplyingView];
|
|
|
+ [__blockSelf insertMessage:rcMessage userInfo:notification.userInfo];
|
|
|
}
|
|
|
else if ([rcMessage.content isMemberOfClass:[KSLiveChatroomDownSeat class]]) { // 成员下麦消息
|
|
|
return;
|
|
@@ -1406,6 +1434,7 @@ static int clickPraiseBtnTimes = 0;
|
|
|
// 显示直播间关闭状态
|
|
|
[__blockSelf closeAlertView];
|
|
|
[__blockSelf displayCloseView];
|
|
|
+ [__blockSelf hideApplyingView];
|
|
|
});
|
|
|
return;
|
|
|
}
|
|
@@ -1414,9 +1443,11 @@ static int clickPraiseBtnTimes = 0;
|
|
|
}
|
|
|
else if ([rcMessage.content isMemberOfClass:[KSRCPauseLiveMessage class]]) { // 主讲人暂停直播
|
|
|
[__blockSelf MBPShow:@"主讲人已暂停直播"];
|
|
|
- [__blockSelf resetNetTips];
|
|
|
[__blockSelf resetConnectionStatus];
|
|
|
+ [__blockSelf resetNetTips];
|
|
|
[__blockSelf closeAlertView];
|
|
|
+ [__blockSelf hideApplyingView];
|
|
|
+ return;
|
|
|
}
|
|
|
else if ([rcMessage.content isMemberOfClass:[KSRCShopRushMessage class]]) { //
|
|
|
|
|
@@ -1438,12 +1469,39 @@ static int clickPraiseBtnTimes = 0;
|
|
|
__blockSelf.blacklistFlag = NO;
|
|
|
}
|
|
|
}
|
|
|
+ else if ([rcMessage.content isMemberOfClass:[KSDownSeatAllMessage class]]) { // 所有麦上用户下麦
|
|
|
+ if (__blockSelf.micStatus == MICSTATUS_CONNECTING) {
|
|
|
+ [__blockSelf kickSeatWithMessage:@"您已被抱下麦"];
|
|
|
+ [__blockSelf insertMessage:rcMessage userInfo:notification.userInfo];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if ([rcMessage.content isMemberOfClass:[KSRejectAllSeatMessage class]]) { // 拒绝所有连麦申请
|
|
|
+ if (__blockSelf.micStatus == MICSTATUS_WAITING) {
|
|
|
+ [__blockSelf MBPShow:@"主讲人拒绝了您的连麦申请"];
|
|
|
+ // 处理连麦状态
|
|
|
+ __blockSelf.micStatus = MICSTATUS_NOMAL;
|
|
|
+ [__blockSelf insertMessage:rcMessage userInfo:notification.userInfo];
|
|
|
+ [__blockSelf hideApplyingView];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
}));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+- (void)hideApplyView {
|
|
|
+ if (self.applyView.isShow) {
|
|
|
+ [self.applyView hideView];
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+- (void)hideApplyingView {
|
|
|
+ if (self.applyingView.isShow) {
|
|
|
+ [self.applyingView hideView];
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
// 发送人数同步消息
|
|
|
- (void)sendMemberCountMessage {
|
|
@@ -1623,7 +1681,7 @@ static int clickPraiseBtnTimes = 0;
|
|
|
if(!cell){
|
|
|
cell = [[KSChatroomTextCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"KSChatroomTextCell"];
|
|
|
}
|
|
|
- if ([messageContent isMemberOfClass:[RCTextMessage class]] || [messageContent isMemberOfClass:[KSLiveChatroomWelcome class]] || [messageContent isMemberOfClass:[KSLiveChatroomLike class]] || [messageContent isMemberOfClass:[KSLiveChatroomSeatApply class]] || [messageContent isMemberOfClass:[KSLiveChatroomSeatResponse class]]){
|
|
|
+ if ([messageContent isMemberOfClass:[RCTextMessage class]] || [messageContent isMemberOfClass:[KSLiveChatroomWelcome class]] || [messageContent isMemberOfClass:[KSLiveChatroomLike class]] || [messageContent isMemberOfClass:[KSLiveChatroomSeatApply class]] || [messageContent isMemberOfClass:[KSLiveChatroomSeatResponse class]] || [messageContent isMemberOfClass:[KSDownSeatAllMessage class]] || [messageContent isMemberOfClass:[KSRejectAllSeatMessage class]] || [messageContent isMemberOfClass:[RCChatroomSeatsControl class]]){
|
|
|
[cell setDataModel:model createrId:self.createrId];
|
|
|
}
|
|
|
return cell;
|
|
@@ -1641,6 +1699,8 @@ static int clickPraiseBtnTimes = 0;
|
|
|
applyMessage.audienceId = UserDefault(UIDKey);
|
|
|
applyMessage.audienceName = UserDefault(NicknameKey);
|
|
|
applyMessage.audienceAvatar = UserDefault(AvatarUrlKey);
|
|
|
+ applyMessage.teacherId = self.createrId;
|
|
|
+ applyMessage.teacherName = self.createrName;
|
|
|
MJWeakSelf;
|
|
|
[self sendMessage:applyMessage displayMessage:YES callback:^(BOOL success) {
|
|
|
if (success) {
|
|
@@ -1706,6 +1766,10 @@ static int clickPraiseBtnTimes = 0;
|
|
|
}
|
|
|
break;
|
|
|
case MICSTATUS_WAITING:
|
|
|
+ {
|
|
|
+ [self.bottomView.seatButton setImage:[UIImage imageNamed:@"seating_image"] forState:UIControlStateNormal];
|
|
|
+ }
|
|
|
+ break;
|
|
|
case MICSTATUS_CONNECTING:
|
|
|
{
|
|
|
[self.bottomView.seatButton setImage:[UIImage imageNamed:@"seat_image"] forState:UIControlStateNormal];
|
|
@@ -1836,7 +1900,7 @@ static int clickPraiseBtnTimes = 0;
|
|
|
}
|
|
|
else {
|
|
|
MJWeakSelf;
|
|
|
- [KSNormalAlertView ks_showAlertWithTitle:@"是否退出直播间" leftTitle:@"取消" rightTitle:@"退出" cancel:^{
|
|
|
+ self.alertView = [LiveRoomAlertView liveroomAlertWithTitle:@"是否退出直播间" leftButtonTitle:@"取消" rightTitle:@"退出" inView:self.view cancel:^{
|
|
|
|
|
|
} confirm:^{
|
|
|
[weakSelf quitAction];
|
|
@@ -1883,20 +1947,16 @@ static int clickPraiseBtnTimes = 0;
|
|
|
if (self.micStatus == MICSTATUS_CONNECTING) { // 连麦中
|
|
|
// 是否取消连麦
|
|
|
MJWeakSelf;
|
|
|
- self.alertView = [KSNormalAlertView ks_showAlertWithTitle:@"连麦中,确认取消连麦吗?" leftTitle:@"取消" rightTitle:@"确定" inView:self.view cancel:^{
|
|
|
+ self.alertView = [LiveRoomAlertView liveroomAlertWithTitle:@"连麦中,确认取消连麦吗?" leftButtonTitle:@"取消" rightTitle:@"确定" inView:self.view cancel:^{
|
|
|
|
|
|
} confirm:^{
|
|
|
[weakSelf connectHostWithStatus:NO];
|
|
|
}];
|
|
|
+
|
|
|
}
|
|
|
else if (self.micStatus == MICSTATUS_WAITING) { // 连麦申请中
|
|
|
// 弹窗取消申请
|
|
|
- MJWeakSelf;
|
|
|
- self.alertView = [KSNormalAlertView ks_showAlertWithTitle:@"连麦申请中,确认取消连麦申请吗?" leftTitle:@"取消" rightTitle:@"确定" inView:self.view cancel:^{
|
|
|
-
|
|
|
- } confirm:^{
|
|
|
- [weakSelf sendSeatMessageApply:NO];
|
|
|
- }];
|
|
|
+ [self displayApplyingView];
|
|
|
}
|
|
|
else {
|
|
|
if (self.blacklistFlag == YES) {
|
|
@@ -1908,13 +1968,13 @@ static int clickPraiseBtnTimes = 0;
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
-// if (self.enableSeat) {
|
|
|
- [self MBPShow:@"已发起连麦申请"];
|
|
|
- [self sendSeatMessageApply:YES];
|
|
|
-// }
|
|
|
-// else {
|
|
|
-// [self MBPShow:@"管理员关闭连麦申请"];
|
|
|
-// }
|
|
|
+ if (self.enableSeat) {
|
|
|
+ // 显示弹窗
|
|
|
+ [self displaySeatApplyView];
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ [self MBPShow:@"管理员关闭连麦申请"];
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
@@ -1938,6 +1998,14 @@ static int clickPraiseBtnTimes = 0;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+- (void)displaySeatApplyView {
|
|
|
+ [self.applyView showInView:self.view];
|
|
|
+}
|
|
|
+
|
|
|
+- (void)displayApplyingView {
|
|
|
+ [self.applyingView showInView:self.view];
|
|
|
+}
|
|
|
+
|
|
|
- (void)showCartAlert {
|
|
|
[self.cardView showViewInView:self.view];
|
|
|
}
|
|
@@ -1945,7 +2013,7 @@ static int clickPraiseBtnTimes = 0;
|
|
|
- (void)quitAction {
|
|
|
if (self.micStatus == MICSTATUS_CONNECTING) {
|
|
|
MJWeakSelf;
|
|
|
- self.alertView = [KSNormalAlertView ks_showAlertWithTitle:@"连麦中,是否退出房间?" leftTitle:@"取消" rightTitle:@"确定" inView:self.view cancel:^{
|
|
|
+ self.alertView = [LiveRoomAlertView liveroomAlertWithTitle:@"连麦中,是否退出房间?" leftButtonTitle:@"取消" rightTitle:@"确定" inView:self.view cancel:^{
|
|
|
|
|
|
} confirm:^{
|
|
|
[weakSelf quitRoom];
|
|
@@ -2256,4 +2324,44 @@ static int clickPraiseBtnTimes = 0;
|
|
|
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
|
|
}
|
|
|
|
|
|
+- (LiveApplyView *)applyView {
|
|
|
+ if (!_applyView) {
|
|
|
+ _applyView = [LiveApplyView shareInstance];
|
|
|
+ MJWeakSelf;
|
|
|
+ [_applyView applySeatCallback:^{
|
|
|
+ [weakSelf applySeatAction];
|
|
|
+ }];
|
|
|
+ }
|
|
|
+ return _applyView;
|
|
|
+}
|
|
|
+
|
|
|
+- (void)applySeatAction {
|
|
|
+ [self MBPShow:@"已发起连麦申请"];
|
|
|
+ [self sendSeatMessageApply:YES];
|
|
|
+}
|
|
|
+
|
|
|
+- (LiveApplyingView *)applyingView {
|
|
|
+ if (!_applyingView) {
|
|
|
+ _applyingView = [LiveApplyingView shareInstance];
|
|
|
+ NSString *avatar = UserDefaultObjectForKey(AvatarUrlKey);
|
|
|
+ [_applyingView.myAvatal sd_setImageWithURL:[NSURL URLWithString:[avatar getUrlEndcodeString]] placeholderImage:[UIImage imageNamed:USERDEFAULT_LOGO]];
|
|
|
+ [_applyingView.teacherAvatal sd_setImageWithURL:[NSURL URLWithString:[self.createrAvatal getUrlEndcodeString]] placeholderImage:[UIImage imageNamed:USERDEFAULT_LOGO]];
|
|
|
+ MJWeakSelf;
|
|
|
+ [_applyingView cancleApplyCallback:^{
|
|
|
+ [weakSelf cancleApplyAction];
|
|
|
+ }];
|
|
|
+ }
|
|
|
+ return _applyingView;
|
|
|
+}
|
|
|
+
|
|
|
+- (void)cancleApplyAction {
|
|
|
+ MJWeakSelf;
|
|
|
+ self.alertView = [LiveRoomAlertView liveroomAlertWithTitle:@"连麦申请中,确认取消连麦申请吗?" leftButtonTitle:@"取消" rightTitle:@"确定" inView:self.view cancel:^{
|
|
|
+
|
|
|
+ } confirm:^{
|
|
|
+ [weakSelf.applyingView hideView];
|
|
|
+ [weakSelf sendSeatMessageApply:NO];
|
|
|
+ }];
|
|
|
+}
|
|
|
+
|
|
|
@end
|