Commit f325df7970ff9dce297030b8a574d500a31ae96b

Authored by 张旭
2 parents 319a2c13 05694338

Merge branch 'master' of bj.gitlab.cnlive.com:ios-team/LiveVideoCloud

# Conflicts:
#	LiveVideoCloud/LiveVideoCloud.xcodeproj/project.pbxproj
Showing 30 changed files with 971 additions and 36 deletions
LiveVideoCloud/LiveVideoCloud.xcodeproj/project.pbxproj
... ... @@ -21,8 +21,13 @@
21 21 810B65071E779B1F00133E15 /* ViewController+MASAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 810B64FD1E779B1F00133E15 /* ViewController+MASAdditions.m */; };
22 22 810B650A1E77B39D00133E15 /* LVCFullScreenPlayerController.m in Sources */ = {isa = PBXBuildFile; fileRef = 810B65091E77B39D00133E15 /* LVCFullScreenPlayerController.m */; };
23 23 8112D4311E7927A5002E00F6 /* LVCPlayerLoadingView.m in Sources */ = {isa = PBXBuildFile; fileRef = 8112D4301E7927A5002E00F6 /* LVCPlayerLoadingView.m */; };
24   - 812E50531E7699DC004F5FCD /* CNLivePlayerSDK.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 812E50501E7699DC004F5FCD /* CNLivePlayerSDK.framework */; };
25   - 812E50581E7699E9004F5FCD /* CNLivePlayerSDK.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 812E50501E7699DC004F5FCD /* CNLivePlayerSDK.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
  24 + 811BB6801E80F858005C6291 /* LVCChatView.m in Sources */ = {isa = PBXBuildFile; fileRef = 811BB67D1E80F858005C6291 /* LVCChatView.m */; };
  25 + 811BB6831E8106A2005C6291 /* CNLivePlayerSDK.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 811BB6821E8106A2005C6291 /* CNLivePlayerSDK.framework */; };
  26 + 811BB6851E8106AF005C6291 /* CNLivePlayerSDK.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 811BB6821E8106A2005C6291 /* CNLivePlayerSDK.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
  27 + 811BB6881E8107B4005C6291 /* LVCChatViewTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 811BB6871E8107B4005C6291 /* LVCChatViewTableViewCell.m */; };
  28 + 811BB68B1E8108DB005C6291 /* LVCChatRoomModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 811BB68A1E8108DB005C6291 /* LVCChatRoomModel.m */; };
  29 + 811BB68E1E8116C8005C6291 /* NSString+StringSize.m in Sources */ = {isa = PBXBuildFile; fileRef = 811BB68D1E8116C8005C6291 /* NSString+StringSize.m */; };
  30 + 81A1B9A91E8277410079FF5F /* LVCInputView.m in Sources */ = {isa = PBXBuildFile; fileRef = 81A1B9A81E8277410079FF5F /* LVCInputView.m */; };
26 31 81FB5B3C1E7A6FFC00F98E1D /* SevenSwitch.m in Sources */ = {isa = PBXBuildFile; fileRef = 81FB5B3B1E7A6FFC00F98E1D /* SevenSwitch.m */; };
27 32 D2029B861E6EAAA50027CD92 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = D2029B851E6EAAA50027CD92 /* main.m */; };
28 33 D2029B911E6EAAA50027CD92 /* animation.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = D2029B901E6EAAA50027CD92 /* animation.xcassets */; };
... ... @@ -204,7 +209,7 @@
204 209 dstPath = "";
205 210 dstSubfolderSpec = 10;
206 211 files = (
207   - 812E50581E7699E9004F5FCD /* CNLivePlayerSDK.framework in Embed Frameworks */,
  212 + 811BB6851E8106AF005C6291 /* CNLivePlayerSDK.framework in Embed Frameworks */,
208 213 D25BF89B1E7FE046007FB138 /* CNLiveChatManager.framework in Embed Frameworks */,
209 214 D25BF89D1E7FE049007FB138 /* CNLiveMsgTools.framework in Embed Frameworks */,
210 215 );
... ... @@ -247,7 +252,17 @@
247 252 810B65091E77B39D00133E15 /* LVCFullScreenPlayerController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LVCFullScreenPlayerController.m; sourceTree = "<group>"; };
248 253 8112D42F1E7927A5002E00F6 /* LVCPlayerLoadingView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LVCPlayerLoadingView.h; sourceTree = "<group>"; };
249 254 8112D4301E7927A5002E00F6 /* LVCPlayerLoadingView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LVCPlayerLoadingView.m; sourceTree = "<group>"; };
250   - 812E50501E7699DC004F5FCD /* CNLivePlayerSDK.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = CNLivePlayerSDK.framework; sourceTree = "<group>"; };
  255 + 811BB67C1E80F858005C6291 /* LVCChatView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LVCChatView.h; sourceTree = "<group>"; };
  256 + 811BB67D1E80F858005C6291 /* LVCChatView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LVCChatView.m; sourceTree = "<group>"; };
  257 + 811BB6821E8106A2005C6291 /* CNLivePlayerSDK.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = CNLivePlayerSDK.framework; sourceTree = "<group>"; };
  258 + 811BB6861E8107B4005C6291 /* LVCChatViewTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LVCChatViewTableViewCell.h; sourceTree = "<group>"; };
  259 + 811BB6871E8107B4005C6291 /* LVCChatViewTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LVCChatViewTableViewCell.m; sourceTree = "<group>"; };
  260 + 811BB6891E8108DB005C6291 /* LVCChatRoomModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LVCChatRoomModel.h; path = LiveVideoCloud/Classes/Sections/homeSections/ChatView/LVCChatRoomModel.h; sourceTree = SOURCE_ROOT; };
  261 + 811BB68A1E8108DB005C6291 /* LVCChatRoomModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = LVCChatRoomModel.m; path = LiveVideoCloud/Classes/Sections/homeSections/ChatView/LVCChatRoomModel.m; sourceTree = SOURCE_ROOT; };
  262 + 811BB68C1E8116C8005C6291 /* NSString+StringSize.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+StringSize.h"; sourceTree = "<group>"; };
  263 + 811BB68D1E8116C8005C6291 /* NSString+StringSize.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+StringSize.m"; sourceTree = "<group>"; };
  264 + 81A1B9A71E8277410079FF5F /* LVCInputView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LVCInputView.h; sourceTree = "<group>"; };
  265 + 81A1B9A81E8277410079FF5F /* LVCInputView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LVCInputView.m; sourceTree = "<group>"; };
251 266 81FB5B3A1E7A6FFC00F98E1D /* SevenSwitch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SevenSwitch.h; sourceTree = "<group>"; };
252 267 81FB5B3B1E7A6FFC00F98E1D /* SevenSwitch.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SevenSwitch.m; sourceTree = "<group>"; };
253 268 D2029B811E6EAAA50027CD92 /* LiveVideoCloud.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = LiveVideoCloud.app; sourceTree = BUILT_PRODUCTS_DIR; };
... ... @@ -568,11 +583,11 @@
568 583 files = (
569 584 D25BF8A31E80C4FC007FB138 /* Accelerate.framework in Frameworks */,
570 585 D2575C7D1E76A4F300E3A8FC /* NHGiftAnimtionSDK.a in Frameworks */,
571   - 812E50531E7699DC004F5FCD /* CNLivePlayerSDK.framework in Frameworks */,
572 586 D25BF89A1E7FE046007FB138 /* CNLiveChatManager.framework in Frameworks */,
573 587 D25BF8971E7FE01B007FB138 /* CNLiveMsgTools.framework in Frameworks */,
574 588 D25BF8991E7FE033007FB138 /* CNLiveChatManager.framework in Frameworks */,
575 589 D25BF89C1E7FE049007FB138 /* CNLiveMsgTools.framework in Frameworks */,
  590 + 811BB6831E8106A2005C6291 /* CNLivePlayerSDK.framework in Frameworks */,
