Authored by 盖剑秋

barrage and close RTMP.

... ... @@ -17,5 +17,6 @@
@property (nonatomic, copy) NSString *app;//1男2女
@property (nonatomic, copy) NSString *type;//直播状态0未直播1直播中
@property (nonatomic, copy) NSString *room;//资讯合并id作为开始/结束的room参数
@property (nonatomic, assign) NSInteger totalTime;
@end
... ...
... ... @@ -19,6 +19,7 @@
_app = [aDecoder decodeObjectForKey:@"app"];
_type = [aDecoder decodeObjectForKey:@"type"];
_room = [aDecoder decodeObjectForKey:@"room"];
_totalTime = [aDecoder decodeIntegerForKey:@"totalTime"];
}
return self;
}
... ... @@ -32,6 +33,6 @@
[aCoder encodeObject:_app forKey:@"app"];
[aCoder encodeObject:_type forKey:@"type"];
[aCoder encodeObject:_room forKey:@"room"];
[aCoder encodeInteger:_totalTime forKey:@"totalTime"];
}
@end
... ...
... ... @@ -144,6 +144,26 @@
_currentRetryCount = 0;
}
- (void)continueRTMP {
if (_currentChannel) {
if ([self startRtmp]) {
[self toastTip:@"开始直播"];
_totalTime = _currentChannel.totalTime;
_timer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(updateInfoView) userInfo:nil repeats:YES];
[_timer fire];
_liveButton.selected = YES;
[self clearLog];
self.socketService.room = _currentChannel.room;
self.socketService.uid = @"9527";
self.socketService.userName = @"aaaa";
[self.socketService connect];
}
}
}
- (void)setUpPush {
_livePush = [TXLivePush new];
[_livePush setLogLevel:LOGLEVEL_ERROR];
... ... @@ -310,6 +330,7 @@
[_livePush startPush:rtmpUrl];
}
_inPushing = YES;
_currentChannel.totalTime = _totalTime;
NSData *data = [NSKeyedArchiver archivedDataWithRootObject:_currentChannel];
[[NSUserDefaults standardUserDefaults] setObject:data forKey:kPushging];
return YES;
... ... @@ -629,6 +650,7 @@
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
if (alertView.firstOtherButtonIndex == buttonIndex) {
[self stopRtmp];
[[NSUserDefaults standardUserDefaults] removeObjectForKey:kPushging];
AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
manager.responseSerializer.acceptableContentTypes = [manager.responseSerializer.acceptableContentTypes setByAddingObject:@"text/html"];
manager.requestSerializer = [YH_HTTPRequestSerializer new];
... ...
... ... @@ -66,7 +66,6 @@
};
[_socket writeDataWithParams:params tag:SOCKET_TAG_SEND_MSG];
// [self loginToServer];
[_socket readDataWithTimeout:1.0 tag:1];
}
... ...
... ... @@ -10,7 +10,8 @@
#import "YH_BarrageTableView.h"
//#import "YH_YohoLoginViewModel.h"
//#import "M16HUDUtil.h"
#import "Macros.h"
#import "UIViewAdditions.h"
#define kBarrageTableViewHeight 253
#define kBarrageTableViewWidth (245 * kScreenPointScale)
#define kInputTextFieldHeight 34
... ... @@ -84,52 +85,52 @@
- (void)setBottomView
{
// CGFloat scalePoint = SCREEN_HEIGHT / 667.0;
//
// [self.barrageTableView setFrame:CGRectMake(0, CGRectGetHeight(self.view.bounds)-kBarrageTableViewHeight * scalePoint-kInputTextFieldBottomEdge, kBarrageTableViewWidth, kBarrageTableViewHeight * scalePoint)];
//
// self.bottomContainerView = [[UIView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(self.barrageTableView.frame) + 5, SCREEN_WIDTH, kInputTextFieldHeight)];
// self.bottomContainerView.backgroundColor = [UIColor clearColor];
// [self.inputTextField setFrame:CGRectMake(kPaddingLeft, 0, CGRectGetWidth(self.view.bounds) - 2*kPaddingLeft, kInputTextFieldHeight)];
//
// self.inputTextBgView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth(self.view.bounds) - 2*kPaddingLeft, kInputTextFieldHeight)];
// self.inputTextBgView.image = [UIImage imageNamed:@"inputTextBg"];
// [self.inputTextField addSubview:self.inputTextBgView];
// [self.inputTextField sendSubviewToBack:self.inputTextBgView];
// [self.bottomContainerView addSubview:self.inputTextField];
// [self.bottomContainerView bringSubviewToFront:self.inputTextField];
//
// self.closeButtonContainer = [[UIView alloc] initWithFrame:CGRectMake(SCREEN_WIDTH - 2*kPaddingLeft- kCloseButtonWidth, 0, kCloseButtonWidth + 2*kPaddingLeft, kInputTextFieldHeight)];
// self.closeButtonContainer.centerY = self.inputTextField.centerY;
// UITapGestureRecognizer *closeGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(closeKeyBoard:)];
// [self.closeButtonContainer addGestureRecognizer:closeGesture];
// self.closeButtonContainer.userInteractionEnabled = YES;
// self.closeButtonContainer.hidden = YES;
// self.keyBoardCloseButton = [[UIButton alloc] initWithFrame:CGRectMake(kPaddingLeft, 0, kCloseButtonWidth, kCloseButtonWidth)];
// [self.keyBoardCloseButton setImage:[UIImage imageNamed:@"keyBoardClose"] forState:UIControlStateNormal];
// self.keyBoardCloseButton.userInteractionEnabled = NO;
// self.keyBoardCloseButton.centerY = self.inputTextField.centerY;
// [self.closeButtonContainer addSubview:self.keyBoardCloseButton];
// [self.bottomContainerView addSubview:self.closeButtonContainer];
//
// [self.view addSubview:self.bottomContainerView];
//
// self.messageTip = [[UIImageView alloc] initWithFrame:CGRectMake(SCREEN_WIDTH - kMessageTipWidth - kMessageTipLeftEdge, self.barrageTableView.bottom - 5 - kMessageTipHeight, kMessageTipWidth, kMessageTipHeight)];
// self.messageTip.image = [UIImage imageNamed:@"message_Tip"];
// self.messageTip.userInteractionEnabled = YES;
// UITapGestureRecognizer *tapGR = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(newsBubbleClick:)];
// tapGR.numberOfTapsRequired = 1;
// [self.messageTip addGestureRecognizer:tapGR];
//
// self.messageArrow = [[UIImageView alloc] initWithFrame:CGRectMake(10, 7, 10, 8)];
// self.messageArrow.image = [UIImage imageNamed:@"messageArrow"];
// [self.messageTip addSubview:self.messageArrow];
//
// [self.newsBubble setFrame:CGRectMake(CGRectGetMaxX(self.messageArrow.frame) + 5, 0, kMessageTipWidth - CGRectGetMaxX(self.messageArrow.frame) - 10, kMessageTipHeight)];
// [self.messageTip addSubview:self.newsBubble];
// self.messageTip.hidden = YES;
//
// [self.view addSubview:self.messageTip];
CGFloat scalePoint = SCREEN_HEIGHT / 667.0;
[self.barrageTableView setFrame:CGRectMake(0, CGRectGetHeight(self.view.bounds)-kBarrageTableViewHeight * scalePoint-kInputTextFieldBottomEdge, kBarrageTableViewWidth, kBarrageTableViewHeight * scalePoint)];
self.bottomContainerView = [[UIView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(self.barrageTableView.frame) + 5, SCREEN_WIDTH, kInputTextFieldHeight)];
self.bottomContainerView.backgroundColor = [UIColor clearColor];
[self.inputTextField setFrame:CGRectMake(kPaddingLeft, 0, CGRectGetWidth(self.view.bounds) - 2*kPaddingLeft, kInputTextFieldHeight)];
self.inputTextBgView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth(self.view.bounds) - 2*kPaddingLeft, kInputTextFieldHeight)];
self.inputTextBgView.image = [UIImage imageNamed:@"inputTextBg"];
[self.inputTextField addSubview:self.inputTextBgView];
[self.inputTextField sendSubviewToBack:self.inputTextBgView];
[self.bottomContainerView addSubview:self.inputTextField];
[self.bottomContainerView bringSubviewToFront:self.inputTextField];
self.closeButtonContainer = [[UIView alloc] initWithFrame:CGRectMake(SCREEN_WIDTH - 2*kPaddingLeft- kCloseButtonWidth, 0, kCloseButtonWidth + 2*kPaddingLeft, kInputTextFieldHeight)];
self.closeButtonContainer.centerY = self.inputTextField.centerY;
UITapGestureRecognizer *closeGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(closeKeyBoard:)];
[self.closeButtonContainer addGestureRecognizer:closeGesture];
self.closeButtonContainer.userInteractionEnabled = YES;
self.closeButtonContainer.hidden = YES;
self.keyBoardCloseButton = [[UIButton alloc] initWithFrame:CGRectMake(kPaddingLeft, 0, kCloseButtonWidth, kCloseButtonWidth)];
[self.keyBoardCloseButton setImage:[UIImage imageNamed:@"keyBoardClose"] forState:UIControlStateNormal];
self.keyBoardCloseButton.userInteractionEnabled = NO;
self.keyBoardCloseButton.centerY = self.inputTextField.centerY;
[self.closeButtonContainer addSubview:self.keyBoardCloseButton];
[self.bottomContainerView addSubview:self.closeButtonContainer];
[self.view addSubview:self.bottomContainerView];
self.messageTip = [[UIImageView alloc] initWithFrame:CGRectMake(SCREEN_WIDTH - kMessageTipWidth - kMessageTipLeftEdge, self.barrageTableView.bottom - 5 - kMessageTipHeight, kMessageTipWidth, kMessageTipHeight)];
self.messageTip.image = [UIImage imageNamed:@"message_Tip"];
self.messageTip.userInteractionEnabled = YES;
UITapGestureRecognizer *tapGR = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(newsBubbleClick:)];
tapGR.numberOfTapsRequired = 1;
[self.messageTip addGestureRecognizer:tapGR];
self.messageArrow = [[UIImageView alloc] initWithFrame:CGRectMake(10, 7, 10, 8)];
self.messageArrow.image = [UIImage imageNamed:@"messageArrow"];
[self.messageTip addSubview:self.messageArrow];
[self.newsBubble setFrame:CGRectMake(CGRectGetMaxX(self.messageArrow.frame) + 5, 0, kMessageTipWidth - CGRectGetMaxX(self.messageArrow.frame) - 10, kMessageTipHeight)];
[self.messageTip addSubview:self.newsBubble];
self.messageTip.hidden = YES;
[self.view addSubview:self.messageTip];
}
-(void)closeKeyBoard:(UIButton *)sender
... ... @@ -232,38 +233,17 @@
#pragma mark - HPGrowingTextViewDelegate
- (BOOL)growingTextView:(HPGrowingTextView *)growingTextView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text
{
// if ([text isEqualToString:@"\n"]) {
// if (![self.inputTextField.text isEqualToString:@""]) {
// if ([GVUserDefaults standardUserDefaults].userLogged) {
// [self.inputTextField resignFirstResponder];
// if (self.sendMsgBlock) {
// self.sendMsgBlock(self.inputTextField.text);
// }
// self.inputTextField.text = @"";
// return YES;
// } else {
// __weak typeof(self) weakSelf = self;
// [self.inputTextField resignFirstResponder];
// [[YH_YohoLoginViewModel loginMgr] excuteBlockRequireHasLogin:^{
// __strong typeof(weakSelf) strongSelf = weakSelf;
// if (strongSelf.sendMsgBlock) {
// strongSelf.sendMsgBlock(self.inputTextField.text);
// }
//
// if (strongSelf.loginToTCPServerBlock) {
// strongSelf.loginToTCPServerBlock();
// }
// strongSelf.inputTextField.text = @"";
// }];
// return YES;
// }
// }else {
// return NO;
// }
// }else if (range.location >= 30) {
// [self showText:@"内容不可以超过30个字"];
// return NO;
// }
if ([text isEqualToString:@"\n"]) {
if (![self.inputTextField.text isEqualToString:@""]) {
return YES;
}else {
return NO;
}
}else if (range.location >= 30) {
[self showText:@"内容不可以超过30个字"];
return NO;
}
return YES;
}
... ... @@ -322,7 +302,7 @@
- (void)showText:(NSString *)text
{
// if ([text notNilOrEmpty]) {
// if (text.length) {
// [M16HUDUtil textOnly:text inView:self.view];
// }
}
... ...