Commit 2d64d84c427eb1bf98f83a793294cf702d35bd43
Merge branch 'master' of bj.gitlab.cnlive.com:ios-team/LiveVideoCloud
# Conflicts: # LiveVideoCloud/LiveVideoCloud/Classes/Sections/LiveSections/Controller/LVCLiveViewController.m # LiveVideoCloud/LiveVideoCloud/Classes/Sections/homeSections/Controller/HomeViewController.m
Showing
16 changed files
with
647 additions
and
255 deletions
LiveVideoCloud/LiveVideoCloud.xcodeproj/project.pbxproj
| ... | ... | @@ -186,16 +186,20 @@ |
| 186 | 186 | D2888DB11E6EC05F003A77C8 /* TempViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D2888DB01E6EC05F003A77C8 /* TempViewController.m */; }; |
| 187 | 187 | D2888DB41E6EC154003A77C8 /* HomeViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D2888DB31E6EC154003A77C8 /* HomeViewController.m */; }; |
| 188 | 188 | D2888DB71E6EC1B8003A77C8 /* LVCMyViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D2888DB61E6EC1B8003A77C8 /* LVCMyViewController.m */; }; |
| 189 | - D29E81ED1E88DC5B008C9906 /* PriChatCell.m in Sources */ = {isa = PBXBuildFile; fileRef = D29E81EC1E88DC5B008C9906 /* PriChatCell.m */; }; | |
| 190 | 189 | D29D88481E88C53300543A03 /* LVCUGCLivePrepareView.m in Sources */ = {isa = PBXBuildFile; fileRef = D29D88471E88C53300543A03 /* LVCUGCLivePrepareView.m */; }; |
| 190 | + D29E81ED1E88DC5B008C9906 /* PriChatCell.m in Sources */ = {isa = PBXBuildFile; fileRef = D29E81EC1E88DC5B008C9906 /* PriChatCell.m */; }; | |
| 191 | + D2A089E81E89FA720071412C /* LVCUGCLivePlayerCell.m in Sources */ = {isa = PBXBuildFile; fileRef = D2A089E71E89FA720071412C /* LVCUGCLivePlayerCell.m */; }; | |
| 192 | + D2A089EB1E8A09CB0071412C /* LVCUGCLivePlayerModel.m in Sources */ = {isa = PBXBuildFile; fileRef = D2A089EA1E8A09CB0071412C /* LVCUGCLivePlayerModel.m */; }; | |
| 191 | 193 | D2A803081E80BD6F009D6F1C /* TopToolView.m in Sources */ = {isa = PBXBuildFile; fileRef = D2A803071E80BD6F009D6F1C /* TopToolView.m */; }; |
| 192 | 194 | D2B2ED7A1E88F90C00F7538A /* CNLiveChatManager.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D2D236B21E88F8E600B7C517 /* CNLiveChatManager.framework */; }; |
| 193 | 195 | D2B2ED7B1E88F90C00F7538A /* CNLiveChatManager.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = D2D236B21E88F8E600B7C517 /* CNLiveChatManager.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; |
| 194 | 196 | D2B2ED7C1E88F90F00F7538A /* CNLiveMsgTools.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D2D236B31E88F8E600B7C517 /* CNLiveMsgTools.framework */; }; |
| 195 | 197 | D2B2ED7D1E88F90F00F7538A /* CNLiveMsgTools.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = D2D236B31E88F8E600B7C517 /* CNLiveMsgTools.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; |
| 198 | + D2B2ED801E88FC5200F7538A /* LVCUGCLiveEndView.m in Sources */ = {isa = PBXBuildFile; fileRef = D2B2ED7F1E88FC5200F7538A /* LVCUGCLiveEndView.m */; }; | |
| 196 | 199 | D2B7B2511E8247D400ED084E /* ChatBarrageManager.m in Sources */ = {isa = PBXBuildFile; fileRef = D2B7B2501E8247D400ED084E /* ChatBarrageManager.m */; }; |
| 197 | 200 | D2B7B2541E824B2D00ED084E /* ChatBarrageView.m in Sources */ = {isa = PBXBuildFile; fileRef = D2B7B2531E824B2D00ED084E /* ChatBarrageView.m */; }; |
| 198 | 201 | D2B7B2571E8261EF00ED084E /* ChatBarrOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = D2B7B2561E8261EF00ED084E /* ChatBarrOperation.m */; }; |
| 202 | + D2CC7B871E891AA50034B8BF /* LVCUGCLiveListController.m in Sources */ = {isa = PBXBuildFile; fileRef = D2CC7B861E891AA50034B8BF /* LVCUGCLiveListController.m */; }; | |
| 199 | 203 | D2D236B41E88F8E600B7C517 /* CNLiveChatManager.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D2D236B21E88F8E600B7C517 /* CNLiveChatManager.framework */; }; |
| 200 | 204 | D2D236B51E88F8E600B7C517 /* CNLiveMsgTools.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D2D236B31E88F8E600B7C517 /* CNLiveMsgTools.framework */; }; |
| 201 | 205 | /* End PBXBuildFile section */ |
| ... | ... | @@ -605,18 +609,26 @@ |
| 605 | 609 | D2888DB31E6EC154003A77C8 /* HomeViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HomeViewController.m; sourceTree = "<group>"; }; |
| 606 | 610 | D2888DB51E6EC1B8003A77C8 /* LVCMyViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LVCMyViewController.h; sourceTree = "<group>"; }; |
| 607 | 611 | D2888DB61E6EC1B8003A77C8 /* LVCMyViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LVCMyViewController.m; sourceTree = "<group>"; }; |
| 608 | - D29E81EB1E88DC5B008C9906 /* PriChatCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PriChatCell.h; sourceTree = "<group>"; }; | |
| 609 | - D29E81EC1E88DC5B008C9906 /* PriChatCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PriChatCell.m; sourceTree = "<group>"; }; | |
| 610 | 612 | D29D88461E88C53300543A03 /* LVCUGCLivePrepareView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LVCUGCLivePrepareView.h; sourceTree = "<group>"; }; |
| 611 | 613 | D29D88471E88C53300543A03 /* LVCUGCLivePrepareView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LVCUGCLivePrepareView.m; sourceTree = "<group>"; }; |
| 614 | + D29E81EB1E88DC5B008C9906 /* PriChatCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PriChatCell.h; sourceTree = "<group>"; }; | |
| 615 | + D29E81EC1E88DC5B008C9906 /* PriChatCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PriChatCell.m; sourceTree = "<group>"; }; | |
| 616 | + D2A089E61E89FA720071412C /* LVCUGCLivePlayerCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LVCUGCLivePlayerCell.h; sourceTree = "<group>"; }; | |
| 617 | + D2A089E71E89FA720071412C /* LVCUGCLivePlayerCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LVCUGCLivePlayerCell.m; sourceTree = "<group>"; }; | |
| 618 | + D2A089E91E8A09CB0071412C /* LVCUGCLivePlayerModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LVCUGCLivePlayerModel.h; sourceTree = "<group>"; }; | |
| 619 | + D2A089EA1E8A09CB0071412C /* LVCUGCLivePlayerModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LVCUGCLivePlayerModel.m; sourceTree = "<group>"; }; | |
| 612 | 620 | D2A803061E80BD6F009D6F1C /* TopToolView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TopToolView.h; sourceTree = "<group>"; }; |
| 613 | 621 | D2A803071E80BD6F009D6F1C /* TopToolView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TopToolView.m; sourceTree = "<group>"; }; |
| 622 | + D2B2ED7E1E88FC5200F7538A /* LVCUGCLiveEndView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LVCUGCLiveEndView.h; sourceTree = "<group>"; }; | |
| 623 | + D2B2ED7F1E88FC5200F7538A /* LVCUGCLiveEndView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LVCUGCLiveEndView.m; sourceTree = "<group>"; }; | |
| 614 | 624 | D2B7B24F1E8247D400ED084E /* ChatBarrageManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ChatBarrageManager.h; sourceTree = "<group>"; }; |
| 615 | 625 | D2B7B2501E8247D400ED084E /* ChatBarrageManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ChatBarrageManager.m; sourceTree = "<group>"; }; |
| 616 | 626 | D2B7B2521E824B2D00ED084E /* ChatBarrageView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ChatBarrageView.h; sourceTree = "<group>"; }; |
| 617 | 627 | D2B7B2531E824B2D00ED084E /* ChatBarrageView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ChatBarrageView.m; sourceTree = "<group>"; }; |
| 618 | 628 | D2B7B2551E8261EF00ED084E /* ChatBarrOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ChatBarrOperation.h; sourceTree = "<group>"; }; |
| 619 | 629 | D2B7B2561E8261EF00ED084E /* ChatBarrOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ChatBarrOperation.m; sourceTree = "<group>"; }; |
| 630 | + D2CC7B851E891AA50034B8BF /* LVCUGCLiveListController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LVCUGCLiveListController.h; sourceTree = "<group>"; }; | |
| 631 | + D2CC7B861E891AA50034B8BF /* LVCUGCLiveListController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LVCUGCLiveListController.m; sourceTree = "<group>"; }; | |
| 620 | 632 | D2D236B21E88F8E600B7C517 /* CNLiveChatManager.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = CNLiveChatManager.framework; sourceTree = "<group>"; }; |
| 621 | 633 | D2D236B31E88F8E600B7C517 /* CNLiveMsgTools.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = CNLiveMsgTools.framework; sourceTree = "<group>"; }; |
| 622 | 634 | /* End PBXFileReference section */ |
| ... | ... | @@ -725,6 +737,8 @@ |
| 725 | 737 | 81A4831F1E88F4BF0097A80A /* LVCProgramModel.m */, |
| 726 | 738 | 81A482FF1E88B0130097A80A /* LVCChatRoomModel.h */, |
| 727 | 739 | 81A483001E88B0130097A80A /* LVCChatRoomModel.m */, |
| 740 | + D2A089E91E8A09CB0071412C /* LVCUGCLivePlayerModel.h */, | |
| 741 | + D2A089EA1E8A09CB0071412C /* LVCUGCLivePlayerModel.m */, | |
| 728 | 742 | ); |
| 729 | 743 | path = Model; |
| 730 | 744 | sourceTree = "<group>"; |
| ... | ... | @@ -1509,6 +1523,8 @@ |
| 1509 | 1523 | D25BF8791E7B8A82007FB138 /* SliderView.m */, |
| 1510 | 1524 | D29D88461E88C53300543A03 /* LVCUGCLivePrepareView.h */, |
| 1511 | 1525 | D29D88471E88C53300543A03 /* LVCUGCLivePrepareView.m */, |
| 1526 | + D2B2ED7E1E88FC5200F7538A /* LVCUGCLiveEndView.h */, | |
| 1527 | + D2B2ED7F1E88FC5200F7538A /* LVCUGCLiveEndView.m */, | |
| 1512 | 1528 | ); |
| 1513 | 1529 | path = View; |
| 1514 | 1530 | sourceTree = "<group>"; |
| ... | ... | @@ -1609,6 +1625,8 @@ |
| 1609 | 1625 | 810B64E21E779AFE00133E15 /* LVCLivePlayerController.m */, |
| 1610 | 1626 | 810B65081E77B39D00133E15 /* LVCFullScreenPlayerController.h */, |
| 1611 | 1627 | 810B65091E77B39D00133E15 /* LVCFullScreenPlayerController.m */, |
| 1628 | + D2CC7B851E891AA50034B8BF /* LVCUGCLiveListController.h */, | |
| 1629 | + D2CC7B861E891AA50034B8BF /* LVCUGCLiveListController.m */, | |
| 1612 | 1630 | D25BF87E1E7BD266007FB138 /* LVCUGCLivePlayerController.h */, |
| 1613 | 1631 | D25BF87F1E7BD266007FB138 /* LVCUGCLivePlayerController.m */, |
| 1614 | 1632 | 81A483151E88BED00097A80A /* LVCTVLiveViewController.h */, |
| ... | ... | @@ -1637,6 +1655,8 @@ |
| 1637 | 1655 | 81A483041E88B32C0097A80A /* LVCHeaderRollCollectionViewCell.m */, |
| 1638 | 1656 | 8112D42F1E7927A5002E00F6 /* LVCPlayerLoadingView.h */, |
| 1639 | 1657 | 8112D4301E7927A5002E00F6 /* LVCPlayerLoadingView.m */, |
| 1658 | + D2A089E61E89FA720071412C /* LVCUGCLivePlayerCell.h */, | |
| 1659 | + D2A089E71E89FA720071412C /* LVCUGCLivePlayerCell.m */, | |
| 1640 | 1660 | D25BF8811E7F775F007FB138 /* LVCUGCPlayerLoadingView.h */, |
| 1641 | 1661 | D25BF8821E7F775F007FB138 /* LVCUGCPlayerLoadingView.m */, |
| 1642 | 1662 | D25BF8911E7FBAEA007FB138 /* LVCUGCBackgroundView.h */, |
| ... | ... | @@ -1868,6 +1888,7 @@ |
| 1868 | 1888 | D2029C941E6EADE10027CD92 /* UIRefreshControl+AFNetworking.m in Sources */, |
| 1869 | 1889 | D2029C911E6EADE10027CD92 /* UIButton+AFNetworking.m in Sources */, |
| 1870 | 1890 | D2029C931E6EADE10027CD92 /* UIProgressView+AFNetworking.m in Sources */, |
| 1891 | + D2A089E81E89FA720071412C /* LVCUGCLivePlayerCell.m in Sources */, | |
| 1871 | 1892 | D2029C8D1E6EADE10027CD92 /* AFAutoPurgingImageCache.m in Sources */, |
| 1872 | 1893 | 81A483111E88B8630097A80A /* LVCChannelDetailsModel.m in Sources */, |
| 1873 | 1894 | D2029D011E6EAE2E0027CD92 /* UIColor+HexString.m in Sources */, |
| ... | ... | @@ -1911,12 +1932,14 @@ |
| 1911 | 1932 | D2029CC41E6EADE10027CD92 /* UIImageView+WebCache.m in Sources */, |
| 1912 | 1933 | D236967E1E7F9E4100E4BF71 /* GiftPayButton.m in Sources */, |
| 1913 | 1934 | 81A483081E88B6140097A80A /* UIView+ViewController.m in Sources */, |
| 1935 | + D2A089EB1E8A09CB0071412C /* LVCUGCLivePlayerModel.m in Sources */, | |
| 1914 | 1936 | D2029CC81E6EADE10027CD92 /* SVProgressAnimatedView.m in Sources */, |
| 1915 | 1937 | D2029C961E6EADE10027CD92 /* MBProgressHUD.m in Sources */, |
| 1916 | 1938 | 810B65071E779B1F00133E15 /* ViewController+MASAdditions.m in Sources */, |
| 1917 | 1939 | D2029C9A1E6EADE10027CD92 /* MJProperty.m in Sources */, |
| 1918 | 1940 | D2029CB91E6EADE10027CD92 /* SDWebImageCompat.m in Sources */, |
| 1919 | 1941 | D2029CB61E6EADE10027CD92 /* MKAnnotationView+WebCache.m in Sources */, |
| 1942 | + D2B2ED801E88FC5200F7538A /* LVCUGCLiveEndView.m in Sources */, | |
| 1920 | 1943 | 810B64FE1E779B1F00133E15 /* MASCompositeConstraint.m in Sources */, |
| 1921 | 1944 | D2029C981E6EADE10027CD92 /* MJExtensionConst.m in Sources */, |
| 1922 | 1945 | D2575C671E76A25400E3A8FC /* LVCInteractionController.m in Sources */, |
| ... | ... | @@ -1936,7 +1959,6 @@ |
| 1936 | 1959 | D2029D041E6EAE2E0027CD92 /* UILabel+ContentSize.m in Sources */, |
| 1937 | 1960 | D25530031E79115100DF38A5 /* AnimQueueManager.m in Sources */, |
| 1938 | 1961 | D2029C871E6EADE10027CD92 /* AFHTTPSessionManager.m in Sources */, |
| 1939 | - D236968D1E7FC7C200E4BF71 /* CNBarrageManager.m in Sources */, | |
| 1940 | 1962 | 81A482F81E88AFA20097A80A /* LVCFirstHeaderReusableView.m in Sources */, |
| 1941 | 1963 | D2029B861E6EAAA50027CD92 /* main.m in Sources */, |
| 1942 | 1964 | D2029C8C1E6EADE10027CD92 /* AFURLSessionManager.m in Sources */, |
| ... | ... | @@ -1976,6 +1998,7 @@ |
| 1976 | 1998 | D2029D081E6EAE2E0027CD92 /* ZXDeviceInfo.m in Sources */, |
| 1977 | 1999 | D24571631E83C40B00AA85D6 /* PrivateView.m in Sources */, |
| 1978 | 2000 | D2029CC21E6EADE10027CD92 /* UIImage+WebP.m in Sources */, |
| 2001 | + D2CC7B871E891AA50034B8BF /* LVCUGCLiveListController.m in Sources */, | |
| 1979 | 2002 | D2029BCD1E6EADD70027CD92 /* BaseViewController.m in Sources */, |
| 1980 | 2003 | 810B64E01E779AE900133E15 /* LVCPlayer.m in Sources */, |
| 1981 | 2004 | 810B64FF1E779B1F00133E15 /* MASConstraint.m in Sources */, | ... | ... |
LiveVideoCloud/LiveVideoCloud/Classes/Sections/LiveSections/Controller/LVCLiveViewController.m
| ... | ... | @@ -12,11 +12,12 @@ |
| 12 | 12 | #import "FilterFunctionView.h" |
| 13 | 13 | #import "LVCUGCLivePrepareView.h" |
| 14 | 14 | #import "LiveBaseView.h" |
| 15 | +#import "LVCUGCLiveEndView.h" | |
| 15 | 16 | |
| 16 | -#define KAppId @"60_irn9edco29" | |
| 17 | -#define KAppKey @"69fe70bda67e059286ad509d9f5377f815955645b52f94" | |
| 18 | - | |
| 19 | -@interface LVCLiveViewController ()<UIGestureRecognizerDelegate> | |
| 17 | +@interface LVCLiveViewController ()<UIGestureRecognizerDelegate> { | |
| 18 | + | |
| 19 | + BOOL _isStreaming; | |
| 20 | +} | |
| 20 | 21 | |
| 21 | 22 | @property (nonatomic, strong) LVCUGCLivePrepareView *prepareView; |
| 22 | 23 | |
| ... | ... | @@ -36,6 +37,7 @@ |
| 36 | 37 | |
| 37 | 38 | @property (nonatomic ,strong) LiveBaseView * _Nullable liveBaseView; |
| 38 | 39 | |
| 40 | +@property (nonatomic, strong) LVCUGCLiveEndView *endView; | |
| 39 | 41 | |
| 40 | 42 | @end |
| 41 | 43 | |
| ... | ... | @@ -58,8 +60,6 @@ |
| 58 | 60 | // 初始化推流 |
| 59 | 61 | NSString *activityId = [NSString stringWithFormat:@"%d%d%d%d%d",arc4random()%9,arc4random()%9,arc4random()%9,arc4random()%9,arc4random()%9]; |
| 60 | 62 | |
| 61 | - [[CNLiveWebcastManager manager] initWithAppId:KAppId appKey:KAppKey]; | |
| 62 | - | |
| 63 | 63 | _kitCN = [[CNLiveGPUStreamerKit alloc] initWithDefaultConfigWithActivityId:activityId channelId:@"iOStest" isHorizontalScreen:@"0"]; |
| 64 | 64 | |
| 65 | 65 | // _kitCN.activityName = @"iOS test"; |
| ... | ... | @@ -120,7 +120,11 @@ |
| 120 | 120 | |
| 121 | 121 | #pragma mark - UIButton Action !!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 122 | 122 | - (void)startCapture:(UIButton *)button { // 开始推流 |
| 123 | + | |
| 123 | 124 | [_quitButton removeFromSuperview]; |
| 125 | + | |
| 126 | + _isStreaming = YES; | |
| 127 | + | |
| 124 | 128 | [_prepareView removeFromSuperview]; |
| 125 | 129 | |
| 126 | 130 | [_kitCN startStream:^{ |
| ... | ... | @@ -192,19 +196,31 @@ |
| 192 | 196 | |
| 193 | 197 | - (void)quitBtnClick { // 退出 |
| 194 | 198 | |
| 199 | + if (_isStreaming) { | |
| 200 | + [self.view addSubview:self.endView]; | |
| 201 | + } else { | |
| 202 | + if (_kitCN.captureState == CNLiveCaptureStateCapturing) { | |
| 203 | + [_kitCN stopPreview]; | |
| 204 | + } | |
| 205 | + [self dismissViewControllerAnimated:YES completion:nil]; | |
| 206 | + } | |
| 207 | +} | |
| 208 | + | |
| 209 | +- (void)continueButtonClick { | |
| 210 | + | |
| 211 | + [_endView removeFromSuperview]; | |
| 212 | +} | |
| 213 | + | |
| 214 | +- (void)endButtonClick { | |
| 215 | + | |
| 195 | 216 | if (_kitCN.streamState == CNLiveStreamStateConnected) { |
| 196 | 217 | [_kitCN stopStream]; |
| 197 | 218 | } |
| 198 | - if (_kitCN.captureState == CNLiveCaptureStateCapturing) { | |
| 199 | - [_kitCN stopPreview]; | |
| 200 | - } | |
| 201 | - | |
| 202 | 219 | [self dismissViewControllerAnimated:YES completion:nil]; |
| 203 | 220 | } |
| 204 | 221 | |
| 205 | 222 | |
| 206 | -#pragma mark - UIGestureRecognizer Action !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
| 207 | - | |
| 223 | +#pragma mark - UIGestureRecognizer Action !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
| 208 | 224 | - (void)onTap:(UIGestureRecognizer *)sender { //对焦与曝光 |
| 209 | 225 | |
| 210 | 226 | CGPoint current = [sender locationInView:self.view]; |
| ... | ... | @@ -217,8 +233,7 @@ |
| 217 | 233 | } |
| 218 | 234 | } |
| 219 | 235 | |
| 220 | -#pragma mark - notification !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
| 221 | - | |
| 236 | +#pragma mark - notification !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
| 222 | 237 | - (void)enterBg { // 进入后台 |
| 223 | 238 | |
| 224 | 239 | [_kitCN appEnterBackground]; |
| ... | ... | @@ -481,6 +496,18 @@ |
| 481 | 496 | return _openFilterButton; |
| 482 | 497 | } |
| 483 | 498 | |
| 499 | +- (LVCUGCLiveEndView *)endView { | |
| 500 | + | |
| 501 | + if (!_endView) { | |
| 502 | + _endView = [[LVCUGCLiveEndView alloc] initWithFrame:CGRectMake(20, SCREEN_HEIGHT * 0.3, SCREEN_WIDTH - 40, SCREEN_WIDTH - 40)]; | |
| 503 | + _endView.layer.cornerRadius = 20; | |
| 504 | + _endView.layer.masksToBounds = YES; | |
| 505 | + [_endView.continueButton addTarget:self action:@selector(continueButtonClick) forControlEvents:UIControlEventTouchUpInside]; | |
| 506 | + [_endView.endButton addTarget:self action:@selector(endButtonClick) forControlEvents:UIControlEventTouchUpInside]; | |
| 507 | + } | |
| 508 | + return _endView; | |
| 509 | +} | |
| 510 | + | |
| 484 | 511 | #pragma mark - Action !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 485 | 512 | - (void)addObservers { |
| 486 | 513 | |
| ... | ... | @@ -502,25 +529,6 @@ |
| 502 | 529 | object:nil]; |
| 503 | 530 | } |
| 504 | 531 | |
| 505 | -- (UIButton *)addButton:(NSString*)title | |
| 506 | - frame:(CGRect)frame | |
| 507 | - action:(SEL)action { | |
| 508 | - UIButton * button; | |
| 509 | - button = [UIButton buttonWithType:UIButtonTypeCustom]; | |
| 510 | - button.frame = frame; | |
| 511 | - [button setTitle: title forState: UIControlStateNormal]; | |
| 512 | - [button addTarget:self action:action forControlEvents:UIControlEventTouchUpInside]; | |
| 513 | - button.titleLabel.font = [UIFont systemFontOfSize:15]; | |
| 514 | - [button setTitleColor:[UIColor colorWithRed:23/255.0 green:110/255.0 blue:254/255.0 alpha:1] forState:UIControlStateNormal]; | |
| 515 | - button.layer.cornerRadius = 10; | |
| 516 | - button.layer.masksToBounds = YES; | |
| 517 | - button.layer.borderColor = [UIColor blackColor].CGColor; | |
| 518 | - button.layer.borderWidth = 1; | |
| 519 | - [self.captureView addSubview:button]; | |
| 520 | - return button; | |
| 521 | - | |
| 522 | -} | |
| 523 | - | |
| 524 | 532 | - (UIButton *)createButtonWithFrame:(CGRect)frame image:(NSString *)image selected:(NSString *)selected { |
| 525 | 533 | |
| 526 | 534 | UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom]; | ... | ... |
LiveVideoCloud/LiveVideoCloud/Classes/Sections/LiveSections/View/LVCUGCLiveEndView.h
0 → 100644
| 1 | +// | |
| 2 | +// LVCUGCLiveEndView.h | |
| 3 | +// LiveVideoCloud | |
| 4 | +// | |
| 5 | +// Created by cnliveJunBo on 17/3/27. | |
| 6 | +// Copyright © 2017年 cnlive. All rights reserved. | |
| 7 | +// | |
| 8 | + | |
| 9 | +#import <UIKit/UIKit.h> | |
| 10 | + | |
| 11 | +@interface LVCUGCLiveEndView : UIView | |
| 12 | + | |
| 13 | +@property (nonatomic, strong) UIButton *continueButton; | |
| 14 | + | |
| 15 | +@property (nonatomic, strong) UIButton *endButton; | |
| 16 | + | |
| 17 | +@end | ... | ... |
LiveVideoCloud/LiveVideoCloud/Classes/Sections/LiveSections/View/LVCUGCLiveEndView.m
0 → 100644
| 1 | +// | |
| 2 | +// LVCUGCLiveEndView.m | |
| 3 | +// LiveVideoCloud | |
| 4 | +// | |
| 5 | +// Created by cnliveJunBo on 17/3/27. | |
| 6 | +// Copyright © 2017年 cnlive. All rights reserved. | |
| 7 | +// | |
| 8 | + | |
| 9 | +#import "LVCUGCLiveEndView.h" | |
| 10 | + | |
| 11 | +#define selfLength self.bounds.size.width | |
| 12 | + | |
| 13 | +@interface LVCUGCLiveEndView() | |
| 14 | + | |
| 15 | +@property (nonatomic, strong) UIImageView *iconView; | |
| 16 | + | |
| 17 | +@property (nonatomic, strong) UILabel *infoLabel; | |
| 18 | +@property (nonatomic, strong) UILabel *attentionLabel; | |
| 19 | + | |
| 20 | +@end | |
| 21 | + | |
| 22 | +@implementation LVCUGCLiveEndView | |
| 23 | + | |
| 24 | +- (instancetype)initWithFrame:(CGRect)frame | |
| 25 | +{ | |
| 26 | + self = [super initWithFrame:frame]; | |
| 27 | + if (self) { | |
| 28 | + self.backgroundColor = [UIColor whiteColor]; | |
| 29 | + [self addSubview:self.iconView]; | |
| 30 | + [self addSubview:self.infoLabel]; | |
| 31 | + [self addSubview:self.attentionLabel]; | |
| 32 | + [self addSubview:self.continueButton]; | |
| 33 | + [self addSubview:self.endButton]; | |
| 34 | + } | |
| 35 | + return self; | |
| 36 | +} | |
| 37 | + | |
| 38 | +#pragma mark - GetMethod !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
| 39 | +- (UIImageView *)iconView { | |
| 40 | + | |
| 41 | + if (!_iconView) { | |
| 42 | + NSString *path = [[NSBundle mainBundle] pathForResource:@"头像" ofType:@"jpg"]; | |
| 43 | + UIImage *image = [UIImage imageWithContentsOfFile:path]; | |
| 44 | + _iconView = [[UIImageView alloc] initWithImage:image]; | |
| 45 | + _iconView.frame = CGRectMake((selfLength - 50) * 0.5, 20, 50, 50); | |
| 46 | + _iconView.layer.cornerRadius = 25; | |
| 47 | + _iconView.layer.masksToBounds = YES; | |
| 48 | + } | |
| 49 | + return _iconView; | |
| 50 | +} | |
| 51 | + | |
| 52 | +- (UILabel *)infoLabel { | |
| 53 | + | |
| 54 | + if (!_infoLabel) { | |
| 55 | + _infoLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, selfLength * 0.3, selfLength, 20)]; | |
| 56 | + _infoLabel.text = @"10000人看过你的直播~"; | |
| 57 | + _infoLabel.textAlignment = NSTextAlignmentCenter; | |
| 58 | + _infoLabel.textColor = [UIColor grayColor]; | |
| 59 | + } | |
| 60 | + return _infoLabel; | |
| 61 | +} | |
| 62 | + | |
| 63 | +- (UILabel *)attentionLabel { | |
| 64 | + | |
| 65 | + if (!_attentionLabel) { | |
| 66 | + _attentionLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, selfLength * 0.5, selfLength, 30)]; | |
| 67 | + _attentionLabel.text = @"确定要结束直播吗?"; | |
| 68 | + _attentionLabel.textAlignment = NSTextAlignmentCenter; | |
| 69 | + _attentionLabel.textColor = [UIColor orangeColor]; | |
| 70 | + _attentionLabel.font = [UIFont systemFontOfSize:21]; | |
| 71 | + } | |
| 72 | + return _attentionLabel; | |
| 73 | +} | |
| 74 | + | |
| 75 | +- (UIButton *)continueButton { | |
| 76 | + | |
| 77 | + if (!_continueButton) { | |
| 78 | + _continueButton = [UIButton buttonWithType:UIButtonTypeCustom]; | |
| 79 | + _continueButton.frame = CGRectMake(15, selfLength * 0.7, selfLength * 0.4, 35); | |
| 80 | + [_continueButton setTitle:@"继续" forState:UIControlStateNormal]; | |
| 81 | + [_continueButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; | |
| 82 | + [_continueButton setTitleColor:[UIColor blackColor] forState:UIControlStateHighlighted]; | |
| 83 | + _continueButton.backgroundColor = [UIColor redColor]; | |
| 84 | + _continueButton.layer.cornerRadius = 17.5; | |
| 85 | + _continueButton.layer.masksToBounds = YES; | |
| 86 | + } | |
| 87 | + return _continueButton; | |
| 88 | +} | |
| 89 | + | |
| 90 | +- (UIButton *)endButton { | |
| 91 | + | |
| 92 | + if (!_endButton) { | |
| 93 | + _endButton = [UIButton buttonWithType:UIButtonTypeCustom]; | |
| 94 | + _endButton.frame = CGRectMake(selfLength * 0.6 - 15, selfLength * 0.7, selfLength * 0.4, 35); | |
| 95 | + [_endButton setTitle:@"结束" forState:UIControlStateNormal]; | |
| 96 | + [_endButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; | |
| 97 | + [_endButton setTitleColor:[UIColor blackColor] forState:UIControlStateHighlighted]; | |
| 98 | + _endButton.backgroundColor = [UIColor redColor]; | |
| 99 | + _endButton.layer.cornerRadius = 17.5; | |
| 100 | + _endButton.layer.masksToBounds = YES; | |
| 101 | + } | |
| 102 | + return _endButton; | |
| 103 | +} | |
| 104 | + | |
| 105 | +@end | ... | ... |
LiveVideoCloud/LiveVideoCloud/Classes/Sections/LiveSections/View/LVCUGCLivePrepareView.m
| ... | ... | @@ -49,11 +49,9 @@ |
| 49 | 49 | |
| 50 | 50 | if (!_titleTextField) { |
| 51 | 51 | _titleTextField = [[UITextField alloc] initWithFrame:CGRectMake(110, SCREEN_HEIGHT * 0.35 + 50, SCREEN_WIDTH - 120, 30)]; |
| 52 | - | |
| 53 | - NSMutableAttributedString *placeholder = [[NSMutableAttributedString alloc]initWithString:@"起个名字开始直播~"]; | |
| 54 | - | |
| 55 | - | |
| 56 | - _titleTextField.attributedPlaceholder = placeholder; | |
| 52 | + | |
| 53 | + UIColor *color = [UIColor colorWithRed:23/255.0 green:110/255.0 blue:254/255.0 alpha:1]; | |
| 54 | + _titleTextField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@"起个名字开始直播~" attributes:@{NSForegroundColorAttributeName: color}]; | |
| 57 | 55 | |
| 58 | 56 | _titleTextField.font = [UIFont systemFontOfSize:19]; |
| 59 | 57 | } | ... | ... |
LiveVideoCloud/LiveVideoCloud/Classes/Sections/homeSections/Controller/HomeViewController.m
| ... | ... | @@ -11,6 +11,7 @@ |
| 11 | 11 | #import "LVCLivePlayerController.h" |
| 12 | 12 | #import "LVCUGCLivePlayerController.h" |
| 13 | 13 | #import "LVCTVLiveViewController.h" |
| 14 | +#import "LVCUGCLiveListController.h" | |
| 14 | 15 | |
| 15 | 16 | @interface HomeViewController () |
| 16 | 17 | |
| ... | ... | @@ -35,6 +36,12 @@ |
| 35 | 36 | [UGCLiveBtn setTitle:@"UGC直播" forState:UIControlStateNormal]; |
| 36 | 37 | [UGCLiveBtn addTarget:self action:@selector(UGCLiveAction) forControlEvents:UIControlEventTouchUpInside]; |
| 37 | 38 | [self.view addSubview:UGCLiveBtn]; |
| 39 | + | |
| 40 | + UIButton *UGCLiveListBtn = [UIButton buttonWithType:UIButtonTypeCustom]; | |
| 41 | + UGCLiveListBtn.frame = CGRectMake(0, 300, self.view.width, 40); | |
| 42 | + [UGCLiveListBtn setTitle:@"UGC直播列表" forState:UIControlStateNormal]; | |
| 43 | + [UGCLiveListBtn addTarget:self action:@selector(UGCLiveListAction) forControlEvents:UIControlEventTouchUpInside]; | |
| 44 | + [self.view addSubview:UGCLiveListBtn]; | |
| 38 | 45 | } |
| 39 | 46 | |
| 40 | 47 | - (void)liveAction |
| ... | ... | @@ -50,6 +57,12 @@ |
| 50 | 57 | [self.navigationController pushViewController:UGCLiveVC animated:YES]; |
| 51 | 58 | } |
| 52 | 59 | |
| 60 | +- (void)UGCLiveListAction | |
| 61 | +{ | |
| 62 | + LVCUGCLiveListController *listVC = [[LVCUGCLiveListController alloc] init]; | |
| 63 | + [self.navigationController pushViewController:listVC animated:YES]; | |
| 64 | +} | |
| 65 | + | |
| 53 | 66 | - (void)didReceiveMemoryWarning { |
| 54 | 67 | [super didReceiveMemoryWarning]; |
| 55 | 68 | // Dispose of any resources that can be recreated. | ... | ... |
LiveVideoCloud/LiveVideoCloud/Classes/Sections/homeSections/Controller/LVCUGCLiveListController.h
0 → 100644
LiveVideoCloud/LiveVideoCloud/Classes/Sections/homeSections/Controller/LVCUGCLiveListController.m
0 → 100644
| 1 | +// | |
| 2 | +// LVCUGCLiveListController.m | |
| 3 | +// LiveVideoCloud | |
| 4 | +// | |
| 5 | +// Created by cnliveJunBo on 17/3/27. | |
| 6 | +// Copyright © 2017年 cnlive. All rights reserved. | |
| 7 | +// | |
| 8 | + | |
| 9 | +#import "LVCUGCLiveListController.h" | |
| 10 | +#import "CommonCrypto/CommonDigest.h" | |
| 11 | + | |
| 12 | +@interface LVCUGCLiveListController () | |
| 13 | + | |
| 14 | +@end | |
| 15 | + | |
| 16 | +@implementation LVCUGCLiveListController | |
| 17 | + | |
| 18 | +- (void)viewDidLoad { | |
| 19 | + [super viewDidLoad]; | |
| 20 | + self.view.backgroundColor = [UIColor whiteColor]; | |
| 21 | + | |
| 22 | + [self loadData]; | |
| 23 | +} | |
| 24 | + | |
| 25 | +- (void)loadData { | |
| 26 | + | |
| 27 | + NSInteger time = [[NSDate date] timeIntervalSince1970]; | |
| 28 | + NSString *timeString = [NSString stringWithFormat:@"%ld", (long)time]; | |
| 29 | + NSMutableDictionary *parameter=[@{@"platform_id": [NSBundle mainBundle].bundleIdentifier, | |
| 30 | + @"timestamp": timeString, | |
| 31 | + @"appId": AppId} mutableCopy]; | |
| 32 | + NSString *string = [NSString stringWithFormat:@"%@&key=%@", [self sortParameters:parameter], AppKey]; | |
| 33 | + NSString *signString = [[self sha1:string] uppercaseString]; | |
| 34 | + [parameter setObject:signString forKey:@"sign"]; | |
| 35 | + | |
| 36 | + [[AFHTTPSessionManager manager] GET:@"http://api.cnlive.com/open/api2/live_epg/sp/activityList4App" parameters:parameter progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) { | |
| 37 | + | |
| 38 | + NSLog(@"%@",responseObject); | |
| 39 | + | |
| 40 | + } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) { | |
| 41 | + | |
| 42 | + NSLog(@"%@",error); | |
| 43 | + }]; | |
| 44 | + | |
| 45 | +} | |
| 46 | + | |
| 47 | +//sha1加密 | |
| 48 | +- (NSString*)sha1:(NSString *)string | |
| 49 | +{ | |
| 50 | + NSData *data = [string dataUsingEncoding:NSUTF8StringEncoding]; | |
| 51 | + | |
| 52 | + uint8_t digest[CC_SHA1_DIGEST_LENGTH]; | |
| 53 | + | |
| 54 | + CC_SHA1(data.bytes, data.length, digest); | |
| 55 | + | |
| 56 | + NSMutableString* output = [NSMutableString stringWithCapacity:CC_SHA1_DIGEST_LENGTH * 2]; | |
| 57 | + | |
| 58 | + for(int i = 0; i < CC_SHA1_DIGEST_LENGTH; i++) | |
| 59 | + [output appendFormat:@"%02x", digest[i]]; | |
| 60 | + | |
| 61 | + while ([[output substringToIndex:1] isEqualToString:@"0"]) { | |
| 62 | + output = [[NSMutableString alloc] initWithString:[output substringFromIndex:1]]; | |
| 63 | + } | |
| 64 | + | |
| 65 | + return output; | |
| 66 | +} | |
| 67 | +//参数排序 | |
| 68 | +- (NSString *)sortParameters:(NSDictionary*)parameters | |
| 69 | +{ | |
| 70 | + //对所有传入参数按照字段名的 ASCII 码从小到大排序 | |
| 71 | + NSArray *keyArr=[parameters allKeys]; | |
| 72 | + NSArray *arr = [keyArr sortedArrayUsingSelector:@selector(compare:)]; | |
| 73 | + | |
| 74 | + NSMutableString *string1 = [[NSMutableString alloc]init]; | |
| 75 | + for (int i=0; i<arr.count; i++) { | |
| 76 | + | |
| 77 | + NSString *parametersString = parameters[[arr objectAtIndex:i]]; | |
| 78 | + if (parametersString.length > 0) { | |
| 79 | + [string1 appendString:[NSString stringWithFormat:@"%@=%@&",[arr objectAtIndex:i],parameters[[arr objectAtIndex:i]]]]; | |
| 80 | + } | |
| 81 | + } | |
| 82 | + | |
| 83 | + if (string1.length > 0) { | |
| 84 | + [string1 deleteCharactersInRange:NSMakeRange(string1.length-1, 1)]; | |
| 85 | + } | |
| 86 | + | |
| 87 | + return string1; | |
| 88 | +} | |
| 89 | + | |
| 90 | +- (void)didReceiveMemoryWarning { | |
| 91 | + [super didReceiveMemoryWarning]; | |
| 92 | + // Dispose of any resources that can be recreated. | |
| 93 | +} | |
| 94 | + | |
| 95 | +@end | ... | ... |
LiveVideoCloud/LiveVideoCloud/Classes/Sections/homeSections/Controller/LVCUGCLivePlayerController.m
| ... | ... | @@ -10,18 +10,16 @@ |
| 10 | 10 | #import <CNLivePlayerSDK/CNLiveWebcastManager.h> |
| 11 | 11 | #import "LVCUGCPlayerLoadingView.h" |
| 12 | 12 | #import "LVCUGCBackgroundView.h" |
| 13 | +#import "LVCUGCLivePlayerCell.h" | |
| 13 | 14 | |
| 14 | -#define KAppId @"60_irn9edco29" | |
| 15 | -#define KAppKey @"69fe70bda67e059286ad509d9f5377f815955645b52f94" | |
| 15 | +static NSString *cellId = @"cellId"; | |
| 16 | 16 | |
| 17 | -@interface LVCUGCLivePlayerController () | |
| 17 | +@interface LVCUGCLivePlayerController ()<UICollectionViewDelegate, UICollectionViewDataSource> | |
| 18 | 18 | |
| 19 | -@property (nonatomic, strong) CNLiveMoviePlayerController *player;// 播放器 | |
| 19 | +@property (nonatomic, strong) UICollectionView *collectionView; | |
| 20 | 20 | |
| 21 | 21 | @property (nonatomic, strong) LVCUGCBackgroundView *bgView; // 背景视图 |
| 22 | 22 | |
| 23 | -@property (nonatomic, strong) LVCUGCPlayerLoadingView *loadingView; // 加载视图 | |
| 24 | - | |
| 25 | 23 | @end |
| 26 | 24 | |
| 27 | 25 | @implementation LVCUGCLivePlayerController |
| ... | ... | @@ -45,226 +43,62 @@ |
| 45 | 43 | |
| 46 | 44 | self.view.backgroundColor = [UIColor whiteColor]; |
| 47 | 45 | |
| 48 | - [self.view addSubview:self.loadingView]; | |
| 49 | 46 | [self.view addSubview:self.bgView]; |
| 47 | + [self.view addSubview:self.collectionView]; | |
| 50 | 48 | |
| 51 | - //添加播放器通知 | |
| 52 | - [self installMovieNotificationObservers]; | |
| 53 | - | |
| 54 | - [[CNLiveWebcastManager manager] initWithAppId:KAppId appKey:KAppKey]; | |
| 55 | - | |
| 56 | - //直播播放 | |
| 57 | - _player = [[CNLiveMoviePlayerController alloc] initLivePlayWithChannelId:@"iOStest" | |
| 58 | - authSuccess:^{ | |
| 59 | - | |
| 60 | - _player.videoDecoderMode = CNLiveMovieVideoDecoderMode_AUTO; | |
| 61 | - _player.view.frame = self.view.bounds; | |
| 62 | - _player.shouldAutoplay = YES; | |
| 63 | - [_player prepareToPlay]; | |
| 64 | - [self.view addSubview:_player.view]; | |
| 65 | - [self.view sendSubviewToBack:_player.view]; | |
| 66 | - | |
| 67 | - } authFailed:^(NSDictionary *errorInfo) { | |
| 68 | - NSLog(@"初始化直播播放器失败:%@", errorInfo); | |
| 69 | - | |
| 70 | - | |
| 71 | - } getAnchorStatusResult:^(BOOL result) { | |
| 72 | - | |
| 73 | - NSLog(@"-------------获取主播状态%d", result ? YES : NO); | |
| 74 | - | |
| 75 | - }]; | |
| 76 | 49 | } |
| 77 | 50 | |
| 78 | -#pragma mark - 添加通知监听 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
| 79 | --(void)installMovieNotificationObservers //添加视频播放通知 | |
| 80 | -{ | |
| 81 | - //视频加载状态改变 | |
| 82 | - [[NSNotificationCenter defaultCenter] addObserver:self | |
| 83 | - selector:@selector(loadStateDidChange:) | |
| 84 | - name:MPMoviePlayerLoadStateDidChangeNotification | |
| 85 | - object:nil]; | |
| 86 | - | |
| 87 | - //视频播放错误及结束原因 | |
| 88 | - [[NSNotificationCenter defaultCenter] addObserver:self | |
| 89 | - selector:@selector(moviePlayBackDidFinish:) | |
| 90 | - name:MPMoviePlayerPlaybackDidFinishNotification | |
| 91 | - object:nil]; | |
| 92 | - | |
| 93 | - //视频缓冲至可播放状态 | |
| 94 | - [[NSNotificationCenter defaultCenter] addObserver:self | |
| 95 | - selector:@selector(mediaIsPreparedToPlayDidChange:) | |
| 96 | - name:MPMediaPlaybackIsPreparedToPlayDidChangeNotification | |
| 97 | - object:nil]; | |
| 98 | - | |
| 99 | - //视频播放状态改变 | |
| 100 | - [[NSNotificationCenter defaultCenter] addObserver:self | |
| 101 | - selector:@selector(moviePlayBackStateDidChange:) | |
| 102 | - name:MPMoviePlayerPlaybackStateDidChangeNotification | |
| 103 | - object:nil]; | |
| 104 | - | |
| 105 | - | |
| 106 | - //获取主播状态通知(点播和普通播放不需要注册该通知) | |
| 107 | - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(anchorStatusChanged:) | |
| 108 | - name:CNLiveAnchorStatusChangedNotification | |
| 109 | - object:nil]; | |
| 51 | +#pragma mark - UICollectionViewDelegate, UICollectionViewDataSource !!!!!!!!!!!!!!!!!!!!!!!!!!! | |
| 52 | +- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView { | |
| 110 | 53 | |
| 54 | + return 1; | |
| 111 | 55 | } |
| 112 | 56 | |
| 113 | -#pragma mark - 移除通知 | |
| 114 | -- (void)removeMovieNotificationObservers | |
| 115 | -{ | |
| 116 | - [[NSNotificationCenter defaultCenter]removeObserver:self | |
| 117 | - name:MPMoviePlayerLoadStateDidChangeNotification | |
| 118 | - object:nil]; | |
| 119 | - [[NSNotificationCenter defaultCenter]removeObserver:self | |
| 120 | - name:MPMoviePlayerPlaybackDidFinishNotification | |
| 121 | - object:nil]; | |
| 122 | - [[NSNotificationCenter defaultCenter]removeObserver:self | |
| 123 | - name:MPMediaPlaybackIsPreparedToPlayDidChangeNotification | |
| 124 | - object:nil]; | |
| 125 | - [[NSNotificationCenter defaultCenter]removeObserver:self | |
| 126 | - name:MPMoviePlayerPlaybackStateDidChangeNotification | |
| 127 | - object:nil]; | |
| 57 | +- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section { | |
| 128 | 58 | |
| 129 | - [[NSNotificationCenter defaultCenter]removeObserver:self | |
| 130 | - name:CNLiveAnchorStatusChangedNotification | |
| 131 | - object:nil]; | |
| 132 | -} | |
| 133 | - | |
| 134 | -#pragma mark - 通知 Action !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
| 135 | -//视频加载状态改变 | |
| 136 | -- (void)loadStateDidChange:(NSNotification *)notification | |
| 137 | -{ | |
| 138 | - if (_player) { | |
| 139 | - MPMovieLoadState loadState = _player.loadState; | |
| 140 | - if ((loadState & MPMovieLoadStatePlaythroughOK) != 0) { | |
| 141 | - | |
| 142 | - NSLog(@"loadStateDidChange: MPMovieLoadStatePlaythroughOK: %d\n", (int)loadState); | |
| 143 | - | |
| 144 | - } else if ((loadState & MPMovieLoadStateStalled) != 0) { | |
| 145 | - NSLog(@"loadStateDidChange: MPMovieLoadStateStalled: %d\n", (int)loadState); | |
| 146 | - | |
| 147 | - } else { | |
| 148 | - NSLog(@"loadStateDidChange: ???: %d\n", (int)loadState); | |
| 149 | - } | |
| 150 | - } | |
| 151 | -} | |
| 152 | - | |
| 153 | -//视频播放错误及结束原因 | |
| 154 | -- (void)moviePlayBackDidFinish:(NSNotification *)notification | |
| 155 | -{ | |
| 156 | - if (_player) { | |
| 157 | - int reason = [[[notification userInfo] valueForKey:MPMoviePlayerPlaybackDidFinishReasonUserInfoKey] intValue]; | |
| 158 | - if (MPMovieFinishReasonPlaybackError == reason) { | |
| 159 | - | |
| 160 | - | |
| 161 | - } else { | |
| 162 | - | |
| 163 | - } | |
| 164 | - | |
| 165 | - switch (reason) | |
| 166 | - { | |
| 167 | - case MPMovieFinishReasonPlaybackEnded: | |
| 168 | - NSLog(@"playbackStateDidChange: MPMovieFinishReasonPlaybackEnded: %d\n", reason); | |
| 169 | - break; | |
| 170 | - | |
| 171 | - case MPMovieFinishReasonUserExited: | |
| 172 | - NSLog(@"playbackStateDidChange: MPMovieFinishReasonUserExited: %d\n", reason); | |
| 173 | - break; | |
| 174 | - | |
| 175 | - case MPMovieFinishReasonPlaybackError: | |
| 176 | - NSLog(@"playbackStateDidChange: MPMovieFinishReasonPlaybackError: %d\n", reason); | |
| 177 | - break; | |
| 178 | - | |
| 179 | - default: | |
| 180 | - NSLog(@"playbackPlayBackDidFinish: ???: %d\n", reason); | |
| 181 | - break; | |
| 182 | - } | |
| 183 | - } | |
| 184 | -} | |
| 185 | - | |
| 186 | -//视频缓冲至可播放状态 | |
| 187 | -- (void)mediaIsPreparedToPlayDidChange:(NSNotification *)notification | |
| 188 | -{ | |
| 189 | - if (_player) { | |
| 190 | - NSLog(@"isPreparedToPlay"); | |
| 191 | - if (_loadingView) { | |
| 192 | - [_loadingView removeFromSuperview]; | |
| 193 | - } | |
| 194 | - } | |
| 59 | + return 4; | |
| 195 | 60 | } |
| 196 | 61 | |
| 197 | -//视频播放状态改变 | |
| 198 | -- (void)moviePlayBackStateDidChange:(NSNotification *)notification | |
| 199 | -{ | |
| 200 | - if (_player) { | |
| 201 | - | |
| 202 | - switch (_player.playbackState) { | |
| 203 | - case MPMoviePlaybackStateStopped: { | |
| 204 | - | |
| 205 | - NSLog(@"moviePlayBackStateDidChange : MPMoviePlaybackStateStopped"); | |
| 206 | - break; | |
| 207 | - } | |
| 208 | - case MPMoviePlaybackStatePlaying: { | |
| 209 | - | |
| 210 | - NSLog(@"moviePlayBackStateDidChange : MPMoviePlaybackStatePlaying"); | |
| 211 | - break; | |
| 212 | - } | |
| 213 | - case MPMoviePlaybackStatePaused: | |
| 214 | - | |
| 215 | - NSLog(@"moviePlayBackStateDidChange : MPMoviePlaybackStatePaused"); | |
| 216 | - break; | |
| 217 | - case MPMoviePlaybackStateInterrupted: | |
| 218 | - | |
| 219 | - NSLog(@"moviePlayBackStateDidChange : MPMoviePlaybackStateInterrupted"); | |
| 220 | - break; | |
| 221 | - case MPMoviePlaybackStateSeekingForward: | |
| 222 | - | |
| 223 | - NSLog(@"moviePlayBackStateDidChange : MPMoviePlaybackStateSeekingForward"); | |
| 224 | - break; | |
| 225 | - case MPMoviePlaybackStateSeekingBackward: | |
| 226 | - | |
| 227 | - NSLog(@"moviePlayBackStateDidChange : MPMoviePlaybackStateSeekingBackward"); | |
| 228 | - break; | |
| 229 | - default: | |
| 230 | - | |
| 231 | - NSLog(@"moviePlayBackStateDidChange : %ld", (long)_player.playbackState); | |
| 232 | - break; | |
| 233 | - } | |
| 234 | - } | |
| 62 | +- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { | |
| 63 | + | |
| 64 | + LVCUGCLivePlayerCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:cellId forIndexPath:indexPath]; | |
| 65 | + | |
| 66 | + return cell; | |
| 235 | 67 | } |
| 236 | 68 | |
| 237 | - | |
| 238 | - | |
| 239 | -// 获取主播状态通知 | |
| 240 | -- (void)anchorStatusChanged:(NSNotification *)notification | |
| 241 | -{ | |
| 242 | - if (_player.anchorStatus == 2) { // 已结束 | |
| 243 | - | |
| 244 | - } | |
| 245 | - _bgView.anchorStatus = _player.anchorStatus; | |
| 69 | +- (void)scrollViewDidScroll:(UIScrollView *)scrollView { | |
| 70 | + | |
| 71 | + NSLog(@"一直"); | |
| 246 | 72 | } |
| 247 | 73 | |
| 248 | -//重新连接获取主播状态 | |
| 249 | -- (void)anchorStatusConnectFailed | |
| 250 | -{ | |
| 74 | +- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView { | |
| 251 | 75 | |
| 76 | + NSLog(@"停止"); | |
| 252 | 77 | } |
| 253 | 78 | |
| 254 | -#pragma mark - getter | |
| 255 | -- (LVCUGCPlayerLoadingView *)loadingView { | |
| 256 | - | |
| 257 | - if (!_loadingView) { | |
| 258 | - _loadingView = [[LVCUGCPlayerLoadingView alloc] initWithFrame:self.view.bounds bgImageURLStr:@""]; | |
| 79 | + | |
| 80 | +#pragma mark - getMethod !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
| 81 | +- (UICollectionView *)collectionView { | |
| 82 | + | |
| 83 | + if (!_collectionView) { | |
| 84 | + UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init]; | |
| 85 | + layout.minimumLineSpacing = 0; | |
| 86 | + layout.minimumInteritemSpacing = 0; | |
| 87 | + layout.itemSize = self.view.bounds.size; | |
| 88 | + _collectionView = [[UICollectionView alloc] initWithFrame:self.view.bounds collectionViewLayout:layout]; | |
| 89 | + _collectionView.pagingEnabled = YES; | |
| 90 | + _collectionView.showsHorizontalScrollIndicator = NO; | |
| 91 | + _collectionView.dataSource = self; | |
| 92 | + _collectionView.delegate = self; | |
| 93 | + [_collectionView registerClass:[LVCUGCLivePlayerCell class] forCellWithReuseIdentifier:cellId]; | |
| 259 | 94 | } |
| 260 | - return _loadingView; | |
| 95 | + return _collectionView; | |
| 261 | 96 | } |
| 262 | 97 | |
| 263 | 98 | - (LVCUGCBackgroundView *)bgView { |
| 264 | 99 | |
| 265 | 100 | if (!_bgView) { |
| 266 | - _bgView = [[LVCUGCBackgroundView alloc] init]; | |
| 267 | - _bgView.backgroundColor = [UIColor whiteColor]; | |
| 101 | + _bgView = [[LVCUGCBackgroundView alloc] initWithFrame:self.view.bounds]; | |
| 268 | 102 | _bgView.hidden = YES; |
| 269 | 103 | } |
| 270 | 104 | return _bgView; | ... | ... |
LiveVideoCloud/LiveVideoCloud/Classes/Sections/homeSections/Model/LVCUGCLivePlayerModel.h
0 → 100644
LiveVideoCloud/LiveVideoCloud/Classes/Sections/homeSections/Model/LVCUGCLivePlayerModel.m
0 → 100644
LiveVideoCloud/LiveVideoCloud/Classes/Sections/homeSections/View/LVCUGCBackgroundView.h
LiveVideoCloud/LiveVideoCloud/Classes/Sections/homeSections/View/LVCUGCBackgroundView.m
| ... | ... | @@ -16,8 +16,6 @@ |
| 16 | 16 | |
| 17 | 17 | @property (nonatomic, strong) UILabel *playInfoLabel; |
| 18 | 18 | |
| 19 | -@property (nonatomic, strong) UIButton *backButton; | |
| 20 | - | |
| 21 | 19 | @end |
| 22 | 20 | |
| 23 | 21 | @implementation LVCUGCBackgroundView |
| ... | ... | @@ -27,6 +25,7 @@ |
| 27 | 25 | { |
| 28 | 26 | self = [super initWithFrame:frame]; |
| 29 | 27 | if (self) { |
| 28 | + self.backgroundColor = [UIColor whiteColor]; | |
| 30 | 29 | [self addSubview:self.iconView]; |
| 31 | 30 | [self addSubview:self.nicknameLabel]; |
| 32 | 31 | [self addSubview:self.playInfoLabel]; |
| ... | ... | @@ -66,7 +65,7 @@ |
| 66 | 65 | NSString *path = [[NSBundle mainBundle] pathForResource:@"头像" ofType:@"jpg"]; |
| 67 | 66 | UIImage *image = [UIImage imageWithContentsOfFile:path]; |
| 68 | 67 | _iconView = [[UIImageView alloc] initWithImage:image]; |
| 69 | - _iconView.frame = CGRectMake((SCREEN_WIDTH - 100) * 0.5, 200, 100, 100); | |
| 68 | + _iconView.frame = CGRectMake((SCREEN_WIDTH - 100) * 0.5, SCREEN_HEIGHT * 0.2, 100, 100); | |
| 70 | 69 | _iconView.layer.cornerRadius = 50; |
| 71 | 70 | _iconView.layer.masksToBounds = YES; |
| 72 | 71 | } |
| ... | ... | @@ -76,9 +75,9 @@ |
| 76 | 75 | - (UILabel *)nicknameLabel { |
| 77 | 76 | |
| 78 | 77 | if (!_nicknameLabel) { |
| 79 | - _nicknameLabel = [[UILabel alloc] initWithFrame:CGRectMake((SCREEN_WIDTH - 100) * 0.5, 310, 100, 30)]; | |
| 78 | + _nicknameLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, SCREEN_HEIGHT * 0.2 + 110, SCREEN_WIDTH, 30)]; | |
| 80 | 79 | _nicknameLabel.textAlignment = NSTextAlignmentCenter; |
| 81 | - _nicknameLabel.text = @"奥斯卡大家发你看"; | |
| 80 | + _nicknameLabel.text = @"这是我的昵称哦"; | |
| 82 | 81 | } |
| 83 | 82 | return _nicknameLabel; |
| 84 | 83 | } |
| ... | ... | @@ -86,9 +85,10 @@ |
| 86 | 85 | - (UILabel *)playInfoLabel { |
| 87 | 86 | |
| 88 | 87 | if (!_playInfoLabel) { |
| 89 | - _playInfoLabel = [[UILabel alloc] initWithFrame:CGRectMake((SCREEN_WIDTH - 100) * 0.5, 350, 100, 50)]; | |
| 88 | + _playInfoLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, SCREEN_HEIGHT * 0.5, SCREEN_WIDTH, 30)]; | |
| 90 | 89 | _playInfoLabel.textAlignment = NSTextAlignmentCenter; |
| 91 | - _playInfoLabel.font = [UIFont systemFontOfSize:18]; | |
| 90 | + _playInfoLabel.font = [UIFont systemFontOfSize:22]; | |
| 91 | + _playInfoLabel.textColor = [UIColor orangeColor]; | |
| 92 | 92 | } |
| 93 | 93 | return _playInfoLabel; |
| 94 | 94 | } |
| ... | ... | @@ -97,12 +97,15 @@ |
| 97 | 97 | |
| 98 | 98 | if (!_backButton) { |
| 99 | 99 | _backButton = [UIButton buttonWithType:UIButtonTypeCustom]; |
| 100 | - _backButton.frame = CGRectMake((SCREEN_WIDTH - 200) * 0.5, 410, 200, 40); | |
| 100 | + _backButton.frame = CGRectMake(20, SCREEN_HEIGHT * 0.65, SCREEN_WIDTH - 40, 40); | |
| 101 | 101 | _backButton.layer.cornerRadius = 20; |
| 102 | 102 | _backButton.layer.masksToBounds = YES; |
| 103 | - _backButton.titleLabel.text = @"返回列表"; | |
| 103 | + [_backButton setTitle:@"返回列表" forState:UIControlStateNormal]; | |
| 104 | 104 | _backButton.titleLabel.textAlignment = NSTextAlignmentCenter; |
| 105 | - _backButton.titleLabel.font = [UIFont systemFontOfSize:18]; | |
| 105 | + _backButton.titleLabel.font = [UIFont systemFontOfSize:20]; | |
| 106 | + _backButton.backgroundColor = [UIColor redColor]; | |
| 107 | + [_backButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; | |
| 108 | + [_backButton setTitleColor:[UIColor blackColor] forState:UIControlStateHighlighted]; | |
| 106 | 109 | } |
| 107 | 110 | return _backButton; |
| 108 | 111 | } | ... | ... |
LiveVideoCloud/LiveVideoCloud/Classes/Sections/homeSections/View/LVCUGCLivePlayerCell.h
0 → 100644
| 1 | +// | |
| 2 | +// LVCUGCLivePlayerCell.h | |
| 3 | +// LiveVideoCloud | |
| 4 | +// | |
| 5 | +// Created by cnliveJunBo on 17/3/28. | |
| 6 | +// Copyright © 2017年 cnlive. All rights reserved. | |
| 7 | +// | |
| 8 | + | |
| 9 | +#import <UIKit/UIKit.h> | |
| 10 | +#import "LVCUGCPlayerLoadingView.h" | |
| 11 | + | |
| 12 | +@interface LVCUGCLivePlayerCell : UICollectionViewCell | |
| 13 | + | |
| 14 | +@property (nonatomic, strong) LVCUGCPlayerLoadingView *loadingView; | |
| 15 | + | |
| 16 | +@property (nonatomic, strong) CNLiveMoviePlayerController *player; // 播放器 | |
| 17 | + | |
| 18 | +@end | ... | ... |
LiveVideoCloud/LiveVideoCloud/Classes/Sections/homeSections/View/LVCUGCLivePlayerCell.m
0 → 100644
| 1 | +// | |
| 2 | +// LVCUGCLivePlayerCell.m | |
| 3 | +// LiveVideoCloud | |
| 4 | +// | |
| 5 | +// Created by cnliveJunBo on 17/3/28. | |
| 6 | +// Copyright © 2017年 cnlive. All rights reserved. | |
| 7 | +// | |
| 8 | + | |
| 9 | +#import "LVCUGCLivePlayerCell.h" | |
| 10 | + | |
| 11 | +@implementation LVCUGCLivePlayerCell | |
| 12 | + | |
| 13 | +- (instancetype)initWithFrame:(CGRect)frame | |
| 14 | +{ | |
| 15 | + self = [super initWithFrame:frame]; | |
| 16 | + if (self) { | |
| 17 | + self.contentView.backgroundColor = [UIColor whiteColor]; | |
| 18 | + | |
| 19 | + [self installMovieNotificationObservers]; | |
| 20 | + [self addSubview:self.loadingView]; | |
| 21 | + } | |
| 22 | + return self; | |
| 23 | +} | |
| 24 | + | |
| 25 | +#pragma mark - GetMethod !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
| 26 | +- (LVCUGCPlayerLoadingView *)loadingView { | |
| 27 | + | |
| 28 | + if (!_loadingView) { | |
| 29 | + _loadingView = [[LVCUGCPlayerLoadingView alloc] initWithFrame:self.contentView.bounds bgImageURLStr:@""]; | |
| 30 | + } | |
| 31 | + return _loadingView; | |
| 32 | +} | |
| 33 | + | |
| 34 | +- (CNLiveMoviePlayerController *)player { | |
| 35 | + | |
| 36 | + if (!_player) { | |
| 37 | + _player = [[CNLiveMoviePlayerController alloc] initLivePlayWithChannelId:@"iOStest" | |
| 38 | + authSuccess:^{ | |
| 39 | + | |
| 40 | + _player.videoDecoderMode = CNLiveMovieVideoDecoderMode_AUTO; | |
| 41 | + _player.view.frame = self.contentView.bounds; | |
| 42 | + _player.shouldAutoplay = YES; | |
| 43 | + [_player prepareToPlay]; | |
| 44 | + [self.contentView addSubview:_player.view]; | |
| 45 | + [self.contentView sendSubviewToBack:_player.view]; | |
| 46 | + | |
| 47 | + } authFailed:^(NSDictionary *errorInfo) { | |
| 48 | + NSLog(@"初始化直播播放器失败:%@", errorInfo); | |
| 49 | + | |
| 50 | + | |
| 51 | + } getAnchorStatusResult:^(BOOL result) { | |
| 52 | + | |
| 53 | + NSLog(@"-------------获取主播状态%d", result ? YES : NO); | |
| 54 | + | |
| 55 | + }]; | |
| 56 | + } | |
| 57 | + return _player; | |
| 58 | +} | |
| 59 | + | |
| 60 | +#pragma mark - 添加通知监听 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
| 61 | +-(void)installMovieNotificationObservers //添加视频播放通知 | |
| 62 | +{ | |
| 63 | + //视频加载状态改变 | |
| 64 | + [[NSNotificationCenter defaultCenter] addObserver:self | |
| 65 | + selector:@selector(loadStateDidChange:) | |
| 66 | + name:MPMoviePlayerLoadStateDidChangeNotification | |
| 67 | + object:nil]; | |
| 68 | + | |
| 69 | + //视频播放错误及结束原因 | |
| 70 | + [[NSNotificationCenter defaultCenter] addObserver:self | |
| 71 | + selector:@selector(moviePlayBackDidFinish:) | |
| 72 | + name:MPMoviePlayerPlaybackDidFinishNotification | |
| 73 | + object:nil]; | |
| 74 | + | |
| 75 | + //视频缓冲至可播放状态 | |
| 76 | + [[NSNotificationCenter defaultCenter] addObserver:self | |
| 77 | + selector:@selector(mediaIsPreparedToPlayDidChange:) | |
| 78 | + name:MPMediaPlaybackIsPreparedToPlayDidChangeNotification | |
| 79 | + object:nil]; | |
| 80 | + | |
| 81 | + //视频播放状态改变 | |
| 82 | + [[NSNotificationCenter defaultCenter] addObserver:self | |
| 83 | + selector:@selector(moviePlayBackStateDidChange:) | |
| 84 | + name:MPMoviePlayerPlaybackStateDidChangeNotification | |
| 85 | + object:nil]; | |
| 86 | + | |
| 87 | + | |
| 88 | + //获取主播状态通知(点播和普通播放不需要注册该通知) | |
| 89 | + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(anchorStatusChanged:) | |
| 90 | + name:CNLiveAnchorStatusChangedNotification | |
| 91 | + object:nil]; | |
| 92 | + | |
| 93 | +} | |
| 94 | + | |
| 95 | +#pragma mark - 通知 Action !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
| 96 | +//视频加载状态改变 | |
| 97 | +- (void)loadStateDidChange:(NSNotification *)notification | |
| 98 | +{ | |
| 99 | + if (_player) { | |
| 100 | + MPMovieLoadState loadState = _player.loadState; | |
| 101 | + if ((loadState & MPMovieLoadStatePlaythroughOK) != 0) { | |
| 102 | + | |
| 103 | + NSLog(@"loadStateDidChange: MPMovieLoadStatePlaythroughOK: %d\n", (int)loadState); | |
| 104 | + | |
| 105 | + } else if ((loadState & MPMovieLoadStateStalled) != 0) { | |
| 106 | + NSLog(@"loadStateDidChange: MPMovieLoadStateStalled: %d\n", (int)loadState); | |
| 107 | + | |
| 108 | + } else { | |
| 109 | + NSLog(@"loadStateDidChange: ???: %d\n", (int)loadState); | |
| 110 | + } | |
| 111 | + } | |
| 112 | +} | |
| 113 | + | |
| 114 | +//视频播放错误及结束原因 | |
| 115 | +- (void)moviePlayBackDidFinish:(NSNotification *)notification | |
| 116 | +{ | |
| 117 | + if (_player) { | |
| 118 | + int reason = [[[notification userInfo] valueForKey:MPMoviePlayerPlaybackDidFinishReasonUserInfoKey] intValue]; | |
| 119 | + if (MPMovieFinishReasonPlaybackError == reason) { | |
| 120 | + | |
| 121 | + | |
| 122 | + } else { | |
| 123 | + | |
| 124 | + } | |
| 125 | + | |
| 126 | + switch (reason) | |
| 127 | + { | |
| 128 | + case MPMovieFinishReasonPlaybackEnded: | |
| 129 | + NSLog(@"playbackStateDidChange: MPMovieFinishReasonPlaybackEnded: %d\n", reason); | |
| 130 | + break; | |
| 131 | + | |
| 132 | + case MPMovieFinishReasonUserExited: | |
| 133 | + NSLog(@"playbackStateDidChange: MPMovieFinishReasonUserExited: %d\n", reason); | |
| 134 | + break; | |
| 135 | + | |
| 136 | + case MPMovieFinishReasonPlaybackError: | |
| 137 | + NSLog(@"playbackStateDidChange: MPMovieFinishReasonPlaybackError: %d\n", reason); | |
| 138 | + break; | |
| 139 | + | |
| 140 | + default: | |
| 141 | + NSLog(@"playbackPlayBackDidFinish: ???: %d\n", reason); | |
| 142 | + break; | |
| 143 | + } | |
| 144 | + } | |
| 145 | +} | |
| 146 | + | |
| 147 | +//视频缓冲至可播放状态 | |
| 148 | +- (void)mediaIsPreparedToPlayDidChange:(NSNotification *)notification | |
| 149 | +{ | |
| 150 | + if (_player) { | |
| 151 | + NSLog(@"isPreparedToPlay"); | |
| 152 | + // if (_loadingView) { | |
| 153 | + // [_loadingView removeFromSuperview]; | |
| 154 | + // } | |
| 155 | + } | |
| 156 | +} | |
| 157 | + | |
| 158 | +//视频播放状态改变 | |
| 159 | +- (void)moviePlayBackStateDidChange:(NSNotification *)notification | |
| 160 | +{ | |
| 161 | + if (_player) { | |
| 162 | + | |
| 163 | + switch (_player.playbackState) { | |
| 164 | + case MPMoviePlaybackStateStopped: { | |
| 165 | + | |
| 166 | + NSLog(@"moviePlayBackStateDidChange : MPMoviePlaybackStateStopped"); | |
| 167 | + break; | |
| 168 | + } | |
| 169 | + case MPMoviePlaybackStatePlaying: { | |
| 170 | + | |
| 171 | + NSLog(@"moviePlayBackStateDidChange : MPMoviePlaybackStatePlaying"); | |
| 172 | + break; | |
| 173 | + } | |
| 174 | + case MPMoviePlaybackStatePaused: | |
| 175 | + | |
| 176 | + NSLog(@"moviePlayBackStateDidChange : MPMoviePlaybackStatePaused"); | |
| 177 | + break; | |
| 178 | + case MPMoviePlaybackStateInterrupted: | |
| 179 | + | |
| 180 | + NSLog(@"moviePlayBackStateDidChange : MPMoviePlaybackStateInterrupted"); | |
| 181 | + break; | |
| 182 | + case MPMoviePlaybackStateSeekingForward: | |
| 183 | + | |
| 184 | + NSLog(@"moviePlayBackStateDidChange : MPMoviePlaybackStateSeekingForward"); | |
| 185 | + break; | |
| 186 | + case MPMoviePlaybackStateSeekingBackward: | |
| 187 | + | |
| 188 | + NSLog(@"moviePlayBackStateDidChange : MPMoviePlaybackStateSeekingBackward"); | |
| 189 | + break; | |
| 190 | + default: | |
| 191 | + | |
| 192 | + NSLog(@"moviePlayBackStateDidChange : %ld", (long)_player.playbackState); | |
| 193 | + break; | |
| 194 | + } | |
| 195 | + } | |
| 196 | +} | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | +// 获取主播状态通知 | |
| 201 | +- (void)anchorStatusChanged:(NSNotification *)notification | |
| 202 | +{ | |
| 203 | + if (_player.anchorStatus == 2) { // 已结束 | |
| 204 | + | |
| 205 | + } | |
| 206 | +// _bgView.anchorStatus = _player.anchorStatus; | |
| 207 | +} | |
| 208 | + | |
| 209 | +//重新连接获取主播状态 | |
| 210 | +- (void)anchorStatusConnectFailed | |
| 211 | +{ | |
| 212 | + | |
| 213 | +} | |
| 214 | + | |
| 215 | +#pragma mark - 移除通知 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
| 216 | +- (void)removeMovieNotificationObservers | |
| 217 | +{ | |
| 218 | + [[NSNotificationCenter defaultCenter]removeObserver:self | |
| 219 | + name:MPMoviePlayerLoadStateDidChangeNotification | |
| 220 | + object:nil]; | |
| 221 | + [[NSNotificationCenter defaultCenter]removeObserver:self | |
| 222 | + name:MPMoviePlayerPlaybackDidFinishNotification | |
| 223 | + object:nil]; | |
| 224 | + [[NSNotificationCenter defaultCenter]removeObserver:self | |
| 225 | + name:MPMediaPlaybackIsPreparedToPlayDidChangeNotification | |
| 226 | + object:nil]; | |
| 227 | + [[NSNotificationCenter defaultCenter]removeObserver:self | |
| 228 | + name:MPMoviePlayerPlaybackStateDidChangeNotification | |
| 229 | + object:nil]; | |
| 230 | + | |
| 231 | + [[NSNotificationCenter defaultCenter]removeObserver:self | |
| 232 | + name:CNLiveAnchorStatusChangedNotification | |
| 233 | + object:nil]; | |
| 234 | +} | |
| 235 | + | |
| 236 | +@end | ... | ... |
LiveVideoCloud/LiveVideoCloud/Classes/Sections/homeSections/View/LVCUGCPlayerLoadingView.m