...
|
...
|
@@ -150,7 +150,7 @@ |
|
|
AFNetworkReachabilityManager *manager = [AFNetworkReachabilityManager sharedManager];
|
|
|
[manager setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
|
|
|
if (status == AFNetworkReachabilityStatusNotReachable) {
|
|
|
[YH_Tool alert:@"网络已断开" type:YHBAlertTypeMessage autoHide:NO];
|
|
|
[YH_Tool alert:@"网络已断开" type:YHBAlertTypeMessage autoHide:YES];
|
|
|
} else {
|
|
|
[YH_Tool hideAlert];
|
|
|
}
|
...
|
...
|
@@ -182,9 +182,10 @@ |
|
|
if (error) {
|
|
|
[self toastTip:[NSString stringWithFormat:@"开始失败,原因:%@",error.localizedDescription]];
|
|
|
[[NSUserDefaults standardUserDefaults] removeObjectForKey:kPushging];
|
|
|
_currentChannel = nil;
|
|
|
}else {
|
|
|
if ([self startRtmp]) {
|
|
|
[self toastTip:@"开始直播"];
|
|
|
[YH_Tool alertMessage:@"直播开始"];
|
|
|
_switchLock = NO;
|
|
|
_totalTime = _currentChannel.totalTime.integerValue;
|
|
|
_timer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(updateInfoView) userInfo:nil repeats:YES];
|
...
|
...
|
@@ -198,10 +199,10 @@ |
|
|
self.socketService.userName = @"";
|
|
|
[self.socketService connect];
|
|
|
|
|
|
_switchLock=NO;
|
|
|
} else {
|
|
|
[self toastTip:@"直播开始失败"];
|
|
|
[[NSUserDefaults standardUserDefaults] removeObjectForKey:kPushging];
|
|
|
_currentChannel = nil;
|
|
|
}
|
|
|
}
|
|
|
[_liveButton addTarget:self action:@selector(liveButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
|
...
|
...
|
@@ -530,9 +531,11 @@ |
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
DLog(@"通知结束成功");
|
|
|
[self toastTip:@"通知结束成功"];
|
|
|
[YH_Tool alertMessage:@"直播结束"];
|
|
|
|
|
|
[sock disconnect];
|
|
|
_socket = nil;
|
|
|
[self loadChannelData];//防止主播再次进入同一间房间。
|
|
|
// [self loadChannelData];//防止主播再次进入同一间房间。
|
|
|
_inPushing = NO;
|
|
|
[_socketTimer invalidate];
|
|
|
_socketTimer = nil;
|
...
|
...
|
@@ -541,7 +544,7 @@ |
|
|
_liveButton.selected = !_liveButton.selected;
|
|
|
|
|
|
[[YH_NetworkAdapter adapter] setStatusWithStat:PushStatusEnd andRoomId:_currentChannel.room completion:^(BOOL flag, NSError *error) {
|
|
|
|
|
|
_currentChannel = nil;
|
|
|
}];
|
|
|
[_socketService logout];
|
|
|
_socketService=nil;
|
...
|
...
|
@@ -619,19 +622,58 @@ |
|
|
|
|
|
- (void)channelPressed:(UIButton *)sender {
|
|
|
|
|
|
if (!_channels.count) {
|
|
|
[self loadChannelData];
|
|
|
[self toastTip:@"暂无可用直播间,稍后再试!"];
|
|
|
return;
|
|
|
}
|
|
|
if (!_inPushing) {
|
|
|
[self loadChannelData];
|
|
|
[self toastTip:@"房间列表更新中!"];
|
|
|
|
|
|
if (_currentChannel) {
|
|
|
if (_totalTime<122) {
|
|
|
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:@"直播时间小于2分钟,不可以结束直播。" delegate:nil cancelButtonTitle:@"ok" otherButtonTitles:nil, nil];
|
|
|
[alert show];
|
|
|
} else {
|
|
|
[YH_EndViewController showInController:self secret:_currentChannel.secret completionBlock:^(NSDictionary *dic, BOOL success) {
|
|
|
[_timer invalidate];
|
|
|
[self socketSendEndNotify];//通知结束。
|
|
|
}];
|
|
|
}
|
|
|
}else {
|
|
|
[YH_RoomSecretViewController showInController:self completionBlock:^(NSDictionary *dic, BOOL success) {
|
|
|
|
|
|
if (success) {
|
|
|
YH_ChannelModel *model = [YH_ChannelModel new];
|
|
|
model.roomTitle = dic[@"name"];
|
|
|
model.roomURL = dic[@"url"];
|
|
|
model.channel_id = dic[@"channel_id"];
|
|
|
model.cid = dic[@"cid"];
|
|
|
model.app = dic[@"app"];
|
|
|
model.type = dic[@"type"];
|
|
|
model.room = dic[@"id"];
|
|
|
model.title = dic[@"title"];
|
|
|
model.secret = dic[@"secret"];
|
|
|
|
|
|
_currentChannel = model;
|
|
|
|
|
|
[[YH_NetworkAdapter adapter] setStatusWithStat:PushStatusStart andRoomId:_currentChannel.room completion:^(BOOL flag, NSError *error) {
|
|
|
|
|
|
if (error) {
|
|
|
[YH_Tool alertMessage:[NSString stringWithFormat:@"开始失败,原因:%@",error.localizedDescription]];
|
|
|
}else {
|
|
|
if ([self startRtmp]) {
|
|
|
[YH_Tool alertMessage:@"开始直播"];
|
|
|
|
|
|
_totalTime = 0;
|
|
|
_timer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(updateInfoView) userInfo:nil repeats:YES];
|
|
|
[_timer fire];
|
|
|
|
|
|
[self clearLog];
|
|
|
|
|
|
}else {
|
|
|
[self toastTip:@"直播开始失败"];
|
|
|
}
|
|
|
}
|
|
|
}];
|
|
|
}else {
|
|
|
[YH_Tool alertMessage:@"开始失败"];
|
|
|
}
|
|
|
}];
|
|
|
}
|
|
|
[self hideAllToolView];
|
|
|
_channelPannel.hidden = sender.selected;
|
|
|
sender.selected = !sender.selected;
|
|
|
|
|
|
}
|
|
|
|
|
|
- (void)fullScreenPressed:(UIButton *)sender {
|
...
|
...
|
@@ -652,16 +694,12 @@ |
|
|
}
|
|
|
|
|
|
- (void)torchPressed:(UIButton *)sender {
|
|
|
|
|
|
[YH_EndViewController showInController:self secret:@"9527" completionBlock:^(NSDictionary *dic, BOOL success) {
|
|
|
|
|
|
}];
|
|
|
// if (_livePush.frontCamera) {//前置摄像头的AVcapturesession会与后置摄像头的闪光灯冲突,所以前置摄像头的情况下不允许开启闪光灯。
|
|
|
// [self toastTip:@"前置摄像头不存在闪光灯。"];
|
|
|
// return;
|
|
|
// }
|
|
|
// [_livePush toggleTorch:!sender.selected];
|
|
|
// sender.selected = !sender.selected;
|
|
|
if (_livePush.frontCamera) {//前置摄像头的AVcapturesession会与后置摄像头的闪光灯冲突,所以前置摄像头的情况下不允许开启闪光灯。
|
|
|
[self toastTip:@"前置摄像头不存在闪光灯。"];
|
|
|
return;
|
|
|
}
|
|
|
[_livePush toggleTorch:!sender.selected];
|
|
|
sender.selected = !sender.selected;
|
|
|
}
|
|
|
|
|
|
- (void)liveButtonPressed:(UIButton *)sender {
|
...
|
...
|
@@ -700,7 +738,8 @@ |
|
|
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
|
|
|
|
|
|
if (alertView.tag == ContinueAlertTag && buttonIndex == 0) {
|
|
|
[self liveButtonPressed:_liveButton];
|
|
|
[self continueRTMP];
|
|
|
// [self liveButtonPressed:_liveButton];
|
|
|
} else if (alertView.tag == ValidateAlertTag && alertView.firstOtherButtonIndex == buttonIndex) {
|
|
|
UITextField *txtField = [alertView textFieldAtIndex:0];
|
|
|
if ([txtField.text isEqualToString:_currentChannel.secret]) {
|
...
|
...
|
@@ -1236,7 +1275,7 @@ |
|
|
|
|
|
_channelButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
|
[_channelButton addTarget:self action:@selector(channelPressed:) forControlEvents:UIControlEventTouchUpInside];
|
|
|
[_channelButton setTitle:@"频道" forState:UIControlStateNormal];
|
|
|
[_channelButton setTitle:@"房间" forState:UIControlStateNormal];
|
|
|
[bottomToolView addSubview:_channelButton];
|
|
|
_beautyButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
|
[_beautyButton addTarget:self action:@selector(beautyPressed:) forControlEvents:UIControlEventTouchUpInside];
|
...
|
...
|
|