Commit 26d467de4f1614fdc7b4d47dd5b052dace57b80b
1 parent
2ef8d273
修复bug
Showing
22 changed files
with
265 additions
and
174 deletions
LiveVideoCloud/LiveVideoCloud.xcodeproj/project.pbxproj
| ... | ... | @@ -32,7 +32,6 @@ |
| 32 | 32 | 81A1B9A91E8277410079FF5F /* LVCInputView.m in Sources */ = {isa = PBXBuildFile; fileRef = 81A1B9A81E8277410079FF5F /* LVCInputView.m */; }; |
| 33 | 33 | 81A482F51E88ACC80097A80A /* LVCTelevisionView.m in Sources */ = {isa = PBXBuildFile; fileRef = 81A482F41E88ACC80097A80A /* LVCTelevisionView.m */; }; |
| 34 | 34 | 81A482F81E88AFA20097A80A /* LVCFirstHeaderReusableView.m in Sources */ = {isa = PBXBuildFile; fileRef = 81A482F71E88AFA20097A80A /* LVCFirstHeaderReusableView.m */; }; |
| 35 | - 81A483011E88B0130097A80A /* LVCBannerModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 81A482FE1E88B0130097A80A /* LVCBannerModel.m */; }; | |
| 36 | 35 | 81A483021E88B0130097A80A /* LVCChatRoomModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 81A483001E88B0130097A80A /* LVCChatRoomModel.m */; }; |
| 37 | 36 | 81A483051E88B32C0097A80A /* LVCHeaderRollCollectionViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 81A483041E88B32C0097A80A /* LVCHeaderRollCollectionViewCell.m */; }; |
| 38 | 37 | 81A483081E88B6140097A80A /* UIView+ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 81A483071E88B6140097A80A /* UIView+ViewController.m */; }; |
| ... | ... | @@ -44,6 +43,7 @@ |
| 44 | 43 | 81A4831A1E88E19C0097A80A /* LVCMoreProgramViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 81A483191E88E19C0097A80A /* LVCMoreProgramViewController.m */; }; |
| 45 | 44 | 81A4831D1E88E1EB0097A80A /* LVCMoreSortTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 81A4831C1E88E1EB0097A80A /* LVCMoreSortTableViewCell.m */; }; |
| 46 | 45 | 81A483201E88F4BF0097A80A /* LVCProgramModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 81A4831F1E88F4BF0097A80A /* LVCProgramModel.m */; }; |
| 46 | + 81CE9E1B1E8CF567000F8F6B /* LVCRequestFailedView.m in Sources */ = {isa = PBXBuildFile; fileRef = 81CE9E1A1E8CF567000F8F6B /* LVCRequestFailedView.m */; }; | |
| 47 | 47 | 81F1C8381E8BBDDA0085C2B8 /* MHPagingScrollView.m in Sources */ = {isa = PBXBuildFile; fileRef = 81F1C8371E8BBDDA0085C2B8 /* MHPagingScrollView.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; |
| 48 | 48 | 81F1C83D1E8BBDE40085C2B8 /* V8HorizontalPickerView.m in Sources */ = {isa = PBXBuildFile; fileRef = 81F1C83B1E8BBDE40085C2B8 /* V8HorizontalPickerView.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; |
| 49 | 49 | 81F1C8401E8BC5CC0085C2B8 /* NSArray+Safety.m in Sources */ = {isa = PBXBuildFile; fileRef = 81F1C83F1E8BC5CC0085C2B8 /* NSArray+Safety.m */; }; |
| ... | ... | @@ -298,8 +298,6 @@ |
| 298 | 298 | 81A482F41E88ACC80097A80A /* LVCTelevisionView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = LVCTelevisionView.m; path = LiveVideoCloud/Classes/Sections/homeSections/View/LVCTelevisionView.m; sourceTree = SOURCE_ROOT; }; |
| 299 | 299 | 81A482F61E88AFA20097A80A /* LVCFirstHeaderReusableView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LVCFirstHeaderReusableView.h; sourceTree = "<group>"; }; |
| 300 | 300 | 81A482F71E88AFA20097A80A /* LVCFirstHeaderReusableView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LVCFirstHeaderReusableView.m; sourceTree = "<group>"; }; |
| 301 | - 81A482FD1E88B0130097A80A /* LVCBannerModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LVCBannerModel.h; sourceTree = "<group>"; }; | |
| 302 | - 81A482FE1E88B0130097A80A /* LVCBannerModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LVCBannerModel.m; sourceTree = "<group>"; }; | |
| 303 | 301 | 81A482FF1E88B0130097A80A /* LVCChatRoomModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LVCChatRoomModel.h; sourceTree = "<group>"; }; |
| 304 | 302 | 81A483001E88B0130097A80A /* LVCChatRoomModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LVCChatRoomModel.m; sourceTree = "<group>"; }; |
| 305 | 303 | 81A483031E88B32C0097A80A /* LVCHeaderRollCollectionViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LVCHeaderRollCollectionViewCell.h; sourceTree = "<group>"; }; |
| ... | ... | @@ -322,6 +320,8 @@ |
| 322 | 320 | 81A4831C1E88E1EB0097A80A /* LVCMoreSortTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LVCMoreSortTableViewCell.m; sourceTree = "<group>"; }; |
| 323 | 321 | 81A4831E1E88F4BF0097A80A /* LVCProgramModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LVCProgramModel.h; sourceTree = "<group>"; }; |
| 324 | 322 | 81A4831F1E88F4BF0097A80A /* LVCProgramModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LVCProgramModel.m; sourceTree = "<group>"; }; |
| 323 | + 81CE9E191E8CF567000F8F6B /* LVCRequestFailedView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LVCRequestFailedView.h; sourceTree = "<group>"; }; | |
| 324 | + 81CE9E1A1E8CF567000F8F6B /* LVCRequestFailedView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LVCRequestFailedView.m; sourceTree = "<group>"; }; | |
| 325 | 325 | 81F1C8361E8BBDDA0085C2B8 /* MHPagingScrollView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MHPagingScrollView.h; sourceTree = "<group>"; }; |
| 326 | 326 | 81F1C8371E8BBDDA0085C2B8 /* MHPagingScrollView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MHPagingScrollView.m; sourceTree = "<group>"; }; |
| 327 | 327 | 81F1C83A1E8BBDE40085C2B8 /* V8HorizontalPickerView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = V8HorizontalPickerView.h; sourceTree = "<group>"; }; |
| ... | ... | @@ -762,8 +762,6 @@ |
| 762 | 762 | 81A482FC1E88B0130097A80A /* Model */ = { |
| 763 | 763 | isa = PBXGroup; |
| 764 | 764 | children = ( |
| 765 | - 81A482FD1E88B0130097A80A /* LVCBannerModel.h */, | |
| 766 | - 81A482FE1E88B0130097A80A /* LVCBannerModel.m */, | |
| 767 | 765 | 81A4830C1E88B8300097A80A /* LVCChannelsModel.h */, |
| 768 | 766 | 81A4830D1E88B8300097A80A /* LVCChannelsModel.m */, |
| 769 | 767 | 81A4830F1E88B8630097A80A /* LVCChannelDetailsModel.h */, |
| ... | ... | @@ -1719,6 +1717,8 @@ |
| 1719 | 1717 | 81A483041E88B32C0097A80A /* LVCHeaderRollCollectionViewCell.m */, |
| 1720 | 1718 | 8112D42F1E7927A5002E00F6 /* LVCPlayerLoadingView.h */, |
| 1721 | 1719 | 8112D4301E7927A5002E00F6 /* LVCPlayerLoadingView.m */, |
| 1720 | + 81CE9E191E8CF567000F8F6B /* LVCRequestFailedView.h */, | |
| 1721 | + 81CE9E1A1E8CF567000F8F6B /* LVCRequestFailedView.m */, | |
| 1722 | 1722 | D2A089E61E89FA720071412C /* LVCUGCLivePlayerCell.h */, |
| 1723 | 1723 | D2A089E71E89FA720071412C /* LVCUGCLivePlayerCell.m */, |
| 1724 | 1724 | D25BF8811E7F775F007FB138 /* LVCUGCPlayerLoadingView.h */, |
| ... | ... | @@ -2037,7 +2037,6 @@ |
| 2037 | 2037 | D2029C9F1E6EADE10027CD92 /* NSObject+MJKeyValue.m in Sources */, |
| 2038 | 2038 | D25BF8A01E80C4BD007FB138 /* UIImage+LVCVagueImage.m in Sources */, |
| 2039 | 2039 | D2888DB11E6EC05F003A77C8 /* TempViewController.m in Sources */, |
| 2040 | - 81A483011E88B0130097A80A /* LVCBannerModel.m in Sources */, | |
| 2041 | 2040 | 810B65021E779B1F00133E15 /* MASViewAttribute.m in Sources */, |
| 2042 | 2041 | D2B7B2511E8247D400ED084E /* ChatBarrageManager.m in Sources */, |
| 2043 | 2042 | D2029CAC1E6EADE10027CD92 /* MJRefreshBackStateFooter.m in Sources */, |
| ... | ... | @@ -2077,6 +2076,7 @@ |
| 2077 | 2076 | D25BF87A1E7B8A82007FB138 /* FilterFunctionView.m in Sources */, |
| 2078 | 2077 | D207BEA11E84C1EC006A0CE8 /* AnimationBaseView.m in Sources */, |
| 2079 | 2078 | D2029D001E6EAE2E0027CD92 /* NSNumber+ScaleHeight.m in Sources */, |
| 2079 | + 81CE9E1B1E8CF567000F8F6B /* LVCRequestFailedView.m in Sources */, | |
| 2080 | 2080 | D2888D9E1E6EBF1B003A77C8 /* LVCLiveViewController.m in Sources */, |
| 2081 | 2081 | D2029C951E6EADE10027CD92 /* UIWebView+AFNetworking.m in Sources */, |
| 2082 | 2082 | 810B650A1E77B39D00133E15 /* LVCFullScreenPlayerController.m in Sources */, | ... | ... |
LiveVideoCloud/LiveVideoCloud/AppDelegate/AppDelegate.m
| ... | ... | @@ -38,10 +38,13 @@ |
| 38 | 38 | NSLog(@"连接服务器失败-----%ld", errors); |
| 39 | 39 | }]; |
| 40 | 40 | */ |
| 41 | - // 20170327 20170328 | |
| 41 | + | |
| 42 | 42 | /* |
| 43 | + CNLiveChatUserInfo *userInfo = [[CNLiveChatUserInfo alloc] initWithUserId:@"20170311" name:@"zzllzzzll" portrait:@"https://y3.cnliveimg.com/mobile/images/mobilehead/2017/03/30/1490844962259_small.jpg"]; | |
| 43 | 44 | */ |
| 44 | - CNLiveChatUserInfo *userInfo = [[CNLiveChatUserInfo alloc] initWithUserId:@"20170328" name:@"20170328" portrait:@""]; | |
| 45 | + | |
| 46 | + // 20170327 20170328 | |
| 47 | + CNLiveChatUserInfo *userInfo = [[CNLiveChatUserInfo alloc] initWithUserId:@"20170311" name:@"zzllzzzll" portrait:@"https://y3.cnliveimg.com/mobile/images/mobilehead/2017/03/30/1490844962259_small.jpg"]; | |
| 45 | 48 | [[CNLiveChatManager sharedCNLiveChatManager] loginServer:userInfo success:^(NSString *userId) { |
| 46 | 49 | NSLog(@"连接服务器-----success"); |
| 47 | 50 | ... | ... |
LiveVideoCloud/LiveVideoCloud/Classes/Sections/homeSections/ChatView/LVCChatView.h
LiveVideoCloud/LiveVideoCloud/Classes/Sections/homeSections/ChatView/LVCChatView.m
| ... | ... | @@ -75,23 +75,23 @@ |
| 75 | 75 | |
| 76 | 76 | LVCMessage *msg = [LVCMessage messageWihtContent:message isRight:YES]; |
| 77 | 77 | dispatch_sync(dispatch_get_main_queue(), ^{ |
| 78 | - [self addData:msg]; | |
| 79 | 78 | if (self.delegate && [self.delegate respondsToSelector:@selector(lvcChatView:sendBarrageWithModel:)]) { |
| 80 | 79 | [self.delegate lvcChatView:self sendBarrageWithModel:model]; |
| 81 | 80 | } |
| 81 | + [self addData:msg]; | |
| 82 | 82 | }); |
| 83 | 83 | |
| 84 | - NSLog(@"电视台--发送消息---success-(%@)",msg.content); | |
| 85 | - | |
| 86 | 84 | } error:^(CNLiveChatErrorCode errors, NSString *messageId, NSString *targetId) { |
| 87 | 85 | NSLog(@"电视台--发送消息---failed-(%ld)",(long)errors); |
| 88 | - | |
| 86 | + [SVProgressHUD showInfoWithStatus:@"抱歉,消息发送失败~"]; | |
| 89 | 87 | }]; |
| 90 | 88 | } |
| 91 | 89 | |
| 92 | 90 | //退出聊天室 |
| 93 | 91 | - (void)quit |
| 94 | 92 | { |
| 93 | + if (!_roomId) return; //如果聊天室不存在,不作处理 | |
| 94 | + | |
| 95 | 95 | [[CNLiveChatManager sharedCNLiveChatManager] quitChatRoom:_roomId success:^(NSString *targetId) { |
| 96 | 96 | NSLog(@"电视台--退出聊天室---success-%@",targetId); |
| 97 | 97 | } error:^(CNLiveChatErrorCode errors, NSString *targetId) { |
| ... | ... | @@ -106,12 +106,19 @@ |
| 106 | 106 | //接收消息 |
| 107 | 107 | dispatch_queue_t globalQueue=dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); |
| 108 | 108 | dispatch_async(globalQueue, ^{ |
| 109 | - LVCMessage *msg = [LVCMessage messageWihtContent:message isRight:NO]; | |
| 109 | + NSString *myUserId = [CNLiveChatManager sharedCNLiveChatManager].currentUserInfo.userId; | |
| 110 | + | |
| 111 | + LVCMessage *msg; | |
| 112 | + if ([message.userInfo.userId isEqualToString:myUserId]) { | |
| 113 | + msg = [LVCMessage messageWihtContent:message isRight:YES]; | |
| 114 | + } else { | |
| 115 | + msg = [LVCMessage messageWihtContent:message isRight:NO]; | |
| 116 | + } | |
| 110 | 117 | |
| 111 | 118 | chatMsgModel *model = [[chatMsgModel alloc] init]; |
| 112 | 119 | model.content = message.messageContent; |
| 113 | 120 | model.isMine = NO; |
| 114 | - | |
| 121 | + | |
| 115 | 122 | dispatch_sync(dispatch_get_main_queue(), ^{ |
| 116 | 123 | [self addData:msg]; |
| 117 | 124 | if (self.delegate && [self.delegate respondsToSelector:@selector(lvcChatView:sendBarrageWithModel:)]) { | ... | ... |
LiveVideoCloud/LiveVideoCloud/Classes/Sections/homeSections/ChatView/LVCChatViewTableViewCell.m
| ... | ... | @@ -51,13 +51,15 @@ |
| 51 | 51 | _bgImageView.frame = message.popFrame; |
| 52 | 52 | _messageLab.text = message.content; |
| 53 | 53 | _messageLab.frame = message.contentFrame; |
| 54 | - _nickNameLab.frame = message.nikenameFrame; | |
| 55 | 54 | _iconImageView.frame = message.portraitsFrame; |
| 56 | 55 | [_iconImageView sd_setImageWithURL:[NSURL URLWithString:message.portraits] placeholderImage:[UIImage imageNamed:@"touxiang"]]; |
| 57 | 56 | _lineLab.hidden = YES; |
| 57 | + _nickNameLab.hidden = YES; | |
| 58 | 58 | |
| 59 | 59 | } else { //收到的消息 |
| 60 | 60 | |
| 61 | + _lineLab.hidden = NO; | |
| 62 | + _nickNameLab.hidden = NO; | |
| 61 | 63 | UIImage *bgImage = [UIImage imageNamed:@"Gift box"]; |
| 62 | 64 | bgImage = [bgImage stretchableImageWithLeftCapWidth:10 topCapHeight:27]; |
| 63 | 65 | _bgImageView.image = bgImage; |
| ... | ... | @@ -65,7 +67,6 @@ |
| 65 | 67 | _nickNameLab.text = message.nikename; |
| 66 | 68 | _nickNameLab.frame = message.nikenameFrame; |
| 67 | 69 | _lineLab.frame = message.lineFrame; |
| 68 | - _lineLab.hidden = NO; | |
| 69 | 70 | [_iconImageView sd_setImageWithURL:[NSURL URLWithString:message.portraits] placeholderImage:[UIImage imageNamed:@"touxiang"]]; |
| 70 | 71 | _iconImageView.frame = message.portraitsFrame; |
| 71 | 72 | _messageLab.text = message.content; |
| ... | ... | @@ -80,6 +81,8 @@ |
| 80 | 81 | { |
| 81 | 82 | if (!_iconImageView) { |
| 82 | 83 | _iconImageView = [[UIImageView alloc] init]; |
| 84 | + _iconImageView.layer.masksToBounds = YES; | |
| 85 | + _iconImageView.layer.cornerRadius = HEAD_SIZE/2; | |
| 83 | 86 | } |
| 84 | 87 | return _iconImageView; |
| 85 | 88 | } | ... | ... |
LiveVideoCloud/LiveVideoCloud/Classes/Sections/homeSections/ChatView/LVCMessage.h
LiveVideoCloud/LiveVideoCloud/Classes/Sections/homeSections/ChatView/LVCMessage.m
| ... | ... | @@ -12,6 +12,8 @@ |
| 12 | 12 | #define ICON_TOP_SPACE 8.0 //头像与cell间距 |
| 13 | 13 | #define POP_TOP_SPACE 10 //pop与cell间距 |
| 14 | 14 | |
| 15 | +#define KScreenWidth ([UIScreen mainScreen].bounds.size.width > [UIScreen mainScreen].bounds.size.height ? [UIScreen mainScreen].bounds.size.height : [UIScreen mainScreen].bounds.size.width) | |
| 16 | + | |
| 15 | 17 | @interface LVCMessage () |
| 16 | 18 | |
| 17 | 19 | @property (nonatomic, strong) NSString *nikename; //昵称 |
| ... | ... | @@ -39,34 +41,38 @@ |
| 39 | 41 | msg.nikename = content.userInfo.name; |
| 40 | 42 | msg.portraits = content.userInfo.portraitUri; |
| 41 | 43 | |
| 42 | - CGFloat width = SCREEN_WIDTH > SCREEN_HEIGHT ? SCREEN_HEIGHT : SCREEN_WIDTH; | |
| 44 | + CGRect contentRect = [msg.content boundingRectWithSize:CGSizeMake((KScreenWidth-60)*0.8, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading attributes:@{NSFontAttributeName : [UIFont systemFontOfSize:14]} context:nil]; | |
| 45 | + | |
| 46 | + CGRect nameRect = [msg.nikename boundingRectWithSize:CGSizeMake((KScreenWidth-60)*0.8, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading attributes:@{NSFontAttributeName : [UIFont systemFontOfSize:10]} context:nil]; | |
| 43 | 47 | |
| 44 | - CGRect rect = [msg.content boundingRectWithSize:CGSizeMake((width-60)*0.8, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading attributes:@{NSFontAttributeName : [UIFont systemFontOfSize:14]} context:nil]; | |
| 45 | 48 | CGRect frameOfLabel = CGRectZero; |
| 46 | 49 | |
| 47 | - frameOfLabel.size = rect.size; | |
| 50 | + frameOfLabel.size = contentRect.size; | |
| 48 | 51 | |
| 49 | 52 | if (isRight) { //我的消息 |
| 50 | 53 | |
| 51 | - msg.portraitsFrame = CGRectMake(SCREEN_WIDTH-45, ICON_TOP_SPACE, ICON_WIDTH, ICON_WIDTH); | |
| 54 | + msg.portraitsFrame = CGRectMake(KScreenWidth-45, ICON_TOP_SPACE, ICON_WIDTH, ICON_WIDTH); | |
| 52 | 55 | |
| 53 | - msg.popFrame = CGRectMake(SCREEN_WIDTH-60-CGRectGetWidth(rect)-POP_TOP_SPACE, POP_TOP_SPACE, CGRectGetWidth(rect)+2*POP_TOP_SPACE, CGRectGetHeight(rect)+2*POP_TOP_SPACE); | |
| 56 | + msg.popFrame = CGRectMake(KScreenWidth-60-CGRectGetWidth(contentRect)-POP_TOP_SPACE, POP_TOP_SPACE, CGRectGetWidth(contentRect)+2*POP_TOP_SPACE, CGRectGetHeight(contentRect)+2*POP_TOP_SPACE); | |
| 54 | 57 | |
| 55 | - msg.contentFrame = CGRectMake(POP_TOP_SPACE, POP_TOP_SPACE, CGRectGetWidth(rect), CGRectGetHeight(rect)); | |
| 58 | + msg.contentFrame = CGRectMake(POP_TOP_SPACE, POP_TOP_SPACE, CGRectGetWidth(contentRect), CGRectGetHeight(contentRect)); | |
| 56 | 59 | |
| 57 | 60 | msg.cellHeight = CGRectGetHeight(msg.popFrame)+20; |
| 58 | 61 | |
| 59 | 62 | } else { //收到的消息 |
| 60 | 63 | |
| 61 | - msg.nikenameFrame = CGRectMake(POP_TOP_SPACE, ICON_TOP_SPACE, CGRectGetWidth(rect), 12); | |
| 64 | + CGFloat maxWith = CGRectGetWidth(nameRect) > CGRectGetWidth(contentRect) ? CGRectGetWidth(nameRect) : CGRectGetWidth(contentRect); | |
| 65 | + CGFloat popWidth = maxWith + 2*POP_TOP_SPACE; | |
| 66 | + | |
| 67 | + msg.nikenameFrame = CGRectMake(POP_TOP_SPACE, ICON_TOP_SPACE, popWidth, 12); | |
| 62 | 68 | |
| 63 | - msg.lineFrame = CGRectMake(POP_TOP_SPACE, 25, CGRectGetWidth(rect), 0.5); | |
| 69 | + msg.lineFrame = CGRectMake(POP_TOP_SPACE, 25, maxWith, 0.5); | |
| 64 | 70 | |
| 65 | 71 | msg.portraitsFrame = CGRectMake(10, ICON_TOP_SPACE , ICON_WIDTH, ICON_WIDTH); |
| 66 | 72 | |
| 67 | - msg.popFrame = CGRectMake(50, POP_TOP_SPACE , CGRectGetWidth(rect)+2*POP_TOP_SPACE, CGRectGetHeight(rect)+2*POP_TOP_SPACE+20); | |
| 73 | + msg.popFrame = CGRectMake(50, POP_TOP_SPACE , popWidth, CGRectGetHeight(contentRect)+2*POP_TOP_SPACE+20); | |
| 68 | 74 | |
| 69 | - msg.contentFrame = CGRectMake(POP_TOP_SPACE, 30, CGRectGetWidth(rect), CGRectGetHeight(rect)); | |
| 75 | + msg.contentFrame = CGRectMake(POP_TOP_SPACE, 30, CGRectGetWidth(contentRect), CGRectGetHeight(contentRect)); | |
| 70 | 76 | |
| 71 | 77 | msg.cellHeight = CGRectGetHeight(msg.popFrame)+20; |
| 72 | 78 | ... | ... |
LiveVideoCloud/LiveVideoCloud/Classes/Sections/homeSections/Controller/LVCLivePlayerController.m
| ... | ... | @@ -59,7 +59,7 @@ |
| 59 | 59 | [super viewDidLoad]; |
| 60 | 60 | self.view.backgroundColor = [UIColor blackColor]; |
| 61 | 61 | |
| 62 | - _roomId = @"778899"; | |
| 62 | + _roomId = [NSString stringWithFormat:@"syn%@",self.model.docID]; | |
| 63 | 63 | playerFrame = CGRectMake(0, 20, SCREEN_WIDTH, SCREEN_WIDTH*9/16); |
| 64 | 64 | _originalDirection = 0; |
| 65 | 65 | |
| ... | ... | @@ -213,7 +213,7 @@ |
| 213 | 213 | |
| 214 | 214 | //旋转至半屏 |
| 215 | 215 | - (void)toHalfScreenWithrotationAngle:(CGFloat)angle |
| 216 | -{ | |
| 216 | +{ | |
| 217 | 217 | _player.isFullScreen = NO; |
| 218 | 218 | _inputView.hidden = NO; |
| 219 | 219 | |
| ... | ... | @@ -260,8 +260,9 @@ |
| 260 | 260 | //退出聊天室 |
| 261 | 261 | [[CNLiveChatManager sharedCNLiveChatManager] quitChatRoom:_roomId success:NULL error:NULL]; |
| 262 | 262 | |
| 263 | + [self removeViews]; | |
| 264 | + | |
| 263 | 265 | self.navigationController.navigationBar.hidden = NO; |
| 264 | - self.tabBarController.tabBar.hidden = NO; | |
| 265 | 266 | [self.navigationController popViewControllerAnimated:YES]; |
| 266 | 267 | } |
| 267 | 268 | } |
| ... | ... | @@ -311,6 +312,17 @@ |
| 311 | 312 | [self.view endEditing:YES]; |
| 312 | 313 | } |
| 313 | 314 | |
| 315 | +- (void)removeViews | |
| 316 | +{ | |
| 317 | + [_player removeFromSuperview]; | |
| 318 | + [_chatView removeFromSuperview]; | |
| 319 | + [_inputView removeFromSuperview]; | |
| 320 | + _player = nil; | |
| 321 | + _chatView = nil; | |
| 322 | + _inputView = nil; | |
| 323 | + _player.delegate = nil; | |
| 324 | + [[NSNotificationCenter defaultCenter] removeObserver:self]; | |
| 325 | +} | |
| 314 | 326 | |
| 315 | 327 | #pragma mark - |
| 316 | 328 | #pragma mark - makeConstraints | ... | ... |
LiveVideoCloud/LiveVideoCloud/Classes/Sections/homeSections/Controller/LVCMoreProgramViewController.m
| ... | ... | @@ -9,6 +9,8 @@ |
| 9 | 9 | #import "LVCMoreProgramViewController.h" |
| 10 | 10 | #import "LVCMoreSortTableViewCell.h" |
| 11 | 11 | #import "LVCProgramModel.h" |
| 12 | +#import "LVCChannelsModel.h" | |
| 13 | +#import "LVCLivePlayerController.h" | |
| 12 | 14 | |
| 13 | 15 | @interface LVCMoreProgramViewController ()<UITableViewDelegate,UITableViewDataSource> |
| 14 | 16 | { |
| ... | ... | @@ -132,6 +134,12 @@ |
| 132 | 134 | { |
| 133 | 135 | [tableView deselectRowAtIndexPath:indexPath animated:YES]; |
| 134 | 136 | |
| 137 | + LVCChannelDetailsModel *details = _data[indexPath.row]; | |
| 138 | + LVCLivePlayerController *playVC = [[LVCLivePlayerController alloc] init]; | |
| 139 | + playVC.model = details; | |
| 140 | + self.navigationController.navigationBar.hidden = YES; | |
| 141 | + self.hidesBottomBarWhenPushed = YES; | |
| 142 | + [self.navigationController pushViewController:playVC animated:YES]; | |
| 135 | 143 | } |
| 136 | 144 | |
| 137 | 145 | #pragma mark - | ... | ... |
LiveVideoCloud/LiveVideoCloud/Classes/Sections/homeSections/Model/LVCBannerModel.h deleted
100644 → 0
| 1 | -// | |
| 2 | -// LVCBannerModel.h | |
| 3 | -// LiveVideoCloud | |
| 4 | -// | |
| 5 | -// Created by iOS on 17/3/27. | |
| 6 | -// Copyright © 2017年 cnlive. All rights reserved. | |
| 7 | -// | |
| 8 | - | |
| 9 | -#import <Foundation/Foundation.h> | |
| 10 | - | |
| 11 | -@interface LVCBannerModel : NSObject | |
| 12 | - | |
| 13 | - | |
| 14 | -@property (nonatomic, copy) NSString *img; // 滚动图片 url | |
| 15 | -@property (nonatomic, copy) NSString *title; // 滚动小标题 | |
| 16 | -@property (nonatomic, copy) NSString *type; | |
| 17 | -@property (nonatomic, copy) NSString *mediaId; | |
| 18 | -@property (nonatomic, copy) NSString *docID; | |
| 19 | -@property (nonatomic, copy) NSString *activityId; | |
| 20 | -@property (nonatomic, copy) NSString *url; | |
| 21 | -@property (nonatomic, copy) NSString *subTitle; | |
| 22 | -@property (nonatomic, copy) NSString *currentPlay; // 正在直播 | |
| 23 | -@property (nonatomic, copy) NSString *nextPlay; // 即将直播 | |
| 24 | - | |
| 25 | -@end |
LiveVideoCloud/LiveVideoCloud/Classes/Sections/homeSections/Model/LVCBannerModel.m deleted
100644 → 0
| 1 | -// | |
| 2 | -// LVCBannerModel.m | |
| 3 | -// LiveVideoCloud | |
| 4 | -// | |
| 5 | -// Created by iOS on 17/3/27. | |
| 6 | -// Copyright © 2017年 cnlive. All rights reserved. | |
| 7 | -// | |
| 8 | - | |
| 9 | -#import "LVCBannerModel.h" | |
| 10 | - | |
| 11 | -@implementation LVCBannerModel | |
| 12 | - | |
| 13 | -- (void)setValue:(id)value forUndefinedKey:(NSString *)key{} | |
| 14 | - | |
| 15 | -@end |
LiveVideoCloud/LiveVideoCloud/Classes/Sections/homeSections/View/LVCFirstHeaderReusableView.h
| ... | ... | @@ -7,11 +7,11 @@ |
| 7 | 7 | // |
| 8 | 8 | |
| 9 | 9 | #import <UIKit/UIKit.h> |
| 10 | -#import "LVCBannerModel.h" | |
| 10 | +#import "LVCChannelDetailsModel.h" | |
| 11 | 11 | |
| 12 | 12 | @interface LVCFirstHeaderReusableView : UICollectionReusableView |
| 13 | 13 | |
| 14 | 14 | @property (nonatomic, strong) NSArray <NSURL *> *imageUrls; |
| 15 | -@property (nonatomic, strong) NSArray <LVCBannerModel *> *modelArray; | |
| 15 | +@property (nonatomic, strong) NSArray <LVCChannelDetailsModel *> *modelArray; | |
| 16 | 16 | |
| 17 | 17 | @end | ... | ... |
LiveVideoCloud/LiveVideoCloud/Classes/Sections/homeSections/View/LVCFirstHeaderReusableView.m
| ... | ... | @@ -77,7 +77,7 @@ static NSString *cellId = @"cellId"; |
| 77 | 77 | [[NSRunLoop currentRunLoop] addTimer:_timer forMode:NSRunLoopCommonModes]; |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | -- (void)setModelArray:(NSArray<LVCBannerModel *> *)modelArray { | |
| 80 | +- (void)setModelArray:(NSArray<LVCChannelDetailsModel *> *)modelArray { | |
| 81 | 81 | _modelArray = modelArray; |
| 82 | 82 | self.cycleViewTitle.text = [NSString stringWithFormat:@" %@",_modelArray[0].title]; |
| 83 | 83 | } |
| ... | ... | @@ -195,11 +195,15 @@ static NSString *cellId = @"cellId"; |
| 195 | 195 | // 选择 |
| 196 | 196 | - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath |
| 197 | 197 | { |
| 198 | - /* | |
| 199 | - LVCBannerModel *model = self.modelArray[indexPath.row % 5]; | |
| 200 | - LVCLivePlayerController *player = [[LVCLivePlayerController alloc]init]; | |
| 201 | - [self.viewController.navigationController pushViewController:player animated:YES]; | |
| 202 | - */ | |
| 198 | + | |
| 199 | + LVCChannelDetailsModel *details = [_modelArray safetyObjectAtIndex:indexPath.row % 5]; | |
| 200 | + self.viewController.tabBarController.tabBar.hidden = YES; | |
| 201 | + LVCLivePlayerController *playVC = [[LVCLivePlayerController alloc] init]; | |
| 202 | + playVC.model = details; | |
| 203 | + self.viewController.navigationController.navigationBar.hidden = YES; | |
| 204 | + self.viewController.hidesBottomBarWhenPushed = YES; | |
| 205 | + [self.viewController.navigationController pushViewController:playVC animated:YES]; | |
| 206 | + self.viewController.hidesBottomBarWhenPushed = NO; | |
| 203 | 207 | } |
| 204 | 208 | |
| 205 | 209 | #pragma mark - 第一个组头设置界面 | ... | ... |
LiveVideoCloud/LiveVideoCloud/Classes/Sections/homeSections/View/LVCPlayer.m
| ... | ... | @@ -10,22 +10,22 @@ |
| 10 | 10 | #import "LVCPlayerLoadingView.h" |
| 11 | 11 | #import "SevenSwitch.h" |
| 12 | 12 | |
| 13 | -@interface LVCPlayer ()<UIGestureRecognizerDelegate> | |
| 13 | +@interface LVCPlayer ()<UIGestureRecognizerDelegate,LVCPlayerLoadingViewDelegate> | |
| 14 | 14 | { |
| 15 | 15 | LVCChannelDetailsModel *_model; |
| 16 | 16 | } |
| 17 | 17 | |
| 18 | +@property (nonatomic, strong) CNLiveMoviePlayerController *player; | |
| 18 | 19 | @property (nonatomic, strong) UIButton *backBtn; //返回 |
| 19 | 20 | @property (nonatomic, strong) UIButton *playOrPauseBtn; //播放/暂停 |
| 20 | 21 | @property (nonatomic, strong) UILabel *titleLab; //标题 |
| 21 | 22 | @property (nonatomic, strong) UIButton *fullScreenBtn; //控制全屏按钮 |
| 22 | 23 | @property (nonatomic, strong) UITapGestureRecognizer *singleTap; //单击手势 |
| 23 | 24 | @property (nonatomic, strong) LVCPlayerLoadingView *loadingView; //加载图 |
| 24 | -@property (nonatomic, strong) CNLiveMoviePlayerController *player; | |
| 25 | 25 | @property (nonatomic, strong) SevenSwitch *barrageSwitch; //弹幕开关 |
| 26 | 26 | @property (nonatomic, strong) UIButton *editBtn; //全屏编辑按钮 |
| 27 | - | |
| 28 | 27 | @property (nonatomic, strong) NSTimer *timer; //控制上下工具条定时器 |
| 28 | + | |
| 29 | 29 | @end |
| 30 | 30 | |
| 31 | 31 | @implementation LVCPlayer |
| ... | ... | @@ -61,7 +61,8 @@ |
| 61 | 61 | { |
| 62 | 62 | /* |
| 63 | 63 | */ |
| 64 | - _player = [[CNLiveMoviePlayerController alloc] initLivePlayWithChannelId:[NSString stringWithFormat:@"82_%@",model.mediaId] authSuccess:^{ | |
| 64 | + NSString *channelId = [NSString stringWithFormat:@"82_%@",model.mediaId]; | |
| 65 | + _player = [[CNLiveMoviePlayerController alloc] initLivePlayWithChannelId:channelId authSuccess:^{ | |
| 65 | 66 | [self addObservers]; |
| 66 | 67 | _player.videoDecoderMode = CNLiveMovieVideoDecoderMode_AUTO; |
| 67 | 68 | _player.shouldAutoplay = YES; |
| ... | ... | @@ -73,6 +74,9 @@ |
| 73 | 74 | |
| 74 | 75 | } authFailed:^(NSDictionary *errorInfo) { |
| 75 | 76 | NSLog(@"初始化点播播放器失败%@", errorInfo); |
| 77 | + [SVProgressHUD showInfoWithStatus:@"抱歉,加载失败~"]; | |
| 78 | + [_loadingView stopLoading]; | |
| 79 | + | |
| 76 | 80 | } getAnchorStatusResult:NULL]; |
| 77 | 81 | |
| 78 | 82 | /* |
| ... | ... | @@ -199,6 +203,14 @@ |
| 199 | 203 | } |
| 200 | 204 | } |
| 201 | 205 | |
| 206 | +#pragma mark - | |
| 207 | +#pragma mark - LVCPlayerLoadingViewDelegate | |
| 208 | +- (void)retryBtnClick | |
| 209 | +{ | |
| 210 | + [_loadingView startLoading]; | |
| 211 | + [_player reload:nil]; | |
| 212 | +} | |
| 213 | + | |
| 202 | 214 | #pragma mark - UIGestureRecognizerDelegate 手势冲突 |
| 203 | 215 | - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch { |
| 204 | 216 | if ([NSStringFromClass([touch.view class]) isEqualToString:@"SevenSwitch"]) { |
| ... | ... | @@ -267,8 +279,9 @@ |
| 267 | 279 | if (_player) { |
| 268 | 280 | int reason = [[[notification userInfo] valueForKey:MPMoviePlayerPlaybackDidFinishReasonUserInfoKey] intValue]; |
| 269 | 281 | if (MPMovieFinishReasonPlaybackError == reason) { |
| 282 | + _loadingView.hidden = NO; | |
| 270 | 283 | } else { |
| 271 | -// _loadingView.retryBtn.hidden = YES; | |
| 284 | + _loadingView.hidden = YES; | |
| 272 | 285 | } |
| 273 | 286 | |
| 274 | 287 | switch (reason) |
| ... | ... | @@ -305,7 +318,7 @@ |
| 305 | 318 | |
| 306 | 319 | if (_player.playbackState == MPMoviePlaybackStatePlaying) { |
| 307 | 320 | _playOrPauseBtn.selected = YES; |
| 308 | - [self.loadingView retry]; | |
| 321 | + _loadingView.hidden = YES; | |
| 309 | 322 | } else { |
| 310 | 323 | _playOrPauseBtn.selected = NO; |
| 311 | 324 | } |
| ... | ... | @@ -511,8 +524,7 @@ |
| 511 | 524 | { |
| 512 | 525 | if (!_contentView) { |
| 513 | 526 | _contentView = [[UIImageView alloc] init]; |
| 514 | - _contentView.image = [UIImage imageNamed:@""]; | |
| 515 | - _contentView.backgroundColor = [UIColor lightGrayColor]; | |
| 527 | + _contentView.backgroundColor = [UIColor blackColor]; | |
| 516 | 528 | _contentView.userInteractionEnabled = YES; |
| 517 | 529 | } |
| 518 | 530 | return _contentView; | ... | ... |
LiveVideoCloud/LiveVideoCloud/Classes/Sections/homeSections/View/LVCPlayerLoadingView.m
| ... | ... | @@ -119,11 +119,11 @@ |
| 119 | 119 | if (!_retryBtn) { |
| 120 | 120 | _retryBtn = [UIButton buttonWithType:UIButtonTypeCustom]; |
| 121 | 121 | [_retryBtn setTitle:@"重试" forState:UIControlStateNormal]; |
| 122 | - [_retryBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; | |
| 122 | + [_retryBtn setTitleColor:[UIColor yellowColor] forState:UIControlStateNormal]; | |
| 123 | 123 | _retryBtn.hidden = YES; |
| 124 | 124 | _retryBtn.layer.cornerRadius = 10; |
| 125 | 125 | _retryBtn.layer.masksToBounds = YES; |
| 126 | - _retryBtn.layer.borderColor = [UIColor blackColor].CGColor; | |
| 126 | + _retryBtn.layer.borderColor = [UIColor yellowColor].CGColor; | |
| 127 | 127 | _retryBtn.layer.borderWidth = 1; |
| 128 | 128 | [_retryBtn addTarget:self action:@selector(retryBtnAction) forControlEvents:UIControlEventTouchUpInside]; |
| 129 | 129 | } | ... | ... |
LiveVideoCloud/LiveVideoCloud/Classes/Sections/homeSections/View/LVCRequestFailedView.h
0 → 100644
| 1 | +// | |
| 2 | +// LVCRequestFailedView.h | |
| 3 | +// LiveVideoCloud | |
| 4 | +// | |
| 5 | +// Created by iOS on 17/3/30. | |
| 6 | +// Copyright © 2017年 cnlive. All rights reserved. | |
| 7 | +// | |
| 8 | + | |
| 9 | +#import <UIKit/UIKit.h> | |
| 10 | + | |
| 11 | +@class LVCRequestFailedView; | |
| 12 | +@protocol LVCRequestFailedViewDelegate <NSObject> | |
| 13 | + | |
| 14 | +- (void)reloadDataWithView:(LVCRequestFailedView *)view; | |
| 15 | + | |
| 16 | +@end | |
| 17 | + | |
| 18 | +@interface LVCRequestFailedView : UIView | |
| 19 | + | |
| 20 | +@property (nonatomic, assign) id<LVCRequestFailedViewDelegate> delegate; | |
| 21 | + | |
| 22 | +- (instancetype)initWithFrame:(CGRect)frame words:(NSString *)text; | |
| 23 | + | |
| 24 | +@end | ... | ... |
LiveVideoCloud/LiveVideoCloud/Classes/Sections/homeSections/View/LVCRequestFailedView.m
0 → 100644
| 1 | +// | |
| 2 | +// LVCRequestFailedView.m | |
| 3 | +// LiveVideoCloud | |
| 4 | +// | |
| 5 | +// Created by iOS on 17/3/30. | |
| 6 | +// Copyright © 2017年 cnlive. All rights reserved. | |
| 7 | +// | |
| 8 | + | |
| 9 | +#import "LVCRequestFailedView.h" | |
| 10 | + | |
| 11 | +@interface LVCRequestFailedView ()<UIGestureRecognizerDelegate> | |
| 12 | +{ | |
| 13 | + NSString *_text; | |
| 14 | +} | |
| 15 | + | |
| 16 | +@property (nonatomic, strong) UIImageView *imageView; | |
| 17 | +@property (nonatomic, strong) UILabel *textLab; | |
| 18 | +@property (nonatomic, strong) UITapGestureRecognizer *singleTap; //单击手势 | |
| 19 | + | |
| 20 | +@end | |
| 21 | + | |
| 22 | +@implementation LVCRequestFailedView | |
| 23 | + | |
| 24 | +- (instancetype)initWithFrame:(CGRect)frame words:(NSString *)text | |
| 25 | +{ | |
| 26 | + self = [super initWithFrame:frame]; | |
| 27 | + if (self) { | |
| 28 | + _text = text; | |
| 29 | + [self addSubview:self.imageView]; | |
| 30 | + [self addSubview:self.textLab]; | |
| 31 | + [self addGestureRecognizer:self.singleTap]; | |
| 32 | + } | |
| 33 | + return self; | |
| 34 | +} | |
| 35 | + | |
| 36 | +- (void)singleTapView | |
| 37 | +{ | |
| 38 | + self.hidden = YES; | |
| 39 | + if (self.delegate && [self.delegate respondsToSelector:@selector(reloadDataWithView:)]) { | |
| 40 | + [self.delegate reloadDataWithView:self]; | |
| 41 | + } | |
| 42 | +} | |
| 43 | + | |
| 44 | +#pragma mark - | |
| 45 | +#pragma mark - getter | |
| 46 | +- (UIImageView *)imageView | |
| 47 | +{ | |
| 48 | + if (!_imageView) { | |
| 49 | + _imageView = [[UIImageView alloc] initWithFrame:CGRectMake(self.width-(self.width*0.25)/2, self.height*0.2, self.width*0.25, self.width*0.25)]; | |
| 50 | + _imageView.image = [UIImage imageNamed:@"warn"]; | |
| 51 | + _imageView.center = self.center; | |
| 52 | + } | |
| 53 | + return _imageView; | |
| 54 | +} | |
| 55 | + | |
| 56 | +- (UILabel *)textLab | |
| 57 | +{ | |
| 58 | + if (!_textLab) { | |
| 59 | + _textLab = [[UILabel alloc] initWithFrame:CGRectMake(0, _imageView.bottom+20, self.width, 20)]; | |
| 60 | + _textLab.text = _text; | |
| 61 | + _textLab.textAlignment = NSTextAlignmentCenter; | |
| 62 | + _textLab.textColor = [UIColor lightGrayColor]; | |
| 63 | + _textLab.font = [UIFont systemFontOfSize:15]; | |
| 64 | + } | |
| 65 | + return _textLab; | |
| 66 | +} | |
| 67 | + | |
| 68 | +- (UITapGestureRecognizer *)singleTap | |
| 69 | +{ | |
| 70 | + if (!_singleTap) { | |
| 71 | + _singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(singleTapView)]; | |
| 72 | + _singleTap.delegate = self; | |
| 73 | + } | |
| 74 | + return _singleTap; | |
| 75 | +} | |
| 76 | +@end | ... | ... |
LiveVideoCloud/LiveVideoCloud/Classes/Sections/homeSections/View/LVCTelevisionView.m
| ... | ... | @@ -12,17 +12,16 @@ |
| 12 | 12 | #import "LVCOtherHeaderReusableView.h" |
| 13 | 13 | #import "LVCChannelDetailsModel.h" |
| 14 | 14 | #import "LVCChannelsModel.h" |
| 15 | -#import "LVCBannerModel.h" | |
| 16 | 15 | #import "LVCLivePlayerController.h" |
| 16 | +#import "LVCRequestFailedView.h" | |
| 17 | 17 | |
| 18 | 18 | static NSString *cellId = @"LVCLiveListCollectionViewCell"; |
| 19 | 19 | static NSString *firstHeaderId = @"LVCFirstHeaderReusableView"; |
| 20 | 20 | static NSString *otherHeaderId = @"LVCOtherHeaderReusableView"; |
| 21 | 21 | |
| 22 | -@interface LVCTelevisionView ()<UICollectionViewDelegate,UICollectionViewDataSource> | |
| 22 | +@interface LVCTelevisionView ()<UICollectionViewDelegate,UICollectionViewDataSource,LVCRequestFailedViewDelegate> | |
| 23 | 23 | { |
| 24 | 24 | long long _timestamp; |
| 25 | - NSTimer *_autoRefreshTimer; | |
| 26 | 25 | CGFloat _refreshTime; |
| 27 | 26 | NSNotification *_liveNotification; |
| 28 | 27 | BOOL _adImageHidden; //开机广告或引导页是否显示完毕 |
| ... | ... | @@ -32,9 +31,7 @@ static NSString *otherHeaderId = @"LVCOtherHeaderReusableView"; |
| 32 | 31 | @property (nonatomic, strong) NSArray *bannerModelArray; //banner数据源 |
| 33 | 32 | @property (nonatomic, strong) NSArray *marqueeModelArray; // |
| 34 | 33 | @property (nonatomic, strong) NSArray *channelsModelArray; // |
| 35 | -@property (nonatomic, strong) UIButton *reloadBtn; // 刷新按钮 | |
| 36 | -@property (nonatomic, strong) UILabel *reloadLab; // 刷新提示文字 | |
| 37 | -@property (nonatomic, strong) UIImageView *reloadImg; //刷新图片 | |
| 34 | +@property (nonatomic, strong) LVCRequestFailedView *failedView; //请求失败提示view | |
| 38 | 35 | |
| 39 | 36 | @end |
| 40 | 37 | |
| ... | ... | @@ -48,60 +45,29 @@ static NSString *otherHeaderId = @"LVCOtherHeaderReusableView"; |
| 48 | 45 | self.backgroundColor = [UIColor lightGrayColor]; |
| 49 | 46 | |
| 50 | 47 | [self loadData]; |
| 51 | - | |
| 52 | -// _timestamp = [[self timestamp] longLongValue]; | |
| 53 | -// if (_refreshTime != 0) { | |
| 54 | -// _autoRefreshTimer = [NSTimer scheduledTimerWithTimeInterval:_refreshTime target:self selector:@selector(autoRefresh) userInfo:nil repeats:YES]; | |
| 55 | -// } | |
| 56 | - | |
| 48 | + [self.collectionView addSubview:self.failedView]; | |
| 57 | 49 | [self addSubview:self.collectionView]; |
| 58 | 50 | [self.collectionView.header beginRefreshing]; |
| 59 | 51 | |
| 60 | - | |
| 61 | 52 | } |
| 62 | 53 | return self; |
| 63 | 54 | } |
| 64 | 55 | |
| 65 | 56 | #pragma mark - |
| 66 | 57 | #pragma mark - action |
| 67 | -- (void)reloadBtnAction | |
| 68 | -{ | |
| 69 | - // [self.reloadBtn removeFromSuperview]; | |
| 70 | - // [self.collectionView.header beginRefreshing]; | |
| 71 | - [self refresh]; | |
| 72 | -} | |
| 73 | - | |
| 74 | 58 | - (void)refresh |
| 75 | 59 | { |
| 76 | - [self.reloadBtn removeFromSuperview]; | |
| 77 | 60 | [self loadData]; |
| 78 | 61 | } |
| 79 | 62 | |
| 80 | -- (void)isNeedToRefresh | |
| 81 | -{ | |
| 82 | - if (_refreshTime != 0) { | |
| 83 | - [_autoRefreshTimer invalidate]; | |
| 84 | - _autoRefreshTimer = nil; | |
| 85 | - _autoRefreshTimer = [NSTimer scheduledTimerWithTimeInterval:_refreshTime target:self selector:@selector(autoRefresh) userInfo:nil repeats:YES]; | |
| 86 | - } | |
| 87 | - long long timestamp = [[self timestamp] longLongValue]; | |
| 88 | - if (timestamp-_timestamp > 180000) { | |
| 89 | - [self.collectionView.header beginRefreshing]; | |
| 90 | - } | |
| 91 | -} | |
| 92 | - | |
| 93 | -- (void)autoRefresh | |
| 63 | +#pragma mark - | |
| 64 | +#pragma mark - LVCRequestFailedViewDelegate | |
| 65 | +- (void)reloadDataWithView:(LVCRequestFailedView *)view | |
| 94 | 66 | { |
| 95 | 67 | [self.collectionView.header beginRefreshing]; |
| 96 | 68 | [self loadData]; |
| 97 | 69 | } |
| 98 | 70 | |
| 99 | -- (void)stopAutoRefresh | |
| 100 | -{ | |
| 101 | - [_autoRefreshTimer invalidate]; | |
| 102 | - _autoRefreshTimer = nil; | |
| 103 | -} | |
| 104 | - | |
| 105 | 71 | #pragma mark - |
| 106 | 72 | #pragma mark - UICollectionViewDataSource |
| 107 | 73 | - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView { |
| ... | ... | @@ -167,7 +133,7 @@ static NSString *otherHeaderId = @"LVCOtherHeaderReusableView"; |
| 167 | 133 | - (NSArray <NSURL *>*)bannerImage { |
| 168 | 134 | |
| 169 | 135 | NSMutableArray *arrayM = [NSMutableArray array]; |
| 170 | - for (LVCBannerModel *model in _bannerModelArray) { | |
| 136 | + for (LVCChannelDetailsModel *model in _bannerModelArray) { | |
| 171 | 137 | NSString *imgStr = model.img; |
| 172 | 138 | NSURL *url = [NSURL URLWithString:imgStr]; |
| 173 | 139 | [arrayM addObject:url]; |
| ... | ... | @@ -190,18 +156,20 @@ static NSString *otherHeaderId = @"LVCOtherHeaderReusableView"; |
| 190 | 156 | |
| 191 | 157 | LVCChannelsModel *model = _channelsModelArray[indexPath.section - 1]; |
| 192 | 158 | LVCChannelDetailsModel *details = model.programs[indexPath.item]; |
| 193 | - self.viewController.tabBarController.tabBar.hidden = YES; | |
| 194 | - | |
| 159 | + self.viewController.hidesBottomBarWhenPushed = YES; | |
| 195 | 160 | LVCLivePlayerController *playVC = [[LVCLivePlayerController alloc] init]; |
| 196 | 161 | playVC.model = details; |
| 197 | 162 | self.viewController.navigationController.navigationBar.hidden = YES; |
| 198 | 163 | [self.viewController.navigationController pushViewController:playVC animated:YES]; |
| 164 | + self.viewController.hidesBottomBarWhenPushed = NO; | |
| 199 | 165 | } |
| 200 | 166 | |
| 201 | 167 | #pragma mark - |
| 202 | 168 | #pragma mark - 加载数据 |
| 203 | 169 | - (void)loadData { |
| 204 | 170 | |
| 171 | + _failedView.hidden = YES; | |
| 172 | + | |
| 205 | 173 | NSDictionary *parameter = @{@"cid": @"zb/", |
| 206 | 174 | @"plat":@"i", |
| 207 | 175 | @"appid":@"spzg", |
| ... | ... | @@ -209,11 +177,6 @@ static NSString *otherHeaderId = @"LVCOtherHeaderReusableView"; |
| 209 | 177 | |
| 210 | 178 | [[AFHTTPSessionManager manager] GET:@"http://app.jczb.cnlive.com/api/appindex?appid=spzg&cid=zb%2F&plat=i&version=1" parameters:nil progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) { |
| 211 | 179 | _timestamp = [[self timestamp] longLongValue]; |
| 212 | -// if (_refreshTime != 0) { | |
| 213 | -// [_autoRefreshTimer invalidate]; | |
| 214 | -// _autoRefreshTimer = nil; | |
| 215 | -// _autoRefreshTimer = [NSTimer scheduledTimerWithTimeInterval:_refreshTime target:self selector:@selector(autoRefresh) userInfo:nil repeats:YES]; | |
| 216 | -// } | |
| 217 | 180 | |
| 218 | 181 | [self.collectionView.header endRefreshing]; |
| 219 | 182 | |
| ... | ... | @@ -230,7 +193,7 @@ static NSString *otherHeaderId = @"LVCOtherHeaderReusableView"; |
| 230 | 193 | |
| 231 | 194 | NSMutableArray *arrayM = [NSMutableArray array]; |
| 232 | 195 | for (NSDictionary *dict in responseObject[@"banner"]) { |
| 233 | - LVCBannerModel *rollModel = [LVCBannerModel mj_objectWithKeyValues:dict]; | |
| 196 | + LVCChannelDetailsModel *rollModel = [LVCChannelDetailsModel mj_objectWithKeyValues:dict]; | |
| 234 | 197 | [arrayM addObject:rollModel]; |
| 235 | 198 | } |
| 236 | 199 | self.bannerModelArray = arrayM; |
| ... | ... | @@ -241,12 +204,12 @@ static NSString *otherHeaderId = @"LVCOtherHeaderReusableView"; |
| 241 | 204 | } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) { |
| 242 | 205 | |
| 243 | 206 | [self.collectionView.header endRefreshing]; |
| 244 | - | |
| 245 | - NSLog(@"获取电视台数据失败"); | |
| 207 | + if (self.channelsModelArray.count == 0 && self.bannerModelArray.count == 0) { | |
| 208 | + _failedView.hidden = NO; | |
| 209 | + } | |
| 246 | 210 | |
| 247 | 211 | }]; |
| 248 | 212 | |
| 249 | - | |
| 250 | 213 | } |
| 251 | 214 | |
| 252 | 215 | - (NSString *)timestamp { |
| ... | ... | @@ -287,38 +250,16 @@ static NSString *otherHeaderId = @"LVCOtherHeaderReusableView"; |
| 287 | 250 | return _collectionView; |
| 288 | 251 | } |
| 289 | 252 | |
| 290 | -//- (UIButton *)reloadBtn | |
| 291 | -//{ | |
| 292 | -// if (!_reloadBtn) { | |
| 293 | -// _reloadBtn = [Tools getReloadBtn]; | |
| 294 | -// // _reloadBtn.backgroundColor = [UIColor brownColor]; | |
| 295 | -// _reloadBtn.x = (self.width-220)/2; | |
| 296 | -// _reloadBtn.y = (self.height-[Tools adapterReloadBtnHeight])/2-50; | |
| 297 | -// [_reloadBtn addTarget:self action:@selector(reloadBtnAction) forControlEvents:UIControlEventTouchUpInside]; | |
| 298 | -// [_reloadBtn addSubview:self.reloadImg]; | |
| 299 | -// [_reloadBtn addSubview:self.reloadLab]; | |
| 300 | -// } | |
| 301 | -// return _reloadBtn; | |
| 302 | -//} | |
| 303 | - | |
| 304 | -//- (UILabel *)reloadLab | |
| 305 | -//{ | |
| 306 | -// if (!_reloadLab) { | |
| 307 | -// _reloadLab = [Tools getReloadLab]; | |
| 308 | -// } | |
| 309 | -// return _reloadLab; | |
| 310 | -//} | |
| 311 | -//- (UIImageView *)reloadImg | |
| 312 | -//{ | |
| 313 | -// if (!_reloadImg) { | |
| 314 | -// _reloadImg = [[UIImageView alloc] init]; | |
| 315 | -// // _reloadImg.backgroundColor = [UIColor redColor]; | |
| 316 | -// _reloadImg.frame = CGRectMake(_reloadBtn.width/2-[Tools adapterImgWidth]/2+10, 0, [Tools adapterImgWidth], [Tools adapterImgWidth]); | |
| 317 | -// } | |
| 318 | -// return _reloadImg; | |
| 319 | -//} | |
| 320 | - | |
| 321 | - | |
| 253 | +- (LVCRequestFailedView *)failedView | |
| 254 | +{ | |
| 255 | + if (!_failedView) { | |
| 256 | + _failedView = [[LVCRequestFailedView alloc] initWithFrame:CGRectMake(0, 0, 150, 100) words:@"您的网络不太顺畅哦~"]; | |
| 257 | + _failedView.center = self.collectionView.center; | |
| 258 | + _failedView.delegate = self; | |
| 259 | + _failedView.hidden = YES; | |
| 260 | + } | |
| 261 | + return _failedView; | |
| 262 | +} | |
| 322 | 263 | |
| 323 | 264 | /* |
| 324 | 265 | // Only override drawRect: if you perform custom drawing. | ... | ... |
LiveVideoCloud/LiveVideoCloud/animation.xcassets/Interaction/22.imageset/Contents.json
LiveVideoCloud/LiveVideoCloud/animation.xcassets/Interaction/privateChat11.imageset/Contents.json
LiveVideoCloud/LiveVideoCloud/animation.xcassets/player/warn.imageset/Contents.json
0 → 100644
| 1 | +{ | |
| 2 | + "images" : [ | |
| 3 | + { | |
| 4 | + "idiom" : "universal", | |
| 5 | + "filename" : "warn.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/LiveVideoCloud/animation.xcassets/player/warn.imageset/warn.png
0 → 100644
11.3 KB