Commit f514989a0fd9418464b17cf57e232808efce71d5

Authored by 王军波
1 parent f325df79

准备界面

LiveVideoCloud/LiveVideoCloud.xcodeproj/project.pbxproj
@@ -179,6 +179,7 @@ @@ -179,6 +179,7 @@
179 D2888DB11E6EC05F003A77C8 /* TempViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D2888DB01E6EC05F003A77C8 /* TempViewController.m */; }; 179 D2888DB11E6EC05F003A77C8 /* TempViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D2888DB01E6EC05F003A77C8 /* TempViewController.m */; };
180 D2888DB41E6EC154003A77C8 /* HomeViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D2888DB31E6EC154003A77C8 /* HomeViewController.m */; }; 180 D2888DB41E6EC154003A77C8 /* HomeViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D2888DB31E6EC154003A77C8 /* HomeViewController.m */; };
181 D2888DB71E6EC1B8003A77C8 /* LVCMyViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D2888DB61E6EC1B8003A77C8 /* LVCMyViewController.m */; }; 181 D2888DB71E6EC1B8003A77C8 /* LVCMyViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D2888DB61E6EC1B8003A77C8 /* LVCMyViewController.m */; };
  182 + D29D88481E88C53300543A03 /* LVCUGCLivePrepareView.m in Sources */ = {isa = PBXBuildFile; fileRef = D29D88471E88C53300543A03 /* LVCUGCLivePrepareView.m */; };
