Commit f6b3010f5cd01135707ec7ed732fda381a168663

Authored by 张旭
2 parents c4a0b971 856c9960

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

LiveVideoCloud.xcodeproj/project.pbxproj
... ... @@ -252,7 +252,7 @@
252 252 D29E81ED1E88DC5B008C9906 /* PriChatCell.m in Sources */ = {isa = PBXBuildFile; fileRef = D29E81EC1E88DC5B008C9906 /* PriChatCell.m */; };
253 253 D2A089E81E89FA720071412C /* LVCUGCLivePlayerCell.m in Sources */ = {isa = PBXBuildFile; fileRef = D2A089E71E89FA720071412C /* LVCUGCLivePlayerCell.m */; };
254 254 D2A089EB1E8A09CB0071412C /* LVCUGCLivePlayerModel.m in Sources */ = {isa = PBXBuildFile; fileRef = D2A089EA1E8A09CB0071412C /* LVCUGCLivePlayerModel.m */; };
255   - D2A089EE1E8A336A0071412C /* LiveLIstService.m in Sources */ = {isa = PBXBuildFile; fileRef = D2A089ED1E8A336A0071412C /* LiveLIstService.m */; };
  255 + D2A089EE1E8A336A0071412C /* LiveListService.m in Sources */ = {isa = PBXBuildFile; fileRef = D2A089ED1E8A336A0071412C /* LiveListService.m */; };
256 256 D2A089F11E8A41120071412C /* LVCUGCLiveListModel.m in Sources */ = {isa = PBXBuildFile; fileRef = D2A089F01E8A41120071412C /* LVCUGCLiveListModel.m */; };
257 257 D2A803081E80BD6F009D6F1C /* TopToolView.m in Sources */ = {isa = PBXBuildFile; fileRef = D2A803071E80BD6F009D6F1C /* TopToolView.m */; };
258 258 D2B2ED801E88FC5200F7538A /* LVCUGCLiveEndView.m in Sources */ = {isa = PBXBuildFile; fileRef = D2B2ED7F1E88FC5200F7538A /* LVCUGCLiveEndView.m */; };
... ... @@ -261,6 +261,7 @@
261 261 D2B7B2571E8261EF00ED084E /* ChatBarrOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = D2B7B2561E8261EF00ED084E /* ChatBarrOperation.m */; };
262 262 D2CBC13B1ECC157A00E00279 /* LVCVerifyLiveAuthService.m in Sources */ = {isa = PBXBuildFile; fileRef = D2CBC13A1ECC157A00E00279 /* LVCVerifyLiveAuthService.m */; };
263 263 D2D7D18D1E8A581000217771 /* timg.jpeg in Resources */ = {isa = PBXBuildFile; fileRef = D2D7D18C1E8A581000217771 /* timg.jpeg */; };
  264 + D2F0486A1EE54E860011E39C /* LVCLiveActivityInfoService.m in Sources */ = {isa = PBXBuildFile; fileRef = D2F048691EE54E860011E39C /* LVCLiveActivityInfoService.m */; };