576 591 );
577 592 runOnlyForDeploymentPostprocessing = 0;
578 593 };
... ... @@ -625,13 +640,35 @@
625 640 path = Masonry;
626 641 sourceTree = "<group>";
627 642 };
  643 + 811BB67B1E80F858005C6291 /* ChatView */ = {
  644 + isa = PBXGroup;
  645 + children = (
  646 + 811BB67C1E80F858005C6291 /* LVCChatView.h */,
  647 + 811BB67D1E80F858005C6291 /* LVCChatView.m */,
  648 + 81A1B9A71E8277410079FF5F /* LVCInputView.h */,
  649 + 81A1B9A81E8277410079FF5F /* LVCInputView.m */,
  650 + 811BB6861E8107B4005C6291 /* LVCChatViewTableViewCell.h */,
  651 + 811BB6871E8107B4005C6291 /* LVCChatViewTableViewCell.m */,
  652 + );
  653 + name = ChatView;
  654 + path = ../ChatView;
  655 + sourceTree = "<group>";
  656 + };
  657 + 812E504D1E769995004F5FCD /* CNLiveSDK */ = {
  658 + isa = PBXGroup;
  659 + children = (
  660 + );
  661 + name = CNLiveSDK;
  662 + path = LiveVideoCloud/Classes/CNLiveSDK;
  663 + sourceTree = SOURCE_ROOT;
  664 + };