182 D2A803081E80BD6F009D6F1C /* TopToolView.m in Sources */ = {isa = PBXBuildFile; fileRef = D2A803071E80BD6F009D6F1C /* TopToolView.m */; }; 183 D2A803081E80BD6F009D6F1C /* TopToolView.m in Sources */ = {isa = PBXBuildFile; fileRef = D2A803071E80BD6F009D6F1C /* TopToolView.m */; };
183 D2B7B2511E8247D400ED084E /* ChatBarrageManager.m in Sources */ = {isa = PBXBuildFile; fileRef = D2B7B2501E8247D400ED084E /* ChatBarrageManager.m */; }; 184 D2B7B2511E8247D400ED084E /* ChatBarrageManager.m in Sources */ = {isa = PBXBuildFile; fileRef = D2B7B2501E8247D400ED084E /* ChatBarrageManager.m */; };
184 D2B7B2541E824B2D00ED084E /* ChatBarrageView.m in Sources */ = {isa = PBXBuildFile; fileRef = D2B7B2531E824B2D00ED084E /* ChatBarrageView.m */; }; 185 D2B7B2541E824B2D00ED084E /* ChatBarrageView.m in Sources */ = {isa = PBXBuildFile; fileRef = D2B7B2531E824B2D00ED084E /* ChatBarrageView.m */; };
@@ -566,6 +567,8 @@ @@ -566,6 +567,8 @@
566 D2888DB31E6EC154003A77C8 /* HomeViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HomeViewController.m; sourceTree = "<group>"; }; 567 D2888DB31E6EC154003A77C8 /* HomeViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HomeViewController.m; sourceTree = "<group>"; };
567 D2888DB51E6EC1B8003A77C8 /* LVCMyViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LVCMyViewController.h; sourceTree = "<group>"; }; 568 D2888DB51E6EC1B8003A77C8 /* LVCMyViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LVCMyViewController.h; sourceTree = "<group>"; };
568 D2888DB61E6EC1B8003A77C8 /* LVCMyViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LVCMyViewController.m; sourceTree = "<group>"; }; 569 D2888DB61E6EC1B8003A77C8 /* LVCMyViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LVCMyViewController.m; sourceTree = "<group>"; };
  570 + D29D88461E88C53300543A03 /* LVCUGCLivePrepareView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LVCUGCLivePrepareView.h; sourceTree = "<group>"; };
  571 + D29D88471E88C53300543A03 /* LVCUGCLivePrepareView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LVCUGCLivePrepareView.m; sourceTree = "<group>"; };
569 D2A803061E80BD6F009D6F1C /* TopToolView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TopToolView.h; sourceTree = "<group>"; }; 572 D2A803061E80BD6F009D6F1C /* TopToolView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TopToolView.h; sourceTree = "<group>"; };
570 D2A803071E80BD6F009D6F1C /* TopToolView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TopToolView.m; sourceTree = "<group>"; }; 573 D2A803071E80BD6F009D6F1C /* TopToolView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TopToolView.m; sourceTree = "<group>"; };
571 D2B7B24F1E8247D400ED084E /* ChatBarrageManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ChatBarrageManager.h; sourceTree = "<group>"; }; 574 D2B7B24F1E8247D400ED084E /* ChatBarrageManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ChatBarrageManager.h; sourceTree = "<group>"; };
@@ -654,14 +657,6 @@ @@ -654,14 +657,6 @@
654 path = ../ChatView; 657 path = ../ChatView;
655 sourceTree = "<group>"; 658 sourceTree = "<group>";
656 }; 659 };
657 - 812E504D1E769995004F5FCD /* CNLiveSDK */ = {  
658 - isa = PBXGroup;  
659 - children = (  
660 - );  
661 - name = CNLiveSDK;  
662 - path = LiveVideoCloud/Classes/CNLiveSDK;  
663 - sourceTree = SOURCE_ROOT;  
664 - };  
665 812E504E1E7699B9004F5FCD /* CNLiveSDK */ = { 660 812E504E1E7699B9004F5FCD /* CNLiveSDK */ = {
666 isa = PBXGroup; 661 isa = PBXGroup;
667 children = ( 662 children = (
@@ -1457,6 +1452,8 @@ @@ -1457,6 +1452,8 @@
1457 D25BF8771E7B8A82007FB138 /* FilterFunctionView.m */, 1452 D25BF8771E7B8A82007FB138 /* FilterFunctionView.m */,
1458 D25BF8781E7B8A82007FB138 /* SliderView.h */, 1453 D25BF8781E7B8A82007FB138 /* SliderView.h */,
1459 D25BF8791E7B8A82007FB138 /* SliderView.m */, 1454 D25BF8791E7B8A82007FB138 /* SliderView.m */,
  1455 + D29D88461E88C53300543A03 /* LVCUGCLivePrepareView.h */,
  1456 + D29D88471E88C53300543A03 /* LVCUGCLivePrepareView.m */,
1460 ); 1457 );
1461 path = View; 1458 path = View;
1462 sourceTree = "<group>"; 1459 sourceTree = "<group>";
@@ -1882,6 +1879,7 @@ @@ -1882,6 +1879,7 @@
1882 D2029CB31E6EADE10027CD92 /* UIScrollView+MJRefresh.m in Sources */, 1879 D2029CB31E6EADE10027CD92 /* UIScrollView+MJRefresh.m in Sources */,
1883 D2029D051E6EAE2E0027CD92 /* UILabel+labelFitSize.m in Sources */, 1880 D2029D051E6EAE2E0027CD92 /* UILabel+labelFitSize.m in Sources */,
1884 D2029CB21E6EADE10027CD92 /* UIScrollView+MJExtension.m in Sources */, 1881 D2029CB21E6EADE10027CD92 /* UIScrollView+MJExtension.m in Sources */,
  1882 + D29D88481E88C53300543A03 /* LVCUGCLivePrepareView.m in Sources */,
1885 D2029D091E6EAE2E0027CD92 /* Foundation+Log.m in Sources */, 1883 D2029D091E6EAE2E0027CD92 /* Foundation+Log.m in Sources */,
1886 D2029C8E1E6EADE10027CD92 /* AFImageDownloader.m in Sources */, 1884 D2029C8E1E6EADE10027CD92 /* AFImageDownloader.m in Sources */,
1887 D2029BCA1E6EADD70027CD92 /* BaseModel.m in Sources */, 1885 D2029BCA1E6EADD70027CD92 /* BaseModel.m in Sources */,
LiveVideoCloud/LiveVideoCloud/Classes/Sections/LiveSections/Controller/LVCLiveViewController.m
@@ -10,45 +10,32 @@ @@ -10,45 +10,32 @@
10 #import <CNLivePlayerSDK/CNLiveGPUStreamerKit.h> 10 #import <CNLivePlayerSDK/CNLiveGPUStreamerKit.h>
11 #import <CNLivePlayerSDK/CNLiveWebcastManager.h> 11 #import <CNLivePlayerSDK/CNLiveWebcastManager.h>
12 #import "FilterFunctionView.h" 12 #import "FilterFunctionView.h"
  13 +#import "LVCUGCLivePrepareView.h"
13 14
14 #define KAppId @"60_irn9edco29" 15 #define KAppId @"60_irn9edco29"
15 #define KAppKey @"69fe70bda67e059286ad509d9f5377f815955645b52f94" 16 #define KAppKey @"69fe70bda67e059286ad509d9f5377f815955645b52f94"
16 17
17 -@interface LVCLiveViewController ()<UIGestureRecognizerDelegate> {  
18 - // 开始直播  
19 - UIButton *_startLiveBtn;  
20 - // 缩放因子  
21 - CGFloat _currentPinchZoomFactor;  
22 -} 18 +@interface LVCLiveViewController ()<UIGestureRecognizerDelegate>
23 19
24 -@property (nonatomic,strong) UIView *captureView; 20 +@property (nonatomic, strong) LVCUGCLivePrepareView *prepareView;
25 21
26 -@property (nonatomic,strong) CNLiveGPUStreamerKit *kitCN; 22 +@property (nonatomic, strong) UIView *captureView;
27 23
28 -@property (nonatomic,strong) FilterFunctionView *filterView; 24 +@property (nonatomic, strong) CNLiveGPUStreamerKit *kitCN;
29 25
30 -@end 26 +@property (nonatomic, strong) FilterFunctionView *filterView;
31 27
32 -@implementation LVCLiveViewController 28 +@property (nonatomic, strong) UIButton *quitButton;
33 29
34 -- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {  
35 -  
36 - if (_kitCN) {  
37 - return UIInterfaceOrientationMaskAllButUpsideDown;  
38 - } else {  
39 - return UIInterfaceOrientationMaskPortrait;  
40 - }  
41 -} 30 +@property (nonatomic, strong) UIButton *openFilterButton;
42 31
43 --(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {  
44 -  
45 - UIInterfaceOrientation orie = [[UIApplication sharedApplication] statusBarOrientation];  
46 - [_kitCN rotatePreviewTo:orie];  
47 -  
48 - if (_kitCN.streamerBase.isStreaming) {  
49 - [_kitCN rotateStreamTo:orie];  
50 - }  
51 -} 32 +@property (nonatomic, strong) UIButton *changeCameraButton;
  33 +
  34 +@property (nonatomic, strong) UIButton *openFlashButton;
  35 +
  36 +@end
  37 +
  38 +@implementation LVCLiveViewController
52 39
53 - (void)viewDidLoad { 40 - (void)viewDidLoad {
54 [super viewDidLoad]; 41 [super viewDidLoad];
@@ -56,17 +43,16 @@ @@ -56,17 +43,16 @@
56 self.view.backgroundColor = [UIColor blueColor]; 43 self.view.backgroundColor = [UIColor blueColor];
57 44
58 [self.view addSubview:self.captureView]; 45 [self.view addSubview:self.captureView];
  46 + [self.view addSubview:self.prepareView];
  47 + [self.view addSubview:self.quitButton];
  48 + [self.view addSubview:self.changeCameraButton];
  49 + [self.view addSubview:self.openFilterButton];
59 50
60 - UIButton *closeBtn = [[UIButton alloc] initWithFrame:CGRectMake(SCREEN_WIDTH - 50, 30, 50, 30)];  
61 - [closeBtn setTitle:@"关闭" forState:UIControlStateNormal];  
62 - [closeBtn addTarget:self action:@selector(closeBtnClivk) forControlEvents:UIControlEventTouchUpInside];  
63 - [self.view addSubview:closeBtn];  
64 -  
65 - // 活动Id 51 + // 初始化推流
66 NSString *activityId = [NSString stringWithFormat:@"%d%d%d%d%d",arc4random()%9,arc4random()%9,arc4random()%9,arc4random()%9,arc4random()%9]; 52 NSString *activityId = [NSString stringWithFormat:@"%d%d%d%d%d",arc4random()%9,arc4random()%9,arc4random()%9,arc4random()%9,arc4random()%9];
67 - // 初始化直播云 53 +
68 [[CNLiveWebcastManager manager] initWithAppId:KAppId appKey:KAppKey]; 54 [[CNLiveWebcastManager manager] initWithAppId:KAppId appKey:KAppKey];
69 - // 初始化推流 55 +
70 _kitCN = [[CNLiveGPUStreamerKit alloc] initWithDefaultConfigWithActivityId:activityId channelId:@"iOStest" isHorizontalScreen:@"0"]; 56 _kitCN = [[CNLiveGPUStreamerKit alloc] initWithDefaultConfigWithActivityId:activityId channelId:@"iOStest" isHorizontalScreen:@"0"];
71 57
72 // _kitCN.activityName = @"iOS test"; 58 // _kitCN.activityName = @"iOS test";
@@ -74,25 +60,14 @@ @@ -74,25 +60,14 @@
74 60
75 // 设置推流配置 61 // 设置推流配置
76 [self setStreamerCfg]; 62 [self setStreamerCfg];
77 - // 添加监听  
78 - [self addObservers];  
79 63
80 - _startLiveBtn = [self addButton:@"开始直播" frame:CGRectMake(100, 40, 80, 40) action:@selector(startCapture:)];  
81 - [_startLiveBtn setTitle:@"开始直播" forState:UIControlStateNormal];  
82 - [_startLiveBtn setTitle:@"停止直播" forState:UIControlStateSelected];  
83 -  
84 - [self addButton:@"关闭预览" frame:CGRectMake(10, 40, 80, 40) action:@selector(startPreview:)];  
85 -// [self addButton:@"退出" frame:CGRectMake(190, 40, 80, 40) action:@selector(quit)];  
86 - [self addButton:@"美颜" frame:CGRectMake(10, 100, 80, 40) action:@selector(openFilter:)];  
87 - [self addButton:@"摄像头" frame:CGRectMake(100, 100, 80, 40) action:@selector(changeCamera:)]; 64 + [self addObservers];
  65 +
88 [self addButton:@"闪光灯" frame:CGRectMake(190, 100, 80, 40) action:@selector(openFlash)]; 66 [self addButton:@"闪光灯" frame:CGRectMake(190, 100, 80, 40) action:@selector(openFlash)];
89 67
90 UITapGestureRecognizer * singleRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onTap:)]; 68 UITapGestureRecognizer * singleRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onTap:)];
91 singleRecognizer.delegate = self; 69 singleRecognizer.delegate = self;
92 [self.captureView addGestureRecognizer:singleRecognizer]; 70 [self.captureView addGestureRecognizer:singleRecognizer];
93 -  
94 - UIPinchGestureRecognizer *pinch = [[UIPinchGestureRecognizer alloc]initWithTarget:self action:@selector(pinchDetected:)];  
95 - [self.view addGestureRecognizer:pinch];  
96 } 71 }
97 72
98 #pragma mark - initialization Streamer 73 #pragma mark - initialization Streamer
@@ -124,36 +99,10 @@ @@ -124,36 +99,10 @@
124 // 启动预览 99 // 启动预览
125 [_kitCN startPreview:self.captureView]; 100 [_kitCN startPreview:self.captureView];
126 101
127 - //水印图片  
128 -// _kitCN.watermark.logoPic = [UIImage imageNamed:@"互动电视180x180"];  
129 -// _kitCN.watermark.logoRect = CGRectMake(0.8, 0.8, 50, 50);  
130 -// _kitCN.watermark.logoAlpha = 0.6;  
131 -  
132 - //水印文字  
133 -// _kitCN.watermark.textLabel = [[UILabel alloc] init];  
134 -// _kitCN.watermark.textLabel.text = [NSString stringWithFormat:@"cnlive"];  
135 -// _kitCN.watermark.textLabel.font = [UIFont systemFontOfSize:8];  
136 -// _kitCN.watermark.textRect = CGRectMake(0.78, 0.88, 0.2, 0.04);  
137 -// [_kitCN.watermark updateTextLabel];  
138 -  
139 -}  
140 -  
141 -#pragma mark - GetMethod !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!  
142 -// 拍摄视图  
143 -- (UIView *)captureView {  
144 -  
145 - if (!_captureView) {  
146 - _captureView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height)];  
147 - _captureView.backgroundColor = [UIColor blackColor];  
148 - }  
149 - return _captureView;  
150 } 102 }
151 103
152 -  
153 #pragma mark - UIButton Action !!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 104 #pragma mark - UIButton Action !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
154 -  
155 -// 开始推流  
156 -- (void)startCapture:(UIButton *)button { 105 +- (void)startCapture:(UIButton *)button { // 开始推流
157 106
158 button.selected = !button.selected; 107 button.selected = !button.selected;
159 108
@@ -164,7 +113,6 @@ @@ -164,7 +113,6 @@
164 NSString *str=[[NSMutableString alloc] initWithData:errorDic[@"errorMessage"] encoding:NSUTF8StringEncoding]; 113 NSString *str=[[NSMutableString alloc] initWithData:errorDic[@"errorMessage"] encoding:NSUTF8StringEncoding];
165 NSLog(@"%@",str); 114 NSLog(@"%@",str);
166 [self toast:errorDic[@"errorMessage"]]; 115 [self toast:errorDic[@"errorMessage"]];
167 - _startLiveBtn.selected = NO;  
168 }]; 116 }];
169 }else{ 117 }else{
170 118
@@ -172,27 +120,8 @@ @@ -172,27 +120,8 @@
172 } 120 }
173 } 121 }
174 122
175 -// 开始 / 关闭 预览  
176 -- (void)startPreview:(UIButton *)button {  
177 -  
178 - button.selected = !button.selected;  
179 - if (button.selected) {  
180 - _startLiveBtn.enabled = NO;  
181 - [button setTitle:@"开启预览" forState:UIControlStateNormal];  
182 - if (_kitCN.streamState == CNLiveStreamStateConnected) {  
183 - [_kitCN stopStream];  
184 - _startLiveBtn.selected = NO;  
185 - }  
186 - [_kitCN stopPreview];  
187 - }else{  
188 - [_kitCN startPreview:self.captureView];  
189 - [button setTitle:@"关闭预览" forState:UIControlStateNormal];  
190 - _startLiveBtn.enabled = YES;  
191 - }  
192 -}  
193 123
194 -// 美颜滤镜  
195 -- (void)openFilter:(UIButton *)button { 124 +- (void)openFilter:(UIButton *)button { // 美颜滤镜
196 125
197 button.selected = !button.selected; 126 button.selected = !button.selected;
198 127
@@ -224,8 +153,8 @@ @@ -224,8 +153,8 @@
224 } 153 }
225 } 154 }
226 155
227 -// 转换前后置摄像头  
228 -- (void)changeCamera:(UIButton *)button { 156 +
  157 +- (void)changeCamera:(UIButton *)button { // 转换前后置摄像头
229 158
230 // button.selected = !button.selected; 159 // button.selected = !button.selected;
231 // if (button.selected) { 160 // if (button.selected) {
@@ -237,15 +166,15 @@ @@ -237,15 +166,15 @@
237 166
238 } 167 }
239 168
240 -// 闪光灯  
241 -- (void)openFlash { 169 +
  170 +- (void)openFlash { // 闪光灯
242 171
243 [_kitCN toggleTorch]; 172 [_kitCN toggleTorch];
244 // [_kitCN setTorchMode:AVCaptureTorchModeOn]; 173 // [_kitCN setTorchMode:AVCaptureTorchModeOn];
245 } 174 }
246 175
247 -// 退出  
248 -- (void)closeBtnClivk { 176 +
  177 +- (void)quitBtnClick { // 退出
249 178
250 if (_kitCN.streamState == CNLiveStreamStateConnected) { 179 if (_kitCN.streamState == CNLiveStreamStateConnected) {
251 [_kitCN stopStream]; 180 [_kitCN stopStream];
@@ -259,8 +188,8 @@ @@ -259,8 +188,8 @@
259 188
260 189
261 #pragma mark - UIGestureRecognizer Action !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 190 #pragma mark - UIGestureRecognizer Action !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
262 -//对焦与曝光  
263 -- (void)onTap:(UIGestureRecognizer *)sender { 191 +
  192 +- (void)onTap:(UIGestureRecognizer *)sender { //对焦与曝光
264 193
265 CGPoint current = [sender locationInView:self.view]; 194 CGPoint current = [sender locationInView:self.view];
266 CGPoint point = [self convertToPointOfInterestFromViewCoordinates:current]; 195 CGPoint point = [self convertToPointOfInterestFromViewCoordinates:current];
@@ -268,29 +197,19 @@ @@ -268,29 +197,19 @@
268 [_kitCN focusAtPoint:point]; 197 [_kitCN focusAtPoint:point];
269 } 198 }
270 199
271 -//缩放  
272 -- (void)pinchDetected:(UIPinchGestureRecognizer *)recognizer {  
273 -  
274 - if (recognizer.state == UIGestureRecognizerStateBegan) {  
275 - _currentPinchZoomFactor = _kitCN.pinchZoomFactor;  
276 - }  
277 - CGFloat zoomFactor = _currentPinchZoomFactor * recognizer.scale;//当前触摸缩放因子*坐标比例  
278 - [_kitCN setPinchZoomFactor:zoomFactor];  
279 -}  
280 -  
281 #pragma mark - notification !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 200 #pragma mark - notification !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
282 -// 进入后台  
283 -- (void)enterBg { 201 +
  202 +- (void)enterBg { // 进入后台
284 203
285 [_kitCN appEnterBackground]; 204 [_kitCN appEnterBackground];
286 } 205 }
287 -// 回到前台  
288 -- (void)becameActive { 206 +
  207 +- (void)becameActive { // 回到前台
289 208
290 [_kitCN appBecomeActive]; 209 [_kitCN appBecomeActive];
291 } 210 }
292 -// 采集状态改变  
293 -- (void)captureStateChange { 211 +
  212 +- (void)captureStateChange { // 采集状态改变
294 213
295 if ( _kitCN.captureState == CNLiveCaptureStateIdle){ 214 if ( _kitCN.captureState == CNLiveCaptureStateIdle){
296 //初始化时状态为空闲 215 //初始化时状态为空闲
@@ -325,8 +244,8 @@ @@ -325,8 +244,8 @@
325 244
326 } 245 }
327 } 246 }
328 -// 推流状态改变  
329 -- (void)streamStateChange { 247 +
  248 +- (void)streamStateChange { // 推流状态改变
330 249
331 if (_kitCN.streamState == CNLiveStreamStateIdle) { 250 if (_kitCN.streamState == CNLiveStreamStateIdle) {
332 251
@@ -362,8 +281,8 @@ @@ -362,8 +281,8 @@
362 NSLog(@"---------CNLiveStopStreamSuccess"); 281 NSLog(@"---------CNLiveStopStreamSuccess");
363 } 282 }
364 } 283 }
365 -// 推流失败  
366 -- (void)onStreamError { 284 +
  285 +- (void)onStreamError { // 推流失败
367 286
368 CNLiveStreamErrorCode err = _kitCN.streamErrorCode; 287 CNLiveStreamErrorCode err = _kitCN.streamErrorCode;
369 288
@@ -384,7 +303,6 @@ @@ -384,7 +303,6 @@
384 else if ( CNLiveStreamErrorCode_ABNORMAL == err) { 303 else if ( CNLiveStreamErrorCode_ABNORMAL == err) {
385 304
386 [self toast:@"推流异常中断~~"]; 305 [self toast:@"推流异常中断~~"];
387 - _startLiveBtn.selected = NO;  
388 306
389 } else if (err == CNLiveStreamErrorCode_CODEC_OPEN_FAILED) { 307 } else if (err == CNLiveStreamErrorCode_CODEC_OPEN_FAILED) {
390 NSLog(@"video codec open failed, try software codec"); 308 NSLog(@"video codec open failed, try software codec");
@@ -403,8 +321,8 @@ @@ -403,8 +321,8 @@
403 321
404 } 322 }
405 323
406 -// 重试  
407 -- (void) tryReconnect { 324 +
  325 +- (void) tryReconnect { // 重试
408 326
409 dispatch_time_t delay = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5 * NSEC_PER_SEC)); 327 dispatch_time_t delay = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5 * NSEC_PER_SEC));
410 dispatch_after(delay, dispatch_get_main_queue(), ^{ 328 dispatch_after(delay, dispatch_get_main_queue(), ^{
@@ -415,18 +333,16 @@ @@ -415,18 +333,16 @@
415 333
416 [_kitCN startStream:^{ 334 [_kitCN startStream:^{
417 NSLog(@"开启推流成功 ------- success"); 335 NSLog(@"开启推流成功 ------- success");
418 - _startLiveBtn.selected = YES;  
419 336
420 } failure:^(NSDictionary *errorDic) { 337 } failure:^(NSDictionary *errorDic) {
421 [self toast:errorDic[@"errorMessage"]]; 338 [self toast:errorDic[@"errorMessage"]];
422 - _startLiveBtn.selected = NO;  
423 }]; 339 }];
424 340
425 }); 341 });
426 } 342 }
427 343
428 -// 提示框  
429 -- (void)toast:(NSString*)message { 344 +
  345 +- (void)toast:(NSString*)message { // 提示框
430 346
431 UIAlertView *toast = [[UIAlertView alloc] initWithTitle:nil 347 UIAlertView *toast = [[UIAlertView alloc] initWithTitle:nil
432 message:message 348 message:message
@@ -441,8 +357,8 @@ @@ -441,8 +357,8 @@
441 } 357 }
442 358
443 359
444 -// 将UI的坐标转换成相机坐标  
445 -- (CGPoint)convertToPointOfInterestFromViewCoordinates:(CGPoint)viewCoordinates { 360 +
  361 +- (CGPoint)convertToPointOfInterestFromViewCoordinates:(CGPoint)viewCoordinates {// 将UI的坐标转换成相机坐标
446 362
447 CGPoint pointOfInterest = CGPointMake(.5f, .5f); 363 CGPoint pointOfInterest = CGPointMake(.5f, .5f);
448 CGSize frameSize = self.view.frame.size; 364 CGSize frameSize = self.view.frame.size;
@@ -476,8 +392,62 @@ @@ -476,8 +392,62 @@
476 return pointOfInterest; 392 return pointOfInterest;
477 } 393 }
478 394
479 -#pragma mark - Action !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 395 +#pragma mark - GetMethod !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  396 +
  397 +- (LVCUGCLivePrepareView *)prepareView {
  398 +
  399 + if (!_prepareView) {
  400 + _prepareView = [[LVCUGCLivePrepareView alloc] initWithFrame:self.view.bounds];
  401 + [_prepareView.startButton addTarget:self action:@selector(startCapture:) forControlEvents:UIControlEventTouchUpInside];
  402 + }
  403 + return _prepareView;
  404 +}
480 405
  406 +- (UIView *)captureView { // 拍摄视图
  407 +
  408 + if (!_captureView) {
  409 + _captureView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height)];
  410 + _captureView.backgroundColor = [UIColor blackColor];
  411 + }
  412 + return _captureView;
  413 +}
  414 +
  415 +- (UIButton *)quitButton {
  416 +
  417 + if (!_quitButton) {
  418 + _quitButton = [self createButtonWithFrame:CGRectMake(SCREEN_WIDTH - 50, 30, 40, 40) image:@"LiveCloseNormal" selected:@"LiveCloseTouch"];
  419 + [_quitButton addTarget:self action:@selector(quitBtnClick) forControlEvents:UIControlEventTouchUpInside];
  420 + }
  421 + return _quitButton;
  422 +}
  423 +
  424 +- (UIButton *)changeCameraButton {
  425 +
  426 + if (!_changeCameraButton) {
  427 + _changeCameraButton = [self createButtonWithFrame:CGRectMake(SCREEN_WIDTH - 100, 30, 40, 40) image:@"LiveCloseNormal" selected:@"LiveCloseTouch"];
  428 + [_changeCameraButton addTarget:self action:@selector(changeCamera:) forControlEvents:UIControlEventTouchUpInside];
  429 + }
  430 + return _changeCameraButton;
  431 +}
  432 +
  433 +- (UIButton *)openFlashButton {
  434 +
  435 + if (!_openFlashButton) {
  436 +
  437 + }
  438 + return _openFlashButton;
  439 +}
  440 +
  441 +- (UIButton *)openFilterButton {
  442 +
  443 + if (!_openFilterButton) {
  444 + _openFilterButton = [self createButtonWithFrame:CGRectMake(SCREEN_WIDTH - 150, 30, 40, 40) image:@"LiveCloseNormal" selected:@"LiveCloseTouch"];
  445 + [_openFilterButton addTarget:self action:@selector(openFilter:) forControlEvents:UIControlEventTouchUpInside];
  446 + }
  447 + return _openFilterButton;
  448 +}
  449 +
  450 +#pragma mark - Action !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
481 - (void)addObservers { 451 - (void)addObservers {
482 452
483 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(captureStateChange) name:CNLiveCaptureStateDidChangeNotification object:nil]; 453 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(captureStateChange) name:CNLiveCaptureStateDidChangeNotification object:nil];
@@ -517,6 +487,15 @@ @@ -517,6 +487,15 @@
517 487
518 } 488 }
519 489
  490 +- (UIButton *)createButtonWithFrame:(CGRect)frame image:(NSString *)image selected:(NSString *)selected {
  491 +
  492 + UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
  493 + [btn setFrame:frame];
  494 + [btn setImage:[UIImage imageNamed:image] forState:UIControlStateNormal];
  495 + [btn setImage:[UIImage imageNamed:selected] forState:UIControlStateSelected];
  496 + return btn;
  497 +}
  498 +