264 265 /* End PBXBuildFile section */
265 266  
266 267 /* Begin PBXContainerItemProxy section */
... ... @@ -786,8 +787,8 @@
786 787 D2A089E71E89FA720071412C /* LVCUGCLivePlayerCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LVCUGCLivePlayerCell.m; sourceTree = "<group>"; };
787 788 D2A089E91E8A09CB0071412C /* LVCUGCLivePlayerModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LVCUGCLivePlayerModel.h; sourceTree = "<group>"; };
788 789 D2A089EA1E8A09CB0071412C /* LVCUGCLivePlayerModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LVCUGCLivePlayerModel.m; sourceTree = "<group>"; };
789   - D2A089EC1E8A336A0071412C /* LiveLIstService.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LiveLIstService.h; sourceTree = "<group>"; };
790   - D2A089ED1E8A336A0071412C /* LiveLIstService.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LiveLIstService.m; sourceTree = "<group>"; };
  790 + D2A089EC1E8A336A0071412C /* LiveListService.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LiveListService.h; sourceTree = "<group>"; };
  791 + D2A089ED1E8A336A0071412C /* LiveListService.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LiveListService.m; sourceTree = "<group>"; };
791 792 D2A089EF1E8A41120071412C /* LVCUGCLiveListModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LVCUGCLiveListModel.h; sourceTree = "<group>"; };
792 793 D2A089F01E8A41120071412C /* LVCUGCLiveListModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LVCUGCLiveListModel.m; sourceTree = "<group>"; };
793 794 D2A803061E80BD6F009D6F1C /* TopToolView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TopToolView.h; sourceTree = "<group>"; };
... ... @@ -803,6 +804,8 @@
803 804 D2CBC1391ECC157A00E00279 /* LVCVerifyLiveAuthService.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LVCVerifyLiveAuthService.h; path = ../LVCVerifyLiveAuthService.h; sourceTree = "<group>"; };
804 805 D2CBC13A1ECC157A00E00279 /* LVCVerifyLiveAuthService.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = LVCVerifyLiveAuthService.m; path = ../LVCVerifyLiveAuthService.m; sourceTree = "<group>"; };
805 806 D2D7D18C1E8A581000217771 /* timg.jpeg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = timg.jpeg; sourceTree = "<group>"; };
  807 + D2F048681EE54E860011E39C /* LVCLiveActivityInfoService.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LVCLiveActivityInfoService.h; sourceTree = "<group>"; };
  808 + D2F048691EE54E860011E39C /* LVCLiveActivityInfoService.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LVCLiveActivityInfoService.m; sourceTree = "<group>"; };
806 809 /* End PBXFileReference section */
807 810  
808 811 /* Begin PBXFrameworksBuildPhase section */
... ... @@ -2019,8 +2022,10 @@
2019 2022 81A483161E88BED00097A80A /* LVCTVLiveViewController.m */,
2020 2023 81A483181E88E19C0097A80A /* LVCMoreProgramViewController.h */,
2021 2024 81A483191E88E19C0097A80A /* LVCMoreProgramViewController.m */,
2022   - D2A089EC1E8A336A0071412C /* LiveLIstService.h */,
2023   - D2A089ED1E8A336A0071412C /* LiveLIstService.m */,
  2025 + D2A089EC1E8A336A0071412C /* LiveListService.h */,
  2026 + D2A089ED1E8A336A0071412C /* LiveListService.m */,
  2027 + D2F048681EE54E860011E39C /* LVCLiveActivityInfoService.h */,
  2028 + D2F048691EE54E860011E39C /* LVCLiveActivityInfoService.m */,
2024 2029 );
2025 2030 path = Controller;
2026 2031 sourceTree = "<group>";
... ... @@ -2258,7 +2263,7 @@
2258 2263 D2029CAF1E6EADE10027CD92 /* MJRefreshStateHeader.m in Sources */,
2259 2264 4BD856091EBACD530082061D /* UIRefreshControl+AFNetworking.m in Sources */,
2260 2265 81F1C8401E8BC5CC0085C2B8 /* NSArray+Safety.m in Sources */,
2261   - D2A089EE1E8A336A0071412C /* LiveLIstService.m in Sources */,
  2266 + D2A089EE1E8A336A0071412C /* LiveListService.m in Sources */,
2262 2267 D2A089E81E89FA720071412C /* LVCUGCLivePlayerCell.m in Sources */,
2263 2268 81A483111E88B8630097A80A /* LVCChannelDetailsModel.m in Sources */,
2264 2269 D2029D011E6EAE2E0027CD92 /* UIColor+HexString.m in Sources */,
... ... @@ -2305,6 +2310,7 @@
2305 2310 810B65031E779B1F00133E15 /* MASViewConstraint.m in Sources */,
2306 2311 D2029BCE1E6EADD70027CD92 /* ZXNavigationController.m in Sources */,
2307 2312 81A482F51E88ACC80097A80A /* LVCTelevisionView.m in Sources */,
  2313 + D2F0486A1EE54E860011E39C /* LVCLiveActivityInfoService.m in Sources */,
