|
@@ -31,6 +31,10 @@
|
|
#import "KSLiveEndView.h"
|
|
#import "KSLiveEndView.h"
|
|
#import "LiveAnimationView.h"
|
|
#import "LiveAnimationView.h"
|
|
|
|
|
|
|
|
+
|
|
|
|
+#import "LiveApplyView.h"
|
|
|
|
+#import "LiveApplyingView.h"
|
|
|
|
+
|
|
#define AUTOHIDE_TIME (10.0f)
|
|
#define AUTOHIDE_TIME (10.0f)
|
|
|
|
|
|
#define PACKAGE_LOST (0.30f)
|
|
#define PACKAGE_LOST (0.30f)
|
|
@@ -141,6 +145,10 @@ typedef NS_ENUM(NSInteger, MICSTATUS) {
|
|
|
|
|
|
@property (nonatomic, assign) BOOL isOtherLogin; // 是否被顶掉
|
|
@property (nonatomic, assign) BOOL isOtherLogin; // 是否被顶掉
|
|
|
|
|
|
|
|
+@property (nonatomic, strong) LiveApplyView *applyView; // 未申请
|
|
|
|
+
|
|
|
|
+@property (nonatomic, strong) LiveApplyingView *applyingView; // 申请中
|
|
|
|
+
|
|
@end
|
|
@end
|
|
|
|
|
|
// 用于记录点赞消息连续点击的次数
|
|
// 用于记录点赞消息连续点击的次数
|
|
@@ -438,7 +446,8 @@ static int clickPraiseBtnTimes = 0;
|
|
if (self.hasShowSuspendView) {
|
|
if (self.hasShowSuspendView) {
|
|
KSLiveStreamVideo *mainVideo = nil;
|
|
KSLiveStreamVideo *mainVideo = nil;
|
|
if (self.videoView.streamId) {
|
|
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]) {
|
|
if ([streamVideo.streamId isEqualToString:self.videoView.streamId]) {
|
|
mainVideo = streamVideo;
|
|
mainVideo = streamVideo;
|
|
break;
|
|
break;
|
|
@@ -579,7 +588,7 @@ static int clickPraiseBtnTimes = 0;
|
|
[strongSelf subscribeRemoteResource:streamArray];
|
|
[strongSelf subscribeRemoteResource:streamArray];
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
-
|
|
|
|
|
|
+ [strongSelf updateVideoViewContainer];
|
|
}
|
|
}
|
|
|
|
|
|
strongSelf.micStatus = MICSTATUS_CONNECTING;
|
|
strongSelf.micStatus = MICSTATUS_CONNECTING;
|
|
@@ -624,8 +633,9 @@ static int clickPraiseBtnTimes = 0;
|
|
__strong typeof(weakSelf) strongSelf = weakSelf;
|
|
__strong typeof(weakSelf) strongSelf = weakSelf;
|
|
strongSelf.liveRoleType = RCRTCLiveRoleTypeAudience;
|
|
strongSelf.liveRoleType = RCRTCLiveRoleTypeAudience;
|
|
[strongSelf.engine.defaultAudioStream setMicrophoneDisable:YES];
|
|
[strongSelf.engine.defaultAudioStream setMicrophoneDisable:YES];
|
|
|
|
+
|
|
|
|
+ NSMutableArray *streamArray = [NSMutableArray array];
|
|
if (strongSelf.room.remoteUsers.count) {
|
|
if (strongSelf.room.remoteUsers.count) {
|
|
- NSMutableArray *streamArray = [NSMutableArray array];
|
|
|
|
NSArray *remoteUserArray = [strongSelf.room.remoteUsers mutableCopy];
|
|
NSArray *remoteUserArray = [strongSelf.room.remoteUsers mutableCopy];
|
|
for (RCRTCRemoteUser *user in remoteUserArray) {
|
|
for (RCRTCRemoteUser *user in remoteUserArray) {
|
|
if (user.remoteStreams.count) {
|
|
if (user.remoteStreams.count) {
|
|
@@ -633,10 +643,12 @@ static int clickPraiseBtnTimes = 0;
|
|
[strongSelf subscribeRemoteResource:streamArray];
|
|
[strongSelf subscribeRemoteResource:streamArray];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- }
|
|
|
|
- else {
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
+ if (streamArray.count == 0) {
|
|
|
|
+ [strongSelf updateVideoViewContainer];
|
|
|
|
+ }
|
|
|
|
+
|
|
strongSelf.micStatus = MICSTATUS_NOMAL;
|
|
strongSelf.micStatus = MICSTATUS_NOMAL;
|
|
// 刷新麦位状态
|
|
// 刷新麦位状态
|
|
[strongSelf renderSeatView];
|
|
[strongSelf renderSeatView];
|
|
@@ -709,11 +721,11 @@ static int clickPraiseBtnTimes = 0;
|
|
|
|
|
|
// 更新视图
|
|
// 更新视图
|
|
- (void)updateVideoViewContainer {
|
|
- (void)updateVideoViewContainer {
|
|
-
|
|
|
|
- if (self.streamVideos.count > 0) {
|
|
|
|
|
|
+ NSMutableArray *steamArray = [self.streamVideos mutableCopy];
|
|
|
|
+ if (steamArray.count > 0) {
|
|
// 渲染主播的流 优先显示主播的共享流
|
|
// 渲染主播的流 优先显示主播的共享流
|
|
KSLiveStreamVideo *mainVideo = nil;
|
|
KSLiveStreamVideo *mainVideo = nil;
|
|
- for (KSLiveStreamVideo *videoSource in self.streamVideos) {
|
|
|
|
|
|
+ for (KSLiveStreamVideo *videoSource in steamArray) {
|
|
if ([videoSource.userId isEqualToString:self.createrId]) { // 主屏只渲染主讲人
|
|
if ([videoSource.userId isEqualToString:self.createrId]) { // 主屏只渲染主讲人
|
|
if ([videoSource.streamTag isEqualToString:@"screenshare"]) { // 如果是共享流
|
|
if ([videoSource.streamTag isEqualToString:@"screenshare"]) { // 如果是共享流
|
|
if (![self.videoView.streamId isEqualToString:videoSource.streamId]) { // 主屏渲染不同 则重新渲染
|
|
if (![self.videoView.streamId isEqualToString:videoSource.streamId]) { // 主屏渲染不同 则重新渲染
|
|
@@ -875,7 +887,8 @@ static int clickPraiseBtnTimes = 0;
|
|
|
|
|
|
// 根据 streamId 确认唯一的音视频流
|
|
// 根据 streamId 确认唯一的音视频流
|
|
- (KSLiveStreamVideo *)fetchStreamVideoWithStreamId:(NSString *)streamId {
|
|
- (KSLiveStreamVideo *)fetchStreamVideoWithStreamId:(NSString *)streamId {
|
|
- for (KSLiveStreamVideo *sVideo in self.streamVideos) {
|
|
|
|
|
|
+ NSMutableArray *streamArray = [self.streamVideos mutableCopy];
|
|
|
|
+ for (KSLiveStreamVideo *sVideo in streamArray) {
|
|
if ([streamId isEqualToString:sVideo.streamId]) {
|
|
if ([streamId isEqualToString:sVideo.streamId]) {
|
|
return sVideo;
|
|
return sVideo;
|
|
}
|
|
}
|
|
@@ -970,10 +983,14 @@ static int clickPraiseBtnTimes = 0;
|
|
|
|
|
|
- (void)resetConnectionStatus {
|
|
- (void)resetConnectionStatus {
|
|
if (self.micStatus == MICSTATUS_CONNECTING) {
|
|
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];
|
|
}
|
|
}
|
|
self.micStatus = MICSTATUS_NOMAL;
|
|
self.micStatus = MICSTATUS_NOMAL;
|
|
- [self removeSeatContainer];
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- (void)resetMicWaitToNomal {
|
|
- (void)resetMicWaitToNomal {
|
|
@@ -1347,7 +1364,8 @@ static int clickPraiseBtnTimes = 0;
|
|
if (seatControlMessage.seatBan) { // 禁止连麦
|
|
if (seatControlMessage.seatBan) { // 禁止连麦
|
|
__blockSelf.enableSeat = NO;
|
|
__blockSelf.enableSeat = NO;
|
|
__blockSelf.micStatus = MICSTATUS_NOMAL;
|
|
__blockSelf.micStatus = MICSTATUS_NOMAL;
|
|
-
|
|
|
|
|
|
+ [__blockSelf hideApplyView];
|
|
|
|
+ [__blockSelf hideApplyingView];
|
|
}
|
|
}
|
|
else { // 开启连麦
|
|
else { // 开启连麦
|
|
__blockSelf.enableSeat = YES;
|
|
__blockSelf.enableSeat = YES;
|
|
@@ -1366,8 +1384,8 @@ static int clickPraiseBtnTimes = 0;
|
|
NSString *titles = [NSString stringWithFormat:@"%@邀请您连麦",[NSString returnNoNullStringWithString:seatApplyMessage.teacherName]];
|
|
NSString *titles = [NSString stringWithFormat:@"%@邀请您连麦",[NSString returnNoNullStringWithString:seatApplyMessage.teacherName]];
|
|
[__blockSelf showInviteAlertMessage:titles];
|
|
[__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) {
|
|
if (__blockSelf.alertView && __blockSelf.alertView.isShow) {
|
|
[__blockSelf.alertView dismissAlertView];
|
|
[__blockSelf.alertView dismissAlertView];
|
|
}
|
|
}
|
|
@@ -1375,6 +1393,7 @@ static int clickPraiseBtnTimes = 0;
|
|
else if (seatApplyMessage.type == SEATHANDLE_KICKSEAT) { // 主讲人将麦上观众抱下麦
|
|
else if (seatApplyMessage.type == SEATHANDLE_KICKSEAT) { // 主讲人将麦上观众抱下麦
|
|
[__blockSelf kickSeatWithMessage:@"您已被抱下麦"];
|
|
[__blockSelf kickSeatWithMessage:@"您已被抱下麦"];
|
|
}
|
|
}
|
|
|
|
+ [__blockSelf hideApplyingView];
|
|
[__blockSelf insertMessage:rcMessage userInfo:notification.userInfo];
|
|
[__blockSelf insertMessage:rcMessage userInfo:notification.userInfo];
|
|
}
|
|
}
|
|
// 连麦回复消息(暂不处理)
|
|
// 连麦回复消息(暂不处理)
|
|
@@ -1390,6 +1409,7 @@ static int clickPraiseBtnTimes = 0;
|
|
[__blockSelf MBPShow:@"主讲人拒绝了您的连麦申请"];
|
|
[__blockSelf MBPShow:@"主讲人拒绝了您的连麦申请"];
|
|
__blockSelf.micStatus = MICSTATUS_NOMAL;
|
|
__blockSelf.micStatus = MICSTATUS_NOMAL;
|
|
}
|
|
}
|
|
|
|
+ [__blockSelf hideApplyingView];
|
|
[__blockSelf insertMessage:rcMessage userInfo:notification.userInfo];
|
|
[__blockSelf insertMessage:rcMessage userInfo:notification.userInfo];
|
|
}
|
|
}
|
|
else if ([rcMessage.content isMemberOfClass:[KSLiveChatroomDownSeat class]]) { // 成员下麦消息
|
|
else if ([rcMessage.content isMemberOfClass:[KSLiveChatroomDownSeat class]]) { // 成员下麦消息
|
|
@@ -1405,6 +1425,7 @@ static int clickPraiseBtnTimes = 0;
|
|
// 显示直播间关闭状态
|
|
// 显示直播间关闭状态
|
|
[__blockSelf closeAlertView];
|
|
[__blockSelf closeAlertView];
|
|
[__blockSelf displayCloseView];
|
|
[__blockSelf displayCloseView];
|
|
|
|
+ [__blockSelf hideApplyingView];
|
|
});
|
|
});
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
@@ -1413,9 +1434,11 @@ static int clickPraiseBtnTimes = 0;
|
|
}
|
|
}
|
|
else if ([rcMessage.content isMemberOfClass:[KSRCPauseLiveMessage class]]) { // 主讲人暂停直播
|
|
else if ([rcMessage.content isMemberOfClass:[KSRCPauseLiveMessage class]]) { // 主讲人暂停直播
|
|
[__blockSelf MBPShow:@"主讲人已暂停直播"];
|
|
[__blockSelf MBPShow:@"主讲人已暂停直播"];
|
|
- [__blockSelf resetNetTips];
|
|
|
|
[__blockSelf resetConnectionStatus];
|
|
[__blockSelf resetConnectionStatus];
|
|
|
|
+ [__blockSelf resetNetTips];
|
|
[__blockSelf closeAlertView];
|
|
[__blockSelf closeAlertView];
|
|
|
|
+ [__blockSelf hideApplyingView];
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
else if ([rcMessage.content isMemberOfClass:[KSRCShopRushMessage class]]) { //
|
|
else if ([rcMessage.content isMemberOfClass:[KSRCShopRushMessage class]]) { //
|
|
|
|
|
|
@@ -1449,6 +1472,7 @@ static int clickPraiseBtnTimes = 0;
|
|
// 处理连麦状态
|
|
// 处理连麦状态
|
|
__blockSelf.micStatus = MICSTATUS_NOMAL;
|
|
__blockSelf.micStatus = MICSTATUS_NOMAL;
|
|
[__blockSelf insertMessage:rcMessage userInfo:notification.userInfo];
|
|
[__blockSelf insertMessage:rcMessage userInfo:notification.userInfo];
|
|
|
|
+ [__blockSelf hideApplyingView];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1458,6 +1482,17 @@ static int clickPraiseBtnTimes = 0;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+- (void)hideApplyView {
|
|
|
|
+ if (self.applyView.isShow) {
|
|
|
|
+ [self.applyView hideView];
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+- (void)hideApplyingView {
|
|
|
|
+ if (self.applyingView.isShow) {
|
|
|
|
+ [self.applyingView hideView];
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
|
|
// 发送人数同步消息
|
|
// 发送人数同步消息
|
|
- (void)sendMemberCountMessage {
|
|
- (void)sendMemberCountMessage {
|
|
@@ -1911,12 +1946,7 @@ static int clickPraiseBtnTimes = 0;
|
|
}
|
|
}
|
|
else if (self.micStatus == MICSTATUS_WAITING) { // 连麦申请中
|
|
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 {
|
|
else {
|
|
if (self.blacklistFlag == YES) {
|
|
if (self.blacklistFlag == YES) {
|
|
@@ -1929,8 +1959,8 @@ static int clickPraiseBtnTimes = 0;
|
|
}
|
|
}
|
|
|
|
|
|
if (self.enableSeat) {
|
|
if (self.enableSeat) {
|
|
- [self MBPShow:@"已发起连麦申请"];
|
|
|
|
- [self sendSeatMessageApply:YES];
|
|
|
|
|
|
+ // 显示弹窗
|
|
|
|
+ [self displaySeatApplyView];
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
[self MBPShow:@"管理员关闭连麦申请"];
|
|
[self MBPShow:@"管理员关闭连麦申请"];
|
|
@@ -1958,6 +1988,14 @@ static int clickPraiseBtnTimes = 0;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+- (void)displaySeatApplyView {
|
|
|
|
+ [self.applyView showInView:self.view];
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+- (void)displayApplyingView {
|
|
|
|
+ [self.applyingView showInView:self.view];
|
|
|
|
+}
|
|
|
|
+
|
|
- (void)showCartAlert {
|
|
- (void)showCartAlert {
|
|
[self.cardView showViewInView:self.view];
|
|
[self.cardView showViewInView:self.view];
|
|
}
|
|
}
|
|
@@ -2276,4 +2314,44 @@ static int clickPraiseBtnTimes = 0;
|
|
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
|
[[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 = [KSNormalAlertView ks_showAlertWithTitle:@"连麦申请中,确认取消连麦申请吗?" leftTitle:@"取消" rightTitle:@"确定" inView:self.view cancel:^{
|
|
|
|
+
|
|
|
|
+ } confirm:^{
|
|
|
|
+ [weakSelf.applyingView hideView];
|
|
|
|
+ [weakSelf sendSeatMessageApply:NO];
|
|
|
|
+ }];
|
|
|
|
+}
|
|
|
|
+
|
|
@end
|
|
@end
|