520 - (void)didReceiveMemoryWarning { 499 - (void)didReceiveMemoryWarning {
521 [super didReceiveMemoryWarning]; 500 [super didReceiveMemoryWarning];
522 // Dispose of any resources that can be recreated. 501 // Dispose of any resources that can be recreated.
LiveVideoCloud/LiveVideoCloud/Classes/Sections/LiveSections/View/FilterFunctionView.m
@@ -28,9 +28,9 @@ @@ -28,9 +28,9 @@
28 { 28 {
29 self = [super initWithFrame:frame]; 29 self = [super initWithFrame:frame];
30 if (self) { 30 if (self) {
31 - [self addSubview:self.slider1];  
32 - [self addSubview:self.slider2];  
33 - [self addSubview:self.slider3]; 31 +// [self addSubview:self.slider1];
  32 +// [self addSubview:self.slider2];
  33 +// [self addSubview:self.slider3];
34 [self addSubview:self.effectPicker]; 34 [self addSubview:self.effectPicker];
35 [self addSubview:self.filterGroupType]; 35 [self addSubview:self.filterGroupType];
36 36
LiveVideoCloud/LiveVideoCloud/Classes/Sections/LiveSections/View/LVCUGCLivePrepareView.h 0 → 100644
  1 +//
  2 +// LVCUGCLivePrepareView.h
  3 +// LiveVideoCloud
  4 +//
  5 +// Created by cnliveJunBo on 17/3/27.
  6 +// Copyright © 2017年 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import <UIKit/UIKit.h>
  10 +
  11 +@interface LVCUGCLivePrepareView : UIView
  12 +
  13 +@property (nonatomic, strong) UIButton *startButton;
  14 +
  15 +@end
LiveVideoCloud/LiveVideoCloud/Classes/Sections/LiveSections/View/LVCUGCLivePrepareView.m 0 → 100644
  1 +//
  2 +// LVCUGCLivePrepareView.m
  3 +// LiveVideoCloud
  4 +//
  5 +// Created by cnliveJunBo on 17/3/27.
  6 +// Copyright © 2017年 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import "LVCUGCLivePrepareView.h"
  10 +
  11 +@interface LVCUGCLivePrepareView()
  12 +
  13 +@property (nonatomic, strong) UIImageView *iconView;
  14 +
  15 +@property (nonatomic, strong) UITextField *titleTextField;
  16 +
  17 +@property (nonatomic, strong) UIView *lineView;
  18 +
  19 +@end
  20 +
  21 +@implementation LVCUGCLivePrepareView
  22 +
  23 +- (instancetype)initWithFrame:(CGRect)frame
  24 +{
  25 + self = [super initWithFrame:frame];
  26 + if (self) {
  27 + self.backgroundColor = [UIColor clearColor];
  28 + [self addSubview:self.iconView];
  29 + [self addSubview:self.titleTextField];
  30 + [self addSubview:self.lineView];
  31 + [self addSubview:self.startButton];
  32 + }
  33 + return self;
  34 +}
  35 +
  36 +#pragma mark - GetMethod !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  37 +- (UIImageView *)iconView {
  38 +
  39 + if (!_iconView) {
  40 + NSString *path = [[NSBundle mainBundle] pathForResource:@"头像" ofType:@"jpg"];
  41 + UIImage *image = [UIImage imageWithContentsOfFile:path];
  42 + _iconView = [[UIImageView alloc] initWithImage:image];
  43 + _iconView.frame = CGRectMake(10, SCREEN_HEIGHT * 0.35, 90, 90);
  44 + _iconView.layer.cornerRadius = 45;
  45 + _iconView.layer.masksToBounds = YES;
  46 + }
  47 + return _iconView;
  48 +}
  49 +
  50 +- (UITextField *)titleTextField {
  51 +
  52 + if (!_titleTextField) {
  53 + _titleTextField = [[UITextField alloc] initWithFrame:CGRectMake(110, SCREEN_HEIGHT * 0.35 + 50, SCREEN_WIDTH - 120, 30)];
  54 + _titleTextField.placeholder = @"起一个名字开始直播吧~";
  55 + _titleTextField.font = [UIFont systemFontOfSize:20];
  56 + }
  57 + return _titleTextField;
  58 +}
  59 +
  60 +- (UIView *)lineView {
  61 +
  62 + if (!_lineView) {
  63 + _lineView = [[UIView alloc] initWithFrame:CGRectMake(110, SCREEN_HEIGHT * 0.35 + 82, SCREEN_WIDTH - 120, 2)];
  64 + _lineView.backgroundColor = [UIColor blackColor];
  65 + }
  66 + return _lineView;
  67 +}
  68 +
  69 +- (UIButton *)startButton {
  70 +
  71 + if (!_startButton) {
  72 + _startButton = [UIButton buttonWithType:UIButtonTypeCustom];
  73 + _startButton.frame = CGRectMake(30, SCREEN_HEIGHT * 0.6, SCREEN_WIDTH - 60, 38);
  74 + _startButton.backgroundColor = [UIColor redColor];
  75 + [_startButton setTitle:@"开始直播" forState:UIControlStateNormal];
  76 + _startButton.titleLabel.font = [UIFont systemFontOfSize:20];
  77 + [_startButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  78 + [_startButton setTitleColor:[UIColor blackColor] forState:UIControlStateHighlighted];
  79 + _startButton.layer.cornerRadius = 19;
  80 + _startButton.layer.masksToBounds = YES;
  81 + }
  82 + return _startButton;
  83 +}
  84 +
  85 +
  86 +@end
LiveVideoCloud/LiveVideoCloud/animation.xcassets/Interaction/defaultUserIcon.imageset/Contents.json
@@ -4,6 +4,14 @@ @@ -4,6 +4,14 @@
4 "idiom" : "universal", 4 "idiom" : "universal",
5 "filename" : "贡献榜小头像.png", 5 "filename" : "贡献榜小头像.png",
6 "scale" : "1x" 6 "scale" : "1x"
  7 + },
  8 + {
  9 + "idiom" : "universal",
  10 + "scale" : "2x"
  11 + },
  12 + {
  13 + "idiom" : "universal",
  14 + "scale" : "3x"
7 } 15 }
8 ], 16 ],
9 "info" : { 17 "info" : {