628 665 812E504E1E7699B9004F5FCD /* CNLiveSDK */ = {
629 666 isa = PBXGroup;
630 667 children = (
  668 + 811BB6821E8106A2005C6291 /* CNLivePlayerSDK.framework */,
631 669 D25BF8981E7FE033007FB138 /* CNLiveChatManager.framework */,
632 670 D25BF8961E7FE01B007FB138 /* CNLiveMsgTools.framework */,
633 671 D25BF87C1E7B8C78007FB138 /* KSYGPUResource.bundle */,
634   - 812E50501E7699DC004F5FCD /* CNLivePlayerSDK.framework */,
635 672 );
636 673 path = CNLiveSDK;
637 674 sourceTree = "<group>";
... ... @@ -1146,6 +1183,8 @@
1146 1183 children = (
1147 1184 D24571561E8393EB00AA85D6 /* UIImageView+ZXExtension.h */,
1148 1185 D24571571E8393EB00AA85D6 /* UIImageView+ZXExtension.m */,
  1186 + 811BB68C1E8116C8005C6291 /* NSString+StringSize.h */,
  1187 + 811BB68D1E8116C8005C6291 /* NSString+StringSize.m */,
1149 1188 D2029CDE1E6EAE2E0027CD92 /* NSNumber+ScaleHeight.h */,
1150 1189 D2029CDF1E6EAE2E0027CD92 /* NSNumber+ScaleHeight.m */,
1151 1190 D2029CE01E6EAE2E0027CD92 /* UIColor+HexString.h */,
... ... @@ -1527,6 +1566,8 @@
1527 1566 D2888DA91E6EC014003A77C8 /* Model */ = {
1528 1567 isa = PBXGroup;
1529 1568 children = (
  1569 + 811BB6891E8108DB005C6291 /* LVCChatRoomModel.h */,
  1570 + 811BB68A1E8108DB005C6291 /* LVCChatRoomModel.m */,
1530 1571 );
1531 1572 path = Model;
1532 1573 sourceTree = "<group>";
... ... @@ -1534,6 +1575,7 @@
1534 1575 D2888DAA1E6EC014003A77C8 /* View */ = {
1535 1576 isa = PBXGroup;
1536 1577 children = (
  1578 + 811BB67B1E80F858005C6291 /* ChatView */,
1537 1579 810B64DE1E779AE900133E15 /* LVCPlayer.h */,
1538 1580 810B64DF1E779AE900133E15 /* LVCPlayer.m */,
1539 1581 8112D42F1E7927A5002E00F6 /* LVCPlayerLoadingView.h */,
... ... @@ -1810,11 +1852,13 @@
1810 1852 D2029CB61E6EADE10027CD92 /* MKAnnotationView+WebCache.m in Sources */,
1811 1853 810B64FE1E779B1F00133E15 /* MASCompositeConstraint.m in Sources */,
1812 1854 D2029C981E6EADE10027CD92 /* MJExtensionConst.m in Sources */,
  1855 + 811BB68B1E8108DB005C6291 /* LVCChatRoomModel.m in Sources */,
1813 1856 D2575C671E76A25400E3A8FC /* LVCInteractionController.m in Sources */,
1814 1857 D2029CAE1E6EADE10027CD92 /* MJRefreshNormalHeader.m in Sources */,
1815 1858 D23696921E7FC83800E4BF71 /* chatMsgModel.m in Sources */,
1816 1859 D2029C901E6EADE10027CD92 /* UIActivityIndicatorView+AFNetworking.m in Sources */,
1817 1860 D2029CC61E6EADE10027CD92 /* SSKeychain.m in Sources */,
  1861 + 811BB68E1E8116C8005C6291 /* NSString+StringSize.m in Sources */,
1818 1862 D2029C8B1E6EADE10027CD92 /* AFURLResponseSerialization.m in Sources */,
1819 1863 D2029C921E6EADE10027CD92 /* UIImageView+AFNetworking.m in Sources */,
1820 1864 D224B1971E826ED800CC61D0 /* ChatBarrageAnimAction.m in Sources */,
... ... @@ -1869,6 +1913,8 @@
1869 1913 810B650A1E77B39D00133E15 /* LVCFullScreenPlayerController.m in Sources */,
1870 1914 D217A24E1E7B77C7003B44CB /* ComboCell.m in Sources */,
1871 1915 D2029CBD1E6EADE10027CD92 /* SDWebImageManager.m in Sources */,
  1916 + 811BB6881E8107B4005C6291 /* LVCChatViewTableViewCell.m in Sources */,
  1917 + 811BB6801E80F858005C6291 /* LVCChatView.m in Sources */,
1872 1918 D2029CB41E6EADE10027CD92 /* UIView+MJExtension.m in Sources */,
1873 1919 81FB5B3C1E7A6FFC00F98E1D /* SevenSwitch.m in Sources */,
1874 1920 D2029CA91E6EADE10027CD92 /* MJRefreshAutoStateFooter.m in Sources */,
... ... @@ -1885,6 +1931,7 @@
1885 1931 D2888DB41E6EC154003A77C8 /* HomeViewController.m in Sources */,
1886 1932 D2B7B2541E824B2D00ED084E /* ChatBarrageView.m in Sources */,
1887 1933 D25530061E7911A800DF38A5 /* GiftAnimationAction.m in Sources */,
  1934 + 81A1B9A91E8277410079FF5F /* LVCInputView.m in Sources */,
1888 1935 D2029CD41E6EADE70027CD92 /* HttpService.m in Sources */,
1889 1936 );
1890 1937 runOnlyForDeploymentPostprocessing = 0;
... ...
LiveVideoCloud/LiveVideoCloud/AppDelegate/AppDelegate.m
... ... @@ -8,6 +8,7 @@
8 8  
9 9 #import "AppDelegate.h"
10 10 #import "ZXTabBarController.h"
  11 +
11 12 @interface AppDelegate ()
12 13  
13 14 @end
... ... @@ -20,6 +21,18 @@
20 21  
21 22 self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
22 23 self.window.rootViewController = [[ZXTabBarController alloc] init];
  24 +
  25 + //初始化直播SDK
  26 + [[CNLiveWebcastManager manager] initWithAppId:AppId appKey:AppKey];
  27 +
  28 + //初始化聊天SDK并连接服务器
  29 + [[CNLiveChatManager sharedCNLiveChatManager] initWithAppKey:AppKey appId:AppId];
  30 + [[CNLiveChatManager sharedCNLiveChatManager] connectServerSuccess:^{
  31 + NSLog(@"连接服务器-----success");
  32 + } error:^(CNLiveChatConnectErrorCode errors) {
  33 + NSLog(@"连接服务器失败-----%ld", errors);
  34 + }];;
  35 +
23 36 [self.window makeKeyAndVisible];
24 37  
25 38 [[CNLiveChatManager sharedCNLiveChatManager] initWithAppKey:AppKey appId:AppId];
... ...
LiveVideoCloud/LiveVideoCloud/Classes/CNLiveSDK/CNLivePlayerSDK.framework/CNLivePlayerSDK
No preview for this file type
LiveVideoCloud/LiveVideoCloud/Classes/CNLiveSDK/CNLivePlayerSDK.framework/Info.plist
No preview for this file type
LiveVideoCloud/LiveVideoCloud/Classes/Sections/homeSections/ChatView/LVCChatRoomModel.h 0 → 100644
  1 +//
  2 +// LVCChatRoomModel.h
  3 +// LiveVideoCloud
  4 +//
  5 +// Created by iOS on 17/3/21.
  6 +// Copyright © 2017年 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import <Foundation/Foundation.h>
  10 +
  11 +@interface LVCChatRoomModel : NSObject
  12 +
  13 +@property (nonatomic, strong) NSString *iconURL;
  14 +@property (nonatomic, strong) NSString *nikeName;
  15 +@property (nonatomic, strong) NSString *message;
  16 +@property (nonatomic, assign) BOOL isReceive;
  17 +
  18 +@end
... ...
LiveVideoCloud/LiveVideoCloud/Classes/Sections/homeSections/ChatView/LVCChatRoomModel.m 0 → 100644
  1 +//
  2 +// LVCChatRoomModel.m
  3 +// LiveVideoCloud
  4 +//
  5 +// Created by iOS on 17/3/21.
  6 +// Copyright © 2017年 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import "LVCChatRoomModel.h"
  10 +
  11 +@implementation LVCChatRoomModel
  12 +
  13 +
  14 +@end
... ...
LiveVideoCloud/LiveVideoCloud/Classes/Sections/homeSections/ChatView/LVCChatView.h 0 → 100644
  1 +//
  2 +// LVCChatView.h
  3 +// LiveVideoCloud
  4 +//
  5 +// Created by iOS on 17/3/21.
  6 +// Copyright © 2017年 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import <UIKit/UIKit.h>
  10 +
  11 +@interface LVCChatView : UIView
  12 +
  13 +- (instancetype)initWithFrame:(CGRect)frame roomId:(NSString *)roomId;
  14 +
  15 +@end
... ...
LiveVideoCloud/LiveVideoCloud/Classes/Sections/homeSections/ChatView/LVCChatView.m 0 → 100644
  1 +//
  2 +// LVCChatView.m
  3 +// LiveVideoCloud
  4 +//
  5 +// Created by iOS on 17/3/21.
  6 +// Copyright © 2017年 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import "LVCChatView.h"
  10 +#import "LVCChatViewTableViewCell.h"
  11 +#import "LVCChatRoomModel.h"
  12 +#import "UILabel+ContentSize.h"
  13 +#import "NSString+StringSize.h"
  14 +
  15 +@interface LVCChatView ()<CNLiveChatManagerDelegate,UITableViewDelegate,UITableViewDataSource>
  16 +{
  17 + NSString *_roomId;
  18 + NSMutableArray *_chatDataArr;
  19 +}
  20 +
  21 +@property (nonatomic, strong) UITableView *tableView;
  22 +@property (nonatomic, strong) UILabel *chatLab;
  23 +@property (nonatomic, strong) NSMutableArray *messageHeight;
  24 +
  25 +@end
  26 +
  27 +@implementation LVCChatView
  28 +
  29 +- (instancetype)initWithFrame:(CGRect)frame roomId:(NSString *)roomId
  30 +{
  31 + self = [super initWithFrame:frame];
  32 + if (self) {
  33 +
  34 + self.backgroundColor = [UIColor whiteColor];
  35 + _chatDataArr = [NSMutableArray new];
  36 + _messageHeight = [NSMutableArray new];
  37 + [self addData];
  38 +
  39 + [self addSubview:self.tableView];
  40 + [self addSubview:self.chatLab];
  41 +
  42 + [self joinChatRoomWithRoomId:roomId];
  43 + }
  44 + return self;
  45 +}
  46 +
  47 +- (void)addData
  48 +{
  49 + for (int i = 0; i < 8; i ++) {
  50 + LVCChatRoomModel *model = [[LVCChatRoomModel alloc] init];
  51 + model.nikeName = @"zzllzz";
  52 + model.isReceive = NO;
  53 + model.message = @"我有一只😁啦啡哦我";
  54 + [_chatDataArr addObject:model];
  55 + [self cellMessageLabelHeightWithModel:model];
  56 + }
  57 +
  58 + [_tableView reloadData];
  59 +}
  60 +
  61 +- (void)joinChatRoomWithRoomId:(NSString *)roomId
  62 +{
  63 + [[CNLiveChatManager sharedCNLiveChatManager] joinExistChatRoom:roomId messageCount:10 success:^(NSString *targetId) {
  64 + NSLog(@"电视台--加入聊天室---success-%@",targetId);
  65 + } error:^(CNLiveChatErrorCode errors, NSString *targetId) {
  66 + NSLog(@"电视台--加入聊天室---failed -%ld",(long)errors);
  67 + }];
  68 +
  69 + [CNLiveChatManager sharedCNLiveChatManager].delegate = self;
  70 +}
  71 +
  72 +//发送消息
  73 +- (void)sendMsgWithMessage:(NSString *)message
  74 +{
  75 + [[CNLiveChatManager sharedCNLiveChatManager] sendMessage:message type:CNLive_ConversationType_CHATROOM targetId:_roomId success:^(CNLiveChatMessage *message) {
  76 +
  77 + NSLog(@"电视台--发送消息---success-%@",message);
  78 +
  79 + } error:^(CNLiveChatErrorCode errors, NSString *messageId, NSString *targetId) {
  80 + NSLog(@"电视台--发送消息---failed-%ld",(long)errors);
  81 + }];
  82 +}
  83 +
  84 +//退出聊天室
  85 +- (void)quit
  86 +{
  87 + [[CNLiveChatManager sharedCNLiveChatManager] quitChatRoom:_roomId success:^(NSString *targetId) {
  88 + NSLog(@"电视台--退出聊天室---success-%@",targetId);
  89 + } error:^(CNLiveChatErrorCode errors, NSString *targetId) {
  90 + NSLog(@"电视台--退出聊天室---success-%ld",(long)errors);
  91 + }];
  92 +}
  93 +
  94 +#pragma mark -
  95 +#pragma mark - CNLiveChatManagerDelegate
  96 +- (void)onReceived:(CNLiveChatMessage *)message
  97 +{
  98 + //接收消息
  99 +}
  100 +
  101 +#pragma mark -
  102 +#pragma mark - UITableView
  103 +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  104 +{
  105 + return _chatDataArr.count;
  106 +}
  107 +
  108 +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  109 +{
  110 + static NSString *cellID = @"cellID";
  111 + LVCChatViewTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
  112 + if (!cell) {
  113 + cell = [[LVCChatViewTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
  114 + }
  115 +
  116 + LVCChatRoomModel *model = _chatDataArr[indexPath.row];
  117 + cell.model = model;
  118 +
  119 + return cell;
  120 +}
  121 +
  122 +- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
  123 +{
  124 + LVCChatRoomModel *model = [_chatDataArr objectAtIndex:indexPath.row];
  125 +
  126 + return [LVCChatViewTableViewCell getCellHeight:model filterName:model.nikeName height:[_messageHeight objectAtIndex:indexPath.row]];
  127 +}
  128 +
  129 +- (void)cellMessageLabelHeightWithModel:(LVCChatRoomModel *)model {
  130 +
  131 + UILabel *messageLabel = [[UILabel alloc]init];
  132 + messageLabel.text = model.message;
  133 +
  134 + messageLabel.width = [messageLabel contentWidth].width;
  135 +
  136 + if ((SCREEN_WIDTH - messageLabel.width - 85) < 0) { // 多行
  137 + CGSize statusLabelSize = [messageLabel.text sizeWithLabelWidth:SCREEN_WIDTH - 85 font:[UIFont systemFontOfSize:14]];
  138 + [_messageHeight addObject:@(statusLabelSize.height)];
  139 + } else { // 单行
  140 + CGSize statusLabelSize = [messageLabel.text sizeWithLabelWidth:messageLabel.width font:[UIFont systemFontOfSize:14]];
  141 + [_messageHeight addObject:@(statusLabelSize.height)];
  142 + }
  143 +}
  144 +
  145 +#pragma mark -
  146 +#pragma mark - gatter
  147 +- (UITableView *)tableView
  148 +{
  149 + if (!_tableView) {
  150 + _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 40, SCREEN_WIDTH, self.height-40) style:UITableViewStylePlain];
  151 + _tableView.delegate = self;
  152 + _tableView.dataSource = self;
  153 + _tableView.backgroundColor = [UIColor blackColorZX];
  154 + _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  155 + _tableView.allowsSelection = NO;
  156 + _tableView.showsVerticalScrollIndicator = NO;
  157 + _tableView.showsHorizontalScrollIndicator = NO;
  158 + }
  159 + return _tableView;
  160 +}
  161 +
  162 +- (UILabel *)chatLab
  163 +{
  164 + if (!_chatLab) {
  165 + _chatLab = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 40)];
  166 + _chatLab.text = @"聊一聊";
  167 + _chatLab.backgroundColor = [UIColor blackColorZX];
  168 + _chatLab.textColor = [UIColor whiteColor];
  169 + _chatLab.textAlignment = NSTextAlignmentCenter;
  170 + }
  171 + return _chatLab;
  172 +}
  173 +
  174 +@end
... ...
LiveVideoCloud/LiveVideoCloud/Classes/Sections/homeSections/ChatView/LVCChatViewTableViewCell.h 0 → 100644
  1 +//
  2 +// LVCChatViewTableViewCell.h
  3 +// LiveVideoCloud
  4 +//
  5 +// Created by iOS on 17/3/21.
  6 +// Copyright © 2017年 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import <UIKit/UIKit.h>
  10 +#import "LVCChatRoomModel.h"
  11 +
  12 +@interface LVCChatViewTableViewCell : UITableViewCell
  13 +
  14 +@property (nonatomic, strong) LVCChatRoomModel *model; //聊天室model
  15 +
  16 ++ (CGFloat)getCellHeight:(LVCChatRoomModel *)message filterName:(NSString *)filterName height:(NSNumber *)height;
  17 +
  18 +
  19 +@end
... ...
LiveVideoCloud/LiveVideoCloud/Classes/Sections/homeSections/ChatView/LVCChatViewTableViewCell.m 0 → 100644
  1 +//
  2 +// LVCChatViewTableViewCell.m
  3 +// LiveVideoCloud
  4 +//
  5 +// Created by iOS on 17/3/21.
  6 +// Copyright © 2017年 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import "LVCChatViewTableViewCell.h"
  10 +#import "UILabel+ContentSize.h"
  11 +#import "NSString+StringSize.h"
  12 +
  13 +#define HEAD_SIZE 35.0f
  14 +
  15 +@interface LVCChatViewTableViewCell ()
  16 +
  17 +@property (nonatomic, strong) UIImageView *iconImageView; //头像
  18 +@property (nonatomic, strong) UILabel *nickNameLab; //昵称
  19 +@property (nonatomic, strong) UILabel *messageLab; //消息
  20 +@property (nonatomic, strong) UILabel *lineLab; //分割线
  21 +@property (nonatomic, strong) UIImageView *bgImageView; //背景
  22 +
  23 +@end
  24 +
  25 +@implementation LVCChatViewTableViewCell
  26 +
  27 +- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
  28 +{
  29 + self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  30 + if (self) {
  31 +
  32 + self.contentView.backgroundColor = [UIColor blackColorZX];
  33 + [self setSelectionStyle:UITableViewCellSelectionStyleNone];
  34 +
  35 + [self.contentView addSubview:self.iconImageView];
  36 + [self.contentView addSubview:self.bgImageView];
  37 + [self.bgImageView addSubview:self.nickNameLab];
  38 + [self.bgImageView addSubview:self.messageLab];
  39 + [self.bgImageView addSubview:self.lineLab];
  40 +
  41 + }
  42 + return self;
  43 +}
  44 +
  45 +- (void)setModel:(LVCChatRoomModel *)model
  46 +{
  47 + if (!model || ![model isKindOfClass:[LVCChatRoomModel class]]) {
  48 + return;
  49 + }
  50 +
  51 + _model = model;
  52 +
  53 + self.messageLab.text = model.message;
  54 + self.nickNameLab.text = model.nikeName;
  55 + if (model.isReceive) { //收到的消息
  56 +
  57 + UIImage *bgImage = [UIImage imageNamed:@"Gift box"];
  58 + bgImage = [bgImage stretchableImageWithLeftCapWidth:0 topCapHeight:50];
  59 + self.bgImageView.image = bgImage;
  60 +
  61 + self.nickNameLab.hidden = NO;
  62 + self.lineLab.hidden = NO;
  63 + self.iconImageView.frame = CGRectMake(10,10,HEAD_SIZE,HEAD_SIZE);
  64 + self.nickNameLab.frame = CGRectMake(13,2.5,200,20);
  65 +
  66 + self.messageLab.width = [self.messageLab contentWidth].width;
  67 +
  68 + //多行
  69 + if ((SCREEN_WIDTH - self.messageLab.width - 85) < 0) {
  70 + CGSize statusLabelSize = [self.messageLab.text sizeWithLabelWidth:SCREEN_WIDTH - 85 font:[UIFont systemFontOfSize:14]];
  71 + self.bgImageView.frame = CGRectMake(60, 7.5, SCREEN_WIDTH - 70, statusLabelSize.height + 35);
  72 + self.messageLab.frame = CGRectMake(13, 27.5, SCREEN_WIDTH - 80, statusLabelSize.height);
  73 + self.lineLab.width = self.bgImageView.width - 20;
  74 +
  75 + } else { //单行
  76 +
  77 + CGSize statusLabelSize = [self.messageLab.text sizeWithLabelWidth:self.messageLab.width font:[UIFont systemFontOfSize:14]];
  78 +
  79 + self.nickNameLab.width = [self.nickNameLab contentWidth].width;
  80 + if (self.nickNameLab.width > self.messageLab.width) {
  81 + self.bgImageView.frame = CGRectMake(60, 7.5, self.nickNameLab.width + 20, statusLabelSize.height + 35);
  82 + self.lineLab.width = self.nickNameLab.width + 5;
  83 + } else {
  84 + self.bgImageView.frame = CGRectMake(60, 7.5, self.messageLab.width + 20, statusLabelSize.height + 35);
  85 + self.lineLab.width = self.messageLab.width + 5;
  86 + }
  87 + self.messageLab.frame = CGRectMake(13, 27.5, self.messageLab.width, statusLabelSize.height);
  88 + }
  89 +
  90 +
  91 + } else { //我的消息
  92 +
  93 + UIImage *bgImage = [UIImage imageNamed:@"Gift box right"];
  94 + bgImage = [bgImage stretchableImageWithLeftCapWidth:10 topCapHeight:27];
  95 + self.bgImageView.image = bgImage;
  96 + self.nickNameLab.hidden = YES;
  97 + self.lineLab.hidden = YES;
  98 + self.iconImageView.frame = CGRectMake(SCREEN_WIDTH - 50,6,40,40);
  99 +
  100 + self.messageLab.width = [self.messageLab contentWidth].width;
  101 +
  102 + if ((SCREEN_WIDTH - self.messageLab.width - 85) < 0) { // 多行
  103 + CGSize statusLabelSize = [self.messageLab.text sizeWithLabelWidth:SCREEN_WIDTH - 85 font:[UIFont systemFontOfSize:14]];
  104 +
  105 + self.bgImageView.frame = CGRectMake(10, 7.5, SCREEN_WIDTH - 65, statusLabelSize.height + 20);
  106 +
  107 + self.messageLab.frame = CGRectMake(10, 10, SCREEN_WIDTH - 85, statusLabelSize.height);
  108 +
  109 + } else { // 单行
  110 + CGSize statusLabelSize = [self.messageLab.text sizeWithLabelWidth:self.messageLab.width font:[UIFont systemFontOfSize:14]];
  111 + self.bgImageView.frame = CGRectMake(SCREEN_WIDTH - self.messageLab.width - 75, 7.5, self.messageLab.width + 20, statusLabelSize.height + 20);
  112 + self.messageLab.frame = CGRectMake(8, 10, self.messageLab.width, statusLabelSize.height);
  113 + }
  114 +
  115 +
  116 + }
  117 +}
  118 +
  119 +#pragma mark - action
  120 ++ (CGFloat)getCellHeight:(LVCChatRoomModel *)message filterName:(NSString *)filterName height:(NSNumber *)height
  121 +{
  122 + if (!message) {
  123 + return 0;
  124 + }
  125 +
  126 + CGFloat height1 = [height floatValue];
  127 +
  128 + if ([message.nikeName isEqualToString:filterName]) {
  129 + return height1 + 20 + 15;
  130 + } else {
  131 + return height1 + 20 + 15 + 40;
  132 + }
  133 +}
  134 +
  135 +
  136 +#pragma mark -
  137 +#pragma mark - getter
  138 +- (UIImageView *)iconImageView
  139 +{
  140 + if (!_iconImageView) {
  141 + _iconImageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 5, HEAD_SIZE, HEAD_SIZE)];
  142 + _iconImageView.image = [UIImage imageNamed:@"touxiang"];
  143 + }
  144 + return _iconImageView;
  145 +}
  146 +
  147 +- (UIImageView *)bgImageView
  148 +{
  149 + if (!_bgImageView) {
  150 + _bgImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 0, 0)];
  151 + }
  152 + return _bgImageView;
  153 +}
  154 +
  155 +- (UILabel *)lineLab
  156 +{
  157 + if (!_lineLab) {
  158 + _lineLab = [[UILabel alloc] initWithFrame:CGRectMake(10, 23.5, 80, 0.5)];
  159 + _lineLab.backgroundColor = [UIColor colorWithHexString:@"#5a5b5b"];
  160 + }
  161 + return _lineLab;
  162 +}
  163 +
  164 +- (UILabel *)nickNameLab
  165 +{
  166 + if (!_nickNameLab) {
  167 + _nickNameLab = [[UILabel alloc] initWithFrame:CGRectMake(13,2.5,200,20)];
  168 + _nickNameLab.font = [UIFont systemFontOfSize:10];
  169 + _nickNameLab.textColor = [UIColor colorWithHexString:@"#5a5b5b"];
  170 + _nickNameLab.text = @"zzll";
  171 + }
  172 + return _nickNameLab;
  173 +}
  174 +
  175 +- (UILabel *)messageLab
  176 +{
  177 + if (!_messageLab) {
  178 + _messageLab = [[UILabel alloc] initWithFrame:CGRectMake(10, 25, SCREEN_WIDTH - 85, 30)];
  179 + _messageLab.textColor = [UIColor whiteColor];
  180 + _messageLab.font = [UIFont systemFontOfSize:14];
  181 + _messageLab.text = @"哈哈哈哈";
  182 + _messageLab.numberOfLines = 0;
  183 + }
  184 + return _messageLab;
  185 +}
  186 +
  187 +
  188 +- (void)awakeFromNib {
  189 + [super awakeFromNib];
  190 + // Initialization code
  191 +}
  192 +
  193 +- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  194 + [super setSelected:selected animated:animated];
  195 +
  196 + // Configure the view for the selected state
  197 +}
  198 +
  199 +@end
