Commit d503181000e5a48f7cf9aa0582157926ee5d510f
Merge branch 'master' of bj.gitlab.cnlive.com:ios-team/LiveVideoCloud
# Conflicts: # LiveVideoCloud/AppDelegate/AppDelegate.m
Showing
24 changed files
with
526 additions
and
114 deletions
LiveVideoCloud.xcodeproj/project.pbxproj
| ... | ... | @@ -234,9 +234,9 @@ |
| 234 | 234 | D2B7B2511E8247D400ED084E /* ChatBarrageManager.m in Sources */ = {isa = PBXBuildFile; fileRef = D2B7B2501E8247D400ED084E /* ChatBarrageManager.m */; }; |
| 235 | 235 | D2B7B2541E824B2D00ED084E /* ChatBarrageView.m in Sources */ = {isa = PBXBuildFile; fileRef = D2B7B2531E824B2D00ED084E /* ChatBarrageView.m */; }; |
| 236 | 236 | D2B7B2571E8261EF00ED084E /* ChatBarrOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = D2B7B2561E8261EF00ED084E /* ChatBarrOperation.m */; }; |
| 237 | + D2C6A8BF1F04998D00543EFA /* LVCVodListModel.m in Sources */ = {isa = PBXBuildFile; fileRef = D2C6A8BE1F04998D00543EFA /* LVCVodListModel.m */; }; | |
| 237 | 238 | D2CBC13B1ECC157A00E00279 /* LVCVerifyLiveAuthService.m in Sources */ = {isa = PBXBuildFile; fileRef = D2CBC13A1ECC157A00E00279 /* LVCVerifyLiveAuthService.m */; }; |
| 238 | 239 | D2D7D18D1E8A581000217771 /* timg.jpeg in Resources */ = {isa = PBXBuildFile; fileRef = D2D7D18C1E8A581000217771 /* timg.jpeg */; }; |
| 239 | - D2EBC8571F01FF9200F198FB /* LVCCommentModel.m in Sources */ = {isa = PBXBuildFile; fileRef = D2EBC8561F01FF9200F198FB /* LVCCommentModel.m */; }; | |
| 240 | 240 | D2EBC8711F02108000F198FB /* LiveListService.m in Sources */ = {isa = PBXBuildFile; fileRef = D2EBC8661F02108000F198FB /* LiveListService.m */; }; |
| 241 | 241 | D2EBC8721F02108000F198FB /* LVCLiveActivityInfoService.m in Sources */ = {isa = PBXBuildFile; fileRef = D2EBC8681F02108000F198FB /* LVCLiveActivityInfoService.m */; }; |
| 242 | 242 | D2EBC8741F02108000F198FB /* LVCUGCLiveListController.m in Sources */ = {isa = PBXBuildFile; fileRef = D2EBC86C1F02108000F198FB /* LVCUGCLiveListController.m */; }; |
| ... | ... | @@ -766,11 +766,11 @@ |
| 766 | 766 | D2B7B2531E824B2D00ED084E /* ChatBarrageView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ChatBarrageView.m; sourceTree = "<group>"; }; |
| 767 | 767 | D2B7B2551E8261EF00ED084E /* ChatBarrOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ChatBarrOperation.h; sourceTree = "<group>"; }; |
| 768 | 768 | D2B7B2561E8261EF00ED084E /* ChatBarrOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ChatBarrOperation.m; sourceTree = "<group>"; }; |
| 769 | + D2C6A8BD1F04998D00543EFA /* LVCVodListModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LVCVodListModel.h; sourceTree = "<group>"; }; | |
| 770 | + D2C6A8BE1F04998D00543EFA /* LVCVodListModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LVCVodListModel.m; sourceTree = "<group>"; }; | |
| 769 | 771 | D2CBC1391ECC157A00E00279 /* LVCVerifyLiveAuthService.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LVCVerifyLiveAuthService.h; path = ../LVCVerifyLiveAuthService.h; sourceTree = "<group>"; }; |
| 770 | 772 | D2CBC13A1ECC157A00E00279 /* LVCVerifyLiveAuthService.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = LVCVerifyLiveAuthService.m; path = ../LVCVerifyLiveAuthService.m; sourceTree = "<group>"; }; |
| 771 | 773 | D2D7D18C1E8A581000217771 /* timg.jpeg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = timg.jpeg; sourceTree = "<group>"; }; |
| 772 | - D2EBC8551F01FF9200F198FB /* LVCCommentModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LVCCommentModel.h; sourceTree = "<group>"; }; | |
| 773 | - D2EBC8561F01FF9200F198FB /* LVCCommentModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LVCCommentModel.m; sourceTree = "<group>"; }; | |
| 774 | 774 | D2EBC8651F02108000F198FB /* LiveListService.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LiveListService.h; sourceTree = "<group>"; }; |
| 775 | 775 | D2EBC8661F02108000F198FB /* LiveListService.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LiveListService.m; sourceTree = "<group>"; }; |
| 776 | 776 | D2EBC8671F02108000F198FB /* LVCLiveActivityInfoService.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LVCLiveActivityInfoService.h; sourceTree = "<group>"; }; |
| ... | ... | @@ -1178,8 +1178,8 @@ |
| 1178 | 1178 | 81A482FC1E88B0130097A80A /* Model */ = { |
| 1179 | 1179 | isa = PBXGroup; |
| 1180 | 1180 | children = ( |
| 1181 | - D2EBC8551F01FF9200F198FB /* LVCCommentModel.h */, | |
| 1182 | - D2EBC8561F01FF9200F198FB /* LVCCommentModel.m */, | |
| 1181 | + D2C6A8BD1F04998D00543EFA /* LVCVodListModel.h */, | |
| 1182 | + D2C6A8BE1F04998D00543EFA /* LVCVodListModel.m */, | |
| 1183 | 1183 | ); |
| 1184 | 1184 | path = Model; |
| 1185 | 1185 | sourceTree = "<group>"; |
| ... | ... | @@ -2280,6 +2280,7 @@ |
| 2280 | 2280 | D2029CA01E6EADE10027CD92 /* NSObject+MJProperty.m in Sources */, |
| 2281 | 2281 | 4BD855FE1EBACD530082061D /* AFSecurityPolicy.m in Sources */, |
| 2282 | 2282 | D2029CB51E6EADE10027CD92 /* SDiOSVersion.m in Sources */, |
| 2283 | + D2C6A8BF1F04998D00543EFA /* LVCVodListModel.m in Sources */, | |
| 2283 | 2284 | 4B45CE981EB86A760079AFB7 /* UILabel+createLabel.m in Sources */, |
| 2284 | 2285 | D2029C9C1E6EADE10027CD92 /* MJPropertyType.m in Sources */, |
| 2285 | 2286 | D22831091E77D8D500627701 /* GiftModel.m in Sources */, |
| ... | ... | @@ -2341,7 +2342,6 @@ |
| 2341 | 2342 | 4BD856181EBAD35C0082061D /* NSDictionary+Safety.m in Sources */, |
| 2342 | 2343 | 4BD856011EBACD530082061D /* AFURLResponseSerialization.m in Sources */, |
| 2343 | 2344 | D2575C4A1E7685DE00E3A8FC /* UIView+Bubbling.m in Sources */, |
| 2344 | - D2EBC8571F01FF9200F198FB /* LVCCommentModel.m in Sources */, | |
| 2345 | 2345 | D2EBC88B1F02361600F198FB /* LVCUGCLiveListView.m in Sources */, |
| 2346 | 2346 | D2029CA61E6EADE10027CD92 /* MJRefreshHeader.m in Sources */, |
| 2347 | 2347 | D2029CC41E6EADE10027CD92 /* UIImageView+WebCache.m in Sources */, | ... | ... |
LiveVideoCloud/AppDelegate/AppDelegate.m
| ... | ... | @@ -28,12 +28,15 @@ |
| 28 | 28 | //APP 启动是初始化直播SDK |
| 29 | 29 | [[CNLiveWebcastManager manager] initWithAppId:UserAppId appKey:UserAppKey isTestEnvironment:self.isTestEnvironment]; |
| 30 | 30 | |
| 31 | - //初始化聊天SDK并连接服务器 | |
| 32 | - [[CNLiveChatManager sharedCNLiveChatManager] initWithAppKey:UserAppKey appId:UserAppId isTestEnvironment:self.isTestEnvironment]; | |
| 31 | + // 初始化评论功能 | |
| 32 | + [[CNLiveCommentManager sharedCNLiveCommentManager] registerWithAppId:@"60_irn9cdak77" appKey:@"a425987ebc86e352b3373c25d5bd082d0cc248b4043028" isTestEnvironment:YES]; | |
| 33 | 33 | |
| 34 | 34 | //初始化用户SDK |
| 35 | 35 | [CNLiveUserSystemCenter setAppId:UserAppId appKey:UserAppKey appSecret:UserAppSceret isTestEnvironment:self.isTestEnvironment]; |
| 36 | 36 | |
| 37 | + //初始化聊天SDK并连接服务器 | |
| 38 | + [[CNLiveChatManager sharedCNLiveChatManager] initWithAppKey:UserAppKey appId:UserAppId isTestEnvironment:self.isTestEnvironment]; | |
| 39 | + | |
| 37 | 40 | /* |
| 38 | 41 | [[CNLiveChatManager sharedCNLiveChatManager] connectServerSuccess:^{ |
| 39 | 42 | NSLog(@"连接服务器-----success"); | ... | ... |
LiveVideoCloud/Classes/Sections/UGCSections/Controller/LVCUGCLivePlayerController.m
| ... | ... | @@ -28,6 +28,7 @@ |
| 28 | 28 | LVCUGCPlayerLoadingView *_thirdLoadView; |
| 29 | 29 | UIImage *_blurImage; |
| 30 | 30 | NSTimer *_currentTimer;// 更新当前播放时间 |
| 31 | + LVCUGCLivePlayerModel *_bgModel; | |
| 31 | 32 | } |
| 32 | 33 | |
| 33 | 34 | @property (nonatomic, strong) UIView *viewOne; |
| ... | ... | @@ -78,32 +79,36 @@ |
| 78 | 79 | [self.view addSubview:self.viewThird]; |
| 79 | 80 | |
| 80 | 81 | if ([_model.activityStatus isEqualToString:@"1"]) { |
| 81 | - [self addLiveBaseView]; | |
| 82 | + [self addLiveBaseViewWithChannelId:_model.channelId]; | |
| 82 | 83 | } |
| 83 | - | |
| 84 | + _bgModel = _model; | |
| 84 | 85 | [self.view addSubview:self.bgView]; |
| 85 | 86 | |
| 86 | 87 | if ([_model.activityStatus isEqualToString:@"0"]) { |
| 87 | 88 | |
| 88 | 89 | _bgView.anchorStatus = 4; |
| 90 | + _bgView.model = _model; | |
| 89 | 91 | |
| 90 | 92 | } else if ([_model.activityStatus isEqualToString:@"4"]) { |
| 91 | 93 | |
| 92 | 94 | _bgView.anchorStatus = 5; |
| 95 | + _bgView.model = _model; | |
| 93 | 96 | |
| 94 | 97 | } else if ([_model.activityStatus isEqualToString:@"-2"]) { |
| 95 | 98 | |
| 96 | 99 | _bgView.anchorStatus = 6; |
| 100 | + _bgView.model = _model; | |
| 97 | 101 | } |
| 98 | 102 | } |
| 99 | 103 | |
| 100 | -- (void)addLiveBaseView | |
| 104 | +- (void)addLiveBaseViewWithChannelId:(NSString *)channelId | |
| 101 | 105 | { |
| 102 | 106 | if (_vodPlayerQuitBtn) { |
| 103 | 107 | [_vodPlayerQuitBtn removeFromSuperview]; |
| 104 | 108 | } |
| 105 | 109 | [_liveBaseView removeFromSuperview]; |
| 106 | 110 | [_viewSecond addSubview:self.liveBaseView ]; |
| 111 | + self.liveBaseView.roomId = channelId; | |
| 107 | 112 | [_liveBaseView addGestureRecognizer:_pan]; |
| 108 | 113 | } |
| 109 | 114 | |
| ... | ... | @@ -251,7 +256,7 @@ |
| 251 | 256 | [_liveBaseView removeFromSuperview]; |
| 252 | 257 | [_viewSecond addSubview:self.vodPlayerQuitBtn]; |
| 253 | 258 | _currentTimer = [NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(timeChange) userInfo:nil repeats:YES]; |
| 254 | - | |
| 259 | + _bgModel = _playArray[_index]; | |
| 255 | 260 | _player = [[CNLiveMoviePlayerController alloc] initVodPlayWithVId:_playArray[_index].activityId |
| 256 | 261 | authSuccess:^{ |
| 257 | 262 | |
| ... | ... | @@ -271,7 +276,7 @@ |
| 271 | 276 | |
| 272 | 277 | } else if ([_playArray[_index].activityStatus isEqualToString:@"1"]) { |
| 273 | 278 | |
| 274 | - [self addLiveBaseView]; | |
| 279 | + [self addLiveBaseViewWithChannelId:_playArray[_index].channelId]; | |
| 275 | 280 | |
| 276 | 281 | _player = [[CNLiveMoviePlayerController alloc] initLivePlayWithChannelId:_playArray[_index].channelId anchorStatus:YES authSuccess:^{ |
| 277 | 282 | |
| ... | ... | @@ -297,14 +302,17 @@ |
| 297 | 302 | } else if ([_playArray[_index].activityStatus isEqualToString:@"0"]) { |
| 298 | 303 | |
| 299 | 304 | _bgView.anchorStatus = 4; |
| 305 | + _bgView.model = _playArray[_index]; | |
| 300 | 306 | |
| 301 | 307 | } else if ([_playArray[_index].activityStatus isEqualToString:@"4"]) { |
| 302 | 308 | |
| 303 | 309 | _bgView.anchorStatus = 5; |
| 310 | + _bgView.model = _playArray[_index]; | |
| 304 | 311 | |
| 305 | 312 | } else if ([_playArray[_index].activityStatus isEqualToString:@"-2"]) { |
| 306 | 313 | |
| 307 | 314 | _bgView.anchorStatus = 6; |
| 315 | + _bgView.model = _playArray[_index]; | |
| 308 | 316 | } |
| 309 | 317 | } |
| 310 | 318 | |
| ... | ... | @@ -375,8 +383,8 @@ |
| 375 | 383 | }]; |
| 376 | 384 | |
| 377 | 385 | } else if ([_playArray[_index].activityStatus isEqualToString:@"1"]) { |
| 378 | - [self addLiveBaseView]; | |
| 379 | - | |
| 386 | + [self addLiveBaseViewWithChannelId:_playArray[_index].channelId]; | |
| 387 | + _bgModel = _playArray[_index]; | |
| 380 | 388 | _player = [[CNLiveMoviePlayerController alloc] initLivePlayWithChannelId:_playArray[_index].channelId anchorStatus:YES authSuccess:^{ |
| 381 | 389 | |
| 382 | 390 | _player.videoDecoderMode = CNLiveMovieVideoDecoderMode_AUTO; |
| ... | ... | @@ -401,14 +409,17 @@ |
| 401 | 409 | } else if ([_playArray[_index].activityStatus isEqualToString:@"0"]) { |
| 402 | 410 | |
| 403 | 411 | _bgView.anchorStatus = 4; |
| 412 | + _bgView.model = _playArray[_index]; | |
| 404 | 413 | |
| 405 | 414 | } else if ([_playArray[_index].activityStatus isEqualToString:@"4"]) { |
| 406 | 415 | |
| 407 | 416 | _bgView.anchorStatus = 5; |
| 417 | + _bgView.model = _playArray[_index]; | |
| 408 | 418 | |
| 409 | 419 | } else if ([_playArray[_index].activityStatus isEqualToString:@"-2"]) { |
| 410 | 420 | |
| 411 | 421 | _bgView.anchorStatus = 6; |
| 422 | + _bgView.model = _playArray[_index]; | |
| 412 | 423 | } |
| 413 | 424 | |
| 414 | 425 | } |
| ... | ... | @@ -529,6 +540,7 @@ |
| 529 | 540 | //1)播放完毕。 |
| 530 | 541 | case MPMovieFinishReasonPlaybackEnded: |
| 531 | 542 | _bgView.anchorStatus = 3; |
| 543 | + _bgView.model = _bgModel; | |
| 532 | 544 | [_currentTimer invalidate]; |
| 533 | 545 | NSLog(@"playbackStateDidChange: MPMovieFinishReasonPlaybackEnded: %d\n", reason); |
| 534 | 546 | break; |
| ... | ... | @@ -630,6 +642,7 @@ |
| 630 | 642 | - (void)anchorStatusChanged:(NSNotification *)notification // 获取主播状态通知 |
| 631 | 643 | { |
| 632 | 644 | _bgView.anchorStatus = _player.anchorStatus; |
| 645 | + _bgView.model = _bgModel; | |
| 633 | 646 | } |
| 634 | 647 | |
| 635 | 648 | ... | ... |
LiveVideoCloud/Classes/Sections/UGCSections/View/LVCUGCBackgroundView.h
| ... | ... | @@ -7,6 +7,7 @@ |
| 7 | 7 | // |
| 8 | 8 | |
| 9 | 9 | #import <UIKit/UIKit.h> |
| 10 | +#import "LVCUGCLivePlayerModel.h" | |
| 10 | 11 | |
| 11 | 12 | @interface LVCUGCBackgroundView : UIView |
| 12 | 13 | |
| ... | ... | @@ -14,4 +15,6 @@ |
| 14 | 15 | |
| 15 | 16 | @property (nonatomic, strong) UIButton *backButton; |
| 16 | 17 | |
| 18 | +@property (nonatomic, strong) LVCUGCLivePlayerModel *model; | |
| 19 | + | |
| 17 | 20 | @end | ... | ... |
LiveVideoCloud/Classes/Sections/UGCSections/View/LVCUGCBackgroundView.m
| ... | ... | @@ -73,6 +73,18 @@ |
| 73 | 73 | } |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | +- (void)setModel:(LVCUGCLivePlayerModel *)model { | |
| 77 | + _model = model; | |
| 78 | + if (model.extensionName.length > 0) { | |
| 79 | + _nicknameLabel.text = model.extensionName; | |
| 80 | + } else { | |
| 81 | + _nicknameLabel.text = @"我的昵称"; | |
| 82 | + } | |
| 83 | + NSString *iconPath = [[NSBundle mainBundle] pathForResource:@"头像" ofType:@"jpg"]; | |
| 84 | + UIImage *iconImage = [UIImage imageWithContentsOfFile:iconPath]; | |
| 85 | + [_iconView sd_setImageWithURL:[NSURL URLWithString:model.extensionIcon] placeholderImage:iconImage]; | |
| 86 | +} | |
| 87 | + | |
| 76 | 88 | #pragma mark - GetMethod !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 77 | 89 | - (UIImageView *)iconView { |
| 78 | 90 | ... | ... |
LiveVideoCloud/Classes/Sections/homeSections/Controller/LVCVodPlayerController.h
LiveVideoCloud/Classes/Sections/homeSections/Controller/LVCVodPlayerController.m
| ... | ... | @@ -75,7 +75,7 @@ typedef enum { |
| 75 | 75 | [self.view addSubview:self.commentView]; |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | -- (void)setModel:(ProgramModel *)model { | |
| 78 | +- (void)setModel:(LVCVodListModel *)model { | |
| 79 | 79 | _model = model; |
| 80 | 80 | |
| 81 | 81 | //用来更新视频当前播放时间 |
| ... | ... | @@ -88,7 +88,7 @@ typedef enum { |
| 88 | 88 | #pragma mark - 初始化播放器 |
| 89 | 89 | - (void)playerInitialize { |
| 90 | 90 | |
| 91 | - _player = [[CNLiveMoviePlayerController alloc] initVodPlayWithVId:self.model.mediaId | |
| 91 | + _player = [[CNLiveMoviePlayerController alloc] initVodPlayWithVId:self.model.vId | |
| 92 | 92 | authSuccess:^{ |
| 93 | 93 | |
| 94 | 94 | _isPlaying = YES; |
| ... | ... | @@ -591,16 +591,19 @@ typedef enum { |
| 591 | 591 | |
| 592 | 592 | switch (_player.playbackState) { |
| 593 | 593 | case MPMoviePlaybackStateStopped: { |
| 594 | + _isPlaying = NO; | |
| 594 | 595 | [self changePlayBtnStatus:NO]; |
| 595 | 596 | NSLog(@"moviePlayBackStateDidChange : MPMoviePlaybackStateStopped"); |
| 596 | 597 | break; |
| 597 | 598 | } |
| 598 | 599 | case MPMoviePlaybackStatePlaying: { |
| 600 | + _isPlaying = YES; | |
| 599 | 601 | [self changePlayBtnStatus:YES]; |
| 600 | 602 | NSLog(@"moviePlayBackStateDidChange : MPMoviePlaybackStatePlaying"); |
| 601 | 603 | break; |
| 602 | 604 | } |
| 603 | 605 | case MPMoviePlaybackStatePaused: |
| 606 | + _isPlaying = NO; | |
| 604 | 607 | [self changePlayBtnStatus:NO]; |
| 605 | 608 | NSLog(@"moviePlayBackStateDidChange : MPMoviePlaybackStatePaused"); |
| 606 | 609 | break; | ... | ... |
LiveVideoCloud/Classes/Sections/homeSections/Controller/LVCVodPlayerFullController.h
LiveVideoCloud/Classes/Sections/homeSections/Controller/LVCVodPlayerListController.m
| ... | ... | @@ -10,6 +10,7 @@ |
| 10 | 10 | #import "LVCTelevisionCell.h" |
| 11 | 11 | #import "LVCRequestFailedView.h" |
| 12 | 12 | #import "LVCVodPlayerController.h" |
| 13 | +#import "CommonCrypto/CommonDigest.h" | |
| 13 | 14 | |
| 14 | 15 | static NSString *vodCellId = @"vodCellId"; |
| 15 | 16 | |
| ... | ... | @@ -45,41 +46,44 @@ static NSString *vodCellId = @"vodCellId"; |
| 45 | 46 | |
| 46 | 47 | _failedView.hidden = YES; |
| 47 | 48 | |
| 48 | - NSString *uid; | |
| 49 | - if ([UserTools isLogin]) { | |
| 50 | - uid = [UserInformationModel manager].uid; | |
| 51 | - } else { | |
| 52 | - uid = [NSString stringWithFormat:@"%u", arc4random()%3]; | |
| 53 | - } | |
| 54 | - NSString *tm = [NSString stringWithFormat:@"%u_%@", arc4random()%10, uid]; | |
| 55 | - | |
| 56 | - NSDictionary *parameter = @{@"cid": @"82_news/", | |
| 57 | - @"page": [NSString stringWithFormat:@"%d", 1], | |
| 58 | - @"pagesize": @"15", | |
| 59 | - @"tm": tm}; | |
| 60 | - | |
| 61 | - [[AFHTTPRequestOperationManager manager] GET:Newslist parameters:[self addParameters:parameter] success:^(AFHTTPRequestOperation *operation, id responseObject) { | |
| 49 | + NSInteger time = [[NSDate date] timeIntervalSince1970]; | |
| 50 | + NSString *timeString = [NSString stringWithFormat:@"%ld", (long)time]; | |
| 51 | + NSMutableDictionary *parameter = [@{ | |
| 52 | + @"appId" : UserAppId, | |
| 53 | + @"pageNumber": @"1", | |
| 54 | + @"pagesize": @"10", | |
| 55 | + @"timestamp": timeString, | |
| 56 | + @"platform_id": [NSBundle mainBundle].bundleIdentifier | |
| 57 | + } mutableCopy]; | |
| 58 | + NSString *string = [NSString stringWithFormat:@"%@&key=%@", [self sortParameters:parameter], UserAppKey]; | |
| 59 | + NSString *signString = [[self sha1:string] uppercaseString]; | |
| 60 | + [parameter setObject:signString forKey:@"sign"]; | |
| 61 | + | |
| 62 | + NSString *vodListURL = @"http://api.cnlive.com/open/api2/vod_epg/getVodListInfo4App"; | |
| 63 | + NSString *testVodListURL = @"http://test.open.cnlive.com/openapi/api2/vod_epg/getVodListInfo4App"; | |
| 64 | + | |
| 65 | + [[AFHTTPRequestOperationManager manager] POST:testVodListURL parameters:parameter success:^(AFHTTPRequestOperation *operation, id responseObject) { | |
| 62 | 66 | |
| 63 | 67 | responseObject = [responseObject validatedDictionary]; |
| 64 | - | |
| 65 | - if (responseObject[@"programs"] && [responseObject[@"programs"] isKindOfClass:[NSArray class]]) { | |
| 66 | - | |
| 67 | - for (NSDictionary *dic in responseObject[@"programs"]) { | |
| 68 | - ProgramModel *programModel = [ProgramModel modelWithDic:dic]; | |
| 69 | - [_programArrayM addObject:programModel]; | |
| 70 | - if (dic[@"comments"] && [dic[@"comments"] isKindOfClass:[NSArray class]] && [dic[@"comments"] count] > 0) { | |
| 71 | - NSMutableArray *comments = [[NSMutableArray alloc] init]; | |
| 72 | - for (NSDictionary *commentDic in dic[@"comments"]) { | |
| 73 | - LVCCommentModel *commentModel = [LVCCommentModel modelWithDic:commentDic]; | |
| 74 | - [comments addObject:commentModel]; | |
| 75 | - } | |
| 76 | - [_programArrayM addObject:comments]; | |
| 68 | + if ([responseObject[@"errorCode"] isEqualToString:@"0"]) { | |
| 69 | + if (responseObject[@"data"] && [responseObject[@"data"] isKindOfClass:[NSArray class]]) { | |
| 70 | + | |
| 71 | + for (NSDictionary *dic in responseObject[@"data"]) { | |
| 72 | + LVCVodListModel *vodListModel = [LVCVodListModel modelWithDic:dic]; | |
| 73 | + [_programArrayM addObject:vodListModel]; | |
| 77 | 74 | } |
| 78 | 75 | } |
| 76 | + _timestamp = [[self timestamp] longLongValue]; | |
| 77 | + [self.tableView.header endRefreshing]; | |
| 78 | + [self.tableView reloadData]; | |
| 79 | + } else { | |
| 80 | + NSLog(@"点播列表请求失败!"); | |
| 81 | + _timestamp = [[self timestamp] longLongValue]; | |
| 82 | + [self.tableView.header endRefreshing]; | |
| 83 | + if (_programArrayM.count == 0) { | |
| 84 | + _failedView.hidden = NO; | |
| 85 | + } | |
| 79 | 86 | } |
| 80 | - _timestamp = [[self timestamp] longLongValue]; | |
| 81 | - [self.tableView.header endRefreshing]; | |
| 82 | - [self.tableView reloadData]; | |
| 83 | 87 | |
| 84 | 88 | } failure:^(AFHTTPRequestOperation *operation, NSError *error) { |
| 85 | 89 | |
| ... | ... | @@ -190,20 +194,50 @@ static NSString *vodCellId = @"vodCellId"; |
| 190 | 194 | } |
| 191 | 195 | |
| 192 | 196 | #pragma mark ------------------------------ 分割线 ---------------------------------------------- |
| 193 | -- (NSDictionary *)addParameters:(NSDictionary *)dict { | |
| 197 | +//sha1加密 | |
| 198 | +- (NSString*)sha1:(NSString *)string | |
| 199 | +{ | |
| 200 | + NSData *data = [string dataUsingEncoding:NSUTF8StringEncoding]; | |
| 201 | + | |
| 202 | + uint8_t digest[CC_SHA1_DIGEST_LENGTH]; | |
| 203 | + | |
| 204 | + CC_SHA1(data.bytes, data.length, digest); | |
| 205 | + | |
| 206 | + NSMutableString* output = [NSMutableString stringWithCapacity:CC_SHA1_DIGEST_LENGTH * 2]; | |
| 194 | 207 | |
| 195 | - if (![dict isKindOfClass:[NSDictionary class]]) { | |
| 196 | - return dict; | |
| 208 | + for(int i = 0; i < CC_SHA1_DIGEST_LENGTH; i++) | |
| 209 | + [output appendFormat:@"%02x", digest[i]]; | |
| 210 | + | |
| 211 | + while ([[output substringToIndex:1] isEqualToString:@"0"]) { | |
| 212 | + output = [[NSMutableString alloc] initWithString:[output substringFromIndex:1]]; | |
| 197 | 213 | } |
| 198 | - if (!dict) { | |
| 199 | - return @{@"appid": JBAppId, @"plat": @"i", @"version": JBAppVersion}; | |
| 200 | - } else { | |
| 201 | - NSMutableDictionary *dic = [[NSMutableDictionary alloc] initWithDictionary:dict]; | |
| 202 | - [dic addEntriesFromDictionary:@{@"appid": JBAppId, @"plat": @"i", @"version": JBAppVersion}]; | |
| 203 | - return [[NSDictionary alloc] initWithDictionary:dic]; | |
| 214 | + | |
| 215 | + return output; | |
| 216 | +} | |
| 217 | +//参数排序 | |
| 218 | +- (NSString *)sortParameters:(NSDictionary*)parameters | |
| 219 | +{ | |
| 220 | + //对所有传入参数按照字段名的 ASCII 码从小到大排序 | |
| 221 | + NSArray *keyArr=[parameters allKeys]; | |
| 222 | + NSArray *arr = [keyArr sortedArrayUsingSelector:@selector(compare:)]; | |
| 223 | + | |
| 224 | + NSMutableString *string1 = [[NSMutableString alloc]init]; | |
| 225 | + for (int i=0; i<arr.count; i++) { | |
| 226 | + | |
| 227 | + NSString *parametersString = parameters[[arr objectAtIndex:i]]; | |
| 228 | + if (parametersString.length > 0) { | |
| 229 | + [string1 appendString:[NSString stringWithFormat:@"%@=%@&",[arr objectAtIndex:i],parameters[[arr objectAtIndex:i]]]]; | |
| 230 | + } | |
| 231 | + } | |
| 232 | + | |
| 233 | + if (string1.length > 0) { | |
| 234 | + [string1 deleteCharactersInRange:NSMakeRange(string1.length-1, 1)]; | |
| 204 | 235 | } |
| 236 | + | |
| 237 | + return string1; | |
| 205 | 238 | } |
| 206 | 239 | |
| 240 | + | |
| 207 | 241 | - (void)didReceiveMemoryWarning { |
| 208 | 242 | [super didReceiveMemoryWarning]; |
| 209 | 243 | // Dispose of any resources that can be recreated. | ... | ... |
LiveVideoCloud/Classes/Sections/homeSections/Model/LVCCommentModel.h deleted
100644 → 0
| 1 | -// | |
| 2 | -// LVCCommentModel.h | |
| 3 | -// LiveVideoCloud | |
| 4 | -// | |
| 5 | -// Created by cnliveJunBo on 17/6/27. | |
| 6 | -// Copyright © 2017年 cnlive. All rights reserved. | |
| 7 | -// | |
| 8 | - | |
| 9 | -#import "BaseModel.h" | |
| 10 | - | |
| 11 | -@interface LVCCommentModel : BaseModel | |
| 12 | - | |
| 13 | -@property (nonatomic, strong)NSString *content; | |
| 14 | -@property (nonatomic, strong)NSString *uid; | |
| 15 | -@property (nonatomic, strong)NSString *facepath; | |
| 16 | -@property (nonatomic, strong)NSString *nick; | |
| 17 | - | |
| 18 | -@end |
LiveVideoCloud/Classes/Sections/homeSections/Model/LVCCommentModel.m deleted
100644 → 0
LiveVideoCloud/Classes/Sections/homeSections/Model/LVCVodListModel.h
0 → 100644
| 1 | +// | |
| 2 | +// LVCVodListModel.h | |
| 3 | +// LiveVideoCloud | |
| 4 | +// | |
| 5 | +// Created by cnliveJunBo on 17/6/29. | |
| 6 | +// Copyright © 2017年 cnlive. All rights reserved. | |
| 7 | +// | |
| 8 | + | |
| 9 | +#import "BaseModel.h" | |
| 10 | + | |
| 11 | +@interface LVCVodListModel : BaseModel | |
| 12 | + | |
| 13 | +@property (nonatomic ,copy) NSString * _Nullable type; | |
| 14 | +@property (nonatomic ,copy) NSString * _Nullable vId; | |
| 15 | +@property (nonatomic ,copy) NSString * _Nullable img; | |
| 16 | +@property (nonatomic ,copy) NSString * _Nullable subTitle; | |
| 17 | +@property (nonatomic ,copy) NSString * _Nullable rates; | |
| 18 | +@property (nonatomic ,copy) NSString * _Nullable desc; | |
| 19 | +@property (nonatomic ,copy) NSString * _Nullable tag; | |
| 20 | +@property (nonatomic ,copy) NSString * _Nullable title; | |
| 21 | +@property (nonatomic ,copy) NSString * _Nullable category; | |
| 22 | + | |
| 23 | +@end | ... | ... |
LiveVideoCloud/Classes/Sections/homeSections/Model/LVCVodListModel.m
0 → 100644
| 1 | +// | |
| 2 | +// LVCVodListModel.m | |
| 3 | +// LiveVideoCloud | |
| 4 | +// | |
| 5 | +// Created by cnliveJunBo on 17/6/29. | |
| 6 | +// Copyright © 2017年 cnlive. All rights reserved. | |
| 7 | +// | |
| 8 | + | |
| 9 | +#import "LVCVodListModel.h" | |
| 10 | + | |
| 11 | +@implementation LVCVodListModel | |
| 12 | + | |
| 13 | +- (void)loadModel | |
| 14 | +{ | |
| 15 | + [super loadModel]; | |
| 16 | + | |
| 17 | + [LVCVodListModel mj_setupReplacedKeyFromPropertyName:^NSDictionary *{ return @{ | |
| 18 | + @"desc":@"description" | |
| 19 | + };}]; | |
| 20 | + | |
| 21 | +} | |
| 22 | + | |
| 23 | +@end | ... | ... |
LiveVideoCloud/Classes/Sections/homeSections/View/LVCCommentCell.h
LiveVideoCloud/Classes/Sections/homeSections/View/LVCCommentCell.m
| ... | ... | @@ -23,12 +23,49 @@ |
| 23 | 23 | { |
| 24 | 24 | self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; |
| 25 | 25 | if (self) { |
| 26 | + [self addSubview:self.iconView]; | |
| 26 | 27 | [self addSubview:self.nameLabel]; |
| 28 | + [self addSubview:self.likeButton]; | |
| 27 | 29 | [self addSubview:self.commentLabel]; |
| 28 | 30 | } |
| 29 | 31 | return self; |
| 30 | 32 | } |
| 31 | 33 | |
| 34 | +- (void)setResult:(CNLiveCommentDetailInfoResult *)result { | |
| 35 | + | |
| 36 | + _result = result; | |
| 37 | + [_iconView sd_setImageWithURL:[NSURL URLWithString:result.facepath] placeholderImage:[UIImage imageNamed:@"load_03"]]; | |
| 38 | + if (result.nick) { | |
| 39 | + _nameLabel.text = result.nick; | |
| 40 | + } else { | |
| 41 | + _nameLabel.text = @"游客"; | |
| 42 | + } | |
| 43 | + _commentLabel.text = result.content; | |
| 44 | + [_commentLabel sizeToFit]; | |
| 45 | + [_likeButton setTitle:result.praise forState:UIControlStateNormal]; | |
| 46 | + [_likeButton setImageEdgeInsets:UIEdgeInsetsMake(12, 5, 12, 35)]; | |
| 47 | + [_likeButton setTitleEdgeInsets:UIEdgeInsetsMake(0, -60, 0, 0)]; | |
| 48 | +} | |
| 49 | + | |
| 50 | +#pragma mark - Action !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
| 51 | +- (void)praiseAction:(UIButton *)btn { | |
| 52 | + | |
| 53 | + [[CNLiveCommentManager sharedCNLiveCommentManager] commentaryLikeWithProgramId:_result.pid sid:_result.uid commentId:_result.commentId completion:^(NSString *errorCode, NSString *errorMsg) { | |
| 54 | + | |
| 55 | + if ([errorCode isEqualToString:@"0"]) { | |
| 56 | + | |
| 57 | + NSLog(@"success"); | |
| 58 | + btn.selected = YES; | |
| 59 | + [btn setUserInteractionEnabled:NO]; | |
| 60 | + _result.praise = [NSString stringWithFormat:@"%ld",[_result.praise integerValue] + 1]; | |
| 61 | + [_likeButton setTitle:_result.praise forState:UIControlStateNormal]; | |
| 62 | + | |
| 63 | + } else { | |
| 64 | + NSLog(@"failed"); | |
| 65 | + } | |
| 66 | + }]; | |
| 67 | +} | |
| 68 | + | |
| 32 | 69 | #pragma mark - GetMethod !!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 33 | 70 | - (UIImageView *)iconView { |
| 34 | 71 | if (!_iconView) { |
| ... | ... | @@ -39,7 +76,8 @@ |
| 39 | 76 | |
| 40 | 77 | - (UILabel *)nameLabel { |
| 41 | 78 | if (!_nameLabel) { |
| 42 | - _nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(60, 10, KScreenWidth-130, 30)]; | |
| 79 | + _nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(60, 10, KScreenWidth-120, 30)]; | |
| 80 | + _nameLabel.textColor = [UIColor grayColorCNLive]; | |
| 43 | 81 | } |
| 44 | 82 | return _nameLabel; |
| 45 | 83 | } |
| ... | ... | @@ -51,13 +89,22 @@ |
| 51 | 89 | [_likeButton setImage:[UIImage imageNamed:@"videoSupportNormal"] forState:UIControlStateNormal]; |
| 52 | 90 | [_likeButton setImage:[UIImage imageNamed:@"videoSupport"] forState:UIControlStateSelected]; |
| 53 | 91 | _likeButton.titleLabel.font = [UIFont systemFontOfSize:12]; |
| 54 | - [_likeButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; | |
| 92 | + [_likeButton setTitleColor:[UIColor grayColorCNLive] forState:UIControlStateNormal]; | |
| 55 | 93 | _likeButton.backgroundColor = [UIColor whiteColor]; |
| 56 | 94 | [_likeButton addTarget:self action:@selector(praiseAction:) forControlEvents:UIControlEventTouchUpInside]; |
| 57 | 95 | } |
| 58 | 96 | return _likeButton; |
| 59 | 97 | } |
| 60 | 98 | |
| 99 | +- (UILabel *)commentLabel { | |
| 100 | + if (!_commentLabel) { | |
| 101 | + _commentLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 55, KScreenWidth-20, 10)]; | |
| 102 | + _commentLabel.textColor = [UIColor grayColorCNLive]; | |
| 103 | + _commentLabel.font = [UIFont systemFontOfSize:14]; | |
| 104 | + } | |
| 105 | + return _commentLabel; | |
| 106 | +} | |
| 107 | + | |
| 61 | 108 | - (void)awakeFromNib { |
| 62 | 109 | [super awakeFromNib]; |
| 63 | 110 | // Initialization code | ... | ... |
LiveVideoCloud/Classes/Sections/homeSections/View/LVCCommentTitleCell.h
LiveVideoCloud/Classes/Sections/homeSections/View/LVCCommentTitleCell.m
| ... | ... | @@ -28,7 +28,7 @@ |
| 28 | 28 | return self; |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | -- (void)setModel:(ProgramModel *)model { | |
| 31 | +- (void)setModel:(LVCVodListModel *)model { | |
| 32 | 32 | |
| 33 | 33 | self.titleLabel.text = model.title; |
| 34 | 34 | self.contentLabel.text = model.desc; |
| ... | ... | @@ -40,7 +40,6 @@ |
| 40 | 40 | |
| 41 | 41 | if (!_titleLabel) { |
| 42 | 42 | _titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, KScreenWidth-20, 40)]; |
| 43 | - [_contentLabel setFont:[UIFont systemFontOfSize:22]]; | |
| 44 | 43 | _titleLabel.text = @"标题"; |
| 45 | 44 | } |
| 46 | 45 | return _titleLabel; |
| ... | ... | @@ -49,7 +48,7 @@ |
| 49 | 48 | - (UILabel *)contentLabel { |
| 50 | 49 | |
| 51 | 50 | if (!_contentLabel) { |
| 52 | - _contentLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 60, KScreenWidth-20, 100)]; | |
| 51 | + _contentLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 60, KScreenWidth-20, 10)]; | |
| 53 | 52 | [_contentLabel setFont:[UIFont systemFontOfSize:14]]; |
| 54 | 53 | _contentLabel.textColor = [UIColor grayColor]; |
| 55 | 54 | _contentLabel.text = @"描述"; | ... | ... |
LiveVideoCloud/Classes/Sections/homeSections/View/LVCCommentView.h
LiveVideoCloud/Classes/Sections/homeSections/View/LVCCommentView.m
| ... | ... | @@ -8,12 +8,24 @@ |
| 8 | 8 | |
| 9 | 9 | #import "LVCCommentView.h" |
| 10 | 10 | #import "LVCCommentTitleCell.h" |
| 11 | +#import "LVCCommentCell.h" | |
| 11 | 12 | |
| 12 | 13 | static NSString *titleCellId = @"titleCellId"; |
| 14 | +static NSString *commentCellId = @"commentCellId"; | |
| 13 | 15 | |
| 14 | -@interface LVCCommentView()<UITableViewDelegate, UITableViewDataSource> | |
| 16 | +@interface LVCCommentView()<UITableViewDelegate, UITableViewDataSource, UITextFieldDelegate> { | |
| 17 | + | |
| 18 | + NSArray *_commentArray; | |
| 19 | + CGFloat _desHeight; | |
| 20 | + NSMutableArray *_cellHeightArrayM; | |
| 21 | +} | |
| 15 | 22 | |
| 16 | 23 | @property (nonatomic, strong) UITableView *tableview; |
| 24 | +@property (nonatomic, strong) UILabel *countLabel; | |
| 25 | +@property (nonatomic, strong) UIView *textViewBackView; // 聊天输入框背景 | |
| 26 | +@property (nonatomic, strong) UITextField *textField; | |
| 27 | +@property (nonatomic, strong) UIButton *resignTextViewBtn; // 点击空白取消评论按钮 | |
| 28 | +@property (nonatomic, strong) UIButton *commentButton; | |
| 17 | 29 | |
| 18 | 30 | @end |
| 19 | 31 | |
| ... | ... | @@ -23,39 +35,130 @@ static NSString *titleCellId = @"titleCellId"; |
| 23 | 35 | { |
| 24 | 36 | self = [super initWithFrame:frame]; |
| 25 | 37 | if (self) { |
| 38 | + _commentArray = [[NSArray alloc] init]; | |
| 39 | + _cellHeightArrayM = [[NSMutableArray alloc] init]; | |
| 40 | + [self addNotification]; | |
| 26 | 41 | [self addSubview:self.tableview]; |
| 27 | 42 | } |
| 28 | 43 | return self; |
| 29 | 44 | } |
| 30 | 45 | |
| 31 | -- (void)setModel:(ProgramModel *)model { | |
| 46 | +- (void)setModel:(LVCVodListModel *)model { | |
| 32 | 47 | |
| 33 | 48 | if (_model != model) { |
| 34 | 49 | _model = model; |
| 35 | 50 | } |
| 36 | - [self.tableview reloadData]; | |
| 51 | + if (model.desc) { | |
| 52 | + CGRect contentRect = [model.desc boundingRectWithSize:CGSizeMake(KScreenWidth-20, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading attributes:@{NSFontAttributeName : [UIFont systemFontOfSize:14]} context:nil]; | |
| 53 | + _desHeight = contentRect.size.height; | |
| 54 | + } else { | |
| 55 | + _desHeight = 0; | |
| 56 | + } | |
| 57 | + [self getCommentListWithPid:@"123"]; | |
| 58 | + [self getCommentCountWithPid:@"123"]; | |
| 59 | +} | |
| 60 | + | |
| 61 | +#pragma mark - 获取评论列表 | |
| 62 | +- (void)getCommentListWithPid:(NSString *)pid { | |
| 63 | + | |
| 64 | + [[CNLiveCommentManager sharedCNLiveCommentManager] getCommentListWithProgramId:pid page:@"1" pageSize:@"10" success:^(CNLiveCommentListResult *result) { | |
| 65 | + | |
| 66 | + _commentArray = result.comments; | |
| 67 | + if (_commentArray && _commentArray.count > 0) { | |
| 68 | + for (CNLiveCommentDetailInfoResult *result in _commentArray) { | |
| 69 | + if (result.content) { | |
| 70 | + CGRect contentRect = [result.content boundingRectWithSize:CGSizeMake(KScreenWidth-20, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading attributes:@{NSFontAttributeName : [UIFont systemFontOfSize:14]} context:nil]; | |
| 71 | + CGFloat contentHeight = contentRect.size.height; | |
| 72 | + [_cellHeightArrayM addObject:[NSString stringWithFormat:@"%f",contentHeight]]; | |
| 73 | + } else { | |
| 74 | + [_cellHeightArrayM addObject:@"0"]; | |
| 75 | + } | |
| 76 | + } | |
| 77 | + } | |
| 78 | + | |
| 79 | + [self.tableview reloadData]; | |
| 80 | + } error:^(NSString *error) { | |
| 81 | + NSLog(@"获取评论列表失败"); | |
| 82 | + }]; | |
| 83 | +} | |
| 84 | + | |
| 85 | +#pragma mark - 获取评论数 | |
| 86 | +- (void)getCommentCountWithPid:(NSString *)pid { | |
| 87 | + | |
| 88 | + [[CNLiveCommentManager sharedCNLiveCommentManager] getCommentCountWithProgramIds:@[pid] completion:^(NSString *errorCode, NSString *errorMsg, NSArray<CNLiveCommentCountResult *> *commentArray) { | |
| 89 | + | |
| 90 | + if ([errorCode isEqualToString:@"0"]) { | |
| 91 | + CNLiveCommentCountResult *result = [commentArray lastObject]; | |
| 92 | + self.countLabel.text = result.count; | |
| 93 | + } | |
| 94 | + }]; | |
| 37 | 95 | } |
| 38 | 96 | |
| 39 | 97 | #pragma mark - UITableViewDelegate !!!!!!!!!!!!!!!!!!!!! |
| 40 | 98 | - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { |
| 41 | - return SCREEN_WIDTH*9/16+40; | |
| 99 | + if (indexPath.section == 0) { | |
| 100 | + return _desHeight+70; | |
| 101 | + } else { | |
| 102 | + return [_cellHeightArrayM[indexPath.row] floatValue] + 60; | |
| 103 | + } | |
| 42 | 104 | } |
| 43 | 105 | |
| 44 | 106 | #pragma mark - UITableViewDataSource !!!!!!!!!!!!!!!!!!!!!!! |
| 107 | +- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { | |
| 108 | + return 2; | |
| 109 | +} | |
| 110 | + | |
| 45 | 111 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { |
| 46 | 112 | |
| 47 | - return 2; | |
| 113 | + if (section == 0) { | |
| 114 | + return 1; | |
| 115 | + } else { | |
| 116 | + return _commentArray.count; | |
| 117 | + } | |
| 48 | 118 | } |
| 49 | 119 | |
| 50 | 120 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { |
| 51 | 121 | |
| 52 | - if (indexPath.row == 0) { | |
| 53 | - | |
| 122 | + if (indexPath.section == 0) { | |
| 123 | + LVCCommentTitleCell *cell = [tableView dequeueReusableCellWithIdentifier:titleCellId forIndexPath:indexPath]; | |
| 124 | + cell.selectionStyle = UITableViewCellSelectionStyleNone; | |
| 125 | + cell.model = self.model; | |
| 126 | + return cell; | |
| 127 | + } else { | |
| 128 | + LVCCommentCell *cell = [tableView dequeueReusableCellWithIdentifier:commentCellId forIndexPath:indexPath]; | |
| 129 | + cell.selectionStyle = UITableViewCellSelectionStyleNone; | |
| 130 | + cell.result = _commentArray[indexPath.row]; | |
| 131 | + return cell; | |
| 132 | + } | |
| 133 | +} | |
| 134 | + | |
| 135 | +- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { | |
| 136 | + | |
| 137 | + if (section == 1) { | |
| 138 | + UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, 90)]; | |
| 139 | + headerView.backgroundColor = [UIColor whiteColor]; | |
| 140 | + UILabel *commentLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 0, 50, 40)]; | |
| 141 | + commentLabel.font = [UIFont systemFontOfSize:20]; | |
| 142 | + commentLabel.text = @"评论"; | |
| 143 | + [headerView addSubview:commentLabel]; | |
| 144 | + [headerView addSubview:self.countLabel]; | |
| 145 | + [headerView addSubview:self.commentButton]; | |
| 146 | + UIView *line = [[UIView alloc]initWithFrame:CGRectMake(0, 89, KScreenWidth, 1)]; | |
| 147 | + line.backgroundColor = [UIColor lightGrayColor]; | |
| 148 | + [headerView addSubview:line]; | |
| 149 | + return headerView; | |
| 150 | + } else { | |
| 151 | + return nil; | |
| 54 | 152 | } |
| 153 | +} | |
| 154 | + | |
| 155 | +- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section { | |
| 55 | 156 | |
| 56 | - LVCCommentTitleCell *cell = [tableView dequeueReusableCellWithIdentifier:titleCellId forIndexPath:indexPath]; | |
| 57 | - cell.model = self.model; | |
| 58 | - return cell; | |
| 157 | + if (section == 0) { | |
| 158 | + return 0; | |
| 159 | + } else { | |
| 160 | + return 90; | |
| 161 | + } | |
| 59 | 162 | } |
| 60 | 163 | |
| 61 | 164 | #pragma mark - GetMethod !!!!!!!!!!!!!!!!!!!!!! |
| ... | ... | @@ -67,10 +170,151 @@ static NSString *titleCellId = @"titleCellId"; |
| 67 | 170 | _tableview.dataSource = self; |
| 68 | 171 | _tableview.showsVerticalScrollIndicator = NO; |
| 69 | 172 | _tableview.showsHorizontalScrollIndicator = NO; |
| 70 | - _tableview.separatorStyle = UITableViewCellSeparatorStyleNone; | |
| 71 | 173 | [_tableview registerClass:[LVCCommentTitleCell class] forCellReuseIdentifier:titleCellId]; |
| 174 | + [_tableview registerClass:[LVCCommentCell class] forCellReuseIdentifier:commentCellId]; | |
| 72 | 175 | } |
| 73 | 176 | return _tableview; |
| 74 | 177 | } |
| 75 | 178 | |
| 179 | +- (UILabel *)countLabel { | |
| 180 | + if (!_countLabel) { | |
| 181 | + _countLabel = [[UILabel alloc] initWithFrame:CGRectMake(KScreenWidth-40, 0, 40, 40)]; | |
| 182 | + _countLabel.font = [UIFont systemFontOfSize:20]; | |
| 183 | + _countLabel.text = @"0"; | |
| 184 | + } | |
| 185 | + return _countLabel; | |
| 186 | +} | |
| 187 | + | |
| 188 | +- (UIView *)textViewBackView { | |
| 189 | + if (!_textViewBackView) { | |
| 190 | + _textViewBackView = [[UIView alloc] initWithFrame:CGRectMake(0, KScreenHeight, KScreenWidth, 40)]; | |
| 191 | + _textViewBackView.backgroundColor = [UIColor colorWithRed:(230.0/255.0) green:(230.0/255.0) blue:(230.0/255.0) alpha:1]; | |
| 192 | + [_textViewBackView addSubview:self.textField]; | |
| 193 | + } | |
| 194 | + return _textViewBackView; | |
| 195 | +} | |
| 196 | + | |
| 197 | +- (UITextField *)textField { | |
| 198 | + if (!_textField) { | |
| 199 | + _textField = [[UITextField alloc] initWithFrame:CGRectMake(5, 5, KScreenWidth - 10, 30)]; | |
| 200 | + _textField.backgroundColor = [UIColor lightGrayColor]; | |
| 201 | + _textField.returnKeyType = UIReturnKeySend; | |
| 202 | + _textField.font = [UIFont systemFontOfSize:14]; | |
| 203 | + _textField.delegate = self; | |
| 204 | + _textField.enablesReturnKeyAutomatically = YES; | |
| 205 | + } | |
| 206 | + return _textField; | |
| 207 | +} | |
| 208 | + | |
| 209 | +- (UIButton *)resignTextViewBtn { | |
| 210 | + if (!_resignTextViewBtn) { | |
| 211 | + _resignTextViewBtn = [UIButton buttonWithType:UIButtonTypeCustom]; | |
| 212 | + [_resignTextViewBtn setFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)]; | |
| 213 | + [_resignTextViewBtn addTarget:self action:@selector(commentBackBtnAction:) forControlEvents:UIControlEventTouchUpInside]; | |
| 214 | + [_resignTextViewBtn addSubview:self.textViewBackView]; | |
| 215 | + } | |
| 216 | + return _resignTextViewBtn; | |
| 217 | +} | |
| 218 | + | |
| 219 | +- (UIButton *)commentButton { | |
| 220 | + if (!_commentButton) { | |
| 221 | + _commentButton = [UIButton buttonWithType:UIButtonTypeCustom]; | |
| 222 | + _commentButton.frame = CGRectMake(10, 40, KScreenWidth-20, 40); | |
| 223 | + _commentButton.backgroundColor = [UIColor colorWithRed:(230.0/255.0) green:(230.0/255.0) blue:(230.0/255.0) alpha:1]; | |
| 224 | + [_commentButton setTitleColor:[UIColor grayColorCNLive] forState:UIControlStateNormal]; | |
| 225 | + [_commentButton setTitle:@" 我来说两句....." forState:UIControlStateNormal]; | |
| 226 | + _commentButton.layer.cornerRadius = 15; | |
| 227 | + _commentButton.layer.masksToBounds = YES; | |
| 228 | + [_commentButton addTarget:self action:@selector(commentBtnAction:) forControlEvents:UIControlEventTouchUpInside]; | |
| 229 | + } | |
| 230 | + return _commentButton; | |
| 231 | +} | |
| 232 | + | |
| 233 | +#pragma mark - Action !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
| 234 | +- (void)addNotification { | |
| 235 | + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil]; | |
| 236 | + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil]; | |
| 237 | +} | |
| 238 | + | |
| 239 | +- (void)commentBtnAction:(UIButton *)button { | |
| 240 | + [self addSubview:self.resignTextViewBtn]; | |
| 241 | + [self.textField becomeFirstResponder]; | |
| 242 | +} | |
| 243 | + | |
| 244 | +- (void)commentBackBtnAction:(UIButton *)button { | |
| 245 | + [button removeFromSuperview]; | |
| 246 | +} | |
| 247 | + | |
| 248 | +#pragma mark - UITextFieldDelegate | |
| 249 | +- (BOOL)textFieldShouldReturn:(UITextField *)textField { | |
| 250 | + | |
| 251 | + [[CNLiveCommentManager sharedCNLiveCommentManager] commentOnProgramWithProgramId:@"123" sid:@"555" comment:textField.text completion:^(NSString *errorCode, NSString *errorMsg) { | |
| 252 | + | |
| 253 | + if ([errorCode isEqualToString:@"0"]) { | |
| 254 | + textField.text = @""; | |
| 255 | + [textField resignFirstResponder]; | |
| 256 | + [self getCommentListWithPid:@"123"]; | |
| 257 | + [self getCommentCountWithPid:@"123"]; | |
| 258 | + } | |
| 259 | + }]; | |
| 260 | + return YES; | |
| 261 | +} | |
| 262 | + | |
| 263 | +#pragma mark <KeyboardNotificationAction> | |
| 264 | +- (void)keyboardWillShow:(NSNotification *)notification { | |
| 265 | + | |
| 266 | + CGRect keyboardRect = [[notification.userInfo objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue]; | |
| 267 | + UIViewAnimationCurve curve = [[notification.userInfo objectForKey:UIKeyboardAnimationCurveUserInfoKey] integerValue]; | |
| 268 | + double duration = [[notification.userInfo objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue]; | |
| 269 | + | |
| 270 | + [UIView animateWithDuration:duration | |
| 271 | + delay:0.0f | |
| 272 | + options:[self animationOptionsForCurve:curve] | |
| 273 | + animations:^{ | |
| 274 | + | |
| 275 | + CGRect inputViewFrame = self.textViewBackView.frame; | |
| 276 | + if (keyboardRect.origin.y == KScreenHeight) { | |
| 277 | + self.textViewBackView.frame = CGRectMake(inputViewFrame.origin.x, | |
| 278 | + self.frame.size.height-(inputViewFrame.size.height), | |
| 279 | + inputViewFrame.size.width, | |
| 280 | + inputViewFrame.size.height); | |
| 281 | + } else { | |
| 282 | + | |
| 283 | + self.textViewBackView.frame = CGRectMake(inputViewFrame.origin.x, | |
| 284 | + self.frame.size.height-keyboardRect.size.height-_textViewBackView.frame.size.height, | |
| 285 | + inputViewFrame.size.width, | |
| 286 | + inputViewFrame.size.height); | |
| 287 | + | |
| 288 | + } | |
| 289 | + } | |
| 290 | + completion:^(BOOL finished) { | |
| 291 | + }]; | |
| 292 | +} | |
| 293 | + | |
| 294 | +- (void)keyboardWillHide:(NSNotification *)notification | |
| 295 | +{ | |
| 296 | + [self.textViewBackView setFrame:CGRectMake(0, KScreenHeight, KScreenWidth, self.textViewBackView.frame.size.height)]; | |
| 297 | + [self.resignTextViewBtn removeFromSuperview]; | |
| 298 | +} | |
| 299 | + | |
| 300 | +- (UIViewAnimationOptions)animationOptionsForCurve:(UIViewAnimationCurve)curve | |
| 301 | +{ | |
| 302 | + switch (curve) { | |
| 303 | + case UIViewAnimationCurveEaseInOut: | |
| 304 | + return UIViewAnimationOptionCurveEaseInOut; | |
| 305 | + break; | |
| 306 | + case UIViewAnimationCurveEaseIn: | |
| 307 | + return UIViewAnimationOptionCurveEaseIn; | |
| 308 | + break; | |
| 309 | + case UIViewAnimationCurveEaseOut: | |
| 310 | + return UIViewAnimationOptionCurveEaseOut; | |
| 311 | + break; | |
| 312 | + case UIViewAnimationCurveLinear: | |
| 313 | + return UIViewAnimationOptionCurveLinear; | |
| 314 | + break; | |
| 315 | + } | |
| 316 | + | |
| 317 | + return kNilOptions; | |
| 318 | +} | |
| 319 | + | |
| 76 | 320 | @end | ... | ... |
LiveVideoCloud/PrefixHeader.pch
| ... | ... | @@ -29,9 +29,8 @@ |
| 29 | 29 | #import <CNLivePlayerSDK/CNLiveWebcastManager.h> |
| 30 | 30 | #import <CNLiveMsgTools/CNLiveMsgManager.h> |
| 31 | 31 | #import <CNLiveChatManager/CNLiveChatManager.h> |
| 32 | -#import <CNLiveUserSystemSDK/CNLiveUserSystemCenter.h> | |
| 33 | - #import "LVCCommentModel.h" | |
| 34 | - | |
| 32 | + #import <CNLiveUserSystemSDK/CNLiveUserSystemCenter.h> | |
| 33 | + #import "LVCVodListModel.h" | |
| 35 | 34 | #import "Common.h" |
| 36 | 35 | #import "MJExtension.h" |
| 37 | 36 | #import "CNLiveMacro.h" |
| ... | ... | @@ -55,6 +54,7 @@ |
| 55 | 54 | #import "WXApi.h" |
| 56 | 55 | #import "WeiboSDK.h" |
| 57 | 56 | #import "AppDelegate.h" |
| 57 | + #import <CNLiveChatManager/CNLiveCommentManager.h> | |
| 58 | 58 | |
| 59 | 59 | |
| 60 | 60 | #if TARGET_OS_IPHONE |
| ... | ... | @@ -78,9 +78,6 @@ |
| 78 | 78 | #define UserAppKey @"4c8658abc5d66f270f9bf5dcd1ef11e3597fab4c4e0af9"//@"13c6f0ad6f459cd479834b0b39cff99c6cf20c970815bb"// |
| 79 | 79 | #define UserAppSceret @"c2faeb120f0ea2e2d47020d4b03cb8a93bed2585897a94"//@"14c887b76ec2ecdf7083fb4c62808f13f6ab77a0f9dfec"// |
| 80 | 80 | |
| 81 | -#define JBAppId @"hdtv" | |
| 82 | -#define JBAppVersion [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"] ///debug用 "CFBundleVersion" | |
| 83 | - | |
| 84 | 81 | |
| 85 | 82 | #define PlaceholderImage @"placehodler" |
| 86 | 83 | #define appDelegate ((AppDelegate *)[UIApplication sharedApplication].delegate) | ... | ... |
LiveVideoCloud/animation.xcassets/videoSupport.imageset/Contents.json
0 → 100644
| 1 | +{ | |
| 2 | + "images" : [ | |
| 3 | + { | |
| 4 | + "idiom" : "universal", | |
| 5 | + "filename" : "videoSupport.png", | |
| 6 | + "scale" : "1x" | |
| 7 | + }, | |
| 8 | + { | |
| 9 | + "idiom" : "universal", | |
| 10 | + "scale" : "2x" | |
| 11 | + }, | |
| 12 | + { | |
| 13 | + "idiom" : "universal", | |
| 14 | + "scale" : "3x" | |
| 15 | + } | |
| 16 | + ], | |
| 17 | + "info" : { | |
| 18 | + "version" : 1, | |
| 19 | + "author" : "xcode" | |
| 20 | + } | |
| 21 | +} | |
| 0 | 22 | \ No newline at end of file | ... | ... |
LiveVideoCloud/animation.xcassets/videoSupport.imageset/videoSupport.png
0 → 100644
1.94 KB
LiveVideoCloud/animation.xcassets/videoSupportNormal.imageset/Contents.json
0 → 100644
| 1 | +{ | |
| 2 | + "images" : [ | |
| 3 | + { | |
| 4 | + "idiom" : "universal", | |
| 5 | + "filename" : "videoSupportNormal.png", | |
| 6 | + "scale" : "1x" | |
| 7 | + }, | |
| 8 | + { | |
| 9 | + "idiom" : "universal", | |
| 10 | + "scale" : "2x" | |
| 11 | + }, | |
| 12 | + { | |
| 13 | + "idiom" : "universal", | |
| 14 | + "scale" : "3x" | |
| 15 | + } | |
| 16 | + ], | |
| 17 | + "info" : { | |
| 18 | + "version" : 1, | |
| 19 | + "author" : "xcode" | |
| 20 | + } | |
| 21 | +} | |
| 0 | 22 | \ No newline at end of file | ... | ... |
LiveVideoCloud/animation.xcassets/videoSupportNormal.imageset/videoSupportNormal.png
0 → 100644
2.01 KB