// // BGTLinkMicPlayController.m // BuguLive // // Created by xfg on 16/12/5. // Copyright © 2016年 xfg. All rights reserved. // #import #import "BGTLinkMicPlayController.h" #import "UserView.h" #import "VoiceLianmaiUserModel.h" #import "VoiceLianmaiView.h" @implementation TCLivePushListenerImpl { } - (void)onPushEvent:(int)evtID withParam:(NSDictionary*)param { if (self.delegate) { [self.delegate onLivePushEvent:self.pushUrl withEvtID:evtID andParam:param]; } } - (void)onNetStatus:(NSDictionary*) param { if (self.delegate) { [self.delegate onLivePushNetStatus:self.pushUrl withParam:param]; } } @end @interface BGTLinkMicPlayController() { BOOL _isNeedLoading; // 是否需要展示加载指示器 UIView* _smallPlayVideoView; // 小主播预览窗口 UIView* _fullScreenVideoView; // 大主播全屏窗口 UIView* _loadingBackground; // 加载中的背景 UIImageView * _loadingImageView; // 加载中的背景图 TCLivePushListenerImpl* _txLivePushListener; // 小主播推流监听 TXLivePushConfig * _txLivePushConfig; // 小主播推流配置 TCLivePlayListenerImpl* _txLivePlayListener; // 拉流监听 TXLivePlayConfig * _txLivePlayConfig; // 拉流配置 NSMutableArray *lianMaiuser; UserView *userView1; UserView *userView2; UserView *userView3; } @property (nonatomic,strong) UIView *userListView; @property(nonatomic, assign) BOOL isBeingLinkMic; // 是否正在连麦中 @end @implementation BGTLinkMicPlayController - (void)viewDidLoad { [super viewDidLoad]; // _lianmaiOpenSound = YES; //声网dev lianMaiuser = [NSMutableArray array]; _isBeingLinkMic = false; [GlobalVariables sharedInstance].isBeingLinkMic = _isBeingLinkMic; _isWaitingResponse = false; _isNeedLoading = YES; _txLivePlayListener = [[TCLivePlayListenerImpl alloc] init]; _txLivePlayListener.delegate = self; _txLivePlayConfig = [[TXLivePlayConfig alloc] init]; _playItemArray = [NSMutableArray array]; _linkMemeberSet = [NSMutableSet set]; self.userListView.hidden = YES; userView1.hidden = YES; userView2.hidden = YES; userView3.hidden = YES; userView1.userInteractionEnabled = YES; userView2.userInteractionEnabled = YES; userView3.userInteractionEnabled = YES; // [self reloduserListView]; [self addLinkMicPlayItem]; } - (UIView *)userListView { if (!_userListView) { int userViewWidth = 80; int userViewHeight = userViewWidth * 1.5; _userListView = [[UIView alloc] initWithFrame:CGRectMake(kScreenW - userViewWidth - 10, kScreenH - userViewHeight*3 - 90, 0, 0)]; _userListView.backgroundColor = kClearColor; [[GlobalVariables sharedInstance].tliveView addSubview:_userListView]; userView1 = [UserView getView]; userView1.delegate = self; userView1.frame = CGRectMake(0, 0, userViewWidth, userViewHeight); userView1.backgroundColor = kRedColor; [_userListView addSubview:userView1]; userView2 = [UserView getView]; userView2.delegate = self; userView2.frame = CGRectMake(0, 0, userViewWidth, userViewHeight); userView2.backgroundColor = kYellowColor; [_userListView addSubview:userView2]; userView3 = [UserView getView]; userView3.delegate = self; userView3.frame = CGRectMake(0, 0, userViewWidth, userViewHeight); [_userListView addSubview:userView3]; } return _userListView; } //点击视频或者音频代理 - (void)clickVideoBtn:(UserView *)view { //如果按钮当前select NO,则要下一步则要关闭视频 if(view.videoBtn.selected == NO) { [self.trtcCloud muteLocalVideo:TRTCVideoStreamTypeBig mute:YES]; } else { [self.trtcCloud muteLocalVideo:TRTCVideoStreamTypeBig mute:NO]; } NSLog(@"点击了视频"); } - (void)clickVoiceBtn:(UserView *)view { //如果按钮当前select NO,则要下一步则要关闭音频 if(view.voiceBtn.selected == NO) { [self.trtcCloud muteLocalAudio:YES]; } else { [self.trtcCloud muteLocalAudio:NO]; } NSLog(@"点击了音频"); } - (void)clickUserView:(UserView *)view { [userView1 setSelect:NO]; [userView2 setSelect:NO]; [userView3 setSelect:NO]; // post notification // NSDictionary * userInfo = [NSDictionary dictionaryWithObject:view.uid forKey:@"uid"]; // [[NSNotificationCenter defaultCenter] postNotificationName:@"showGiftView" object:self userInfo:userInfo]; [view setSelect:YES]; } #pragma mark - ----------------------- 腾讯云 delegate ----------------------- - (void)enterRoomWithTXTRTC { // 创建 SDK 实例(单例模式)并设置事件监听器 // Create trtc instance(singleton) and set up event listeners _trtcCloud = [TRTCCloud sharedInstance]; [_trtcCloud addDelegate:self]; // [self.trtcCloud switchRole:TRTCRoleAnchor]; [self.trtcCloud startLocalAudio:TRTCAudioQualityMusic]; // [self.trtcCloud switchRole:TRTCRoleAudience]; TRTCParams *params = [[TRTCParams alloc] init]; // 以字符串房间号为例 params.roomId = self.roomIDStr.intValue; params.userId = [IMAPlatform sharedInstance].host.userId; // 从业务后台获取到的 UserSig params.userSig = [IMALoginParam loadFromLocal].userSig; // 替换成您的 SDKAppID params.sdkAppId = TXSDKAppID; // 根据需要指定用户角色 params.role = TRTCRoleAudience; if (self.liveInfo.user_id.intValue == [IMAPlatform sharedInstance].host.userId.intValue) { params.role = TRTCRoleAnchor; } // 根据需要指定场景 [self.trtcCloud enterRoom:params appScene:TRTCAppSceneLIVE]; self.trtcCloud = [TRTCCloud sharedInstance]; // 将 denny 的主路画面切换到一个悬浮的小窗口中(假如该迷你小窗口为 miniFloatingView) // [self.trtcCloud updateRemoteView:miniFloatingView streamType:TRTCVideoStreamTypeBig forUser:@"denny"]; // 将远端用户 denny 的主路画面设置为填充模式,并开启左右镜像模式 TRTCRenderParams *param = [[TRTCRenderParams alloc] init]; param.fillMode = TRTCVideoFillMode_Fill; param.mirrorType = TRTCVideoMirrorTypeDisable; // 播放 denny 的摄像头画面(我们称之为“主路画面”) [self.trtcCloud startRemoteView:self.liveInfo.user_id streamType:TRTCVideoStreamTypeBig view:_fullScreenVideoView]; } //我们可以让自己的类继承TRTCCloudDelegate,并重载 onError 函数,最后将 this 指针通过 TRTCCCloud 的 delegate 属性设置给 SDK,就可以在当前类中监听来自 SDK 的回调事件了。 // 监听 SDK 的事件,并对“摄像头未被授权”等错误进行日志打印 - (void)onError:(TXLiteAVError)errCode errMsg:(nullable NSString *)errMsg extInfo:(nullable NSDictionary *)extInfo{ NSLog(@"onError code: %d message: %@", errCode, errMsg); if (ERR_CAMERA_NOT_AUTHORIZED == errCode) { NSString *errorInfo = @"Current application is not authorized to use the camera:"; errorInfo = [errorInfo stringByAppendingString: errMsg]; NSLog(@"%@",errorInfo); // [self toastTip:errorInfo]; } } - (void)onEnterRoom:(NSInteger)result { if (result > 0) { // result 代表加入房间所消耗的时间(毫秒) // [self toastTip:@"Enter room succeed!"]; NSLog(@"加入房间成功"); } else { // result 代表进房失败的错误码 // [self toastTip:@"Enter room failed!"]; } } - (void)onRemoteUserEnterRoom:(NSString *)userId { if(self.isBeingLinkMic) { //功能描述:订阅远端用户的视频流,并绑定视频渲染控件 [self.trtcCloud startRemoteView:self.liveInfo.user_id streamType:TRTCVideoStreamTypeBig view:self.videoContrainerViewAgora]; if(userId.intValue != self.liveInfo.user_id.intValue && userId.intValue != [IMAPlatform sharedInstance].host.userId.intValue && ![lianMaiuser containsObject:userId]) { [lianMaiuser addObject:userId]; // [self reloduserListView]; } } else { if(userId.intValue == self.liveInfo.user_id.intValue) { TRTCRenderParams *params = [[TRTCRenderParams alloc] init]; // 画面镜像模式 params.mirrorType = TRTCVideoMirrorTypeDisable; // 画面填充模式 params.fillMode = TRTCVideoFillMode_Fill; // 画面旋转角度 params.rotation = TRTCVideoRotation_0; // 设置远端画面的渲染模式 [self.trtcCloud setRemoteRenderParams:userId streamType:TRTCVideoStreamTypeBig params:params]; //功能描述:订阅远端用户的视频流,并绑定视频渲染控件 [self.trtcCloud startRemoteView:userId streamType:TRTCVideoStreamTypeBig view:self.videoContrainerView]; } else { if([GlobalVariables sharedInstance].isBeingPK) { //如果正在pk把对方的也加进来 // AgoraRtcVideoCanvas *videoCanvas = [[AgoraRtcVideoCanvas alloc] init]; // videoCanvas.uid = uid; // videoCanvas.renderMode = AgoraVideoRenderModeHidden; // videoCanvas.view = self.rightVideoContrainerView; // // 设置远端视图 // [self.agoraKit setupRemoteVideo:videoCanvas]; TRTCRenderParams *params = [[TRTCRenderParams alloc] init]; // 画面镜像模式 params.mirrorType = TRTCVideoMirrorTypeDisable; // 画面填充模式 params.fillMode = TRTCVideoFillMode_Fill; // 画面旋转角度 params.rotation = TRTCVideoRotation_0; // 设置远端画面的渲染模式 [self.trtcCloud setRemoteRenderParams:userId streamType:TRTCVideoStreamTypeBig params:params]; //功能描述:订阅远端用户的视频流,并绑定视频渲染控件 [self.trtcCloud startRemoteView:userId streamType:TRTCVideoStreamTypeBig view:self.rightVideoContrainerView]; } } } //用户加入 NSMutableDictionary *parmDict = [NSMutableDictionary dictionary]; [parmDict setObject:@"live_multi_room" forKey:@"ctl"]; [parmDict setObject:@"api_mic_list" forKey:@"act"]; [parmDict setObject:[BogoNetwork shareInstance].token forKey:@"token"]; [parmDict setObject:[BogoNetwork shareInstance].uid forKey:@"uid"]; [parmDict setObject:self.liveInfo.room_id forKey:@"video_id"]; [[NetHttpsManager manager] POSTWithParameters:parmDict SuccessBlock:^(NSDictionary *responseJson) { FWWeakify(self) if ([responseJson toInt:@"status"] == 1) { NSMutableArray *model_arr = [NSMutableArray array]; NSArray *arr = [responseJson valueForKey:@"list"]; if ([arr isKindOfClass:[NSArray class]]) { for (NSDictionary *dic in arr) { VoiceLianmaiUserModel *model =[VoiceLianmaiUserModel mj_objectWithKeyValues: dic]; if(model.user_id.intValue == self.liveInfo.user_id.intValue) { continue; } [model_arr addObject:model]; } } [self adjustPlayItemVoiceUserList:model_arr]; } } FailureBlock:^(NSError *error) { }]; [self updateLianMaiCoin]; } // 离开房间事件回调 - (void)onExitRoom:(NSInteger)reason { if (reason == 0) { NSLog(@"主动调用 exitRoom 退出房间"); } else if (reason == 1) { NSLog(@"被服务器踢出当前房间"); } else if (reason == 2) { NSLog(@"当前房间整个被解散"); } //自己在连麦中,退出房间,关闭连麦 if (self.isLinkingMic) { [BGLiveSDKViewModel tLiveStopMick:self.roomIDStr toUserId:[IMAPlatform sharedInstance].host.userId]; } } - (void)onUserVoiceVolume:(NSArray *)userVolumes totalVolume:(NSInteger)totalVolume { NSLog(@"totalVolume"); NSLog(@"%ld",totalVolume); /*bug:当a用户在麦上正在说话时,切换到无网状态,此时虽然还显示在麦上(im还没下线), 但观众席听不到声音,光圈还在闪烁 原因: 这时观众席speakers 里面找不到a,就不会进入for循环,就不会更新a的声音为0 解决: 1先找到 麦上的用户 2去判断有无声音 */ for (TRTCVolumeInfo *info in userVolumes) { NSString *uid = @""; if (info.userId.intValue == 0) { uid = [IMAPlatform sharedInstance].host.userId; }else{ uid = [NSString stringWithFormat:@"%@",info.userId]; } if([[userView1 uid] isEqualToString:uid]) { userView1.totalVolume = info.volume; } if([[userView2 uid] isEqualToString:uid]) { userView2.totalVolume = info.volume; } if([[userView3 uid] isEqualToString:uid]) { userView3.totalVolume = info.volume; } //speaker.volume } if(userVolumes.count == 0) { userView1.totalVolume = 0; userView2.totalVolume = 0; userView3.totalVolume = 0; } // [self.uiController.micView setUsers:self.users]; } #pragma mark - ----------------------- 腾讯云 delegate end ----------------------- - (void)joinChannel2 { // 频道内每个用户的 uid 必须是唯一的 int uid = [IMAPlatform sharedInstance].host.userId.intValue; [self.trtcCloud startLocalAudio:TRTCAudioQualityMusic]; // 主播: TRTCRoleAnchor // 观众: TRTCRoleAudience // [self.trtcCloud switchRole:TRTCRoleAudience]; TRTCParams *params = [[TRTCParams alloc] init]; // 以字符串房间号为例 params.roomId = self.liveInfo.room_id.intValue; params.userId = [IMAPlatform sharedInstance].host.userId; // 从业务后台获取到的 UserSig params.userSig = [IMALoginParam loadFromLocal].userSig; // 替换成您的 SDKAppID params.sdkAppId = TXSDKAppID; // 根据需要指定用户角色 params.role = TRTCRoleAudience; // 根据需要指定场景 [self.trtcCloud enterRoom:params appScene:TRTCAppSceneLIVE]; } -(void)updateLianMaiCoin { //用户加入 NSMutableDictionary *parmDict = [NSMutableDictionary dictionary]; [parmDict setObject:@"live_multi_room" forKey:@"ctl"]; [parmDict setObject:@"api_mic_list" forKey:@"act"]; [parmDict setObject:[BogoNetwork shareInstance].token forKey:@"token"]; [parmDict setObject:[BogoNetwork shareInstance].uid forKey:@"uid"]; [parmDict setObject:self.liveInfo.room_id forKey:@"video_id"]; [[NetHttpsManager manager] POSTWithParameters:parmDict SuccessBlock:^(NSDictionary *responseJson) { FWWeakify(self) if ([responseJson toInt:@"status"] == 1) { NSMutableArray *model_arr = [NSMutableArray array]; NSArray *arr = [responseJson valueForKey:@"list"]; if ([arr isKindOfClass:[NSArray class]]) { for (NSDictionary *dic in arr) { VoiceLianmaiUserModel *model =[VoiceLianmaiUserModel mj_objectWithKeyValues: dic]; if(model.user_id.intValue == self.liveInfo.user_id.intValue) { continue; } if(model.user_id.intValue == userView1.uid.intValue) { userView1.numberLab.text = model.coin; } if(model.user_id.intValue == userView2.uid.intValue) { userView2.numberLab.text = model.coin; } if(model.user_id.intValue == userView2.uid.intValue) { userView3.numberLab.text = model.coin; } } } } } FailureBlock:^(NSError *error) { }]; } - (void)addLinkMicPlayItem { for (int i = 0; i<2; i++) { BGTLinkMicPlayItem* playItem = [[BGTLinkMicPlayItem alloc] init]; playItem.videoView = [[UIView alloc] init]; [self.view addSubview:playItem.videoView]; playItem.livePlayListener = [[TCLivePlayListenerImpl alloc] init]; playItem.livePlayListener.delegate = self; TXLivePlayConfig * playConfig0 = [[TXLivePlayConfig alloc] init]; playItem.livePlayer = [[TXLivePlayer alloc] init]; playItem.livePlayer.delegate = playItem.livePlayListener; [playItem.livePlayer setConfig: playConfig0]; [playItem.livePlayer setRenderMode:RENDER_MODE_FILL_EDGE]; playItem.pending = false; playItem.itemIndex = i; [playItem emptyPlayInfo]; [_playItemArray addObject:playItem]; } } - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; if (_smallPlayVideoView == nil) { _smallPlayVideoView = [[UIView alloc] init]; [self.view addSubview:_smallPlayVideoView]; } if (_fullScreenVideoView == nil) { _fullScreenVideoView = self.videoContrainerView; } } #pragma mark - ----------------------- 开始、停止连麦 ----------------------- #pragma mark 开始连麦 - (void)startVideoLiveLinkMic { // if (_isBeingLinkMic || _isWaitingResponse) // { //// [self initializeAgoraEngine]; //// [self setChannelProfile]; // [self setClientRole]; // [self setupLocalVideo]; // [self reloduserListView];; // } if (_isBeingLinkMic) { return; } _isBeingLinkMic = YES; [self authorizationCheck]; //结束从CDN拉流 // [self stopRtmp]; // self.videoContrainerViewAgora.hidden = NO; //1.加入房 // [self initializeAgoraEngine]; // [self setChannelProfile]; // [self setClientRole]; // [self setupLocalVideo]; // [self reloduserListView]; [self joinChannel2]; //2.设置自己的预览图 //3.加载主播视频 //4.加载其他观众视图 [GlobalVariables sharedInstance].isBeingLinkMic = _isBeingLinkMic; } #pragma mark 停止连麦 - (void)stopLinkMic { _isNeedLoading = YES; // [self.agoraKit setClientRole:AgoraClientRoleAudience]; [self.trtcCloud switchRole:(TRTCRoleAudience)]; //自己在连麦中,退出房间,关闭连麦 if (self.isLinkingMic) { self.isLinkingMic = NO; [BGLiveSDKViewModel tLiveStopMick:self.roomIDStr toUserId:[IMAPlatform sharedInstance].host.userId]; } if (_isBeingLinkMic) { } } - (void)startLinkMic:(TLiveMickModel *)mickModel { if (!_isBeingLinkMic) { _push_rtmp2 = mickModel.push_rtmp2; _play_rtmp_acc = mickModel.play_rtmp_acc; [self startVideoLiveLinkMic]; } } #pragma mark - //语音连麦窗口 - (void)adjustPlayItemVoiceUserList:(NSArray *)userlist { NSLog(@"刷新语音连麦视图"); NSLog(@"userlist = %@",userlist); self.userListView.hidden = NO; userView1.hidden = YES; userView2.hidden = YES; userView3.hidden = YES; // NSMutableArray *needAddLianMaiUser = [NSMutableArray array];//需要连麦的列表 // NSMutableArray *needDelLianMaiUser = [NSMutableArray array];//需要删除的列表 //默认自己没有在连麦中 self.isLinkingMic = NO; for (int i=0; i 1) { [realViewArr mas_remakeConstraints:^(MASConstraintMaker *make) { make.height.equalTo(@(userViewHeight)); make.width.equalTo(@(userViewWidth)); }]; [realViewArr mas_distributeViewsAlongAxis:MASAxisTypeVertical withFixedItemLength:userViewHeight leadSpacing:0 tailSpacing:0]; } else if(realViewArr.count == 1) { [realViewArr[0] mas_remakeConstraints:^(MASConstraintMaker *make) { make.bottom.equalTo(self.userListView); make.height.equalTo(@(userViewHeight)); make.width.equalTo(@(userViewWidth)); }]; } } #pragma mark 调整连麦窗口 - (void)adjustPlayItem:(TLiveMickListModel *)mickListModel { } - (BGTLinkMicPlayItem*)getPlayItemByStreamUrl:(NSString*)streamUrl { if (streamUrl) { for (BGTLinkMicPlayItem* playItem in _playItemArray) { if ([streamUrl isEqualToString:playItem.playUrl]) { return playItem; } } } return nil; } #pragma mark 请求连麦超时 - (void)onWaitLinkMicResponseTimeOut { if (_isWaitingResponse == YES) { _isWaitingResponse = NO; [self toastTip:ASLocalizedString(@"连麦请求超时,主播没有做出回应")]; } } #pragma mark 连麦过程出错处理 - (void)handleLinkMicFailed:(NSString*)message { [self toastTip:message]; //结束连麦 [self stopLinkMic]; [self startRtmp:self.create_type]; } - (BOOL)startRtmp:(NSInteger)create_type { [super startRtmp:create_type]; if([GlobalVariables sharedInstance].openAgora) { // [self initializeAgoraEngine]; [self enterRoomWithTXTRTC]; // [self setClientRole]; // [self setupLocalVideo]; // [self joinChannel]; } return YES; } #pragma mark 权限检查 - (void)authorizationCheck { //检查麦克风权限 AVAuthorizationStatus statusAudio = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeAudio]; if (statusAudio == AVAuthorizationStatusDenied) { [self toastTip:ASLocalizedString(@"获取麦克风权限失败,请前往隐私-麦克风设置里面打开应用权限")]; return; } //是否有摄像头权限 AVAuthorizationStatus statusVideo = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo]; if (statusVideo == AVAuthorizationStatusDenied) { [self toastTip:ASLocalizedString(@"获取摄像头权限失败,请前往隐私-相机设置里面打开应用权限")]; return; } if ([[[UIDevice currentDevice] systemVersion] floatValue] < 8.0) { [self toastTip:ASLocalizedString(@"系统不支持硬编码, 启动连麦失败")]; return; } } #pragma mark - ----------------------- 代理事件 ----------------------- - (void)onReceiveMemberJoinNotify:(NSString*)userID withStreamID:(NSString*)streamID { } - (void)onReceiveMemberExitNotify:(NSString*)userID { } - (void)onLivePushEvent:(NSString*) pushUrl withEvtID:(int)event andParam:(NSDictionary*)param { NSLog(@"==========PushEvtID2:%d",event); if (event == PUSH_EVT_PUSH_BEGIN) // 开始推流事件通知 { //2.通知主播拉取自己的流 // [_tcLinkMicMgr sendMemberJoinNotify:_liveInfo.userid withJoinerID:profile.identifier andJoinerPlayUrl:_playUrl]; } else if (event == PUSH_ERR_NET_DISCONNECT) { //推流失败事件通知 [self handleLinkMicFailed:ASLocalizedString(@"推流失败,结束连麦")]; } else if (event == PUSH_WARNING_HW_ACCELERATION_FAIL) { [self handleLinkMicFailed:ASLocalizedString(@"启动硬编码失败,结束连麦")]; } } - (void)onLivePushNetStatus:(NSString*)pushUrl withParam:(NSDictionary*) param { [super onNetStatus:param]; } - (void)onLivePlayEvent:(NSString*)playUrl withEvtID:(int)event andParam:(NSDictionary*)param { BGTLinkMicPlayItem *playItem = [self getPlayItemByStreamUrl:playUrl]; if (event == PLAY_EVT_PLAY_BEGIN) { if (playItem) { [playItem stopLoading]; } else { [self stopLoading]; } } else if (event == PLAY_EVT_PLAY_END) { if (playItem) { [playItem stopLoading]; } } else if (event == PLAY_ERR_NET_DISCONNECT) { if (playItem) { [playItem stopPlay]; [playItem stopLoading]; [playItem emptyPlayInfo]; } } else if (event == PLAY_WARNING_HW_ACCELERATION_FAIL) { if (playItem) { [playItem stopLoading]; } } else if (event == PLAY_ERR_GET_RTMP_ACC_URL_FAIL) { [playItem reStartPlay]; } [super onPlayEvent:event withParam:param]; } - (void)onLivePlayNetStatus:(NSString*)playUrl withParam:(NSDictionary*)param { } #pragma mark - ----------------------- 结束视频 ----------------------- - (void)endVideo { [self stopLinkMic]; [super stopRtmp]; } #pragma mark - ----------------------- 加载动画 ----------------------- - (void)startLoading { if (_loadingBackground) { _loadingBackground.hidden = NO; } if (_loadingImageView) { _loadingImageView.hidden = NO; [_loadingImageView startAnimating]; } } - (void)stopLoading { if (_loadingBackground) { _loadingBackground.hidden = YES; _loadingBackground = nil; } if (_loadingImageView) { _loadingImageView.hidden = YES; [_loadingImageView stopAnimating]; _loadingImageView = nil; } } #pragma mark - ----------------------- 进入前后台 ----------------------- #pragma mark app进入后台 - (void)onAppDidEnterBackGround { [super onAppDidEnterBackGround]; if (_isBeingLinkMic) { [_txLivePush pausePush]; } } #pragma mark app将要进入前台 - (void)onAppWillEnterForeground { [super onAppWillEnterForeground]; if (_isBeingLinkMic) { [_txLivePush resumePush]; } } @end