Commit 69c0eaecd7e8bcb849863f408254f60bc980ed5f

Authored by 张旭
1 parent ebb60740

整合推流和交互页面

LiveVideoCloud/LiveVideoCloud/Classes/Helpers/Tools.h
... ... @@ -27,6 +27,8 @@ typedef NS_ENUM(NSInteger, ShowMessageType) {//消息背景类型
27 27  
28 28 + (void)closeBouces;
29 29  
  30 ++ (void)showNaviViewWithMessage:(NSString *_Nonnull)message;
  31 +
30 32 + (NSString *_Nullable)dictionaryToJson:(NSDictionary *_Nullable)dic;
31 33  
32 34 + (NSDictionary *_Nullable)dictionaryWithJsonString:(NSString *_Nullable)jsonString;
... ...
LiveVideoCloud/LiveVideoCloud/Classes/Helpers/Tools.m
... ... @@ -83,6 +83,32 @@
83 83 }];
84 84 }
85 85  
  86 ++ (void)showNaviViewWithMessage:(NSString *_Nonnull)message
  87 +{
  88 + UIImageView *bgView = [[UIImageView alloc] initWithFrame:CGRectMake(0, - 60, SCREEN_WIDTH, 60)];
  89 + bgView.backgroundColor = [UIColor cyanColor];
  90 + UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(10, 25, SCREEN_WIDTH - 20, 30)];
  91 + label.text = message;
  92 + label.textAlignment = NSTextAlignmentCenter;
  93 + label.textColor = [UIColor whiteColor];
  94 + [bgView addSubview:label];
  95 + [[UIApplication sharedApplication].keyWindow addSubview:bgView];
  96 +
  97 + [UIView animateWithDuration:0.5 animations:^{
  98 + bgView.top = 0;
  99 + } completion:^(BOOL finished) {
  100 + NSTimer *timer = [NSTimer timerWithTimeInterval:3 repeats:NO block:^(NSTimer * _Nonnull timer) {
  101 + [UIView animateWithDuration:0.5 animations:^{
  102 + bgView.top = - 60;
  103 + } completion:^(BOOL finished) {
  104 + [bgView removeFromSuperview];
  105 + }];
  106 + }];
  107 + [[NSRunLoop currentRunLoop] addTimer:timer forMode:NSRunLoopCommonModes];
  108 + }];
  109 +}
  110 +
  111 +