... ...
LiveVideoCloud/LiveVideoCloud/Classes/Sections/homeSections/ChatView/LVCInputView.h 0 → 100644
  1 +//
  2 +// LVCInputView.h
  3 +// LiveVideoCloud
  4 +//
  5 +// Created by iOS on 17/3/22.
  6 +// Copyright © 2017年 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import <UIKit/UIKit.h>
  10 +
  11 +@class LVCInputView;
  12 +@protocol LVCInputViewDelegate <NSObject>
  13 +
  14 +- (void)lvcInputView:(LVCInputView *)inputView sendMessage:(NSString *)message;
  15 +
  16 +@end
  17 +
  18 +@interface LVCInputView : UIView
  19 +
  20 +@property (nonatomic, assign) id<LVCInputViewDelegate> delegate;
  21 +
  22 +@end
... ...
LiveVideoCloud/LiveVideoCloud/Classes/Sections/homeSections/ChatView/LVCInputView.m 0 → 100644
  1 +//
  2 +// LVCInputView.m
  3 +// LiveVideoCloud
  4 +//
  5 +// Created by iOS on 17/3/22.
  6 +// Copyright © 2017年 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import "LVCInputView.h"
  10 +
  11 +#define RGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16)) / 255.0 green:((float)((rgbValue & 0xFF00) >> 8)) / 255.0 blue:((float)(rgbValue & 0xFF)) / 255.0 alpha:1.0]
  12 +
  13 +@interface LVCInputView ()<UITextFieldDelegate>
  14 +
  15 +@property (nonatomic, strong) UITextField *inputTextField;
  16 +@property (nonatomic, strong) UIButton *sendBtn;
  17 +@end
  18 +
  19 +@implementation LVCInputView
  20 +
  21 +- (instancetype)initWithFrame:(CGRect)frame
  22 +{
  23 + self = [super initWithFrame:frame];
  24 + if (self) {
  25 +
  26 + self.backgroundColor = RGB(0xf6f6f6);
  27 +
  28 + [self addSubview:self.inputTextField];
  29 + [self addSubview:self.sendBtn];
  30 +
  31 + [self setUI];
  32 + }
  33 + return self;
  34 +}
  35 +
  36 +#pragma mark -
  37 +#pragma mark - action
  38 +- (void)sendBtnClick:(UIButton *)btn
  39 +{
  40 + NSString *temp = [_inputTextField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
  41 +
  42 + if (temp.length > 0) {
  43 +
  44 + if (self.delegate && [self.delegate respondsToSelector:@selector(lvcInputView:sendMessage:)]) {
  45 + [self.delegate lvcInputView:self sendMessage:_inputTextField.text];
  46 + }
  47 +
  48 + [self endEditing:YES];
  49 + _inputTextField.text = @"";
  50 +
  51 + }
  52 +
  53 +}
  54 +
  55 +#pragma mark -
  56 +#pragma mark - UITextFieldDelegate
  57 +- (BOOL)textFieldShouldReturn:(UITextField *)textField
  58 +{
  59 + NSString *temp = [textField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
  60 +
  61 + if (temp.length > 0) {
  62 +
  63 + if (self.delegate && [self.delegate respondsToSelector:@selector(lvcInputView:sendMessage:)]) {
  64 + [self.delegate lvcInputView:self sendMessage:_inputTextField.text];
  65 + }
  66 +
  67 + [self endEditing:YES];
  68 + textField.text = @"";
  69 + return YES;
  70 + }
  71 +
  72 + return NO;
  73 +}
  74 +
  75 +- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
  76 +{
  77 + return YES;
  78 +
  79 +}
  80 +
  81 +#pragma mark -
  82 +#pragma mark - makeConstraints
  83 +- (void)setUI
  84 +{
  85 + [self.inputTextField mas_makeConstraints:^(MASConstraintMaker *make) {
  86 + make.top.mas_equalTo(6);
  87 + make.left.mas_offset(10);
  88 + make.bottom.equalTo(self.mas_bottom).offset(-6);
  89 + make.right.equalTo(self).offset(-50);
  90 + }];
  91 +
  92 + [self.sendBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  93 + make.left.equalTo(self.inputTextField.mas_right).offset(10);
  94 + make.centerY.equalTo(self.mas_centerY);
  95 + make.width.height.mas_equalTo(30);
  96 + }];
  97 +}
  98 +
  99 +#pragma mark -
  100 +#pragma mark - getter
  101 +- (UITextField *)inputTextField
  102 +{
  103 + if (!_inputTextField) {
  104 + _inputTextField = [[UITextField alloc] init];
  105 + _inputTextField.returnKeyType = UIReturnKeySend;
  106 + _inputTextField.borderStyle = UITextBorderStyleRoundedRect;
  107 + _inputTextField.font = [UIFont systemFontOfSize:16];
  108 + _inputTextField.placeholder = @"说点什么吧..";
  109 + _inputTextField.delegate = self;
  110 + }
  111 + return _inputTextField;
  112 +}
  113 +
  114 +- (UIButton *)sendBtn {
  115 + if (_sendBtn == nil) {
  116 + _sendBtn = [[UIButton alloc]init];
  117 + _sendBtn.titleLabel.textColor = RGB(0x666666);
  118 + _sendBtn.titleLabel.font = [UIFont systemFontOfSize:14];
  119 + [_sendBtn setImage:[UIImage imageNamed:@"send"] forState:UIControlStateNormal];
  120 + [_sendBtn addTarget:self action:@selector(sendBtnClick:) forControlEvents:UIControlEventTouchUpInside];
  121 + }
  122 + return _sendBtn;
  123 +}
  124 +
  125 +/*
  126 +// Only override drawRect: if you perform custom drawing.
  127 +// An empty implementation adversely affects performance during animation.
  128 +- (void)drawRect:(CGRect)rect {
  129 + // Drawing code
  130 +}
  131 +*/
  132 +
  133 +@end
... ...
LiveVideoCloud/LiveVideoCloud/Classes/Sections/homeSections/Controller/LVCFullScreenPlayerController.m
... ... @@ -33,7 +33,11 @@
33 33 - (void)viewDidLoad {
34 34 [super viewDidLoad];
35 35 self.view.backgroundColor = [UIColor blackColor];
  36 +}
36 37  
  38 +- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
  39 +{
  40 + [self.view endEditing:YES];
37 41 }
38 42  
39 43 - (void)didReceiveMemoryWarning {
... ...
LiveVideoCloud/LiveVideoCloud/Classes/Sections/homeSections/Controller/LVCLivePlayerController.m
... ... @@ -9,20 +9,22 @@
9 9 #import "LVCLivePlayerController.h"
10 10 #import "LVCPlayer.h"
11 11 #import "LVCFullScreenPlayerController.h"
  12 +#import "LVCInputView.h"
  13 +#import "LVCChatView.h"
12 14  
13   -#define WIDTH_SCREEN [UIScreen mainScreen].bounds.size.width
14   -#define HEIGHT_SCREEN [UIScreen mainScreen].bounds.size.height
15   -
16   -@interface LVCLivePlayerController ()<LVCPlayerDelegate>
  15 +@interface LVCLivePlayerController ()<LVCPlayerDelegate,LVCInputViewDelegate>
17 16 {
18 17 BOOL isHiddenStatusBar; //记录状态的隐藏显示
19 18 CGRect playerFrame; //
20 19 NSInteger _originalDirection; //记录原始方向
21 20  
22   -
  21 + CGFloat keyboardHeight; //键盘高度
  22 +
23 23 }
24 24 @property (nonatomic, strong) LVCPlayer *player;
25 25 @property (nonatomic, strong) LVCFullScreenPlayerController *fullVC;
  26 +@property (nonatomic, strong) LVCInputView *inputView;
  27 +@property (nonatomic, strong) LVCChatView *chatView;
26 28  
27 29 @end
28 30  
... ... @@ -44,15 +46,17 @@
44 46 - (void)viewDidLoad {
45 47 [super viewDidLoad];
46 48  
47   - self.view.backgroundColor = [UIColor whiteColor];
  49 + self.view.backgroundColor = [UIColor blackColor];
48 50  
49   - playerFrame = CGRectMake(0, 0,WIDTH_SCREEN, WIDTH_SCREEN*9/16);
  51 + playerFrame = CGRectMake(0, 20, SCREEN_WIDTH, SCREEN_WIDTH*9/16);
50 52 _originalDirection = 0;
51 53  
52 54 //注册通知
53 55 [self addObservers];
54 56  
55 57 [self.view addSubview:self.player];
  58 + [self.view addSubview:self.chatView];
  59 + [self.view addSubview:self.inputView];
56 60  
57 61 [self makeConstraints];
58 62 }
... ... @@ -63,8 +67,18 @@
63 67 selector:@selector(onDeviceOrientationChange:)
64 68 name:UIDeviceOrientationDidChangeNotification
65 69 object:nil];
66   -
67   -
  70 +
  71 + //增加监听,当键盘出现或改变时收出消息
  72 + [[NSNotificationCenter defaultCenter] addObserver:self
  73 + selector:@selector(keyboardWillShow:)
  74 + name:UIKeyboardWillShowNotification
  75 + object:nil];
  76 + //增加监听,当键退出时收出消息
  77 + [[NSNotificationCenter defaultCenter] addObserver:self
  78 + selector:@selector(keyboardWillHide:)
  79 + name:UIKeyboardWillHideNotification
  80 + object:nil];
  81 +
68 82 }
69 83  
70 84 #pragma mark -
... ... @@ -84,7 +98,6 @@
84 98 [self toHalfScreenWithrotationAngle:-M_PI_2];
85 99 }
86 100 _originalDirection = 0;
87   - _player.isFullScreen = NO;
88 101 }
89 102 break;
90 103  
... ... @@ -111,32 +124,52 @@
111 124 }
112 125 }
113 126  
  127 +//当键盘出现
  128 +- (void)keyboardWillShow:(NSNotification *)aNotification{
  129 + //获取键盘的高度
  130 + NSDictionary* info = [aNotification userInfo];
  131 + CGSize kbSize = [[info objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue].size;
  132 + _inputView.frame = CGRectMake(0, SCREEN_HEIGHT-kbSize.height-50, SCREEN_WIDTH, 50);
  133 +}
  134 +
  135 +- (void)keyboardWillHide:(NSNotification *)aNotification{
  136 + _inputView.frame = CGRectMake(0, SCREEN_HEIGHT-50, SCREEN_WIDTH, 50);
  137 +}
  138 +
114 139 //旋转至全屏
115 140 - (void)toFullWithrotationAngle:(CGFloat)angle
116 141 {
117   - if (self.player.isFullScreen) return;
118   -
  142 + if (_player.isFullScreen) return;
  143 +
  144 + _player.isFullScreen = YES;
  145 +
119 146 [self presentViewController:self.fullVC animated:NO completion:^{
120 147 [_player removeFromSuperview];
121 148 [self.fullVC.view addSubview:self.player];
  149 + [_inputView removeFromSuperview];
  150 + [self.fullVC.view addSubview:self.inputView];
122 151 [self makePlayerViewConstraints:YES];
  152 +
123 153 self.player.transform = CGAffineTransformMakeRotation(angle);
124 154 [UIView animateWithDuration:0.3 animations:^{
125 155 self.player.transform = CGAffineTransformMakeRotation(0);
126 156 }];
127 157 }];
128 158  
129   - self.player.isFullScreen = YES;
130   -
131 159 }
132 160  
133 161 //旋转至半屏
134 162 - (void)toHalfScreenWithrotationAngle:(CGFloat)angle
135 163 {
  164 + _player.isFullScreen = NO;
  165 +
136 166 [_fullVC dismissViewControllerAnimated:NO completion:^{
137 167 [_player removeFromSuperview];
138 168 [self.view addSubview:self.player];
  169 + [self.inputView removeFromSuperview];
  170 + [self.view addSubview:self.inputView];
139 171 [self makePlayerViewConstraints:NO];
  172 +
140 173 self.player.transform = CGAffineTransformMakeRotation(angle);
141 174 [UIView animateWithDuration:0.3 animations:^{
142 175 self.player.transform = CGAffineTransformMakeRotation(0);
... ... @@ -149,7 +182,7 @@
149 182 - (void)lvcPlayer:(LVCPlayer *)player clickedBackBtn:(UIButton *)backBtn
150 183 {
151 184 //如果是全屏返回半屏,如果是半屏直接退出
152   - if (self.player.isFullScreen) {
  185 + if (_player.isFullScreen) {
153 186 [self toHalfScreenWithrotationAngle:M_PI_2];
154 187 self.player.isFullScreen = NO;
155 188 } else {
... ... @@ -161,7 +194,7 @@
161 194  
162 195 - (void)lvcPlayer:(LVCPlayer *)player clickedFullScreenBtn:(UIButton *)fullScreenBtn
163 196 {
164   - if (self.player.isFullScreen == YES) {//全屏
  197 + if (_player.isFullScreen) {//全屏
165 198 [self toHalfScreenWithrotationAngle:M_PI_2];
166 199 self.player.isFullScreen = NO;
167 200  
... ... @@ -172,7 +205,20 @@
172 205  
173 206 - (void)lvcPlayer:(LVCPlayer *)player clickedEditBtn:(UIButton *)editBtn
174 207 {
175   - NSLog(@"开始编辑~~~~");
  208 +
  209 +}
  210 +
  211 +#pragma mark -
  212 +#pragma mark - LVCInputViewDelegate
  213 +- (void)lvcInputView:(LVCInputView *)inputView sendMessage:(NSString *)message
  214 +{
  215 + NSLog(@"发送消息(%@)",message);
  216 +
  217 +}
  218 +
  219 +- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
  220 +{
  221 + [self.view endEditing:YES];
176 222 }
177 223  
178 224 #pragma mark -
... ... @@ -180,23 +226,35 @@
180 226 - (void)makeConstraints
181 227 {
182 228 [self.player mas_makeConstraints:^(MASConstraintMaker *make) {
183   - make.top.left.right.mas_equalTo(0);
  229 + make.top.mas_equalTo(20);
  230 + make.left.right.mas_equalTo(0);
184 231 make.height.equalTo(@(playerFrame.size.height));
185 232 }];
  233 +
  234 + _inputView.frame = CGRectMake(0, SCREEN_HEIGHT-50, SCREEN_WIDTH, 49);
  235 +
186 236 }
187 237  
188 238 - (void)makePlayerViewConstraints:(BOOL)fullScreen
189 239 {
190   - if (fullScreen) {
  240 + if (fullScreen) { //全屏
  241 +
191 242 [self.player mas_remakeConstraints:^(MASConstraintMaker *make) {
192 243 make.top.left.right.bottom.mas_equalTo(0);
193 244 }];
194 245  
195   - } else {
  246 + _inputView.frame = CGRectMake(0, SCREEN_HEIGHT-50, SCREEN_WIDTH, 49);
  247 +
  248 + } else { //半屏
  249 +
196 250 [self.player mas_remakeConstraints:^(MASConstraintMaker *make) {
197   - make.top.left.right.mas_equalTo(0);
  251 + make.top.mas_equalTo(20);
  252 + make.left.right.mas_equalTo(0);
198 253 make.height.equalTo(@(playerFrame.size.height));
199 254 }];
  255 +
  256 + _inputView.frame = CGRectMake(0, SCREEN_HEIGHT-50, SCREEN_WIDTH, 49);
  257 +
200 258 }
201 259 }
202 260  
... ... @@ -218,6 +276,24 @@
218 276 }
219 277 return _fullVC;
220 278 }
  279 +
  280 +- (LVCInputView *)inputView
  281 +{
  282 + if (!_inputView) {
  283 + _inputView = [[LVCInputView alloc]init];
  284 + _inputView.delegate = self;
  285 + }
  286 + return _inputView;
  287 +}
  288 +
  289 +- (LVCChatView *)chatView
  290 +{
  291 + if (!_chatView) {
  292 + _chatView = [[LVCChatView alloc] initWithFrame:CGRectMake(0, SCREEN_WIDTH*9/16+20, SCREEN_WIDTH, SCREEN_HEIGHT-SCREEN_WIDTH*9/16-20-49) roomId:@"1122"];
  293 + }
  294 + return _chatView;
  295 +}
  296 +
221 297 - (void)didReceiveMemoryWarning {
222 298 [super didReceiveMemoryWarning];
223 299 // Dispose of any resources that can be recreated.
... ...
LiveVideoCloud/LiveVideoCloud/Classes/Sections/homeSections/View/LVCPlayer.h
... ... @@ -27,7 +27,7 @@
27 27  
28 28 @property (nonatomic, strong) UIImageView *contentView; //所有空间统一管理在这个view中
29 29 @property (nonatomic, strong) UIButton *backBtn; //返回
30   -@property (nonatomic, assign) BOOL isFullScreen; //是否是全屏
  30 +@property (nonatomic, readwrite, assign) BOOL isFullScreen; //是否是全屏
31 31  
32 32 - (void)stopPlaying;
33 33  
... ...
LiveVideoCloud/LiveVideoCloud/Classes/Sections/homeSections/View/LVCPlayer.m
... ... @@ -14,10 +14,8 @@
14 14 #define kAppKey @"69fe70bda67e059286ad509d9f5377f815955645b52f94"
15 15 #define kbundleId @"com.cnlive.zhangxu.LiveVideoCloud"
16 16  
17   -@interface LVCPlayer ()
18   -{
19   - BOOL _isFull;
20   -}
  17 +@interface LVCPlayer ()<UIGestureRecognizerDelegate>
  18 +
21 19 @property (nonatomic, strong) UIImageView *topBgView; //顶部蒙版
22 20 @property (nonatomic, strong) UIImageView *bottomBgView; //底部蒙版
23 21 @property (nonatomic, strong) UIButton *playOrPauseBtn; //播放/暂停
... ... @@ -117,7 +115,10 @@
117 115 self.bottomBgView.alpha = self.bottomBgView.alpha == 0 ? 1 : 0;
118 116 self.editBtn.alpha = self.editBtn.alpha == 0 ? 1 : 0;
119 117 }];
120   - [[UIApplication sharedApplication] setStatusBarHidden:self.topBgView.alpha == 0 ? YES : NO withAnimation:UIStatusBarAnimationFade];
  118 +
  119 + if (_isFullScreen) {
  120 + [[UIApplication sharedApplication] setStatusBarHidden:self.topBgView.alpha == 0 ? YES : NO withAnimation:UIStatusBarAnimationFade];
  121 + }
121 122  
122 123 }
123 124  
... ... @@ -135,6 +136,14 @@
135 136 }
136 137 }
137 138  
  139 +#pragma mark - UIGestureRecognizerDelegate 手势冲突
  140 +- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch {
  141 + if ([NSStringFromClass([touch.view class]) isEqualToString:@"SevenSwitch"]) {
  142 + return NO;
  143 + }
  144 + return YES;
  145 +}
  146 +
138 147 #pragma mark -
139 148 #pragma mark - Notification
140 149 - (void)addObservers
... ... @@ -342,7 +351,7 @@
342 351 [self.backBtn mas_makeConstraints:^(MASConstraintMaker *make) {
343 352 make.left.equalTo(self.topBgView).with.offset(5);
344 353 make.width.height.mas_equalTo(30);
345   - make.top.equalTo(self.topBgView).with.offset(20);
  354 + make.top.equalTo(self.topBgView).with.offset(10);
346 355 }];
347 356  
348 357 [self.topBgView mas_makeConstraints:^(MASConstraintMaker *make) {
... ... @@ -364,7 +373,9 @@
364 373  
365 374 [self.titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
366 375 make.left.equalTo(self.backBtn).offset(40);
367   - make.top.trailing.bottom.mas_equalTo(0);
  376 + make.top.mas_equalTo(15);
  377 + make.height.mas_equalTo(20);
  378 + make.right.equalTo(self.topBgView).offset(-100);
368 379 }];
369 380  
370 381 [self.playOrPauseBtn mas_makeConstraints:^(MASConstraintMaker *make) {
... ... @@ -387,7 +398,37 @@
387 398  
388 399 #pragma mark -
389 400 #pragma mark - setter
  401 +- (void)setIsFullScreen:(BOOL)isFullScreen
  402 +{
  403 + _isFullScreen = isFullScreen;
390 404  
  405 + if (isFullScreen) {
  406 +
  407 + _barrageSwitch.hidden = NO;
  408 + _editBtn.hidden = NO;
  409 +
  410 + [self.backBtn mas_updateConstraints:^(MASConstraintMaker *make) {
  411 + make.top.equalTo(self.topBgView).with.offset(20);
  412 + }];
  413 +
  414 + [self.titleLab mas_updateConstraints:^(MASConstraintMaker *make) {
  415 + make.top.mas_equalTo(25);
  416 + }];
  417 +
  418 + } else {
  419 +
  420 + _barrageSwitch.hidden = YES;
  421 + _editBtn.hidden = YES;
  422 +
  423 + [self.backBtn mas_updateConstraints:^(MASConstraintMaker *make) {
  424 + make.top.equalTo(self.topBgView).with.offset(10);
  425 + }];
  426 +
  427 + [self.titleLab mas_updateConstraints:^(MASConstraintMaker *make) {
  428 + make.top.mas_equalTo(15);
  429 + }];
  430 + }
  431 +}
391 432  
392 433 #pragma mark -
393 434 #pragma mark - getter
... ... @@ -478,6 +519,7 @@
478 519 {
479 520 if (!_singleTap) {
480 521 _singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(singleTapView)];
  522 + _singleTap.delegate = self;
481 523 }
482 524 return _singleTap;
483 525 }
... ... @@ -492,7 +534,7 @@
492 534 _barrageSwitch.activeColor = [UIColor blackColor];
493 535 _barrageSwitch.inactiveColor = [UIColor blackColor];
494 536 _barrageSwitch.on = YES;
495   -// _barrageSwitch.hidden = YES;
  537 + _barrageSwitch.hidden = YES;
496 538 [_barrageSwitch addTarget:self action:@selector(barrageSwitchAction) forControlEvents:UIControlEventValueChanged];
497 539 }
498 540 return _barrageSwitch;
... ... @@ -504,6 +546,7 @@
504 546 _editBtn = [UIButton buttonWithType:UIButtonTypeCustom];
505 547 [_editBtn setImage:[UIImage imageNamed:@"Barrage input"] forState:UIControlStateNormal];
506 548 [_editBtn addTarget:self action:@selector(editBtnAction:) forControlEvents:UIControlEventTouchUpInside];
  549 + _editBtn.hidden = YES;
507 550 }
508 551 return _editBtn;
509 552 }
... ...
LiveVideoCloud/LiveVideoCloud/UtilKits/Category/NSString+StringSize.h 0 → 100755
  1 +//
  2 +// NSString+StringSize.h
  3 +// testTableview
  4 +//
  5 +// Created by cnliveJunBo on 16/11/7.
  6 +// Copyright © 2016年 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import <UIKit/UIKit.h>
  10 +
  11 +@interface NSString (StringSize)
  12 +- (CGSize)sizeWithLabelWidth:(CGFloat)width font:(UIFont *)font;
  13 +@end
... ...
LiveVideoCloud/LiveVideoCloud/UtilKits/Category/NSString+StringSize.m 0 → 100755
  1 +//
  2 +// NSString+StringSize.m
  3 +// testTableview
  4 +//
  5 +// Created by cnliveJunBo on 16/11/7.
  6 +// Copyright © 2016年 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import "NSString+StringSize.h"
  10 +
  11 +@implementation NSString (StringSize)
  12 +- (CGSize)sizeWithLabelWidth:(CGFloat)width font:(UIFont *)font{
  13 + NSDictionary *dict=@{NSFontAttributeName : font};
  14 + CGRect rect=[self boundingRectWithSize:CGSizeMake(width,MAXFLOAT) options:(NSStringDrawingUsesLineFragmentOrigin|NSStringDrawingUsesFontLeading) attributes:dict context:nil];
  15 + CGFloat sizeWidth=ceilf(CGRectGetWidth(rect));
  16 + CGFloat sizeHieght=ceilf(CGRectGetHeight(rect));
  17 + return CGSizeMake(sizeWidth, sizeHieght);
  18 +}
  19 +@end
... ...
LiveVideoCloud/LiveVideoCloud/animation.xcassets/player/Gift box right.imageset/Contents.json 0 → 100644
  1 +{
  2 + "images" : [
  3 + {
  4 + "idiom" : "universal",
  5 + "scale" : "1x"
  6 + },
  7 + {
  8 + "idiom" : "universal",
  9 + "scale" : "2x"
  10 + },
  11 + {
  12 + "idiom" : "universal",
  13 + "filename" : "Gift box right.png",
  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/Gift box right.imageset/Gift box right.png 0 → 100644

1.54 KB

LiveVideoCloud/LiveVideoCloud/animation.xcassets/player/Gift box.imageset/Contents.json 0 → 100644
  1 +{
  2 + "images" : [
  3 + {
  4 + "idiom" : "universal",
  5 + "filename" : "Gift box.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/Gift box.imageset/Gift box.png 0 → 100644

2.07 KB

LiveVideoCloud/LiveVideoCloud/animation.xcassets/player/fenxiangshupinghou_weixiao.imageset/Contents.json 0 → 100644
  1 +{
  2 + "images" : [
  3 + {
  4 + "idiom" : "universal",
  5 + "filename" : "fenxiangshupinghou_weixiao.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/fenxiangshupinghou_weixiao.imageset/fenxiangshupinghou_weixiao.png 0 → 100644

1.85 KB

LiveVideoCloud/LiveVideoCloud/animation.xcassets/player/keyboard.imageset/Contents.json 0 → 100644
  1 +{
  2 + "images" : [
  3 + {
  4 + "idiom" : "universal",
  5 + "filename" : "keyboard.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/keyboard.imageset/keyboard.png 0 → 100644

1.67 KB

LiveVideoCloud/LiveVideoCloud/animation.xcassets/player/send.imageset/Contents.json 0 → 100644
  1 +{
  2 + "images" : [
  3 + {
  4 + "idiom" : "universal",
  5 + "filename" : "send.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/send.imageset/send.png 0 → 100644

4.77 KB

LiveVideoCloud/LiveVideoCloud/animation.xcassets/player/touxiang.imageset/Contents.json 0 → 100644
  1 +{
  2 + "images" : [
  3 + {
  4 + "idiom" : "universal",
  5 + "filename" : "touxiang.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/touxiang.imageset/touxiang.png 0 → 100644

6.29 KB