IVTLivePreviewViewController.m
22.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
//
// IVTLivePreviewViewController.m
// IVTMeLiveTwo
//
// Created by XRG on 16/8/23.
// Copyright © 2016年 QLQ. All rights reserved.
//
#import "IVTLivePreviewViewController.h"
#import "AppDelegate.h"
#import "IVTKSYPushLiveShowViewController.h"
#import <CoreLocation/CoreLocation.h>
#import "ShareContentModel.h"
#import "ShareView.h"
@interface IVTLivePreviewViewController ()<UITextFieldDelegate,CLLocationManagerDelegate>
{
// 直播标题
UITextField *LiveTitle;
// 分享提示
UILabel * _shareNoti;
// 开启直播按钮
UIButton * _startPushRtmp;
// 关闭直播按钮
UIButton *_closeBtn;
UIView *_lineView;
// 分享btn
UIButton *_weiboBtn;
UIButton *_weixinBtn;
UIButton *_friendCircle;
UIButton *_qq;
UIButton *_qqZone;
// 用户当前地理位置
NSString *currentLocation;
UIButton *_location;
UIButton *_openLocation;
ShareContentModel *_shareEntity;
// 经度
CGFloat longitude;
// 维度
CGFloat latitude;
// 经纬度Tag
int isAllowLocation;
}
@property (retain, nonatomic) CLLocationManager *locManager;
@end
@implementation IVTLivePreviewViewController
- (void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
self.navigationController.navigationBarHidden = YES;
}
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
self.navigationController.navigationBarHidden = NO;
}
- (void)viewDidLoad {
[super viewDidLoad];
[self initUI];
[self initData];
[self initLocationManager];
}
- (void)viewDidAppear:(BOOL)animated
{
[LiveTitle becomeFirstResponder];
}
- (void)textFieldDidBeginEditing:(UITextField *)textField; // became first responder
{
LiveTitle = textField;
}
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
[self performSelector:@selector(timeEnough:) withObject:nil afterDelay:3.0];
[self beginPushLiveFunc:nil];
return YES;
}
- (BOOL)canBecomeFirstResponder
{
return YES;
}
#pragma mark - 数据初始化
- (void)initData
{
isAllowLocation = 1;
}
#pragma mark - 初始化UI
-(void)initUI{
__unsafe_unretained typeof (self) wself = self;
// 背景图
UIImageView* bgview = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"预览背景图"]];
bgview.frame = CGRectMake(0, 0,kScreenWidth, kScreenHeight);
[self.view addSubview:bgview];
LiveTitle = [[UITextField alloc] init];
LiveTitle.placeholder = @"写个标题吧!"; //默认显示的字
[LiveTitle setBackgroundColor:[UIColor clearColor]];
[LiveTitle setBorderStyle:UITextBorderStyleNone]; //外框类型
[LiveTitle setValue:[UIColor YXColorWithHexCode:@"#A0A0A0"] forKeyPath:@"_placeholderLabel.textColor"];
[LiveTitle setValue:[UIFont IVTH1Font] forKeyPath:@"_placeholderLabel.font"];
LiveTitle.delegate = self;
LiveTitle.textAlignment = NSTextAlignmentCenter;
LiveTitle.font = [UIFont IVTH1Font];
LiveTitle.textColor = [UIColor YXColorWithHexCode:@"#A0A0A0"];
LiveTitle.secureTextEntry = NO; //是否以密码形式显示
LiveTitle.autocorrectionType = UITextAutocorrectionTypeNo;//设置是否启动自动提醒更正功能
LiveTitle.autocapitalizationType = UITextAutocapitalizationTypeNone;
LiveTitle.returnKeyType = UIReturnKeyDone; //键盘返回类型
LiveTitle.clearButtonMode = UITextFieldViewModeWhileEditing; //编辑时会出现个修改X
LiveTitle.keyboardType = UIKeyboardTypeDefault;//键盘显示类型
LiveTitle.autoresizingMask = UIViewAutoresizingFlexibleHeight;//自适应高度
[self.view addSubview:LiveTitle];
[LiveTitle mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.equalTo(wself.view.mas_centerX);
make.top.equalTo(wself.view).offset(95);
make.size.mas_equalTo(CGSizeMake(200, 40));
}];
_closeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
[self.view addSubview:_closeBtn];
[_closeBtn setImage:[UIImage imageNamed:@"开始直播-关闭"] forState:UIControlStateNormal];
[_closeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.equalTo(wself.view).offset(-12);
make.top.equalTo(wself.view).offset(29);
make.size.mas_equalTo(CGSizeMake(30, 30));
}];
[_closeBtn addTarget:self action:@selector(closeClickFunc:) forControlEvents:UIControlEventTouchUpInside];
_friendCircle= [UIButton buttonWithType:UIButtonTypeCustom];
[self.view addSubview:_friendCircle];
[_friendCircle setImage:[UIImage imageNamed:@"朋友圈关闭"] forState:UIControlStateNormal];
[_friendCircle setImage:[UIImage imageNamed:@"朋友圈关闭"] forState: UIControlStateHighlighted];
[_friendCircle setImage:[UIImage imageNamed:@"朋友圈打开"] forState:UIControlStateSelected];
[_friendCircle setImage:[UIImage imageNamed:@"朋友圈打开"] forState:UIControlStateSelected | UIControlStateHighlighted];
[_friendCircle addTarget:self action:@selector(friendCircleFunc:) forControlEvents:UIControlEventTouchUpInside];
[_friendCircle mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(LiveTitle.mas_bottom).with.offset(45);
make.centerX.equalTo(wself.view);
make.size.mas_equalTo(CGSizeMake(33, 33));
}];
_weixinBtn= [UIButton buttonWithType:UIButtonTypeCustom];
[self.view addSubview:_weixinBtn];
[_weixinBtn setImage:[UIImage imageNamed:@"微信关闭"] forState:UIControlStateNormal];
[_weixinBtn setImage:[UIImage imageNamed:@"微信关闭"] forState: UIControlStateHighlighted];
[_weixinBtn setImage:[UIImage imageNamed:@"微信打开"] forState:UIControlStateSelected];
[_weixinBtn setImage:[UIImage imageNamed:@"微信打开"] forState:UIControlStateSelected | UIControlStateHighlighted];
[_weixinBtn addTarget:self action:@selector(WEIXINShareFunc:) forControlEvents:UIControlEventTouchUpInside];
[_weixinBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(LiveTitle.mas_bottom).with.offset(45);
make.right.equalTo(_friendCircle.mas_left).with.offset(-20);
make.size.mas_equalTo(CGSizeMake(33, 33));
}];
// 分享按钮
_qq = [UIButton buttonWithType:UIButtonTypeCustom];
[self.view addSubview:_qq];
[_qq setImage:[UIImage imageNamed:@"qq关闭"] forState:UIControlStateNormal];
[_qq setImage:[UIImage imageNamed:@"qq关闭"] forState: UIControlStateHighlighted];
[_qq setImage:[UIImage imageNamed:@"qq打开"] forState:UIControlStateSelected];
[_qq setImage:[UIImage imageNamed:@"qq打开"] forState:UIControlStateSelected | UIControlStateHighlighted];
[_qq addTarget:self action:@selector(QQShareFunc:) forControlEvents:UIControlEventTouchUpInside];
[_qq mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(LiveTitle.mas_bottom).with.offset(45);
make.right.equalTo(_weixinBtn.mas_left).with.offset(-20);
make.size.mas_equalTo(CGSizeMake(33, 33));
}];
_qqZone= [UIButton buttonWithType:UIButtonTypeCustom];
[self.view addSubview:_qqZone];
[_qqZone setImage:[UIImage imageNamed:@"空间关闭"] forState:UIControlStateNormal];
[_qqZone setImage:[UIImage imageNamed:@"空间关闭"] forState: UIControlStateHighlighted];
[_qqZone setImage:[UIImage imageNamed:@"空间打开"] forState:UIControlStateSelected];
[_qqZone setImage:[UIImage imageNamed:@"空间打开"] forState:UIControlStateSelected | UIControlStateHighlighted];
[_qqZone addTarget:self action:@selector(QQZONEShareFunc:) forControlEvents:UIControlEventTouchUpInside];
[_qqZone mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(LiveTitle.mas_bottom).with.offset(45);
make.leading.equalTo(_friendCircle.mas_trailing).with.offset(20);
make.size.mas_equalTo(CGSizeMake(33, 33));
}];
_weiboBtn= [UIButton buttonWithType:UIButtonTypeCustom];
[self.view addSubview:_weiboBtn];
[_weiboBtn setImage:[UIImage imageNamed:@"微博关闭"] forState:UIControlStateNormal];
[_weiboBtn setImage:[UIImage imageNamed:@"微博关闭"] forState: UIControlStateHighlighted];
[_weiboBtn setImage:[UIImage imageNamed:@"微博打开"] forState:UIControlStateSelected];
[_weiboBtn setImage:[UIImage imageNamed:@"微博打开"] forState:UIControlStateSelected | UIControlStateHighlighted];
[_weiboBtn addTarget:self action:@selector(WEIBOShareFunc:) forControlEvents:UIControlEventTouchUpInside];
[_weiboBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(LiveTitle.mas_bottom).with.offset(45);
make.leading.equalTo(_qqZone.mas_trailing).with.offset(20);
make.size.mas_equalTo(CGSizeMake(33, 33));
}];
UIImageView *imageView =[[UIImageView alloc]init];
imageView.frame =CGRectMake(0, 0, 100, 30);
imageView.image = [UIImage imageNamed:@"提示弹框"];
_shareNoti = [[UILabel alloc] init];
_shareNoti.frame =CGRectMake(0, 0, 100, 30);
_shareNoti.backgroundColor = [UIColor clearColor];
_shareNoti.textAlignment = 1;
_shareNoti.textColor = [UIColor whiteColor];
_shareNoti.font = [UIFont systemFontOfSize:10];
_shareNoti.text = [NSString stringWithFormat:@"分享已开启"];
_shareNoti.hidden = YES;
[self.view addSubview:_shareNoti];
[_shareNoti addSubview:imageView];
_lineView =[[UIView alloc]init];
[self.view addSubview:_lineView];
_lineView.backgroundColor = [UIColor YXColorWithHexCode:@"#787878"];
[_lineView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(LiveTitle.mas_bottom).with.offset(120);
make.height.mas_equalTo(@(0.5));
make.width.mas_equalTo(@(296));
make.centerX.equalTo(wself.view.mas_centerX);
}];
//中间的小白线
// _centerLabel = [[UILabel alloc] init];
// _centerLabel.backgroundColor = [UIColor YXColorWithHexCode:@"#787878"];
// [self.view addSubview:_centerLabel];
// [_centerLabel mas_makeConstraints:^(MASConstraintMaker *make) {
// make.centerX.equalTo(wself.view.mas_centerX);
// make.top.equalTo(_lineView.mas_bottom).with.offset(21);
// make.size.mas_equalTo(CGSizeMake(2, 11));
// }];
_location = [UIButton buttonWithType:UIButtonTypeCustom];
[_location setBackgroundImage:[UIImage imageNamed:@"直播-打开定位图标"] forState:UIControlStateNormal];
[_location setImage:[UIImage imageNamed:@"like_selected"] forState:UIControlStateSelected];
[self.view addSubview:_location];
[_location mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.equalTo(wself.view.mas_centerX).offset(-40);
make.top.equalTo(_lineView.mas_bottom).offset(19);
make.size.mas_equalTo(CGSizeMake(10, 12));
}];
_openLocation = [UIButton buttonWithType:UIButtonTypeCustom];
[_openLocation setTitle:@"已开定位" forState:UIControlStateNormal];
[_openLocation setTitle:@"关闭定位" forState:UIControlStateSelected];
[_openLocation setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[_openLocation setTitleColor:[UIColor whiteColor] forState:UIControlStateSelected];
_openLocation.titleLabel.font = [UIFont YXFontOfSize:13];
[self.view addSubview:_openLocation];
[_openLocation mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.equalTo(wself.view.mas_centerX).offset(30);
make.top.equalTo(_lineView.mas_bottom).offset(19);
make.size.mas_equalTo(CGSizeMake(55, 15));
}];
[_openLocation addTarget:self action:@selector(openLocationFunc:) forControlEvents:UIControlEventTouchUpInside];
// _AddTopic = [UIButton buttonWithType:UIButtonTypeCustom];
// [_AddTopic setTitle:@"# 添加话题" forState:UIControlStateNormal];
// [_AddTopic setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
// _AddTopic.titleLabel.font = [UIFont YXFontOfSize:13];
// [self.view addSubview:_AddTopic];
// [_AddTopic mas_makeConstraints:^(MASConstraintMaker *make) {
// make.left.equalTo(_centerLabel.mas_left).offset(13);
// make.top.equalTo(_lineView.mas_bottom).offset(19);
// make.size.mas_equalTo(CGSizeMake(70, 15));
// }];
// 开始直播btn
_startPushRtmp = [UIButton buttonWithType:UIButtonTypeCustom];
[_startPushRtmp setBackgroundImage:[UIImage imageNamed:@"开始直播按钮"] forState:UIControlStateNormal];
[_startPushRtmp setTitle:@"开始直播" forState:UIControlStateNormal];
[_startPushRtmp setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
_startPushRtmp.titleLabel.font = [UIFont YXFontOfSize:14];
[self.view addSubview:_startPushRtmp];
[_startPushRtmp mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.equalTo(wself.view.mas_centerX);
make.top.equalTo(_openLocation.mas_bottom).offset(36);
make.size.mas_equalTo(CGSizeMake(259, 40));
}];
[_startPushRtmp addTarget:self action:@selector(beginPushLiveFunc:) forControlEvents:UIControlEventTouchUpInside];
}
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
_shareNoti.hidden = YES;
[_weiboBtn setSelected:NO];
[_weixinBtn setSelected:NO];
[_friendCircle setSelected:NO];
[_qq setSelected:NO];
[_qqZone setSelected:NO];
}
#pragma mark - 分享直播相关方法
- (void)QQShareFunc:(UIButton *)sender
{
[_qq setSelected:!_qq.isSelected];
if (_qq.isSelected) {
_shareNoti.text = [NSString stringWithFormat:@"QQ分享已开启"];
_shareNoti.hidden = NO;
_shareNoti.center = CGPointMake(_qq.center.x, _qq.center.y - 40);
[_qqZone setSelected:NO];
[_weixinBtn setSelected:NO];
[_friendCircle setSelected:NO];
[_weiboBtn setSelected:NO];
}else{
_shareNoti.hidden = YES;
}
}
- (void)WEIXINShareFunc:(UIButton *)sender
{
[_weixinBtn setSelected:!_weixinBtn.isSelected];
if (_weixinBtn.isSelected) {
_shareNoti.text = [NSString stringWithFormat:@"微信分享已开启"];
_shareNoti.hidden = NO;
_shareNoti.center = CGPointMake(_weixinBtn.center.x, _weixinBtn.center.y - 40);
[_qqZone setSelected:NO];
[_friendCircle setSelected:NO];
[_qq setSelected:NO];
[_weiboBtn setSelected:NO];
}else{
_shareNoti.hidden = YES;
}
}
- (void)QQZONEShareFunc:(UIButton *)sender
{
[_qqZone setSelected:!_qqZone.isSelected];
if (_qqZone.isSelected) {
_shareNoti.text = [NSString stringWithFormat:@"QQ空间分享已开启"];
_shareNoti.hidden = NO;
_shareNoti.center = CGPointMake(_qqZone.center.x, _qqZone.center.y - 40);
[_friendCircle setSelected:NO];
[_weixinBtn setSelected:NO];
[_qq setSelected:NO];
[_weiboBtn setSelected:NO];
}else{
_shareNoti.hidden = YES;
}
}
- (void)WEIBOShareFunc:(UIButton *)sender
{
[_weiboBtn setSelected:!_weiboBtn.isSelected];
if (_weiboBtn.isSelected) {
_shareNoti.text = [NSString stringWithFormat:@"新浪分享已开启"];
_shareNoti.hidden = NO;
_shareNoti.center = CGPointMake(_weiboBtn.center.x, _weiboBtn.center.y - 40);
[_friendCircle setSelected:NO];
[_weixinBtn setSelected:NO];
[_qqZone setSelected:NO];
[_qq setSelected:NO];
}else{
_shareNoti.hidden = YES;
}
}
- (void)friendCircleFunc:(UIButton *)sender
{
[_friendCircle setSelected:!_weiboBtn.isSelected];
if (_friendCircle.isSelected) {
_shareNoti.text = [NSString stringWithFormat:@"新浪分享已开启"];
_shareNoti.hidden = NO;
_shareNoti.center = CGPointMake(_friendCircle.center.x, _friendCircle.center.y - 40);
[_weiboBtn setSelected:NO];
[_weixinBtn setSelected:NO];
[_qqZone setSelected:NO];
[_qq setSelected:NO];
}else{
_shareNoti.hidden = YES;
}
}
- (void)getShareInfoFunc:(id)sender
{
}
#pragma mark - 定位初始化
- (void)initLocationManager
{
//初始化位置管理器
_locManager = [[CLLocationManager alloc]init];
//设置代理
_locManager.delegate = self;
//设置位置经度
_locManager.desiredAccuracy = kCLLocationAccuracyBest;
//设置每隔100米更新位置
_locManager.distanceFilter = 100;
//开始定位服务
[_locManager startUpdatingLocation];
// 询问是否需要开启定位
[_locManager requestWhenInUseAuthorization];
// 默认是要传位置上去的
}
#pragma mark - 定位相关方法
- (void)openLocationFunc:(UIButton *)sender
{
// 判断的手机的定位功能是否开启
if ([[UIDevice currentDevice].systemVersion floatValue] >=8.0 ) {
// 开启定位:设置 > 隐私 > 位置 > 定位服务
if([CLLocationManager
locationServicesEnabled]&&[_openLocation.titleLabel.text isEqualToString:@"已开定位"]) {
[self.locManager startUpdatingLocation]; // 需求是不论开关都要把经纬度提交上去
isAllowLocation = 0;
[_openLocation setTitle:@"关闭定位" forState:UIControlStateNormal];
LRLog(@"关闭定位功能!isAllowLocation:%d",isAllowLocation);
}else if([_openLocation.titleLabel.text isEqualToString:@"关闭定位"]){
[self.locManager startUpdatingLocation]; // 需求是不论开关都要把经纬度提交上去
isAllowLocation = 1;
[_openLocation setTitle:@"已开定位" forState:UIControlStateNormal];
LRLog(@"开启定位功能!isAllowLocation:%d",isAllowLocation);
}
}
}
//地理位置发生改变时触发
-(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
//获取经纬度
latitude = newLocation.coordinate.latitude;
longitude = newLocation.coordinate.longitude;
LRLog(@"纬度:%f",latitude);
LRLog(@"纬度:%f",longitude);
currentLocation = [NSString stringWithFormat:@"纬度:%f,纬度:%f",newLocation.coordinate.latitude,newLocation.coordinate.longitude];
// 停止位置更新
[manager stopUpdatingLocation];
}
//定位失误时触发
-(void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error
{
LRLog(@"error:%@",error);
}
#pragma mark - 开启直播
- (void)beginPushLiveFunc:(UIButton *)sender
{
_startPushRtmp.enabled = NO;
[self performSelector:@selector(timeEnough:) withObject:nil afterDelay:10.0];
__unsafe_unretained typeof (self) wself = self;
if (LiveTitle.text.length == 0) {
[HUDUtil showError:@"标题不要为空"];
}else{
[HUDUtil showLoading];
NSString *userStr = [NSString stringWithFormat:@"%@%@",[IVTAccountTool getUserId],[IVTThirdFuncTool timeStamp]];
self.roomJID = [[XMPPManager sharedInstance] getRoomJID:userStr];
NSMutableDictionary *paramDict = [[NSMutableDictionary alloc] init];
[paramDict setObject:[IVTAccountTool getUserId] forKey:@"username"];
[paramDict setObject:[IVTAccountTool getPassword] forKey:@"captcha"];
[paramDict setObject:[LiveTitle.text base64EncodedFromString] forKey:@"name"] ;
[paramDict setObject:self.roomJID forKey:@"chatroomAddr"]; // xmpp 和 直播关联的地方
[paramDict setObject:[NSString stringWithFormat:@"%d",isAllowLocation] forKey:@"isAllowLocation"];
[paramDict setObject:[NSString stringWithFormat:@"%.f",longitude] forKey:@"longitude"];
[paramDict setObject:[NSString stringWithFormat:@"%.f",latitude] forKey:@"latitude"];
[[IVTNetworkAPIClient sharedClient] startPushLive:paramDict success:^(NSDictionary *successData) {
[HUDUtil hide];
IVTKSYPushLiveShowViewController *pushVC = [[IVTKSYPushLiveShowViewController alloc]init];
pushVC.roomJID = wself.roomJID;
pushVC.liveIDES = [successData objectForKey:@"liveId"];
pushVC.hostURL = [NSURL URLWithString:[NSString stringWithFormat:@"%@",[successData objectForKey:@"uplive"]]];
NSString *userPhotoUrl = [IVTAccountTool getAvatarUrl];
NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:[successData valueForKey:@"liveId"],@"id",[successData valueForKey:@"recordAddr"],@"recordAddr",[successData valueForKey:@"uplive"],@"videoAddr",userPhotoUrl,@"thumbnail", nil];
[IVTAccountTool insertToMyLiveListArrayWithLiveDict:dict];
[[NSNotificationCenter defaultCenter] postNotificationName:@"liveNumberChanged" object:nil];
if (_qq.selected == YES) {
pushVC.shareType = [NSNumber numberWithInteger:1];
}else if(_qqZone.selected == YES){
pushVC.shareType = [NSNumber numberWithInteger:2];
}else if(_weixinBtn.selected == YES){
pushVC.shareType = [NSNumber numberWithInteger:3];
}else if(_friendCircle.selected == YES){
pushVC.shareType = [NSNumber numberWithInteger:4];
}else if(_weiboBtn.selected == YES){
pushVC.shareType = [NSNumber numberWithInteger:5];
}
[AppDelegate appDelegate].startPushLiveVC = pushVC;
[wself.navigationController pushViewController:pushVC animated:YES];
// username=xxx&captcha=xxx
// 参数:liveId(视频id 必填 int类型)
NSMutableDictionary * paramDict = [[NSMutableDictionary alloc] init];
[paramDict setObject:[successData objectForKey:@"liveId"] forKey:@"liveId"];
[paramDict setObject:[IVTAccountTool getUserName] forKey:@"username"];
[paramDict setObject:[IVTAccountTool getPassword] forKey:@"captcha"];
} error:^(NSDictionary *successData) {
NSString *msg = successData[@"description"];
[HUDUtil showError:msg];
self.roomJID = nil;
} failure:^(NSError *failureError) {
[HUDUtil showError:@"网络异常"];
}];
}
}
- (void)timeEnough:(id)sender
{
_startPushRtmp.enabled = YES;
}
#pragma mark dismiss当前页
- (void)closeClickFunc:(UIButton *)sender
{
[self dismissViewControllerAnimated:YES completion:^{
LRLog(@"");
}];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
@end