86 112 /**
87 113 把字典转换成格式化的JSON格式的字符串
88 114  
... ...
LiveVideoCloud/LiveVideoCloud/Classes/Sections/InteractionSections/AnimationBaseView.m
... ... @@ -14,7 +14,7 @@
14 14 - (instancetype)initWithFrame:(CGRect)frame
15 15 {
16 16 if (self = [super initWithFrame:frame]) {
17   - self.backgroundColor = [UIColor redColor];
  17 +
18 18 self.clipsToBounds = YES;
19 19 }
20 20 return self;
... ...
LiveVideoCloud/LiveVideoCloud/Classes/Sections/InteractionSections/Chat/ChatMsgModel/chatMsgModel.m
... ... @@ -35,7 +35,7 @@
35 35 //如果计算过高度,直接返回
36 36 if (_priCellHeight) return _priCellHeight;
37 37  
38   - _priCellHeight = 0;
  38 + _priCellHeight = 10;
39 39 NSString *content = self.content;
40 40 //文字
41 41 CGFloat textMaxW = self.priCellWidth;
... ... @@ -43,7 +43,7 @@
43 43 CGSize textSize = [content boundingRectWithSize:textMaxSize options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName : [UIFont systemFontOfSize:kContentFont]} context:nil].size;
44 44  
45 45 //底部空隙
46   - _priCellHeight += textSize.height + 5;
  46 + _priCellHeight += textSize.height + 10;
47 47 // NSLog(@"pricellHeight = %f",_priCellHeight);
48 48 return _priCellHeight;
49 49 }
... ...
LiveVideoCloud/LiveVideoCloud/Classes/Sections/InteractionSections/Gift/GiftViews/GiftListView.m
... ... @@ -111,6 +111,7 @@
111 111 - (void)sendClick
112 112 {
113 113 NSLog(@"sendClick");
  114 + [Tools showNaviViewWithMessage:@"请先充值钻石哦"];
114 115 }
115 116  
116 117 - (void)payClick
... ...
LiveVideoCloud/LiveVideoCloud/Classes/Sections/InteractionSections/LiveBaseView.h
... ... @@ -16,8 +16,13 @@ typedef NS_ENUM(NSInteger, BounceBtnType) {//弹窗按钮类型
16 16 BounceBtnTypeHome ,//主页按钮点击
17 17 };
18 18  
  19 +typedef NS_ENUM(NSInteger, JumpControllerType) {//跳转控制器类型
  20 + JumpControllerTypePresent = 1,//present
  21 + JumpControllerTypePush //push
  22 +};
19 23 @interface LiveBaseView : BaseView
20 24  
  25 +@property (nonatomic) JumpControllerType jumpType;
21 26 @property (nonatomic ,strong) UIViewController * _Nullable viewController;
22 27 @property (nonatomic ,strong ,readonly) PresentView * _Nullable presentView;
23 28 @property (nonatomic ,strong ,readonly) AnimationBaseView * _Nullable animationBaseView;
... ...
LiveVideoCloud/LiveVideoCloud/Classes/Sections/InteractionSections/LiveBaseView.m
... ... @@ -52,7 +52,7 @@ typedef NS_ENUM(NSInteger, PopType) {//弹窗类型
52 52 @property (nonatomic ,assign ) CGFloat offsetHeight;
53 53 @property (nonatomic ,strong ) UISwitch * _Nullable barrageSwitch;
54 54 @property (nonatomic ,strong ) ChatBarrageManager * _Nullable chatManager;
55   -@property (nonatomic ,strong) ChatBarrageView * _Nullable barrageView;
  55 +@property (nonatomic ,strong ) ChatBarrageView * _Nullable barrageView;
56 56  
57 57 @end
58 58  
... ... @@ -87,8 +87,8 @@ typedef NS_ENUM(NSInteger, PopType) {//弹窗类型
87 87 self.chatTableView.alpha = 0.7;
88 88  
89 89 [self.animationBaseView addSubview:self.topToolsView];
90   - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:self];
91   - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHidden:) name:UIKeyboardWillHideNotification object:self];
  90 + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
  91 + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHidden:) name:UIKeyboardWillHideNotification object:nil];
92 92  
93 93 [CNLiveChatManager sharedCNLiveChatManager].delegate = self;
94 94 [[CNLiveChatManager sharedCNLiveChatManager] joinChatRoom:@"1234" messageCount:10 success:^(NSString *targetId) {
... ... @@ -102,9 +102,16 @@ typedef NS_ENUM(NSInteger, PopType) {//弹窗类型
102 102 return self;
103 103 }
104 104  
  105 +- (void)dealloc
  106 +{
  107 + [[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillShowNotification object:nil];
  108 + [[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillHideNotification object:nil];
  109 +}
  110 +
105 111 - (void)keyboardWillShow:(NSNotification *)notify {
106   - if ([notify.object isKindOfClass:[LiveBaseView class]]) {
107   -
  112 + NSString *class = [[NSUserDefaults standardUserDefaults] objectForKey:keyboard];
  113 + if ([class isEqualToString:NSStringFromClass([self class])])
  114 + {
108 115 NSDictionary *userInfo = notify.userInfo;
109 116 CGRect newFrameKeyboard = [userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue];//变化前的frame
110 117 [UIView animateWithDuration:0.25 animations:^{
... ... @@ -115,7 +122,9 @@ typedef NS_ENUM(NSInteger, PopType) {//弹窗类型
115 122 }
116 123  
117 124 - (void)keyboardWillHidden:(NSNotification *)notify {
118   - if ([notify.object isKindOfClass:[LiveBaseView class]]) {
  125 + NSString *class = [[NSUserDefaults standardUserDefaults] objectForKey:keyboard];
  126 + if ([class isEqualToString:NSStringFromClass([self class])])
  127 + {
119 128 [UIView animateWithDuration:0.1 animations:^{
120 129 self.animationBaseView.top = 0;
121 130 [self.animationBaseView setNeedsDisplay];
... ... @@ -259,7 +268,8 @@ typedef NS_ENUM(NSInteger, PopType) {//弹窗类型
259 268 case BtnClickTypeChat:
260 269 {
261 270 self.popType = PopTypeChat;
262   -
  271 + [[NSUserDefaults standardUserDefaults] setObject:NSStringFromClass([self class]) forKey:keyboard];
  272 + [[NSUserDefaults standardUserDefaults] synchronize];
263 273 [self showCommentText];
264 274 }
265 275 break;
... ... @@ -268,6 +278,8 @@ typedef NS_ENUM(NSInteger, PopType) {//弹窗类型
268 278 self.popType = PopTypePriMessage;
269 279 [self hiddenView:YES];
270 280 [self showPrivateView];
  281 + [[NSUserDefaults standardUserDefaults] setObject:NSStringFromClass([PrivateView class]) forKey:keyboard];
  282 + [[NSUserDefaults standardUserDefaults] synchronize];
271 283 }
272 284 break;
273 285 case BtnClickTypeGift:
... ... @@ -345,7 +357,6 @@ typedef NS_ENUM(NSInteger, PopType) {//弹窗类型
345 357 [self.giftPopView removeFromSuperview];
346 358 }];
347 359 }
348   -
349 360 }
350 361 break;
351 362 default:
... ... @@ -353,7 +364,6 @@ typedef NS_ENUM(NSInteger, PopType) {//弹窗类型
353 364 }
354 365 }
355 366  
356   -
357 367 #pragma mark - buttonClick触摸屏幕关闭方法
358 368 - (void)tapGestureClick:(UITapGestureRecognizer *)gesture
359 369 {
... ... @@ -364,7 +374,20 @@ typedef NS_ENUM(NSInteger, PopType) {//弹窗类型
364 374  
365 375 - (void)closeAction
366 376 {
367   - [self.viewController.navigationController popViewControllerAnimated:YES];
  377 + switch (self.jumpType) {
  378 + case JumpControllerTypePresent:
  379 + {
  380 + [self.viewController dismissViewControllerAnimated:YES completion:nil];
  381 + }
  382 + break;
  383 + case JumpControllerTypePush:
  384 + {
  385 + [self.viewController.navigationController popViewControllerAnimated:YES];
  386 + }
  387 + break;
  388 + default:
  389 + break;
  390 + }
368 391 }
369 392  
370 393 - (void)sendClick
... ...
LiveVideoCloud/LiveVideoCloud/Classes/Sections/InteractionSections/PrivateView/PriChatCell.m
... ... @@ -37,15 +37,43 @@
37 37 [self bindView];
38 38 [self.icon sd_setImageWithURL:[NSURL URLWithString:model.icon] placeholderImage:nil];
39 39 self.content.text = model.content;
  40 + CGSize size = [self.content labelSizeWithWidth:_model.priCellWidth];
  41 + if (_model.isMine) {
  42 + if (_model.priCellHeight < 37) {//1行 // 36.7
  43 +
  44 + self.content.frame = CGRectMake(self.width - 30 - size.width - 10, 2.5, size.width, size.height);//self.height - 5
  45 + self.content.textAlignment = NSTextAlignmentRight;
  46 + self.content.centerY = self.icon.centerY;
  47 + }else
  48 + {
  49 + self.content.frame = CGRectMake(self.width - 30 - size.width - 10, 10, size.width, size.height);//self.height - 5
  50 + self.content.textAlignment = NSTextAlignmentLeft;
  51 + }
  52 + }else
  53 + {
  54 + if (_model.priCellHeight < 37) {//1行
  55 + self.icon.frame = CGRectMake(5, 6, 25, 25);
  56 + self.icon.centerY = (self.height - 25)*0.5 + 12.5;//13.353516;
  57 + self.content.frame = CGRectMake(5 + 30 + 10, 2.5, size.width, size.height);//self.height - 5
  58 + self.content.textAlignment = NSTextAlignmentLeft;
  59 + self.content.centerY = self.icon.centerY;
  60 + }else
  61 + {
  62 + self.icon.frame = CGRectMake(5, 6, 25, 25);
  63 + self.icon.centerY = (self.height - 25)*0.5 + 12.5;//13.353516;
  64 + self.content.frame = CGRectMake(5 + 30 + 10, 10, size.width, size.height);//self.height - 5
  65 + self.content.textAlignment = NSTextAlignmentLeft;
  66 + }
  67 + }
40 68 }
41 69  
42 70 - (void)bindView
43 71 {
44 72 if (_model.isMine) {
45 73 self.icon.frame = CGRectMake(self.width - 30, 6, 25, 25);
46   - NSLog(@"self.icon.centerY%f",self.height * 0.5);//13.353516
  74 + NSLog(@"self.icon.centerY%f,%f",self.height * 0.5,_model.priCellHeight);//13.353516 21.707031 155.363281
47 75 self.icon.centerY = (self.height - 25)*0.5 + 12.5;//13.353516;
48   - self.content.frame = CGRectMake(self.width - 30 - 5 - CHAT_POP_WIDTH, 2.5, CHAT_POP_WIDTH, self.height - 5);
  76 + self.content.frame = CGRectMake(self.width - 30 - CHAT_POP_WIDTH, 2.5, CHAT_POP_WIDTH - 10, self.height - 5);
49 77 self.content.backgroundColor = [UIColor blueColorZX];
50 78  
51 79 }else{
... ... @@ -66,8 +94,6 @@
66 94 _content.textColor = [UIColor blackColor];
67 95 _content.numberOfLines = 0;
68 96 _content.font = [UIFont systemFontOfSize:kContentFont];
69   - _content.layer.cornerRadius = 10;
70   - _content.layer.masksToBounds = YES;
71 97 [self addSubview:_content];
72 98 }
73 99 return _content;
... ...
LiveVideoCloud/LiveVideoCloud/Classes/Sections/InteractionSections/PrivateView/PrivateView.m
... ... @@ -45,8 +45,8 @@ static NSString *message_content = @&quot;message_content&quot;;
45 45 [self.bottomTool addSubview:self.sendBtn];
46 46 [self.bottomTool addSubview:self.textField];
47 47  
48   - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:self];
49   - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHidden:) name:UIKeyboardWillHideNotification object:self];
  48 + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
  49 + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHidden:) name:UIKeyboardWillHideNotification object:nil];
50 50 }
51 51 return self;
52 52 }
... ... @@ -63,9 +63,17 @@ static NSString *message_content = @&quot;message_content&quot;;
63 63 [self textFieldShouldReturn:self.textField];
64 64 }
65 65  
  66 +- (void)dealloc
  67 +{
  68 + [[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillShowNotification object:nil];
  69 + [[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillHideNotification object:nil];
  70 +}
  71 +
66 72 - (void)keyboardWillShow:(NSNotification *)notify {
67 73  
68   - if ([notify.object isKindOfClass:[PrivateView class]]) {
  74 + NSString *class = [[NSUserDefaults standardUserDefaults] objectForKey:keyboard];
  75 + if ([class isEqualToString:NSStringFromClass([self class])])
  76 + {
69 77 NSDictionary *userInfo = notify.userInfo;
70 78 CGRect newFrameKeyboard = [userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue];//变化前的frame
71 79 [UIView animateWithDuration:0.25 animations:^{
... ... @@ -77,8 +85,9 @@ static NSString *message_content = @&quot;message_content&quot;;
77 85 }
78 86  
79 87 - (void)keyboardWillHidden:(NSNotification *)notify {
80   -
81   - if ([notify.object isKindOfClass:[PrivateView class]]) {
  88 + NSString *class = [[NSUserDefaults standardUserDefaults] objectForKey:keyboard];
  89 + if ([class isEqualToString:NSStringFromClass([self class])])
  90 + {
82 91 [UIView animateWithDuration:0.1 animations:^{
83 92 self.top = SCREEN_HEIGHT - 300;
84 93 }];
... ...
LiveVideoCloud/LiveVideoCloud/Classes/Sections/LiveSections/Controller/LVCLiveViewController.m
... ... @@ -11,6 +11,7 @@
11 11 #import <CNLivePlayerSDK/CNLiveWebcastManager.h>
12 12 #import "FilterFunctionView.h"
13 13 #import "LVCUGCLivePrepareView.h"
  14 +#import "LiveBaseView.h"
14 15  
15 16 #define KAppId @"60_irn9edco29"
16 17 #define KAppKey @"69fe70bda67e059286ad509d9f5377f815955645b52f94"
... ... @@ -33,6 +34,9 @@
33 34  
34 35 @property (nonatomic, strong) UIButton *openFlashButton;
35 36  
  37 +@property (nonatomic ,strong) LiveBaseView * _Nullable liveBaseView;
  38 +
  39 +
36 40 @end
37 41  
38 42 @implementation LVCLiveViewController
... ... @@ -43,6 +47,7 @@
43 47 self.view.backgroundColor = [UIColor blueColor];
44 48  
45 49 [self.view addSubview:self.captureView];
  50 +
46 51 [self.view addSubview:self.prepareView];
47 52 [self.view addSubview:self.quitButton];
48 53 [self.view addSubview:self.changeCameraButton];
... ... @@ -101,13 +106,28 @@
101 106  
102 107 }
103 108  
  109 +- (LiveBaseView *)liveBaseView
  110 +{
  111 + if (!_liveBaseView)
  112 + {
  113 + _liveBaseView = [LiveBaseView liveBaseView];
  114 + _liveBaseView.jumpType = JumpControllerTypePresent;
  115 + _liveBaseView.viewController = self;
  116 + _liveBaseView.backgroundColor = [UIColor clearColor];
  117 + }
  118 + return _liveBaseView;
  119 +}
  120 +
104 121 #pragma mark - UIButton Action !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
105 122 - (void)startCapture:(UIButton *)button { // 开始推流
106   -
  123 + [_quitButton removeFromSuperview];
107 124 [_prepareView removeFromSuperview];
108 125  
109 126 [_kitCN startStream:^{
110 127 NSLog(@"开启推流成功 ------- success");
  128 +
  129 + [self.view insertSubview:self.liveBaseView atIndex:1];
  130 +
111 131 } failure:^(NSDictionary *errorDic) {
112 132 NSString *str=[[NSMutableString alloc] initWithData:errorDic[@"errorMessage"] encoding:NSUTF8StringEncoding];
113 133 NSLog(@"%@",str);
... ...
LiveVideoCloud/LiveVideoCloud/Classes/Sections/homeSections/Controller/HomeViewController.m
... ... @@ -8,31 +8,16 @@
8 8  
9 9 #import "HomeViewController.h"
10 10 #import "LVCLivePlayerController.h"
11   -#import "LVCInteractionController.h"
12 11 #import "LVCLivePlayerController.h"
13 12 #import "LVCUGCLivePlayerController.h"
14 13 #import "LVCTVLiveViewController.h"
15 14  
16 15 @interface HomeViewController ()
17 16  
18   -@property (nonatomic ,strong) UIButton * _Nullable interactionBtn;
19   -
20 17 @end
21 18  
22 19 @implementation HomeViewController
23 20  
24   -- (void)viewWillAppear:(BOOL)animated
25   -{
26   - [super viewWillAppear:animated];
27   - [[UIApplication sharedApplication].keyWindow addSubview:self.interactionBtn];
28   -}
29   -
30   -- (void)viewWillDisappear:(BOOL)animated
31   -{
32   - [super viewWillDisappear:animated];
33   - [self.interactionBtn removeFromSuperview];
34   -}
35   -
36 21 - (void)viewDidLoad {
37 22 [super viewDidLoad];
38 23 // Do any additional setup after loading the view.
... ... @@ -50,8 +35,6 @@
50 35 [UGCLiveBtn setTitle:@"UGC直播" forState:UIControlStateNormal];
51 36 [UGCLiveBtn addTarget:self action:@selector(UGCLiveAction) forControlEvents:UIControlEventTouchUpInside];
52 37 [self.view addSubview:UGCLiveBtn];
53   -
54   - [[UIApplication sharedApplication].keyWindow addSubview:self.interactionBtn];
55 38 }
56 39  
57 40 - (void)liveAction
... ... @@ -67,28 +50,6 @@
67 50 [self.navigationController pushViewController:UGCLiveVC animated:YES];
68 51 }
69 52  
70   -- (void)interactionAction
71   -{
72   - LVCInteractionController *intVC = [[LVCInteractionController alloc] init];
73   - self.navigationController.navigationBar.hidden = YES;
74   - [self.navigationController pushViewController:intVC animated:YES];
75   -}
76   -
77   -
78   -- (UIButton *)interactionBtn
79   -{
80   - if (!_interactionBtn)
81   - {
82   - UIButton *interactionBtn = [UIButton buttonWithType:UIButtonTypeCustom];
83   - interactionBtn.frame = CGRectMake(200, 400, 50, 30);
84   - [interactionBtn setTitle:@"互动" forState:UIControlStateNormal];
85   - [interactionBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
86   - [interactionBtn addTarget:self action:@selector(interactionAction) forControlEvents:UIControlEventTouchUpInside];
87   - _interactionBtn = interactionBtn;
88   - }
89   - return _interactionBtn;
90   -}
91   -
92 53 - (void)didReceiveMemoryWarning {
93 54 [super didReceiveMemoryWarning];
94 55 // Dispose of any resources that can be recreated.
... ...
LiveVideoCloud/LiveVideoCloud/UtilKits/Const/ZXConst.m
... ... @@ -23,3 +23,4 @@ CGFloat const kContentFont = 14.0;
23 23  
24 24 /** 详细内容字体字号 */
25 25 CGFloat const kDetailContentFont = 12.0;
  26 +
... ...
LiveVideoCloud/LiveVideoCloud/UtilKits/Macro/Macros/NotificationMacro.h
... ... @@ -16,5 +16,4 @@
16 16 /** 标题按钮重复点击的通知 */
17 17 static NSString *const ZXTitleButtonDidRepeatClickNotification = @"ZXTitleButtonDidRepeatClickNotification";
18 18  
19   -
20 19 #endif /* NotificationMacro_h */
... ...
LiveVideoCloud/LiveVideoCloud/UtilKits/Macro/Macros/UserDefaultKeyMacro.h
... ... @@ -16,6 +16,7 @@
16 16 /** 用户搜索信息key */
17 17 static NSString *const UserInfoAllKeys = @"UserInfoAllKeys";
18 18  
19   -
  19 +/** 当前键盘监听者 */
  20 +static NSString *const keyboard = @"keyboard";
20 21  
21 22 #endif /* UserDefaultKeyMacro_h */
... ...