2308 2314 D2029CA21E6EADE10027CD92 /* MJRefreshAutoFooter.m in Sources */,
2309 2315 D2029CC71E6EADE10027CD92 /* SVIndefiniteAnimatedView.m in Sources */,
2310 2316 D2029CA31E6EADE10027CD92 /* MJRefreshBackFooter.m in Sources */,
... ...
LiveVideoCloud/Classes/Sections/homeSections/Controller/LVCLiveActivityInfoService.h 0 → 100644
  1 +//
  2 +// LVCLiveActivityInfoService.h
  3 +// LiveVideoCloud
  4 +//
  5 +// Created by cnliveJunBo on 17/6/5.
  6 +// Copyright © 2017年 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import <Foundation/Foundation.h>
  10 +
  11 +@interface LVCLiveActivityInfoService : HttpService
  12 +
  13 ++ (NSURLSessionDataTask *)getLiveActivityInfoWithActivityId:(NSString *)activityId Handler:(completionHandler)handler;
  14 +
  15 ++ (NSString*)sha1:(NSString *)string;
  16 +
  17 ++ (NSString *)sortParameters:(NSDictionary*)parameters;
  18 +
  19 +@end
... ...
LiveVideoCloud/Classes/Sections/homeSections/Controller/LVCLiveActivityInfoService.m 0 → 100644
  1 +//
  2 +// LVCLiveActivityInfoService.m
  3 +// LiveVideoCloud
  4 +//
  5 +// Created by cnliveJunBo on 17/6/5.
  6 +// Copyright © 2017年 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import "LVCLiveActivityInfoService.h"
  10 +#import "CommonCrypto/CommonDigest.h"
  11 +
  12 +@implementation LVCLiveActivityInfoService
  13 +
  14 +// 获取直播活动信息
  15 ++ (NSURLSessionDataTask *)getLiveActivityInfoWithActivityId:(NSString *)activityId Handler:(completionHandler)handler
  16 +{
  17 + NSInteger time = [[NSDate date] timeIntervalSince1970];
  18 + NSString *timeString = [NSString stringWithFormat:@"%ld", (long)time];
  19 + NSMutableDictionary *parameter=[@{@"platform_id": [NSBundle mainBundle].bundleIdentifier,
  20 + @"activityId":activityId,
  21 + @"timestamp": timeString,
  22 + @"appId": UserAppId} mutableCopy];
  23 + NSString *string = [NSString stringWithFormat:@"%@&key=%@", [self sortParameters:parameter], UserAppKey];
  24 + NSString *signString = [[self sha1:string] uppercaseString];
  25 + [parameter setObject:signString forKey:@"sign"];
  26 +
  27 + NSMutableDictionary *params = parameter.mutableCopy;
  28 + completionHandler compleionHandler = ^(id data,NSError *error) {
  29 + handler(data,error);
  30 + };
  31 + return [[HttpService service] sendRequestWithHttpMethod:E_HTTP_REQUEST_METHOD_GET URLPath:[ZXServerUrl getLiveActivityInfoURL] parameters:params completionHandler:compleionHandler];
  32 +}
  33 +
  34 +//sha1加密
  35 ++ (NSString*)sha1:(NSString *)string
  36 +{
  37 + NSData *data = [string dataUsingEncoding:NSUTF8StringEncoding];
  38 +
  39 + uint8_t digest[CC_SHA1_DIGEST_LENGTH];
  40 +
  41 + CC_SHA1(data.bytes, data.length, digest);
  42 +
  43 + NSMutableString* output = [NSMutableString stringWithCapacity:CC_SHA1_DIGEST_LENGTH * 2];
  44 +
  45 + for(int i = 0; i < CC_SHA1_DIGEST_LENGTH; i++)
  46 + [output appendFormat:@"%02x", digest[i]];
  47 +
  48 + while ([[output substringToIndex:1] isEqualToString:@"0"]) {
  49 + output = [[NSMutableString alloc] initWithString:[output substringFromIndex:1]];
  50 + }
  51 +
  52 + return output;
  53 +}
  54 +
  55 +//参数排序
  56 ++ (NSString *)sortParameters:(NSDictionary*)parameters
  57 +{
  58 + //对所有传入参数按照字段名的 ASCII 码从小到大排序
  59 + NSArray *keyArr=[parameters allKeys];
  60 + NSArray *arr = [keyArr sortedArrayUsingSelector:@selector(compare:)];
  61 +
  62 + NSMutableString *string1 = [[NSMutableString alloc]init];
  63 + for (int i=0; i<arr.count; i++) {
  64 +
  65 + NSString *parametersString = parameters[[arr objectAtIndex:i]];
  66 + if (parametersString.length > 0) {
  67 + [string1 appendString:[NSString stringWithFormat:@"%@=%@&",[arr objectAtIndex:i],parameters[[arr objectAtIndex:i]]]];
  68 + }
  69 + }
  70 +
  71 + if (string1.length > 0) {
  72 + [string1 deleteCharactersInRange:NSMakeRange(string1.length-1, 1)];
  73 + }
  74 +
  75 + return string1;
  76 +}
  77 +
  78 +@end
