// // QXRoomViewController.m // QXLive // // Created by 启星 on 2025/6/7. // #import "QXRoomViewController.h" #import "QXRoomSongListView.h" #import "QXSoundListView.h" #import "QXUpSeatView.h" #import "QXMineNetwork.h" #import "QXGiftPlayerManager.h" #import "QXAgoraEngine.h" #import "QXRoomSettingView.h" #import "QXRoomSeatContentView.h" #import "QXSongListModel.h" #import "QXAlertView.h" #import "QXCreateRoomViewController.h" #import "QXRoomBgSettingView.h" #import "QXRoomBgMusicView.h" #import "QXRoomUserInfoView.h" #import "QXHeadlineView.h" #import "QXDirectSetScaleView.h" #import "QXRoomPKSearchView.h" #import "QXAgoraEngineEx.h" #import "QXCabinMovieView.h" #import "QXReportViewController.h" #import "QXMessageViewController.h" #import "QXRoomSubsidyViewController.h" #import "QXRoomViewController+Friend.h" #import "QXAllRoomHourRankView.h" #import "QXRedBagSendView.h" #import "QXRoomViewController+RedPacket.h" #import "QXRoomViewController+Activity.h" #import "QXRoomViewController+QXGiftDrift.h" #import "QXRedBagRecordViewController.h" #import "QXRoomEmojiView.h" #import "QXGiftDisplayManager.h" #import "QXRoomDayTaskTagView.h" #import "QXTaskViewController.h" @interface QXRoomViewController ()< QXRoomBottomViewDelegate, QXRoomSettingViewDelegate, QXAgoraEngineMediaPlayerDelegate, QXRoomUserInfoViewDelegate > @property (nonatomic,strong)UIImageView *roomBgImageView; @property (nonatomic,strong)UIView *roomBgCoverView; /// 点唱view @property (nonatomic,strong)QXRoomSongListView *songListView; /// 声音特效 @property (nonatomic,strong)QXSoundListView *soundListView; /// 申请上麦 @property (nonatomic,strong)QXUpSeatView *upSeatView; @property (nonatomic,strong)UIButton *soundBtn; @property (nonatomic,strong)UIButton *upSeatBtn; /// 排麦按钮 @property (nonatomic,strong)QXUpSeatCountView *micTeamView; /// 礼物特效 @property (nonatomic,strong)UIView *bgEffectView; /// 设置 @property (nonatomic,strong)QXRoomSettingView *settingView; /// 房间背景 @property (nonatomic,strong)QXRoomBgSettingView *roomBgSetView; /// 背景音乐 @property (nonatomic,strong)QXRoomBgMusicView *musicView; // 查看用户信息 @property (nonatomic,strong)QXRoomUserInfoView *userInfoView; ///头条 @property (nonatomic,strong)QXHeadlineView *headlineView; /// 发布头条 @property (nonatomic,strong)QXDirectSetScaleView *sendHeadLineView; /// pk search @property (nonatomic,strong)QXRoomPKSearchView *pkSearchView; /// 电影房 @property (nonatomic,strong)QXCabinMovieView *movieView; /// 连送按钮 @property (nonatomic,strong)QXContinuousGiftView *continuousView; @property (nonatomic,strong)QXAllRoomHourRankView *hourRankView; @property (nonatomic,strong)QXAllRoomHourRankTagView *hourRankIconView; @property (nonatomic,strong)QXRoomEmojiView *emojiView; @property (nonatomic,strong)QXRoomDayTaskTagView *dayTaskTagView; @end @implementation QXRoomViewController - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. [self initRedpacketManager]; [self initGiftDriftManager]; [self initActivityObeserver]; // [self performSelector:@selector(test) afterDelay:5]; } //-(void)test{ // [self roomPKRecieveLoserWantToRunRoadWithUserInfo:nil]; //27b36h //} -(void)viewWillAppear:(BOOL)animated{ [super viewWillAppear:animated]; [self.navigationController setNavigationBarHidden:YES animated:YES]; if (QXGlobal.shareGlobal.isOpenRecharge) { self.dayTaskTagView.hidden = NO; } } -(void)viewDidAppear:(BOOL)animated{ [super viewDidAppear:animated]; NSMutableArray *marr = [[NSMutableArray alloc]initWithArray:self.navigationController.viewControllers]; // for (UIViewController *vc in marr) { // if ([vc isKindOfClass:[QXRoomViewController class]]) { // [marr removeObject:vc]; // break; // } // } NSInteger count = 0; for (int i = 0; i < marr.count; i++) { UIViewController *vc = marr[i]; if ([vc isKindOfClass:[QXRoomViewController class]]){ count++; } if ([vc isKindOfClass:[QXRoomViewController class]] && (i == marr.count-2)) { [marr removeObject:vc]; self.navigationController.viewControllers = marr; } } if (count>=2) { for (int i = 0; i < marr.count; i++) { UIViewController *vc = marr[i]; if ([vc isKindOfClass:[QXRoomViewController class]]) { [marr removeObject:vc]; self.navigationController.viewControllers = marr; break; } } } [self playHWDMP4]; dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ [[QXGiftPlayerManager shareManager] startPlay]; [[QXGiftDisplayManager sharedManager] becomeFront]; }); self.navigationController.viewControllers = marr; // self.navigationController.interactivePopGestureRecognizer.enabled = NO; } -(void)viewDidDisappear:(BOOL)animated{ [super viewDidDisappear:animated]; // [[QXGiftPlayerManager shareManager] stopPlay]; self.continuousView.hidden = YES; [self stopHWDMP4]; } -(void)viewWillDisappear:(BOOL)animated{ [super viewWillDisappear:animated]; [[QXGiftPlayerManager shareManager] stopPlay]; [[QXGiftDisplayManager sharedManager] inBackGround]; } -(void)initSubViews{ // [self updateBgImage:@"room_background"]; self.bgImageHidden = YES; self.roomBgImageView = [[UIImageView alloc] initWithFrame:self.view.bounds]; // self.roomBgImageView.image = [UIImage imageNamed:@"room_background"]; self.roomBgImageView.contentMode = UIViewContentModeScaleAspectFill; self.roomBgImageView.clipsToBounds = YES; [self.view addSubview:self.roomBgImageView]; self.roomBgCoverView = [[UIView alloc] initWithFrame:self.view.bounds]; self.roomBgCoverView.backgroundColor = [UIColor colorWithWhite:0.0 alpha:0.2]; [self.view addSubview:self.roomBgCoverView]; self.view.backgroundColor = RGB16(0x333333); self.titleView = [[QXRoomTitleView alloc] initWithFrame:CGRectMake(0, kSafeAreaTop, SCREEN_WIDTH, ScaleWidth(74))]; self.titleView.roomId = self.roomId; self.titleView.delegate = self; [self.view addSubview:self.titleView]; [self.view insertSubview:self.seatContentView belowSubview:self.titleView]; [self.seatContentView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.right.equalTo(self.view); make.top.mas_equalTo(self.titleView.bottom+20); make.height.mas_equalTo(ScaleWidth(60+50*2)+51*3+1+0); }]; [self.view addSubview:self.bottomView]; [self.bottomView mas_makeConstraints:^(MASConstraintMaker *make) { make.bottom.equalTo(self.view); make.height.mas_equalTo(36+kSafeAreaBottom); make.left.right.equalTo(self.view); }]; [self.view addSubview:self.upSeatBtn]; [self.upSeatBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.right.mas_equalTo(-16); make.size.mas_equalTo(CGSizeMake(ScaleWidth(56), ScaleWidth(27))); make.bottom.equalTo(self.bottomView.mas_top).offset(-18); }]; self.soundBtn.hidden = YES; [self.view addSubview:self.soundBtn]; [self.soundBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.centerX.equalTo(self.upSeatBtn); make.size.mas_equalTo(CGSizeMake(ScaleWidth(52), ScaleWidth(25))); make.bottom.equalTo(self.upSeatBtn.mas_top).offset(-12); }]; self.micTeamView.hidden = YES; [self.view addSubview:self.micTeamView]; [self.micTeamView mas_makeConstraints:^(MASConstraintMaker *make) { make.right.equalTo(self.view); make.size.mas_equalTo(CGSizeMake(ScaleWidth(98), ScaleWidth(43))); make.bottom.equalTo(self.soundBtn.mas_top).offset(-12); }]; [self.view addSubview:self.chatListView]; [self.chatListView mas_makeConstraints:^(MASConstraintMaker *make) { make.bottom.equalTo(self.bottomView.mas_top); make.left.equalTo(self.view); make.top.equalTo(self.seatContentView.mas_bottom); make.right.equalTo(self.soundBtn.mas_left).offset(-16); }]; [self.sendGiftView reloadData]; if (self.isReJoin) { [self.chatListView insertNoitce]; [self getRoomInfo]; }else{ [self joinRoom]; } [self.view addSubview:self.hourRankIconView]; [self.view addSubview:self.redBagTagView]; [self.view addSubview:self.dayTaskTagView]; [self setupEffectView]; // [self.view addSubview:self.headlineView]; } #pragma mark - 特效 - (void)setupEffectView { if (!_bgEffectView) { [self.view insertSubview:self.bgEffectView aboveSubview:self.seatContentView]; CGFloat padding = ScaleWidth(20); [self.bgEffectView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.bottom.left.right.equalTo(self.view); }]; QXEffectContentView *fullEffectView = [[QXGiftPlayerManager shareManager] defaultFullEffectView]; [fullEffectView mas_makeConstraints:^(MASConstraintMaker *make) { make.centerX.centerY.equalTo(self.bgEffectView); make.size.mas_equalTo(CGSizeMake(SCREEN_WIDTH, SCREEN_HEIGHT)); }]; QXEffectContentView *chatEffectView = [[QXGiftPlayerManager shareManager] defaultChatEffectView]; [chatEffectView mas_makeConstraints:^(MASConstraintMaker *make) { // make.top.equalTo(self.seatContentView.mas_bottom).offset(padding); // make.left.right.equalTo(self.bgEffectView); make.bottom.mas_equalTo(-padding); make.centerX.equalTo(self.bgEffectView); make.size.mas_equalTo(CGSizeMake(SCREEN_WIDTH, SCREEN_HEIGHT)); }]; } BOOL isClose = [[NSUserDefaults standardUserDefaults] boolForKey:kEffectsCLose]; [[QXGiftPlayerManager shareManager] openOrCloseEffectViewWith:!isClose]; } -(void)setRoomModel:(QXRoomModel *)roomModel{ _roomModel = roomModel; } -(void)setRoomId:(NSString *)roomId{ _roomId = roomId; [self.chatListView insertNoitce]; MJWeakSelf [QXMineNetwork roomOnlineListWithRoomId:self.roomId page:1 successBlock:^(NSArray * _Nonnull onPitList, NSArray * _Nonnull offPitList) { NSMutableArray *arr = [NSMutableArray arrayWithArray:onPitList]; [arr addObjectsFromArray:offPitList]; weakSelf.titleView.onlineUsers = arr; } failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) { }]; } #pragma mark - 获取房间信息 -(void)joinRoom{ if (self.roomModel) { [self resetSubviews]; [self configRoomDataIsJoin:YES]; }else{ MJWeakSelf [[QXRoomMessageManager shared] joinGroupWithRoomId:self.roomId]; QXGlobal.shareGlobal.roomId = self.roomId; QXGlobal.shareGlobal.roomVC = self; [QXMineNetwork joinRoomWithRoomId:self.roomId successBlock:^(QXRoomModel * _Nonnull roomModel) { weakSelf.roomModel = roomModel; [self resetSubviews]; [self configRoomDataIsJoin:YES]; } failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) { showToast(msg); [[QXGlobal shareGlobal] quitRoomWithRoomId:self.roomId]; dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ [weakSelf.navigationController popViewControllerAnimated:YES]; }); }]; } //// roomModel.room_info.pk_room_id = @"33"; // // // } failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) { // showToast(msg); // [[QXGlobal shareGlobal] quitRoomWithRoomId:self.roomId]; // dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ // [weakSelf.navigationController popViewControllerAnimated:YES]; // }); // // }]; } -(void)getUserOnlineStatusWithUserIds:(NSString*)userIds{ [QXMineNetwork roomUserOnlineStatusWithUserIds:userIds roomId:self.roomId successBlock:^(NSArray * _Nonnull list) { for (QXUserModel *md in list) { if (md.user_id.longLongValue > 0) { [[NSNotificationCenter defaultCenter] postNotificationName:noticeRoomUserOnlineStatusDidChanged object:@{@"user_id":md.user_id,@"is_online":[NSNumber numberWithBool:md.is_online]}]; } } } failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) { }]; } -(void)getRoomInfo{ MJWeakSelf [QXMineNetwork getRoomInfoWithRoomId:self.roomId successBlock:^(QXRoomModel * _Nonnull roomModel) { weakSelf.roomModel = roomModel; [weakSelf resetSubviews]; [weakSelf configRoomDataIsJoin:NO]; } failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) { }]; [QXMineNetwork roomOnlineListWithRoomId:self.roomId page:1 successBlock:^(NSArray * _Nonnull onPitList, NSArray * _Nonnull offPitList) { NSMutableArray *arr = [NSMutableArray arrayWithArray:onPitList]; [arr addObjectsFromArray:offPitList]; weakSelf.titleView.onlineUsers = arr; } failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) { }]; } -(void)resetSubviews{ if (self.roomModel.room_info.type_id.intValue != 6) { [self.roomBgImageView sd_setImageWithURL:[NSURL URLWithString:self.roomModel.room_info.room_background]]; }else{ self.roomBgImageView.image = [UIImage imageNamed:@"cp_room_bg"]; } if (self.roomModel.room_info.type_id.intValue == 1 || self.roomModel.room_info.type_id.intValue == 3 || self.roomModel.room_info.type_id.intValue == 4 || self.roomModel.room_info.type_id.intValue == 8) { // 点唱房 if (self.roomModel.room_info.label_id.intValue == 1) { if (self.roomModel.pk_info.pk_room_id.intValue>0) { /// 在pk状态 [self.seatContentView setType:(QXRoomSeatViewTypePK)]; [self.seatContentView mas_remakeConstraints:^(MASConstraintMaker *make) { make.left.right.equalTo(self.view); make.top.mas_equalTo(self.titleView.bottom+12); make.height.mas_equalTo(ScaleWidth(330)); }]; [self.chatListView mas_remakeConstraints:^(MASConstraintMaker *make) { make.bottom.equalTo(self.bottomView.mas_top); make.left.equalTo(self.view); make.top.equalTo(self.seatContentView.mas_bottom); // make.right.equalTo(self.soundBtn.mas_left).offset(-16); make.width.mas_equalTo(ScaleWidth(280)); }]; }else{ // 聊天 [self.seatContentView setType:(QXRoomSeatViewTypeNormal)]; [self.seatContentView mas_remakeConstraints:^(MASConstraintMaker *make) { make.left.right.equalTo(self.view); make.top.mas_equalTo(self.titleView.bottom+20); make.height.mas_equalTo(ScaleWidth(60+50*2)+51*3+1+0); }]; [self.chatListView mas_remakeConstraints:^(MASConstraintMaker *make) { make.bottom.equalTo(self.bottomView.mas_top); make.left.equalTo(self.view); make.top.equalTo(self.seatContentView.mas_bottom); // make.right.equalTo(self.soundBtn.mas_left).offset(-16); make.width.mas_equalTo(ScaleWidth(280)); }]; } }else{ if (_musicView) { [[QXAgoraEngine sharedEngine] ktv_EndSing]; [_musicView removeFromSuperview]; _musicView = nil; } [self.seatContentView setType:(QXRoomSeatViewTypeSing)]; // k歌 [self.seatContentView mas_remakeConstraints:^(MASConstraintMaker *make) { make.left.right.equalTo(self.view); make.top.mas_equalTo(kSafeAreaTop+44); make.height.mas_equalTo(ScaleWidth(277)+44+ScaleWidth(50-10)+51); }]; [self.chatListView mas_remakeConstraints:^(MASConstraintMaker *make) { make.bottom.equalTo(self.bottomView.mas_top); make.left.equalTo(self.view); make.top.equalTo(self.seatContentView.mas_bottom).offset(-(ScaleWidth(50-10)+51)); // make.right.equalTo(self.soundBtn.mas_left).offset(-16); make.width.mas_equalTo(ScaleWidth(280)); }]; } }else if (self.roomModel.room_info.type_id.intValue == 2) { [self.seatContentView setType:(QXRoomSeatViewTypeAuction)]; [self.seatContentView mas_remakeConstraints:^(MASConstraintMaker *make) { make.left.right.equalTo(self.view); make.top.mas_equalTo(kSafeAreaTop+ScaleWidth(40)+12); make.height.mas_equalTo(ScaleWidth(328)); }]; [self.chatListView mas_remakeConstraints:^(MASConstraintMaker *make) { make.bottom.equalTo(self.bottomView.mas_top); make.left.equalTo(self.view); make.top.equalTo(self.seatContentView.mas_bottom); // make.right.equalTo(self.soundBtn.mas_left).offset(-16); make.width.mas_equalTo(ScaleWidth(280)); }]; }else if (self.roomModel.room_info.type_id.intValue == 6) { //小黑屋 [self.seatContentView setType:(QXRoomSeatViewTypeCabin)]; self.titleView.hidden = YES; self.upSeatBtn.hidden = YES; self.bottomView.isCabinRoom = YES; [self.seatContentView mas_remakeConstraints:^(MASConstraintMaker *make) { make.left.right.equalTo(self.view); make.top.mas_equalTo(kSafeAreaTop); make.height.mas_equalTo(ScaleWidth(380)); }]; [self.chatListView mas_remakeConstraints:^(MASConstraintMaker *make) { make.bottom.equalTo(self.bottomView.mas_top); make.left.equalTo(self.view); make.top.equalTo(self.seatContentView.mas_bottom); make.width.mas_equalTo(ScaleWidth(280)); }]; [self.view insertSubview:self.movieView atIndex:0]; }else if (self.roomModel.room_info.type_id.intValue == 7) { /// 交友房 [self resetFriendViews]; } if (self.roomModel.room_info.last_pk_room_id.isExist) { if (![self.roomModel.room_info.last_pk_room_id isEqualToString:self.roomModel.pk_info.pk_room_id]) { [[QXAgoraEngineEx sharedEngine] quitEXChannelWithLastPkRoomId:self.roomModel.room_info.last_pk_room_id]; } } if (self.roomModel.gift_cycle.xlh_info.xlh_status.intValue == 1) { self.acTagView.end_time = self.roomModel.gift_cycle.xlh_info.end_time; [self.view addSubview:self.acTagView]; }else{ [self.acTagView stopTimer]; [self.acTagView removeFromSuperview]; } if (self.roomModel.hour_ranking_open == 1) { self.hourRankIconView.hidden = NO; }else{ self.hourRankIconView.hidden = YES; } } -(void)configRoomDataIsJoin:(BOOL)isJoin{ self.seatContentView.hidden = NO; self.bottomView.hidden = NO; NSMutableArray *userIds = [NSMutableArray array]; for (QXRoomPitModel *md in self.roomModel.room_info.pit_list) { if (md.user_id.longLongValue > 0) { [userIds addObject:md.user_id]; } } [self getUserOnlineStatusWithUserIds:[userIds componentsJoinedByString:@","]]; self.micTeamView.countLabel.text = self.roomModel.room_info.queue_number; self.titleView.roomModel = self.roomModel; if (self.roomModel.room_info.type_id.intValue == 6) { self.bottomView.isCabinRoom = YES; [[QXAgoraEngine sharedEngine] setClientRoleBroadcaster:YES]; }else{ if (self.roomModel.user_info.pit_number.intValue > 0) { [[QXAgoraEngine sharedEngine] setClientRoleBroadcaster:YES]; [[QXAgoraEngine sharedEngine] enableAudio:NO]; [[QXAgoraEngine sharedEngine] muteLocalAudioStream:NO]; self.seatContentView.myPitNumber = self.roomModel.user_info.pit_number.intValue; }else{ self.seatContentView.myPitNumber = -1; [[QXAgoraEngine sharedEngine] setClientRoleBroadcaster:NO]; [[QXAgoraEngine sharedEngine] enableAudio:NO]; [[QXAgoraEngine sharedEngine] muteLocalAudioStream:YES]; } } self.seatContentView.roomModel = self.roomModel; if ((self.roomModel.room_info.type_id.intValue == 1 || self.roomModel.room_info.type_id.intValue == 3 || self.roomModel.room_info.type_id.intValue == 4 || self.roomModel.room_info.type_id.intValue == 8) && self.roomModel.room_info.label_id.intValue == 2){ /// k歌房没有背景音乐 [QXAgoraEngine sharedEngine].isPlayBgMusic = NO; }else{ [QXAgoraEngine sharedEngine].isPlayBgMusic = YES; } //音效按钮 if (self.seatContentView.myPitNumber == 9) { self.soundBtn.hidden = NO; self.titleView.isCompere = YES; }else{ self.soundBtn.hidden = YES; self.titleView.isCompere = NO; } if (self.roomModel.room_info.head_line != nil) { if (_headlineView == nil) { self.headlineView.model = self.roomModel.room_info.head_line; [self.view addSubview:self.headlineView]; } } [self configBottomTools]; if (isJoin) { MJWeakSelf [[QXAgoraEngine sharedEngine] joinChannel:self.roomId withRoom:self agora_token:self.roomModel.user_info.agora_token agora_rtm_token:self.roomModel.user_info.agora_rtm_token isUpSeat:self.seatContentView.myPitNumber>0 successBock:^{ if (weakSelf.roomModel.song_user_info && (weakSelf.roomModel.room_info.type_id.intValue == 1 || weakSelf.roomModel.room_info.type_id.intValue == 3 || weakSelf.roomModel.room_info.type_id.intValue == 4 || weakSelf.roomModel.room_info.type_id.intValue == 8) && weakSelf.roomModel.room_info.label_id.intValue == 2) { if ([weakSelf.roomModel.song_user_info.user_id isEqualToString:QXGlobal.shareGlobal.loginModel.user_id]) { // [[QXAgoraEngine sharedEngine] ktv_EndSing]; // [[QXAgoraEngine sharedEngine] ktv_StartSing:YES withSong:weakSelf.roomModel.song_user_info]; weakSelf.seatContentView.songInfo = weakSelf.roomModel.song_user_info; weakSelf.seatContentView.nextInfo = weakSelf.roomModel.nextInfo; /// 临时上麦 if (weakSelf.seatContentView.myPitNumber <= 0) { /// 我不在麦上 临时拉起权限 weakSelf.bottomView.status = 2; [weakSelf.bottomView setMuteAudioStatus:1]; } }else{ weakSelf.seatContentView.songInfo = weakSelf.roomModel.song_user_info; weakSelf.seatContentView.nextInfo = weakSelf.roomModel.nextInfo; } } if (self.roomModel.room_info.type_id.intValue == 6) { NSInteger uid = 0; if (![weakSelf.roomModel.cp_user.user_id isEqualToString:QXGlobal.shareGlobal.loginModel.user_id]) { uid = weakSelf.roomModel.cp_user.user_id.longLongValue; }else{ uid = weakSelf.roomModel.cp_user.user_id1.longLongValue; } //// if (_movieView) { //// [_movieView removeFromSuperview]; //// _movieView = nil; //// } [[QXAgoraEngine sharedEngine] startPreViewWithUid:uid view:self.movieView.videoView]; [[QXAgoraEngine sharedEngine] setClientRoleBroadcaster:YES]; [[QXAgoraEngine sharedEngine] enableAudio:NO]; [[QXAgoraEngine sharedEngine] muteLocalAudioStream:NO]; } }]; }else{ if (self.roomModel.song_user_info && (self.roomModel.room_info.type_id.intValue == 1 || self.roomModel.room_info.type_id.intValue == 3 || self.roomModel.room_info.type_id.intValue == 4 || self.roomModel.room_info.type_id.intValue == 8) && self.roomModel.room_info.label_id.intValue == 2) { if ([self.roomModel.song_user_info.user_id isEqualToString:QXGlobal.shareGlobal.loginModel.user_id]) { self.seatContentView.songInfo = self.roomModel.song_user_info; self.seatContentView.nextInfo = self.roomModel.nextInfo; }else{ self.seatContentView.songInfo = self.roomModel.song_user_info; self.seatContentView.nextInfo = self.roomModel.nextInfo; } } } [QXRoomMessageManager shared].delegate = self; [QXAgoraEngine sharedEngine].delegate = self; if (self.roomModel.room_info.type_id.intValue == 1 || self.roomModel.room_info.type_id.intValue == 3 || self.roomModel.room_info.type_id.intValue == 4 || self.roomModel.room_info.type_id.intValue == 8) { // 点唱房 if (self.roomModel.room_info.label_id.intValue == 1) { if (self.roomModel.pk_info.pk_id.intValue>0) { MJWeakSelf [QXMineNetwork getRoomInfoWithRoomId:self.roomModel.pk_info.pk_room_id successBlock:^(QXRoomModel * _Nonnull roomModel) { weakSelf.seatContentView.pkRoomModel = roomModel; } failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) { }]; if (self.seatContentView.myPitNumber == 9) { [QXMineNetwork updateShengWangTokenWithRoomId:weakSelf.roomModel.pk_info.pk_room_id successBlock:^(NSString * _Nonnull token) { NSString *pkUserId = weakSelf.roomModel.pk_info.invite_pk_user_id; if ([pkUserId isEqualToString:QXGlobal.shareGlobal.loginModel.user_id]) { pkUserId = weakSelf.roomModel.pk_info.receive_pk_user_id; } [[QXAgoraEngineEx sharedEngine] joinExWithAgora_token:token channel:weakSelf.roomModel.pk_info.pk_room_id pkUserId:pkUserId]; } failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) { }]; } } } } if (self.roomModel.room_info.type_id.intValue == 2) { [self auctionListDidChanged:self.roomModel.room_auction.auction_list]; } } -(void)configMicType:(BOOL)isOnSeat{ if (self.roomModel.room_info.room_up_pit_type.intValue == 1 && self.roomModel.room_info.type_id.intValue != 6) { self.micTeamView.hidden = NO; }else{ self.micTeamView.hidden = YES; } self.upSeatBtn.selected = isOnSeat; } -(void)configBottomTools{ if (self.roomModel.room_info.type_id.intValue == 6) { self.bottomView.isCabinRoom = YES; return; } self.bottomView.roomModel = self.roomModel; BOOL hasPK = NO; // if ((self.roomModel.room_info.type_id.intValue == 1 || self.roomModel.room_info.type_id.intValue == 3 || self.roomModel.room_info.type_id.intValue == 4 || self.roomModel.room_info.type_id.intValue == 8) && self.roomModel.room_info.label_id.intValue == 1) { if ((self.roomModel.room_info.type_id.intValue == 1) && self.roomModel.room_info.label_id.intValue == 1) { hasPK = YES; } BOOL hasSong = NO; if ((self.roomModel.room_info.type_id.intValue == 1) && self.roomModel.room_info.label_id.intValue == 2) { hasSong = YES; } /// 暂时不要pk // hasPK = NO; // /// 暂时不要ktv // hasSong = NO; /// 普通麦位 if (self.seatContentView.myPitNumber <= 0) { self.bottomView.status = 1; [self configMicType:NO]; [self.bottomView setRoleType:(QXRoomRoleTypeAudience) hasPK:hasPK hasSong:hasSong]; }else{ if (self.seatContentView.myPitNumber == 9) { [self.bottomView setRoleType:(QXRoomRoleTypeCompere) hasPK:hasPK hasSong:hasSong]; }else{ [self.bottomView setRoleType:(QXRoomRoleTypeAudience) hasPK:hasPK hasSong:hasSong]; } self.bottomView.status = 2; [self configMicType:YES]; } } /// 声浪回调 -(void)onRTCEngineRoomPublishSoundLevelUpdate:(NSDictionary *)soundLevels{ // if (self.roomModel.room_info.type_id.intValue == 1 && self.roomModel.room_info.label_id.intValue == 1) { // for (NSString *userId in soundLevels.allKeys) { // for (QXRoomSeatContentView *seatContentView in self.seatContentView.normalSeatView.seatArray) { // if ([seatContentView.pitModel.user_id isEqualToString:userId]) { // if ([soundLevels[userId] integerValue] > 0) { // [seatContentView startAudioAnimation]; // }else { // [seatContentView stopAudioAnimation]; // } // break; // } // } // } // } // for (AgoraRtcAudioVolumeInfo *info in soundLevels) { // if (info.uid == 0) { // if (info.volume > 0) { // [seatView startAudioAnimation]; // }else { // [seatView stopAudioAnimation]; // } // break; // }else{ // if (info.volume > 0) { // [seatView startAudioAnimation]; // }else { // [seatView stopAudioAnimation]; // } // break; // } // } // for (NSString *userId in soundLevels.allKeys) { // QXRoomSeatContentView *seatView = self.seatContentView.seatDict[userId]; // if ([soundLevels[userId] integerValue] > 0) { // [seatView startAudioAnimation]; // }else { // [seatView stopAudioAnimation]; // } // } } -(void)rtcEngineLocalAudioMixingDidFinish{ } -(void)rtcEngineVideoFirstLoadWithUid:(NSInteger)uid size:(CGSize)size{ self.movieView.hidden = NO; [self.view bringSubviewToFront:self.movieView]; } -(void)rtcEngineVideoDidStart:(NSInteger)uid{ self.movieView.hidden = NO; [self.view bringSubviewToFront:self.movieView]; } -(void)rtcEngineVideoDidStop:(NSInteger)uid{ if (self.movieView.isFullScreen) { [self.movieView resetView]; } self.movieView.hidden = YES; } #pragma mark - 推送通知 -(void)roomOnlineNumberDidChangedOnlineNumber:(NSString *)onlineNumber{ [self.titleView setOnlineNumber:onlineNumber]; } /// 下一首歌状态发生变化 -(void)nextSongDidChangedWithNextSong:(QXSongListModel *)nextInfo{ self.seatContentView.nextInfo = nextInfo; } /// 演唱者歌词回调 -(void)rtcEngineSongLrc:(NSString *)lrcUrl{ self.seatContentView.lrcUrl = lrcUrl; } // 演唱者歌曲播放回调 -(void)rtcEngineSongProgress:(NSUInteger)progress{ if ((self.roomModel.room_info.type_id.intValue == 1 || self.roomModel.room_info.type_id.intValue == 3 || self.roomModel.room_info.type_id.intValue == 4 || self.roomModel.room_info.type_id.intValue == 8) && self.roomModel.room_info.label_id.intValue == 2) { self.seatContentView.progress = progress; }else{ self.musicView.progress = progress; } } /// 观众同步歌词 -(void)roomSongLrcProgress:(NSUInteger)progress{ self.seatContentView.progress = progress; } // 有人发起点歌申请 -(void)applySongWaitAgreeWithUserNickname:(NSString *)nickname{ if (self.seatContentView.myPitNumber == 9) { // 弹出是否同意 MJWeakSelf QXAlertView *al = [[QXAlertView alloc] initWithFrame:CGRectMake(0, 0, ScaleWidth(300), ScaleWidth(175))]; al.type = QXAlertViewTypeAgreeSong; al.message = [NSString stringWithFormat:@"%@ 正在发起点歌",nickname]; al.commitBlock = ^{ [QXMineNetwork agreeApplySongWithRoomId:weakSelf.roomId type:@"1" successBlock:^(NSDictionary * _Nonnull dict) { } failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) { showToast(msg); }]; }; al.cancelBlock = ^{ [QXMineNetwork agreeApplySongWithRoomId:weakSelf.roomId type:@"2" successBlock:^(NSDictionary * _Nonnull dict) { } failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) { showToast(msg); }]; }; [[QXGlobal shareGlobal] showView:al popType:(PopViewTypeTopToCenter) tapDismiss:NO finishBlock:^{ }]; } } // 主播拒绝了点歌申请 -(void)applySongNoAgreeWithUserId:(NSString *)userId{ if ([userId isEqualToString:[QXGlobal shareGlobal].loginModel.user_id]) { showToast(@"主持拒绝了您的点歌申请"); } } /// 切歌后回调 -(void)nextSongDidStartWithSongInfo:(QXSongListModel *)songInfo nextInfo:(QXSongListModel *)nextInfo{ self.seatContentView.songInfo = songInfo; self.seatContentView.nextInfo = nextInfo; if ([songInfo.user_id isEqualToString:QXGlobal.shareGlobal.loginModel.user_id]) { // [[QXAgoraEngine sharedEngine] ktv_EndSing]; // [[QXAgoraEngine sharedEngine] ktv_StartSing:YES withSong:songInfo]; if (self.seatContentView.myPitNumber <= 0) { /// 我不在麦上 临时拉起权限 self.bottomView.status = 2; [self.bottomView setMuteAudioStatus:1]; } }else{ // [[QXAgoraEngine sharedEngine] ktv_EndSing]; // [[QXAgoraEngine sharedEngine] ktv_LoadLrcWithSong:songInfo]; if (self.seatContentView.myPitNumber <= 0) { self.bottomView.status = 1; } } } /// 插入消息 -(void)didInsertMessge:(QXRoomChatListModel *)message{ [self.chatListView insertMessage:message]; } -(void)didInsertMessge:(QXRoomChatListModel *)message userId:(NSString *)userId{ if ([userId isEqualToString:[QXGlobal shareGlobal].loginModel.user_id]) { [self.chatListView insertMessage:message]; } } /// 上下麦发生变化 -(void)didUpDownSeatWithUser:(QXUserHomeModel *)user isUpSeat:(BOOL)isUpSeat pit_number:(NSInteger)pit_number isPK:(BOOL)isPK{ [self.seatContentView didUpDownSeatWithUser:user isUpSeat:isUpSeat pit_number:pit_number isPK:isPK]; if ([user.user_id isEqualToString:QXGlobal.shareGlobal.loginModel.user_id]) { [[QXAgoraEngine sharedEngine] setClientRoleBroadcaster:isUpSeat]; self.bottomView.status = isUpSeat?2:1; if (!isUpSeat) { /// 下麦 停止音频模块 [[QXAgoraEngine sharedEngine] enableAudio:NO]; self.seatContentView.myPitNumber = -1; if (_musicView) { [[QXAgoraEngine sharedEngine] ktv_EndSing]; [_musicView removeFromSuperview]; _musicView = nil; } }else{ /// 上麦 停止音频模块 (因首次上麦 未打开麦克风 所以此处需要停止音频模块) [[QXAgoraEngine sharedEngine] enableAudio:NO]; /// 开启本地推流 虽音频模块未打开,但本地音乐及音效需要进行推流 [[QXAgoraEngine sharedEngine] muteLocalAudioStream:NO]; self.seatContentView.myPitNumber = pit_number; } if (self.seatContentView.myPitNumber == 9) { self.soundBtn.hidden = NO; self.titleView.isCompere = YES; }else{ self.soundBtn.hidden = YES; self.titleView.isCompere = NO; } [self configBottomTools]; } } -(void)roomSeatExchangedWithFromPitNumber:(NSInteger)fromPitNumber toPitNumber:(NSInteger)toPitNumber userInfo:(QXUserHomeModel*)userInfo isPK:(BOOL)isPK{ [self.seatContentView roomSeatExchangedWithFromPitNumber:fromPitNumber toPitNumber:toPitNumber userInfo:userInfo isPK:isPK]; if ([userInfo.user_id isEqualToString:QXGlobal.shareGlobal.loginModel.user_id]) { if (toPitNumber == 9) { self.soundBtn.hidden = NO; self.titleView.isCompere = YES; }else{ self.soundBtn.hidden = YES; self.titleView.isCompere = NO; } self.seatContentView.myPitNumber = toPitNumber; } } // 踢出房间 -(void)userDidTakeOffWithUserInfo:(QXUserHomeModel *)userInfo{ if ([userInfo.user_id isEqualToString:QXGlobal.shareGlobal.loginModel.user_id]) { [[QXGlobal shareGlobal] quitRoomWithRoomId:self.roomId]; // self.navigationController.interactivePopGestureRecognizer.enabled = YES; [self.navigationController popViewControllerAnimated:YES]; } } // 设置管理员 | 主持 -(void)roomSetManagerOrCompere:(QXUserHomeModel *)userInfo isManager:(BOOL)isManager isAdd:(BOOL)isAdd{ if ([userInfo.user_id isEqualToString:QXGlobal.shareGlobal.loginModel.user_id]) { if (isManager) { if (isAdd) { self.roomModel.user_info.is_management = @"1"; }else{ self.roomModel.user_info.is_management = @"0"; } }else{ if (isAdd) { self.roomModel.user_info.is_host = @"1"; }else{ self.roomModel.user_info.is_host = @"0"; } } } } /// 清除魅力 -(void)roomClearCharm{ [self.seatContentView clearCharm]; } -(void)roomClearUserCharmWithUserId:(NSString *)userId{ [self.seatContentView roomClearUserCharmWithUserId:userId]; } /// 收到礼物设置魅力 -(void)didRecieveGiftWithWithUserInfo:(QXUserHomeModel *)userInfo{ [self.seatContentView setSeatCharmWithUser:userInfo]; } -(void)didRecieveGiftWithWithUserInfos:(NSArray *)userInfos{ [self.seatContentView setSeatCharmWithUsers:userInfos]; } /// 拍卖者上麦 -(void)auctionUpSeatWithUserInfo:(QXUserHomeModel *)userInfo isUpSeat:(BOOL)isUpSeat{ [self.seatContentView didAuctiontUpDownSeatWithUser:userInfo isUpSeat:isUpSeat]; if ([userInfo.user_id isEqualToString:QXGlobal.shareGlobal.loginModel.user_id]) { [[QXAgoraEngine sharedEngine] setClientRoleBroadcaster:isUpSeat]; self.bottomView.status = isUpSeat?2:1; if (!isUpSeat) { /// 下麦 停止音频模块 [[QXAgoraEngine sharedEngine] enableAudio:NO]; self.seatContentView.myPitNumber = -1; if (_musicView) { [[QXAgoraEngine sharedEngine] ktv_EndSing]; [_musicView removeFromSuperview]; _musicView = nil; } }else{ /// 上麦 停止音频模块 (因首次上麦 未打开麦克风 所以此处需要停止音频模块) [[QXAgoraEngine sharedEngine] enableAudio:NO]; /// 开启本地推流 虽音频模块未打开,但本地音乐及音效需要进行推流 [[QXAgoraEngine sharedEngine] muteLocalAudioStream:NO]; self.seatContentView.myPitNumber = 888; } if (self.seatContentView.myPitNumber == 9) { self.soundBtn.hidden = NO; self.titleView.isCompere = YES; }else{ self.soundBtn.hidden = YES; self.titleView.isCompere = NO; } [self configBottomTools]; } } /// 用户 禁言|禁麦 状态 发生变化 -(void)userMuteStatusDidChanged:(QXUserHomeModel *)userInfo isMute:(NSString *)isMute isMutePit:(NSString *)isMutePit{ if ([userInfo.user_id isEqualToString:QXGlobal.shareGlobal.loginModel.user_id]) { self.roomModel.user_info.is_mute = isMute; self.roomModel.user_info.is_mute_pit = isMutePit; if (isMutePit.intValue == 1) { [self.bottomView setMuteAudioStatus:0]; [[QXAgoraEngine sharedEngine] enableAudio:NO]; [[QXAgoraEngine sharedEngine] muteLocalAudioStream:YES]; } } } /// 二卡八麦位状态变化 -(void)roomSeatStatusDidChangedIsLock:(NSString *)is_lock pit_number:(NSString *)pit_number{ [self.seatContentView setSeatIsLock:is_lock pitNumber:pit_number]; } -(void)aplayMicInLineNumberDidChanged:(NSString *)number{ self.micTeamView.countLabel.text = number; } -(void)cabinRoomValueDidChanged:(NSString *)hotValue{ [self.seatContentView cabinRoomHotValueDidChanged:hotValue]; } -(void)roomOnlineNumberDidChangedIsAdd:(BOOL)isAdd{ [self.titleView onlineNumberIsAdd:isAdd]; } -(void)roomUserInfoDidChanged:(QXUserHomeModel *)user{ [self.seatContentView roomUserInfoDidChanged:user]; } -(void)previewUserInfoWithUserId:(NSString *)userId{ QXRoomOwnerModel *md = [QXRoomOwnerModel new]; md.user_id = userId; [self didClickUserHeaderWithPitModel:nil userModel:md isPkRoom:NO pkRoomId:@"" isNoTakeOff:NO]; } -(void)auctionGiftAction:(QXRoomPitModel *)user auctionId:(NSString *)auctionId{ self.sendGiftView.type = QXSendGiftViewTypeAuction; QXRoomPitModel *model = [[QXRoomPitModel alloc] init]; model.pit_number = @"-1"; model.user_id = user.user_id; model.nickname = user.nickname; model.avatar = user.avatar; self.sendGiftView.userModel = model; self.sendGiftView.auctionId = auctionId; self.sendGiftView.roomId = self.roomId; [self.sendGiftView showInView:self.view]; // [[QXGlobal shareGlobal] showView:self.sendGiftView controller:self popType:(PopViewTypeBottomToUpActionSheet) tapDismiss:YES finishBlock:^{ // // }]; } ///修改房间类型 -(void)auctionTypeDidChanged:(NSString *)type{ [self.seatContentView auctionTypeDidChanged:type]; } /// 开始拍卖 -(void)auctionStartOrEndIsStart:(BOOL)isStart user:(QXRoomAuctionUser *)user getUser:(QXRoomAuctionUser *)getUser{ [self.seatContentView auctionStartOrEndIsStart:isStart user:user getUser:getUser]; if (!isStart) { [self auctionListDidChanged:@[]]; } } /// 拍卖列表发生变化 -(void)auctionListDidChanged:(NSArray *)auctionList{ BOOL haveMe = NO; // for (QXRoomPitModel*pitModel in auctionList) { // if ([pitModel.user_id isEqualToString:QXGlobal.shareGlobal.loginModel.user_id]) { // haveMe = YES; // break; // } // } for (int i = 0; i < auctionList.count; i++) { if (i < 3) { QXRoomPitModel*pitModel = auctionList[i]; if ([pitModel.user_id isEqualToString:QXGlobal.shareGlobal.loginModel.user_id]) { haveMe = YES; break; } } } if ([self.roomModel.room_auction.auction_user.user_id isEqualToString:QXGlobal.shareGlobal.loginModel.user_id]) { haveMe = YES; } if (self.seatContentView.myPitNumber>=0) { haveMe = YES; } if (haveMe == NO) { self.bottomView.status = 1; [[QXAgoraEngine sharedEngine] setClientRoleBroadcaster:NO]; }else{ self.bottomView.status = 2; if ([QXAgoraEngine sharedEngine].isOpenMic) { [self.bottomView setMuteAudioStatus:1]; }else{ [self.bottomView setMuteAudioStatus:0]; } } [self.seatContentView auctionListDidChanged:auctionList]; } /// 拍卖被延时 -(void)auctionTimeDelayWithEndTime:(NSString *)endTime{ [self.seatContentView auctionDelayTimeWithEndTime:endTime]; } /// 清空消息 -(void)didClearAllMessage{ [self.chatListView clearMessage]; } // 麦序模式发生变化 -(void)aplayPitModeDidChanged:(NSString *)upMicType{ self.roomModel.room_info.room_up_pit_type = upMicType; if (upMicType.intValue == 1) { self.micTeamView.hidden = NO; }else{ // if (self.seatContentView.myPitNumber > 0) { // self.upSeatBtn.selected = YES; // }else{ // self.upSeatBtn.selected = NO; // } self.micTeamView.hidden = YES; } self.settingView.roomModel = self.roomModel; } /// 房间类型发生变化 -(void)roomTypeDidChanged{ [self getRoomInfo]; } /// 房间信息发生变化 -(void)roomInfoDidChanged:(QXRoomInfoModel *)roomInfo{ self.roomModel.room_info.room_name = roomInfo.room_name; self.roomModel.room_info.room_cover = roomInfo.room_cover; self.roomModel.room_info.room_number = roomInfo.room_number; self.roomModel.room_info.room_background = roomInfo.room_background; self.titleView.roomModel = self.roomModel; [self.roomBgImageView sd_setImageWithURL:[NSURL URLWithString:roomInfo.room_background]]; } // 下一首歌 -(void)rtcEngineBackgroundMusicNextSong:(QXSongListModel *)songModel{ self.musicView.songModel = songModel; } -(void)songRoomCharmRankListDidChanged:(NSArray *)list{ [self.seatContentView songRoomCharmRankListDidChanged:list]; } #pragma mark - pk 相关 -(void)recievePKInviteWithSendRoomId:(NSString *)SendRoomId AcceptRoomId:(NSString *)AcceptRoomId PkId:(NSString *)PkId message:(nonnull NSString *)message{ if (self.seatContentView.myPitNumber == 9) { /// 找主持 主持弹窗 发起者不会收到 MJWeakSelf QXAlertView *al = [[QXAlertView alloc] initWithFrame:CGRectMake(0, 0, ScaleWidth(300), ScaleWidth(175))]; al.type = QXAlertViewTypeAgreeSong; al.message = message; al.commitBlock = ^{ [QXMineNetwork roomPkAgreeWithPk_id:PkId type:@"1" successBlock:^(NSDictionary * _Nonnull dict) { } failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) { showToast(msg); }]; }; al.cancelBlock = ^{ // [QXMineNetwork roomPkAgreeWithPk_id:PkId type:@"2" successBlock:^(NSDictionary * _Nonnull dict) { // // } failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) { // showToast(msg); // }]; }; [[QXGlobal shareGlobal] showView:al popType:(PopViewTypeTopToCenter) tapDismiss:NO finishBlock:^{ }]; } } /// 败方想跑路 -(void)roomPKRecieveLoserWantToRunRoadWithUserInfo:(QXUserHomeModel *)fromUserInfo{ if (self.seatContentView.myPitNumber == 9) { /// 找主持 主持弹窗 发起者不会收到 MJWeakSelf QXAlertView *al = [[QXAlertView alloc] initWithFrame:CGRectMake(0, 0, ScaleWidth(300), ScaleWidth(175))]; al.type = QXAlertViewTypeAgreeSong; al.message = [NSString stringWithFormat:@"%@想结束本场PK,您确定结束吗",fromUserInfo.nickname]; al.commitBlock = ^{ [QXMineNetwork roomPkEndWithPk_id:weakSelf.roomModel.pk_info.pk_id type:@"3" user_id:[QXGlobal shareGlobal].loginModel.user_id successBlock:^(NSDictionary * _Nonnull dict) { } failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) { }]; }; al.cancelBlock = ^{ // [QXMineNetwork roomPkAgreeWithPk_id:PkId type:@"2" successBlock:^(NSDictionary * _Nonnull dict) { // // } failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) { // showToast(msg); // }]; }; [[QXGlobal shareGlobal] showView:al popType:(PopViewTypeTopToCenter) tapDismiss:NO finishBlock:^{ }]; } } -(void)agreeOrRefusePKIsAgree:(BOOL)isAgree user_id:(nonnull NSString *)user_id room_id:(nonnull NSString *)room_id pk_id:(NSString*)pk_id{ if (isAgree) { /// 更新自己房间信息 更换界面 // [self getRoomInfo]; MJWeakSelf // 获取自己房间信息 [QXMineNetwork getRoomInfoWithRoomId:self.roomId successBlock:^(QXRoomModel * _Nonnull roomModel) { // 获取自己房间信息成功回调 // 更新当前的数据 weakSelf.roomModel = roomModel; // 重置视图 [weakSelf resetSubviews]; // 更新赋值 weakSelf.seatContentView.roomModel = roomModel; // 这里的roomId 是对方的roomid 获取对方房间信息 赋值给右侧视图 pk分为左右两侧 左侧为自己 右侧是对方 // 获取pk的对方的房间信息 [QXMineNetwork getRoomInfoWithRoomId:room_id successBlock:^(QXRoomModel * _Nonnull roomModel) { // 获取pk的对方的房间信息成功回调 // 赋值 weakSelf.seatContentView.pkRoomModel = roomModel; } failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) { }]; if (weakSelf.seatContentView.myPitNumber == 9) { // 如果自己当前在9号麦 加入对方房间 // 获取声网token 这里的roomid是对方房间的roomid [QXMineNetwork updateShengWangTokenWithRoomId:weakSelf.roomModel.pk_info.pk_room_id successBlock:^(NSString * _Nonnull token) { NSString *pkUserId = weakSelf.roomModel.pk_info.invite_pk_user_id; if ([pkUserId isEqualToString:QXGlobal.shareGlobal.loginModel.user_id]) { pkUserId = weakSelf.roomModel.pk_info.receive_pk_user_id; } /// 加入扩展流 [[QXAgoraEngineEx sharedEngine] joinExWithAgora_token:token channel:weakSelf.roomModel.pk_info.pk_room_id pkUserId:pkUserId]; } failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) { }]; } } failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) { }]; } } -(void)pkStartWithPkEndTimes:(NSString *)pk_end_times pk_id:(NSString*)pk_id{ [self.seatContentView pkStartWithPkEndTimes:pk_end_times pk_id:pk_id]; } -(void)roomPKValueDidChangedWithRoomIdA:(NSString *)room_id_a create_value_a:(NSString *)create_value_a room_id_b:(NSString *)room_id_b receive_value_b:(NSString *)receive_value_b{ [self.seatContentView roomPKValueDidChangedWithRoomIdA:room_id_a create_value_a:create_value_a room_id_b:room_id_b receive_value_b:receive_value_b]; } -(void)pkResultWithIsVictory:(NSInteger)isVictory end_time:(nonnull NSString *)end_time victory_name:(nonnull NSString *)victory_name victory_cover:(nonnull NSString *)victory_cover defeated_name:(nonnull NSString *)defeated_name defeated_cover:(nonnull NSString *)defeated_cover{ [self.seatContentView pkResultWithIsVictory:isVictory end_time:end_time victory_name:victory_name victory_cover:victory_cover defeated_name:defeated_name defeated_cover:defeated_cover]; } -(void)pkDisConnect{ [[QXAgoraEngineEx sharedEngine] quitEXChannelWithLastPkRoomId:@""]; [self getRoomInfo]; } -(void)pkMuteRemoteAudio:(BOOL)isMute fromUserInfo:(nonnull QXUserHomeModel *)fromUserInfo{ [[QXAgoraEngineEx sharedEngine] muteLocalEXAudioStream:isMute fromUserInfo:fromUserInfo]; } -(void)recieveHeadline:(QXHeadLineModel *)headline{ if (_headlineView) { self.headlineView.model = headline; [self.view addSubview:self.headlineView]; }else{ self.headlineView.model = headline; [self.view addSubview:self.headlineView]; } } #pragma mark - QXRoomBottomViewDelegate -(void)didClickEventType:(QXRoomBottomViewEventType)type isSelected:(BOOL)isSelected{ switch (type) { case QXRoomBottomViewEventTypePlayAudio:{ [[QXAgoraEngine sharedEngine] muteAllRemoteAudioStreams:isSelected]; [[QXAgoraEngineEx sharedEngine] muteRemoteEXAudioStream:isSelected]; } break; case QXRoomBottomViewEventTypeMuteAudio:{ if (!isSelected) { /// 静音时麦圈停止 if ((self.roomModel.room_info.type_id.intValue == 1 || self.roomModel.room_info.type_id.intValue == 3 || self.roomModel.room_info.type_id.intValue == 4 || self.roomModel.room_info.type_id.intValue == 8) && self.roomModel.room_info.label_id.intValue == 1) { // QXRoomSeatContentView *seatContentView = self.seatContentView.normalSeatView.mySeatView; // if (seatContentView.isSeatSpeaking) { // [seatContentView stopAudioAnimation]; // } } } QXLOG(isSelected?@"开麦":@"闭麦"); [[QXAgoraEngine sharedEngine] enableAudio:isSelected]; if (isSelected) { [[QXAgoraEngine sharedEngine] setClientRoleBroadcaster:YES]; [[QXAgoraEngine sharedEngine] muteLocalAudioStream:NO]; }else{ AgoraRtcAudioVolumeInfo *info = [[AgoraRtcAudioVolumeInfo alloc] init]; info.uid = [QXGlobal shareGlobal].loginModel.user_id.longLongValue; info.volume = 0; [[NSNotificationCenter defaultCenter] postNotificationName:noticeUserSpeak object:info]; NSDictionary *dict = @{ @"is_mute":[NSNumber numberWithInteger:0], }; NSString *jsonStr = [dict jsonStringEncoded]; [[QXRoomMessageManager shared] sendChatMessage:jsonStr messageType:(QXRoomMessageTypeMuteLocalAudio) needInsertMessage:NO]; } // [[QXAgoraEngine sharedEngine] muteLocalAudioStream:!isSelected]; } break; case QXRoomBottomViewEventTypeMessage:{ QXMessageViewController *vc = [[QXMessageViewController alloc] initWithIsFromRoom:YES]; QXBaseNavigationController *na = [[QXBaseNavigationController alloc] initWithRootViewController:vc]; na.modalPresentationStyle = UIModalPresentationFormSheet; [self presentViewController:na animated:YES completion:nil]; } break; case QXRoomBottomViewEventTypePK:{ self.pkSearchView.roomId = self.roomModel.room_info.room_id; [self.pkSearchView showInView:self.view]; } break; case QXRoomBottomViewEventTypeMusic:{ if ((self.roomModel.room_info.type_id.intValue == 1 || self.roomModel.room_info.type_id.intValue == 3 || self.roomModel.room_info.type_id.intValue == 4 || self.roomModel.room_info.type_id.intValue == 8) && self.roomModel.room_info.label_id.intValue == 1){ MJWeakSelf QXAlertView *al = [[QXAlertView alloc] initWithFrame:CGRectMake(0, 0, ScaleWidth(300), ScaleWidth(175))]; al.type = QXAlertViewTypeApplySong; al.commitBlock = ^{ [QXMineNetwork applySongWithRoomId:weakSelf.roomId successBlock:^(NSDictionary * _Nonnull dict) { showToast(@"已发起点歌,请等待主持同意"); } failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) { showToast(msg); }]; }; [[QXGlobal shareGlobal] showView:al popType:(PopViewTypeTopToCenter) tapDismiss:NO finishBlock:^{ }]; }else{ self.songListView.isCompere = self.seatContentView.myPitNumber==9; self.songListView.isBgMusic = [QXAgoraEngine sharedEngine].isPlayBgMusic; [self.songListView showInView:self.view]; } } break; case QXRoomBottomViewEventTypeGift:{ self.sendGiftView.type = QXSendGiftViewTypeRoom; if (self.sendGiftView.titles.count == 0) { [self.sendGiftView reloadData]; } QXRoomPitModel *compereModel = nil; QXRoomPitModel *guestModel = nil; NSMutableArray *pitArr = [NSMutableArray array]; if (self.roomModel.room_info.pit_list.count == 10) { QXRoomPitModel *md = self.roomModel.room_info.pit_list[8]; if (md.user_id.longValue > 0 && ![QXGlobal.shareGlobal.loginModel.user_id isEqualToString:md.user_id]) { md.isSelected = NO; [pitArr addObject:md]; QXRoomPitModel *lastMd = self.roomModel.room_info.pit_list[9]; if (lastMd.user_id.longValue > 0 && ![QXGlobal.shareGlobal.loginModel.user_id isEqualToString:lastMd.user_id]) { lastMd.isSelected = NO; [pitArr addObject:lastMd]; } }else{ QXRoomPitModel *lastMd = self.roomModel.room_info.pit_list[9]; if (lastMd.user_id.longValue > 0 && ![QXGlobal.shareGlobal.loginModel.user_id isEqualToString:lastMd.user_id]) { lastMd.isSelected = NO; [pitArr addObject:lastMd]; } } for (int i = 0; i < self.roomModel.room_info.pit_list.count;i++) { QXRoomPitModel *md = self.roomModel.room_info.pit_list[i]; md.isSelected = NO; if (md.pit_number.intValue == 9) { compereModel = md; continue; }else if (md.pit_number.intValue == 10) { guestModel = md; continue; }else{ if (md.user_id.longValue > 0 && ![md.user_id isEqualToString:[QXGlobal shareGlobal].loginModel.user_id]) { [pitArr addObject:md]; } } } }else{ for (int i = 0; i < self.roomModel.room_info.pit_list.count;i++) { QXRoomPitModel *md = self.roomModel.room_info.pit_list[i]; md.isSelected = NO; if ([self.roomModel.room_info.type_id isEqualToString:@"2"]) { /// 拍卖房主持位和拍卖为可能为同一个人 if ([md.user_id isEqualToString:self.roomModel.room_auction.auction_user.user_id]) { continue; } } if (md.pit_number.intValue == 9) { compereModel = md; if (md.user_id.longValue > 0 && ![md.user_id isEqualToString:[QXGlobal shareGlobal].loginModel.user_id]) { [pitArr insertObject:md atIndex:0]; } continue; }else if (md.pit_number.intValue == 10) { guestModel = md; continue; } if (md.user_id.longValue > 0 && ![md.user_id isEqualToString:[QXGlobal shareGlobal].loginModel.user_id]) { [pitArr addObject:md]; } } } // k歌麦位 if (self.roomModel.song_user_info) { if ([self.roomModel.song_user_info.user_id isEqualToString:compereModel.user_id] || [self.roomModel.song_user_info.user_id isEqualToString:guestModel.user_id]) { }else{ QXRoomPitModel*md = [[QXRoomPitModel alloc] init]; md.nickname = self.roomModel.song_user_info.nickname; md.user_id = self.roomModel.song_user_info.user_id; md.avatar = self.roomModel.song_user_info.avatar; md.pit_number = @"9999"; md.isSelected = NO; [pitArr addObject:md]; } } if (self.roomModel.song_pit_list.count > 0) { for (QXRoomPitModel*md in self.roomModel.song_pit_list) { if ([md.user_id isEqualToString:self.roomModel.song_user_info.user_id]) { continue; } if (md.user_id.longValue > 0 && ![QXGlobal.shareGlobal.loginModel.user_id isEqualToString:md.user_id]) { md.isSelected = NO; [pitArr addObject:md]; } } } // 拍卖 if (self.roomModel.room_auction.auction_user) { QXRoomPitModel*md = [[QXRoomPitModel alloc] init]; md.nickname = self.roomModel.room_auction.auction_user.nickname; md.user_id = self.roomModel.room_auction.auction_user.user_id; md.avatar = self.roomModel.room_auction.auction_user.avatar; md.pit_number = @"9999"; md.isSelected = NO; [pitArr addObject:md]; } if (self.roomModel.room_auction.auction_list.count > 0) { for (QXRoomPitModel*md in self.roomModel.room_auction.auction_list) { if ([md.user_id isEqualToString:compereModel.user_id]) { continue; } if (md.user_id.longValue > 0 && ![QXGlobal.shareGlobal.loginModel.user_id isEqualToString:md.user_id]) { md.isSelected = NO; [pitArr addObject:md]; } } } self.sendGiftView.pitUsers = pitArr; self.sendGiftView.roomId = self.roomId; [self.sendGiftView showInView:self.view]; // [[QXGlobal shareGlobal] showView:self.sendGiftView controller:self popType:(PopViewTypeBottomToUpActionSheet) tapDismiss:YES finishBlock:^{ // // }]; } break; case QXRoomBottomViewEventTypeSetting:{ if (self.roomModel.user_info.is_room_owner.intValue == 1) { BOOL isUpSeat = self.seatContentView.myPitNumber>0; self.settingView.roomModel = self.roomModel; [self.settingView updateRole:(QXRoomRoleTypeOwner) isUpSeat:isUpSeat]; [self.settingView showInView:self.view]; return; }else if (self.roomModel.user_info.is_management.intValue == 1) { BOOL isUpSeat = self.seatContentView.myPitNumber>0; self.settingView.roomModel = self.roomModel; [self.settingView updateRole:(QXRoomRoleTypeManager) isUpSeat:isUpSeat]; [self.settingView showInView:self.view]; return; }else if (self.roomModel.user_info.is_host.intValue == 1) { self.settingView.roomModel = self.roomModel; BOOL isUpSeat = self.seatContentView.myPitNumber==9; [self.settingView updateRole:(QXRoomRoleTypeCompere) isUpSeat:isUpSeat]; [self.settingView showInView:self.view]; return; }else{ self.settingView.roomModel = self.roomModel; BOOL isUpSeat = self.seatContentView.myPitNumber>0; [self.settingView updateRole:(QXRoomRoleTypeAudience) isUpSeat:isUpSeat]; [self.settingView showInView:self.view]; } } break; case QXRoomBottomViewEventTypeEmoji:{ [self.emojiView showInView:self.view]; } break; default: break; } } -(void)didSendMessage:(NSString *)message redpacketModel:(nonnull QXRedPacketModel *)redpacketModel{ if (redpacketModel) { // self.redbagDrawView.type = QXRedBagDrawTypeOpen; self.redbagDrawView.isFromToComment = YES; self.redbagDrawView.redpacketModel = redpacketModel; [self.redbagDrawView showInView:self.view]; } } #pragma mark - 麦位点击用户信息 -(void)didClickUserHeaderWithPitModel:(QXRoomPitModel *)pitModel userModel:(id)userModel isPkRoom:(BOOL)isPkRoom pkRoomId:(NSString *)pkRoomId isNoTakeOff:(BOOL)isNoTakeOff{ if (isPkRoom) { self.userInfoView.isPK = YES; self.userInfoView.isCompere = NO; self.userInfoView.isOwner = NO; self.userInfoView.isManager = NO; self.userInfoView.roomId = pkRoomId; }else{ self.userInfoView.isPK = NO; if (self.seatContentView.myPitNumber == 9 || self.roomModel.user_info.is_host.intValue == 1) { self.userInfoView.isCompere = YES; }else{ self.userInfoView.isCompere = NO; } if (self.roomModel.user_info.is_room_owner.intValue == 1) { self.userInfoView.isOwner = YES; }else{ self.userInfoView.isOwner = NO; } if (self.roomModel.user_info.is_management.intValue == 1) { self.userInfoView.isManager = YES; }else{ self.userInfoView.isManager = NO; } self.userInfoView.isNoTakeOff = isNoTakeOff; self.userInfoView.roomId = self.roomModel.room_info.room_id; } if (pitModel) { // self.userInfoView.isUpSeat = YES; self.userInfoView.pitNumber = pitModel.pit_number; self.userInfoView.userId = pitModel.user_id; }else{ // self.userInfoView.isUpSeat = NO; self.userInfoView.pitNumber = @""; if ([userModel isKindOfClass:[QXRoomOwnerModel class]]) { QXRoomOwnerModel*md = (QXRoomOwnerModel*)userModel; self.userInfoView.userId = md.user_id; } } [self.userInfoView showInView:self.view]; } #pragma mark - QXRoomSettingViewDelegate -(void)didClickSetModel:(QXRoomSettingModel *)model{ switch (model.type) { case QXRoomSettingTypeRoomClearMessage:{ [[QXRoomMessageManager shared] sendChatMessage:@"" messageType:(QXRoomMessageTypeClearMessage) needInsertMessage:NO]; [self.chatListView clearMessage]; [self.settingView hide]; } break; case QXRoomSettingTypeRoomSetting:{ MJWeakSelf QXCreateRoomViewController *vc = [[QXCreateRoomViewController alloc] init]; vc.roomModel = self.roomModel; vc.editSucceessBlock = ^(QXRoomModel * _Nonnull roomModel) { weakSelf.roomModel = roomModel; }; [self.navigationController pushViewController:vc animated:YES]; [self.settingView hide]; } break; case QXRoomSettingTypeRoomBgImage:{ self.roomBgSetView.roomId = self.roomId; [self.roomBgSetView showInView:self.view]; [self.settingView hide]; } break; case QXRoomSettingTypeRoomBgMusic:{ if (_musicView == nil) { [self.musicView showInView:self.view]; } MJWeakSelf self.musicView.closeActionBlock = ^{ [weakSelf.musicView removeFromSuperview]; [[QXAgoraEngine sharedEngine] ktv_EndSing]; self->_musicView = nil; }; self.musicView.moreActionBlock = ^{ weakSelf.songListView.isBgMusic = [QXAgoraEngine sharedEngine].isPlayBgMusic; [weakSelf.songListView showInView:weakSelf.view]; }; self.musicView.nextActionBlock = ^{ [[QXAgoraEngine sharedEngine] nextBgMusic]; }; self.musicView.pauseActionBlock = ^(UIButton * _Nonnull playBtn) { playBtn.selected = !playBtn.selected; if (playBtn.isSelected) { [[QXAgoraEngine sharedEngine] pausePlayMusic]; }else{ [[QXAgoraEngine sharedEngine] resumePlayMusic]; } }; [self.settingView hide]; self.songListView.isBgMusic = [QXAgoraEngine sharedEngine].isPlayBgMusic; [self.songListView showInView:self.view]; } break; case QXRoomSettingTypeRoomReport:{ QXReportViewController *reportVC = [[QXReportViewController alloc] init]; reportVC.reportType = @"2"; reportVC.fromId = self.roomId; [self.navigationController pushViewController:reportVC animated:YES]; } break; case QXRoomSettingTypeRoomSubsidy:{ QXRoomSubsidyViewController *reportVC = [[QXRoomSubsidyViewController alloc] init]; reportVC.room_id = self.roomId; [self.navigationController pushViewController:reportVC animated:YES]; } break; case QXRoomSettingTypeSendRedBag:{ QXRedBagSendView *redbagView = [[QXRedBagSendView alloc] init]; redbagView.room_id = self.roomId; [redbagView showInView:self.view]; } break; default: break; } } -(void)didClickHeadLine{ self.sendHeadLineView.isHeadline = YES; MJWeakSelf showLoadingInView(self.view); [QXMineNetwork headlineInitSuccessBlock:^(NSDictionary * _Nonnull dict) { hideLoadingInView(weakSelf.view); NSString *countdown = [NSString stringWithFormat:@"%@",dict[@"countdown"]]; NSString *next_money = [NSString stringWithFormat:@"%@",dict[@"next_money"]]; NSString *now_money = [NSString stringWithFormat:@"%@",dict[@"now_money"]]; weakSelf.sendHeadLineView.coin = next_money; weakSelf.sendHeadLineView.now_coin = now_money; weakSelf.sendHeadLineView.minutes = countdown; [weakSelf.sendHeadLineView showInView:weakSelf.view]; } failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) { hideLoadingInView(weakSelf.view); }]; } -(void)soundAction{ [self.soundListView showInView:self.view]; } #pragma mark - 用户信息查看后操作 -(void)didClickEventType:(QXRoomUserInfoViewEventType)evntType userModel:(nonnull QXRoomUserInfoModel *)userModel pitNumber:(nonnull NSString *)pitNumber{ switch (evntType) { case QXRoomUserInfoViewEventTypeAtTA:{ // @TA [self.bottomView atUserWithName:userModel.nickname]; } break; case QXRoomUserInfoViewEventTypeChat:{ // 聊天 [[QXGlobal shareGlobal] chatWithUserID:userModel.user_id nickname:userModel.nickname avatar:userModel.avatar navagationController:self.navigationController]; } break; case QXRoomUserInfoViewEventTypeGift:{ self.sendGiftView.type = QXSendGiftViewTypeRoom; // 送礼物 if (self.sendGiftView.titles.count == 0) { [self.sendGiftView reloadData]; } QXRoomPitModel *model = [[QXRoomPitModel alloc] init]; model.pit_number = pitNumber; model.user_id = userModel.user_id; model.nickname = userModel.nickname; model.avatar = userModel.avatar; self.sendGiftView.userModel = model; self.sendGiftView.roomId = self.userInfoView.roomId; [self.sendGiftView showInView:self.view]; // [[QXGlobal shareGlobal] showView:self.sendGiftView controller:self popType:(PopViewTypeBottomToUpActionSheet) tapDismiss:YES finishBlock:^{ // // }]; } break; default: break; } } -(void)sendGiftWithUser:(QXRoomPitModel *)user{ self.sendGiftView.type = QXSendGiftViewTypeRoom; // 送礼物 if (self.sendGiftView.titles.count == 0) { [self.sendGiftView reloadData]; } QXRoomPitModel *model = [[QXRoomPitModel alloc] init]; model.pit_number = @""; model.user_id = user.user_id; model.nickname = user.nickname; model.avatar = user.avatar; self.sendGiftView.userModel = model; self.sendGiftView.roomId = self.roomId; [self.sendGiftView showInView:self.view]; // [[QXGlobal shareGlobal] showView:self.sendGiftView controller:self popType:(PopViewTypeBottomToUpActionSheet) tapDismiss:YES finishBlock:^{ // // }]; } #pragma - mark 麦位操作 -(void)upSeatAction{ // if (self.roomModel.room_info.room_up_pit_type.intValue == 1) { // self.upSeatView.isCompere = (self.seatContentView.myPitNumber == 9 || self.roomModel.user_info.is_room_owner.intValue == 1); // self.upSeatView.roomId = self.roomId; // [self.upSeatView showInView:self.view]; // }else{ BOOL isUpSeat = !self.upSeatBtn.selected; [self upDownSeatNetworkWithPitNum:@"" isUpSeat:isUpSeat]; // } } -(void)micTeamAction{ self.upSeatView.isCompere = (self.seatContentView.myPitNumber == 9 || self.roomModel.user_info.is_room_owner.intValue == 1); self.upSeatView.roomId = self.roomId; [self.upSeatView showInView:self.view]; } -(void)upDownSeatNetworkWithPitNum:(NSString*)pitNum isUpSeat:(BOOL)isUpSeat{ [QXMineNetwork roomUpSeatWithRoomId:self.roomId pit_number:pitNum isUpSeat:isUpSeat successBlock:^(NSDictionary * _Nonnull dict) { } failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) { showToast(msg); }]; } -(QXRoomSeatView *)seatContentView{ if (!_seatContentView) { _seatContentView = [[QXRoomSeatView alloc] initWithType:(QXRoomSeatViewTypeNone)]; _seatContentView.hidden = YES; _seatContentView.delegate = self; } return _seatContentView; } -(QXRoomBottomView *)bottomView{ if (!_bottomView) { _bottomView = [[QXRoomBottomView alloc] init]; _bottomView.delegate = self; _bottomView.vc = self; _bottomView.hidden = YES; } return _bottomView; } -(QXRoomChatListView *)chatListView{ if (!_chatListView) { _chatListView = [[QXRoomChatListView alloc] init]; _chatListView.delegate = self; } return _chatListView; } - (QXRoomSongListView *)songListView{ if (!_songListView) { _songListView = [[QXRoomSongListView alloc] initWithFrame:[UIScreen mainScreen].bounds]; _songListView.roomId = self.roomId; } return _songListView; } - (QXSendGiftView *)sendGiftView{ if (!_sendGiftView) { _sendGiftView = [[QXSendGiftView alloc] initWithType:QXSendGiftViewTypeRoom]; _sendGiftView.vc = self; _sendGiftView.roomId = self.roomId; // [_sendGiftView reloadData]; MJWeakSelf _sendGiftView.roomSendSuccessBlock = ^(QXSendGiftViewType sendType, QXGiftModel * _Nonnull giftModel, NSString * _Nonnull giftCount, NSString * _Nonnull userId, NSString * _Nonnull optionId) { // if (self->_continuousView == nil) { [weakSelf.view addSubview:weakSelf.continuousView]; // } weakSelf.continuousView.giftModel = giftModel; weakSelf.continuousView.sendType = sendType; weakSelf.continuousView.userId = userId; weakSelf.continuousView.giftCount = giftCount; switch (sendType) { case QXSendGiftViewTypeFriend:{ weakSelf.continuousView.heartId = optionId; weakSelf.continuousView.auctionId = @""; } break; case QXSendGiftViewTypeAuction:{ weakSelf.continuousView.auctionId = optionId; weakSelf.continuousView.heartId = @""; } break; default: break; } }; _sendGiftView.jumpActivityGiftBlock = ^(QXGiftModel * _Nonnull gift, NSString * _Nonnull userIds) { if (gift.gift_bag.intValue == 10) { weakSelf.skyView.giftModel = gift; weakSelf.skyView.roomId = weakSelf.roomId; weakSelf.skyView.userIds = userIds; weakSelf.skyView.heartId = weakSelf.sendGiftView.heartId; weakSelf.skyView.auctionId = weakSelf.sendGiftView.auctionId; if (weakSelf.sendGiftView.type == QXSendGiftViewTypeAuction) { weakSelf.skyView.heartId = @""; weakSelf.skyView.auctionId = weakSelf.sendGiftView.auctionId; } [weakSelf.sendGiftView hide]; [weakSelf.skyView showInView:weakSelf.view]; }else if(gift.gift_bag.intValue == 11) { weakSelf.ageView.giftModel = gift; weakSelf.ageView.roomId = weakSelf.roomId; weakSelf.ageView.userIds = userIds; weakSelf.ageView.heartId = weakSelf.sendGiftView.heartId; weakSelf.ageView.auctionId = weakSelf.sendGiftView.auctionId; if (weakSelf.sendGiftView.type == QXSendGiftViewTypeAuction) { weakSelf.skyView.heartId = @""; weakSelf.skyView.auctionId = weakSelf.sendGiftView.auctionId; } [weakSelf.sendGiftView hide]; [weakSelf.ageView showInView:weakSelf.view]; }else if(gift.gift_bag.intValue == 12) { weakSelf.timeView.giftModel = gift; weakSelf.timeView.roomId = weakSelf.roomId; weakSelf.timeView.userIds = userIds; weakSelf.timeView.heartId = weakSelf.sendGiftView.heartId; weakSelf.timeView.auctionId = weakSelf.sendGiftView.auctionId; if (weakSelf.sendGiftView.type == QXSendGiftViewTypeAuction) { weakSelf.skyView.heartId = @""; weakSelf.skyView.auctionId = weakSelf.sendGiftView.auctionId; } [weakSelf.sendGiftView hide]; [weakSelf.timeView showInView:weakSelf.view]; } }; } return _sendGiftView; } -(QXSoundListView *)soundListView{ if (!_soundListView) { _soundListView = [[QXSoundListView alloc] initWithFrame:[UIScreen mainScreen].bounds]; } return _soundListView; } -(UIButton *)soundBtn{ if (!_soundBtn) { _soundBtn = [[UIButton alloc] init]; [_soundBtn setImage:[UIImage imageNamed:@"room_sound"] forState:(UIControlStateNormal)]; [_soundBtn addTarget:self action:@selector(soundAction) forControlEvents:(UIControlEventTouchUpInside)]; // _soundBtn.hidden = YES; } return _soundBtn; } -(UIButton *)upSeatBtn{ if (!_upSeatBtn) { _upSeatBtn = [[UIButton alloc] init]; _upSeatBtn.needEventInterval = 0.5; [_upSeatBtn setImage:[UIImage imageNamed:@"room_upseat"] forState:(UIControlStateNormal)]; [_upSeatBtn setImage:[UIImage imageNamed:@"room_downseat"] forState:(UIControlStateSelected)]; [_upSeatBtn addTarget:self action:@selector(upSeatAction) forControlEvents:(UIControlEventTouchUpInside)]; } return _upSeatBtn; } -(QXUpSeatView *)upSeatView{ if (!_upSeatView) { _upSeatView = [[QXUpSeatView alloc] initWithFrame:[UIScreen mainScreen].bounds]; } return _upSeatView; } #pragma mark - 特效 - (UIView *)bgEffectView { if (!_bgEffectView) { _bgEffectView = [[QXGiftPlayerManager shareManager] defaultBgEffectView]; } return _bgEffectView; } -(QXRoomSettingView *)settingView{ if (!_settingView) { _settingView = [[QXRoomSettingView alloc] initWithFrame:[UIScreen mainScreen].bounds]; _settingView.delegate = self; } return _settingView; } -(QXRoomBgSettingView *)roomBgSetView{ if (!_roomBgSetView) { _roomBgSetView = [[QXRoomBgSettingView alloc] initWithFrame:[UIScreen mainScreen].bounds]; } return _roomBgSetView; } -(QXRoomBgMusicView *)musicView{ if (!_musicView) { _musicView = [[QXRoomBgMusicView alloc] init]; } return _musicView; } -(QXRoomUserInfoView *)userInfoView{ if (!_userInfoView) { _userInfoView = [[QXRoomUserInfoView alloc] initWithFrame:[UIScreen mainScreen].bounds]; _userInfoView.delegate = self; } return _userInfoView; } -(QXHeadlineView *)headlineView{ if (!_headlineView) { MJWeakSelf _headlineView = [[QXHeadlineView alloc] init]; _headlineView.getHeadlineBlock = ^{ [weakSelf didClickHeadLine]; }; } return _headlineView; } -(QXDirectSetScaleView *)sendHeadLineView{ if (!_sendHeadLineView) { _sendHeadLineView = [[QXDirectSetScaleView alloc] init]; _sendHeadLineView.roomId = self.roomId; } return _sendHeadLineView; } -(QXRoomPKSearchView *)pkSearchView{ if (!_pkSearchView) { _pkSearchView = [[QXRoomPKSearchView alloc] init]; } return _pkSearchView; } -(QXCabinMovieView *)movieView{ if (!_movieView) { _movieView = [[QXCabinMovieView alloc] init]; } return _movieView; } -(QXContinuousGiftView *)continuousView{ if (!_continuousView) { MJWeakSelf _continuousView = [[QXContinuousGiftView alloc] initWithFrame:CGRectMake(SCREEN_WIDTH-65-12, SCREEN_HEIGHT-70-78-52-34-20-70, 65, 65)]; _continuousView.roomId = self.roomId; _continuousView.dissMissBlock = ^(QXGiftModel * _Nonnull gift) { [weakSelf.continuousView removeFromSuperview]; self->_continuousView = nil; }; } return _continuousView; } -(QXUpSeatCountView *)micTeamView{ if (!_micTeamView) { _micTeamView = [[QXUpSeatCountView alloc] init]; MJWeakSelf [_micTeamView addTapBlock:^(id _Nonnull obj) { [weakSelf micTeamAction]; }]; // _micTeamView.needEventInterval = 0.5; // [_micTeamView setImage:[UIImage imageNamed:@"room_mic_team"] forState:(UIControlStateNormal)]; // [_micTeamView addTarget:self action:@selector(micTeamAction) forControlEvents:(UIControlEventTouchUpInside)]; } return _micTeamView; } -(QXSkyPraizeView *)skyView{ if (!_skyView) { _skyView = [[QXSkyPraizeView alloc] init]; MJWeakSelf _skyView.startBlock = ^{ [weakSelf.skyView hide]; weakSelf.meetView.roomId = weakSelf.roomId; [weakSelf.meetView showInView:weakSelf.view]; }; } return _skyView; } -(QXAgePraizeView *)ageView{ if (!_ageView) { _ageView = [[QXAgePraizeView alloc] init]; MJWeakSelf _ageView.startBlock = ^{ [weakSelf.ageView hide]; weakSelf.meetView.roomId = weakSelf.roomId; [weakSelf.meetView showInView:weakSelf.view]; }; } return _ageView; } -(QXTimePraizeView *)timeView{ if (!_timeView) { _timeView = [[QXTimePraizeView alloc] init]; MJWeakSelf _timeView.startBlock = ^{ [weakSelf.timeView hide]; weakSelf.meetView.roomId = weakSelf.roomId; [weakSelf.meetView showInView:weakSelf.view]; }; } return _timeView; } -(QXActivityTagView *)acTagView{ if (!_acTagView) { _acTagView = [[QXActivityTagView alloc] init]; MJWeakSelf _acTagView.startBlock = ^{ [weakSelf.skyView hide]; weakSelf.meetView.roomId = weakSelf.roomId; [weakSelf.meetView showInView:weakSelf.view]; }; } return _acTagView; } -(QXMeetActivityView *)meetView{ if (!_meetView) { _meetView = [[QXMeetActivityView alloc] init]; _meetView.roomId = self.roomId; } return _meetView; } -(void)stopHWDMP4{ [self.seatContentView stopHWDMP4]; } -(void)playHWDMP4{ [self.seatContentView playHWDMP4]; } -(void)destroyViews{ if (_skyView) { [_skyView destroyViews]; _skyView = nil; } if (_ageView) { [_ageView destroyViews]; _ageView = nil; } if (_timeView) { [_timeView destroyViews]; _timeView = nil; } } -(QXAllRoomHourRankTagView *)hourRankIconView{ if (!_hourRankIconView) { _hourRankIconView = [[QXAllRoomHourRankTagView alloc] init]; MJWeakSelf _hourRankIconView.startBlock = ^{ [weakSelf.hourRankView showInView:weakSelf.view]; }; _hourRankIconView.hidden = YES; } return _hourRankIconView; } -(QXAllRoomHourRankView *)hourRankView{ if (!_hourRankView) { _hourRankView = [[QXAllRoomHourRankView alloc] init]; } return _hourRankView; } -(QXRedBagTagView *)redBagTagView{ if (!_redBagTagView) { _redBagTagView = [[QXRedBagTagView alloc] init]; _redBagTagView.hidden = YES; MJWeakSelf _redBagTagView.startBlock = ^(BOOL isList) { if (isList) { weakSelf.redbagListView.dataArray = [QXRedPacketManager sharedManager].allRedPackets; [weakSelf.redbagListView showInView:weakSelf.view]; }else{ QXRedPacketModel *model = [QXRedPacketManager sharedManager].allRedPackets.firstObject; if (model.is_qiang.intValue == 1) { QXRedBagRecordViewController *vc = [[QXRedBagRecordViewController alloc] init]; vc.redbagId = model.redpacket_id; [weakSelf.navigationController pushViewController:vc animated:YES]; }else{ weakSelf.redbagDrawView.isFromToComment = NO; weakSelf.redbagDrawView.isCollectedRoom = weakSelf.roomModel.user_info.is_collect.intValue==1; weakSelf.redbagDrawView.redpacketModel = model; [weakSelf.redbagDrawView showInView:weakSelf.view]; } } }; } return _redBagTagView; } -(QXRedBagDrawView *)redbagDrawView{ if (!_redbagDrawView) { _redbagDrawView = [[QXRedBagDrawView alloc] init]; _redbagDrawView.room_id = self.roomId; MJWeakSelf _redbagDrawView.toInputPwdBlock = ^(NSString * _Nonnull password, QXRedPacketModel * _Nonnull redpacketModel) { [weakSelf.bottomView inputMessageWithName:password redpacketModel:redpacketModel]; }; _redbagDrawView.collectRoomBlock = ^{ [weakSelf.titleView setRoomCollect:YES]; }; } return _redbagDrawView; } -(QXRedBagListView *)redbagListView{ if (!_redbagListView) { _redbagListView = [[QXRedBagListView alloc] init]; MJWeakSelf _redbagListView.didSelectedRedBlock = ^(QXRedPacketModel * _Nonnull model) { if (model.is_qiang.intValue == 1) { QXRedBagRecordViewController *vc = [[QXRedBagRecordViewController alloc] init]; vc.redbagId = model.redpacket_id; [weakSelf.navigationController pushViewController:vc animated:YES]; }else{ weakSelf.redbagDrawView.isFromToComment = NO; weakSelf.redbagDrawView.isCollectedRoom = weakSelf.roomModel.user_info.is_collect.intValue==1; weakSelf.redbagDrawView.redpacketModel = model; [weakSelf.redbagDrawView showInView:weakSelf.view]; } }; } return _redbagListView; } -(QXRoomEmojiView *)emojiView{ if (!_emojiView) { _emojiView = [[QXRoomEmojiView alloc] init]; } return _emojiView; } -(QXRoomDayTaskTagView *)dayTaskTagView{ if (!_dayTaskTagView) { _dayTaskTagView = [[QXRoomDayTaskTagView alloc] init]; _dayTaskTagView.hidden = YES; MJWeakSelf _dayTaskTagView.startBlock = ^{ QXTaskViewController *vc = [[QXTaskViewController alloc] init]; [weakSelf.navigationController pushViewController:vc animated:YES]; }; } return _dayTaskTagView; } @end