... ...
LiveVideoCloud/Classes/Sections/homeSections/Controller/LVCUGCLiveListView.m
... ... @@ -7,12 +7,13 @@
7 7 //
8 8  
9 9 #import "LVCUGCLiveListView.h"
10   -#import "LiveLIstService.h"
  10 +#import "LiveListService.h"
11 11 #import "LVCUGCLivePlayerCell.h"
12 12 #import "LVCUGCLiveListModel.h"
13 13 #import "LVCUGCLivePlayerModel.h"
14 14 #import "LVCUGCLivePlayerController.h"
15 15 #import "LVCRequestFailedView.h"
  16 +#import "LVCLiveActivityInfoService.h"
16 17  
17 18 static NSString *cellId = @"cellId";
18 19  
... ... @@ -50,7 +51,7 @@ static NSString *cellId = @&quot;cellId&quot;;
50 51  
51 52 _failedView.hidden = YES;
52 53  
53   - [LiveLIstService getLiveListWithHandler:^(id data, NSError *error) {
  54 + [LiveListService getLiveListWithHandler:^(id data, NSError *error) {
54 55  
55 56 if (error) {
56 57 NSLog(@"失败===>error:%@",error);
... ... @@ -99,11 +100,25 @@ static NSString *cellId = @&quot;cellId&quot;;
99 100  
100 101 - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
101 102  
102   - LVCUGCLivePlayerController *player = [[LVCUGCLivePlayerController alloc] init];
103   - player.index = indexPath.row;
104   - player.playArray = _arrayM;
105   - player.model = _arrayM[indexPath.row];
106   - [self.viewController.navigationController pushViewController:player animated:YES];
  103 + LVCUGCLivePlayerModel *model = _arrayM[indexPath.row];
  104 + // 判断此时直播状态
  105 + [LVCLiveActivityInfoService getLiveActivityInfoWithActivityId:model.activityId Handler:^(id data, NSError *error) {
  106 +
  107 + if (error) {
  108 +
  109 + [Tools showHUDInView:self withString:@"跳转出错" autoHide:YES];
  110 + return ;
  111 + }
  112 +
  113 + NSString *activityStatus = [NSString stringWithFormat:@"%@",data[@"activityStatus"]];
  114 + model.activityStatus = activityStatus ? activityStatus : @"0";
  115 +
  116 + LVCUGCLivePlayerController *player = [[LVCUGCLivePlayerController alloc] init];
  117 + player.index = indexPath.row;
  118 + player.playArray = _arrayM;
  119 + player.model = model;
  120 + [self.viewController.navigationController pushViewController:player animated:YES];
  121 + }];
107 122 }
108 123  
109 124 #pragma mark - LVCRequestFailedViewDelegate
... ...
LiveVideoCloud/Classes/Sections/homeSections/Controller/LiveLIstService.h renamed to LiveVideoCloud/Classes/Sections/homeSections/Controller/LiveListService.h
... ... @@ -8,12 +8,12 @@
8 8  
9 9 #import "HttpService.h"
10 10  
11   -@interface LiveLIstService : HttpService
  11 +@interface LiveListService : HttpService
  12 +
12 13 + (NSURLSessionDataTask *)getLiveListWithHandler:(completionHandler)handler;
13 14  
14 15 + (NSString*)sha1:(NSString *)string;
15 16  
16   -
17 17 + (NSString *)sortParameters:(NSDictionary*)parameters;
18 18  
19 19 @end
... ...
LiveVideoCloud/Classes/Sections/homeSections/Controller/LiveLIstService.m renamed to LiveVideoCloud/Classes/Sections/homeSections/Controller/LiveListService.m
... ... @@ -6,10 +6,10 @@
6 6 // Copyright © 2017年 cnlive. All rights reserved.
7 7 //
8 8  
9   -#import "LiveLIstService.h"
  9 +#import "LiveListService.h"
10 10 #import "CommonCrypto/CommonDigest.h"
11 11  
12   -@implementation LiveLIstService
  12 +@implementation LiveListService
13 13  
14 14 + (NSURLSessionDataTask *)getLiveListWithHandler:(completionHandler)handler
15 15 {
... ...
LiveVideoCloud/UtilKits/ServerUrl/ZXServerUrl.h
... ... @@ -30,6 +30,9 @@
30 30 /** 直播列表 */
31 31 + (NSString *)getLiveListURL;
32 32  
  33 +/** 直播活动详情 */
  34 ++ (NSString *)getLiveActivityInfoURL;
  35 +
33 36 /** 验证主播是否有直播权限 */
34 37 + (NSString *)verifyLiveAuthURL;
35 38 @end
... ...
LiveVideoCloud/UtilKits/ServerUrl/ZXServerUrl.m
... ... @@ -26,6 +26,9 @@ static NSString *g_SearchContentURL = @&quot;/from/huntKeyWordApi/huntKeyWords.do&quot;;//
26 26 /** 直播列表 */
27 27 static NSString *g_LiveListURL = @"/open/api2/live_epg/sp/activityList4App";
28 28  
  29 +/** 直播活动详情 */
  30 +static NSString *g_LiveActivityInfoURL = @"/open/api2/live_epg/getLiveActivityPlayInfo4App";
  31 +
29 32 /** 验证主播是否有直播权限 */
30 33 static NSString *g_VerifyLiveAuthURL = @"/open/api2/live_epg/channel/info4App";
31 34  
... ... @@ -63,6 +66,12 @@ static NSString *g_VerifyLiveAuthURL = @&quot;/open/api2/live_epg/channel/info4App&quot;;
63 66 return [NSString stringWithFormat:@"%@%@", serverBaseURL, g_LiveListURL];
64 67 }
65 68  
  69 +/** 直播活动详情 */
  70 ++ (NSString *)getLiveActivityInfoURL
  71 +{
  72 + return [NSString stringWithFormat:@"%@%@", serverBaseURL, g_LiveActivityInfoURL];
  73 +}
  74 +
66 75 /** 验证主播是否有直播权限 */
67 76 + (NSString *)verifyLiveAuthURL
68 77 {
... ...
LiveVideoCloud/UtilKits/UserTools/UserTools.m
... ... @@ -249,8 +249,8 @@
249 249 parms[@"platform_id"] = [NSBundle mainBundle].bundleIdentifier;
250 250 parms[@"channelId"] = [UserInformationModel manager].uid;
251 251  
252   - NSString *string = [NSString stringWithFormat:@"%@&key=%@", [LiveLIstService sortParameters:parms], UserAppKey];
253   - NSString *signString = [[LiveLIstService sha1:string] uppercaseString];
  252 + NSString *string = [NSString stringWithFormat:@"%@&key=%@", [LiveListService sortParameters:parms], UserAppKey];
  253 + NSString *signString = [[LiveListService sha1:string] uppercaseString];
254 254 parms[@"sign"] = signString ;
255 255  
256 256  
... ... @@ -280,8 +280,8 @@
280 280 parms[@"channelId"] = [UserInformationModel manager].uid; //@"295606"; //
281 281 //parms[@"activityStatus"] = @2;
282 282  
283   - NSString *string = [NSString stringWithFormat:@"%@&key=%@", [LiveLIstService sortParameters:parms], UserAppKey];
284   - NSString *signString = [[LiveLIstService sha1:string] uppercaseString];
  283 + NSString *string = [NSString stringWithFormat:@"%@&key=%@", [LiveListService sortParameters:parms], UserAppKey];
  284 + NSString *signString = [[LiveListService sha1:string] uppercaseString];
285 285 parms[@"sign"] = signString ;
286 286 // activityList4App
287 287 NSString *host = [@"http://api.cnlive.com/open/api2/live_epg/channel/activityList4App" stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
... ...