Commit 08b73c0342be35296353ec680a1c138161e26f9e

Authored by zhangxiaowen
1 parent 966a5db2

no message

CNLivePlayer/Classes/Header/CNLivePlayerConst.h
@@ -9,10 +9,5 @@ @@ -9,10 +9,5 @@
9 #ifndef CNLivePlayerConst_h 9 #ifndef CNLivePlayerConst_h
10 #define CNLivePlayerConst_h 10 #define CNLivePlayerConst_h
11 11
12 -#define CNLivePlayer_AppId @"60_irn9edco29"  
13 -  
14 -#define CNLivePlayer_AppKey @"69fe70bda67e059286ad509d9f5377f815955645b52f94"  
15 -  
16 -#define CNLivePlayer_BundleID @"com.cnlive.video"  
17 12
18 #endif /* CNLivePlayerConst_h */ 13 #endif /* CNLivePlayerConst_h */
CNLivePlayer/Classes/Player/CNLivePlayer.h
@@ -13,6 +13,9 @@ @@ -13,6 +13,9 @@
13 // 枚举定义 13 // 枚举定义
14 #import "CNLivePlayerDefines.h" 14 #import "CNLivePlayerDefines.h"
15 15
  16 +//常量
  17 +#import "CNLivePlayerConst.h"
  18 +
16 // 播放器管理类 19 // 播放器管理类
17 #import "CNLivePlayerManager.h" 20 #import "CNLivePlayerManager.h"
18 21
@@ -58,7 +61,7 @@ typedef void(^AuthFailureBlock)(NSDictionary *errorInfo); @@ -58,7 +61,7 @@ typedef void(^AuthFailureBlock)(NSDictionary *errorInfo);
58 * url 视频url 61 * url 视频url
59 * 62 *
60 */ 63 */
61 -- (instancetype)initWithContentURL:(NSURL *)url; 64 +- (instancetype)initWithContentURL:(NSString *)url;
62 65
63 66
64 /* 初始化点播播放器 初始化成功后才能对播放器进行设置(如:自动播放、是否开启硬件解码等)和调用准备播放视频方法(prepareToPlay) 67 /* 初始化点播播放器 初始化成功后才能对播放器进行设置(如:自动播放、是否开启硬件解码等)和调用准备播放视频方法(prepareToPlay)
CNLivePlayer/Classes/Player/CNLivePlayer.m
@@ -13,12 +13,11 @@ @@ -13,12 +13,11 @@
13 #import "CNLivePlayerTools.h" 13 #import "CNLivePlayerTools.h"
14 //IM 14 //IM
15 #import <CNLiveMsgTools/CNLiveMsgManager.h> 15 #import <CNLiveMsgTools/CNLiveMsgManager.h>
16 -//常量  
17 -#import "CNLivePlayerConst.h"  
18 //url 16 //url
19 #import "CNLivePlayerUrl.h" 17 #import "CNLivePlayerUrl.h"
20 //缓存视频 18 //缓存视频
21 #import <KSYHTTPCache/HTTPCacheDefines.h> 19 #import <KSYHTTPCache/HTTPCacheDefines.h>
  20 +#import "CNLiveHTTPProxyService.h"
22 21
23 @interface CNLivePlayer () { 22 @interface CNLivePlayer () {
24 NSString *_idName; 23 NSString *_idName;
@@ -44,10 +43,6 @@ @@ -44,10 +43,6 @@
44 } 43 }
45 @property (nonatomic, strong, readwrite) UIView *view; 44 @property (nonatomic, strong, readwrite) UIView *view;
46 @property (nonatomic, copy) NSString *videoUrl; 45 @property (nonatomic, copy) NSString *videoUrl;
47 -/*  
48 - * 是否缓存(暂时不能用)  
49 - */  
50 -@property (nonatomic, assign) BOOL openCache;  
51 46
52 @end 47 @end
53 48
@@ -65,7 +60,7 @@ NSString * const CNLiveHostStatusChangedNotification = @&quot;CNLiveAnchorStatusChang @@ -65,7 +60,7 @@ NSString * const CNLiveHostStatusChangedNotification = @&quot;CNLiveAnchorStatusChang
65 * url 视频url 60 * url 视频url
66 * 61 *
67 */ 62 */
68 -- (instancetype)initWithContentURL:(NSURL *)url { 63 +- (instancetype)initWithContentURL:(NSString *)url {
69 self = [super init]; 64 self = [super init];
70 if (self) { 65 if (self) {
71 [UIApplication sharedApplication].idleTimerDisabled = YES; 66 [UIApplication sharedApplication].idleTimerDisabled = YES;
@@ -76,8 +71,8 @@ NSString * const CNLiveHostStatusChangedNotification = @&quot;CNLiveAnchorStatusChang @@ -76,8 +71,8 @@ NSString * const CNLiveHostStatusChangedNotification = @&quot;CNLiveAnchorStatusChang
76 _rate = @"2"; 71 _rate = @"2";
77 72
78 [self addMovieNotificationObservers]; 73 [self addMovieNotificationObservers];
79 -  
80 - self.player = [[KSYMoviePlayerController alloc] initWithContentURL:url]; 74 + NSString *proxyUrl = [[CNLiveHTTPProxyService manager] getProxyUrl:url];
  75 + self.player = [[KSYMoviePlayerController alloc] initWithContentURL:[NSURL URLWithString:PLAYER_OpenCache?proxyUrl:url]];
81 [self.view addSubview:self.player.view]; 76 [self.view addSubview:self.player.view];
82 _player.view.frame = self.view.bounds; 77 _player.view.frame = self.view.bounds;
83 _player.view.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight; 78 _player.view.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
@@ -324,7 +319,8 @@ NSString * const CNLiveHostStatusChangedNotification = @&quot;CNLiveAnchorStatusChang @@ -324,7 +319,8 @@ NSString * const CNLiveHostStatusChangedNotification = @&quot;CNLiveAnchorStatusChang
324 __strong typeof(self) strongSelf = weakSelf; 319 __strong typeof(self) strongSelf = weakSelf;
325 strongSelf.videoUrl = model.url; 320 strongSelf.videoUrl = model.url;
326 if(!strongSelf.player){ 321 if(!strongSelf.player){
327 - strongSelf.player = [[KSYMoviePlayerController alloc] initWithContentURL:[NSURL URLWithString:strongSelf.videoUrl]]; 322 + NSString *proxyUrl = [[CNLiveHTTPProxyService manager] getProxyUrl:strongSelf.videoUrl];
  323 + strongSelf.player = [[KSYMoviePlayerController alloc] initWithContentURL:[NSURL URLWithString:PLAYER_OpenCache?proxyUrl:strongSelf.videoUrl]];
328 [strongSelf.view addSubview:self.player.view]; 324 [strongSelf.view addSubview:self.player.view];
329 strongSelf.player.view.frame = self.view.bounds; 325 strongSelf.player.view.frame = self.view.bounds;
330 strongSelf.player.view.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight; 326 strongSelf.player.view.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
@@ -460,7 +456,8 @@ NSString * const CNLiveHostStatusChangedNotification = @&quot;CNLiveAnchorStatusChang @@ -460,7 +456,8 @@ NSString * const CNLiveHostStatusChangedNotification = @&quot;CNLiveAnchorStatusChang
460 __strong typeof(self) strongSelf = weakSelf; 456 __strong typeof(self) strongSelf = weakSelf;
461 strongSelf.videoUrl = videoURL; 457 strongSelf.videoUrl = videoURL;
462 if(!strongSelf.player){ 458 if(!strongSelf.player){
463 - strongSelf.player = [[KSYMoviePlayerController alloc] initWithContentURL:[NSURL URLWithString:videoUrl]]; 459 + NSString *proxyUrl = [[CNLiveHTTPProxyService manager] getProxyUrl:strongSelf.videoUrl];
  460 + strongSelf.player = [[KSYMoviePlayerController alloc] initWithContentURL:[NSURL URLWithString:PLAYER_OpenCache?proxyUrl:strongSelf.videoUrl]];
464 [strongSelf.view addSubview:strongSelf.player.view]; 461 [strongSelf.view addSubview:strongSelf.player.view];
465 strongSelf.player.view.frame = strongSelf.view.bounds; 462 strongSelf.player.view.frame = strongSelf.view.bounds;
466 strongSelf.player.view.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight; 463 strongSelf.player.view.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
@@ -537,7 +534,8 @@ NSString * const CNLiveHostStatusChangedNotification = @&quot;CNLiveAnchorStatusChang @@ -537,7 +534,8 @@ NSString * const CNLiveHostStatusChangedNotification = @&quot;CNLiveAnchorStatusChang
537 __strong typeof(self) strongSelf = weakSelf; 534 __strong typeof(self) strongSelf = weakSelf;
538 strongSelf.videoUrl = url; 535 strongSelf.videoUrl = url;
539 if(!strongSelf.player){ 536 if(!strongSelf.player){
540 - strongSelf.player = [[KSYMoviePlayerController alloc] initWithContentURL:[NSURL URLWithString:url]]; 537 + NSString *proxyUrl = [[CNLiveHTTPProxyService manager] getProxyUrl:strongSelf.videoUrl];
  538 + strongSelf.player = [[KSYMoviePlayerController alloc] initWithContentURL:[NSURL URLWithString:PLAYER_OpenCache?proxyUrl:strongSelf.videoUrl]];
541 [strongSelf.view addSubview:strongSelf.player.view]; 539 [strongSelf.view addSubview:strongSelf.player.view];
542 strongSelf.player.view.frame = strongSelf.view.bounds; 540 strongSelf.player.view.frame = strongSelf.view.bounds;
543 strongSelf.player.view.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight; 541 strongSelf.player.view.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
@@ -622,7 +620,7 @@ NSString * const CNLiveHostStatusChangedNotification = @&quot;CNLiveAnchorStatusChang @@ -622,7 +620,7 @@ NSString * const CNLiveHostStatusChangedNotification = @&quot;CNLiveAnchorStatusChang
622 selector:@selector(mediaIsPreparedToPlayDidChange:) 620 selector:@selector(mediaIsPreparedToPlayDidChange:)
623 name:MPMediaPlaybackIsPreparedToPlayDidChangeNotification 621 name:MPMediaPlaybackIsPreparedToPlayDidChangeNotification
624 object:nil]; 622 object:nil];
625 - if(self.openCache){ 623 + if(PLAYER_OpenCache){
626 // 缓存状态 624 // 缓存状态
627 [[NSNotificationCenter defaultCenter] addObserver:self 625 [[NSNotificationCenter defaultCenter] addObserver:self
628 selector:@selector(mediaCacheDidChanged:) 626 selector:@selector(mediaCacheDidChanged:)
CNLivePlayer/Classes/Player/CNLivePlayerManager.h
@@ -14,6 +14,7 @@ @@ -14,6 +14,7 @@
14 #define PLAYER_ChannelName [CNLivePlayerManager manager].channelName?[CNLivePlayerManager manager].channelName:@"" 14 #define PLAYER_ChannelName [CNLivePlayerManager manager].channelName?[CNLivePlayerManager manager].channelName:@""
15 #define PLAYER_Tag [CNLivePlayerManager manager].tag?[CNLivePlayerManager manager].tag:@"" 15 #define PLAYER_Tag [CNLivePlayerManager manager].tag?[CNLivePlayerManager manager].tag:@""
16 #define PLAYER_TestEnvironment [CNLivePlayerManager manager].isTestEnvironment 16 #define PLAYER_TestEnvironment [CNLivePlayerManager manager].isTestEnvironment
  17 +#define PLAYER_OpenCache [CNLivePlayerManager manager].openCache
17 18
18 NS_ASSUME_NONNULL_BEGIN 19 NS_ASSUME_NONNULL_BEGIN
19 20
@@ -35,6 +36,11 @@ NS_ASSUME_NONNULL_BEGIN @@ -35,6 +36,11 @@ NS_ASSUME_NONNULL_BEGIN
35 */ 36 */
36 @property (nonatomic, assign, readonly) BOOL isTestEnvironment; 37 @property (nonatomic, assign, readonly) BOOL isTestEnvironment;
37 38
  39 +/*
  40 + * 是否开启边播放边缓存
  41 + */
  42 +@property (nonatomic, assign) BOOL openCache;
  43 +
38 /** 44 /**
39 * 用户ID 45 * 用户ID
40 */ 46 */
@@ -73,6 +79,16 @@ NS_ASSUME_NONNULL_BEGIN @@ -73,6 +79,16 @@ NS_ASSUME_NONNULL_BEGIN
73 + (void)setAppId:(NSString *)appId appKey:(NSString *)appKey isTestEnvironment:(BOOL)isTestEnvironment; 79 + (void)setAppId:(NSString *)appId appKey:(NSString *)appKey isTestEnvironment:(BOOL)isTestEnvironment;
74 80
75 /** 81 /**
  82 + @abstract 初始化直播云SDK
  83 + @param appId 在open.cnlive.com网站申请得到的appId
  84 + @param appKey 在open.cnlive.com网站申请得到的appKey
  85 + @param isTestEnvironment YES:测试环境 NO:正式环境
  86 + @param openCache YES:开启视频边播放边缓存 NO:关闭视频边播放边缓存
  87 + @warning 必传参数
  88 + */
  89 ++ (void)setAppId:(NSString *)appId appKey:(NSString *)appKey isTestEnvironment:(BOOL)isTestEnvironment openCache:(BOOL)openCache;
  90 +
  91 +/**
76 @abstract 获取版本号 92 @abstract 获取版本号
77 */ 93 */
78 + (NSString *)getVersion; 94 + (NSString *)getVersion;
CNLivePlayer/Classes/Player/CNLivePlayerManager.m
@@ -8,9 +8,9 @@ @@ -8,9 +8,9 @@
8 8
9 #import "CNLivePlayerManager.h" 9 #import "CNLivePlayerManager.h"
10 #import <libksygpulive/KSYGPUStreamerKit.h> 10 #import <libksygpulive/KSYGPUStreamerKit.h>
11 -#import "CNLivePlayerConst.h"  
12 #import "CNLivePlayerUrl.h" 11 #import "CNLivePlayerUrl.h"
13 #import "CNLivePlayerDBTool.h" 12 #import "CNLivePlayerDBTool.h"
  13 +#import "CNLiveHTTPProxyService.h"
14 14
15 @interface CNLivePlayerManager() 15 @interface CNLivePlayerManager()
16 /** 16 /**
@@ -40,6 +40,7 @@ static CNLivePlayerManager * _instance = nil; @@ -40,6 +40,7 @@ static CNLivePlayerManager * _instance = nil;
40 _instance = [[self alloc] init]; 40 _instance = [[self alloc] init];
41 //清除播放器鉴权缓存 41 //清除播放器鉴权缓存
42 [CNLivePlayerManager clearAuthentication]; 42 [CNLivePlayerManager clearAuthentication];
  43 + //创建数据库
43 [[CNLivePlayerDBTool shared] createTable]; 44 [[CNLivePlayerDBTool shared] createTable];
44 45
45 }); 46 });
@@ -53,24 +54,63 @@ static CNLivePlayerManager * _instance = nil; @@ -53,24 +54,63 @@ static CNLivePlayerManager * _instance = nil;
53 } 54 }
54 55
55 + (void)setAppId:(NSString *)appId appKey:(NSString *)appKey isTestEnvironment:(BOOL)isTestEnvironment{ 56 + (void)setAppId:(NSString *)appId appKey:(NSString *)appKey isTestEnvironment:(BOOL)isTestEnvironment{
56 - [[CNLivePlayerManager manager] setAppId:appId appKey:appKey isTestEnvironment:isTestEnvironment]; 57 + [CNLivePlayerManager setAppId:appId appKey:appKey isTestEnvironment:isTestEnvironment openCache:NO];
57 58
58 } 59 }
59 60
60 -#pragma mark - 私有方法  
61 -- (void)setAppId:(NSString *)appId appKey:(NSString *)appKey {  
62 - [self setAppId:appId appKey:appKey isTestEnvironment:NO]; 61 ++ (void)setAppId:(NSString *)appId appKey:(NSString *)appKey isTestEnvironment:(BOOL)isTestEnvironment openCache:(BOOL)openCache{
  62 + [[CNLivePlayerManager manager] setAppId:appId appKey:appKey isTestEnvironment:isTestEnvironment openCache:openCache];
  63 +
63 } 64 }
64 65
65 -- (void)setAppId:(NSString *)appId appKey:(NSString *)appKey isTestEnvironment:(BOOL)isTestEnvironment { 66 +#pragma mark - 私有方法
  67 +- (void)setAppId:(NSString *)appId appKey:(NSString *)appKey isTestEnvironment:(BOOL)isTestEnvironment openCache:(BOOL)openCache{
66 [CNLivePlayerManager manager].appId = appId ? [NSString stringWithFormat:@"%@",appId] : @""; 68 [CNLivePlayerManager manager].appId = appId ? [NSString stringWithFormat:@"%@",appId] : @"";
67 [CNLivePlayerManager manager].appKey = appKey ? [NSString stringWithFormat:@"%@",appKey] : @""; 69 [CNLivePlayerManager manager].appKey = appKey ? [NSString stringWithFormat:@"%@",appKey] : @"";
68 [CNLivePlayerManager manager].isTestEnvironment = isTestEnvironment; 70 [CNLivePlayerManager manager].isTestEnvironment = isTestEnvironment;
  71 + [CNLivePlayerManager manager].openCache = openCache;
  72 + if(openCache){
  73 + //进入前台
  74 + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationDidBecomeActive) name:UIApplicationDidBecomeActiveNotification object:nil];
  75 + //进入后台
  76 + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationDidEnterBackground) name:UIApplicationDidEnterBackgroundNotification object:nil];
  77 + //缓存视频的位置
  78 + [[CNLiveHTTPProxyService manager] setCacheRoot:[NSTemporaryDirectory() stringByAppendingPathComponent:@"cnlive_player_cache"]];
  79 + //边播放边缓存
  80 + [[CNLiveHTTPProxyService manager] startServer];
  81 +
  82 + }
69 if (PLAYER_TestEnvironment) { 83 if (PLAYER_TestEnvironment) {
70 NSLog(@"CNLivePlayer的版本是:%@", [CNLivePlayerManager getVersion]); 84 NSLog(@"CNLivePlayer的版本是:%@", [CNLivePlayerManager getVersion]);
  85 + if(openCache){
  86 + //边播放边缓存
  87 + NSLog(@"CNLivePlayer-->开启边播放边缓存");
  88 +
  89 + }
  90 +
  91 + }
  92 +
  93 +}
  94 +
  95 +- (void)applicationDidBecomeActive{
  96 + if (![[CNLiveHTTPProxyService manager] isRunning]) {
  97 + [[CNLiveHTTPProxyService manager] startServer];
  98 +
  99 + }
  100 +
  101 +}
  102 +
  103 +- (void)applicationDidEnterBackground{
  104 + if ([[CNLiveHTTPProxyService manager] isRunning]) {
  105 + [[CNLiveHTTPProxyService manager] stopServer];
  106 +
71 } 107 }
72 } 108 }
73 109
  110 +- (void)dealloc{
  111 + [[NSNotificationCenter defaultCenter] removeObserver:self];
  112 +}
  113 +
74 + (NSString *)getVersion { 114 + (NSString *)getVersion {
75 KSYGPUStreamerKit *kit = [[KSYGPUStreamerKit alloc] init]; 115 KSYGPUStreamerKit *kit = [[KSYGPUStreamerKit alloc] init];
76 NSString *str = [[[kit.streamerBase getKSYVersion] componentsSeparatedByString:@"-"] lastObject]; 116 NSString *str = [[[kit.streamerBase getKSYVersion] componentsSeparatedByString:@"-"] lastObject];
CNLivePlayer/Classes/Player/CNLivePlayerTools.m
@@ -9,7 +9,6 @@ @@ -9,7 +9,6 @@
9 #import "CNLivePlayerTools.h" 9 #import "CNLivePlayerTools.h"
10 #import "CommonCrypto/CommonDigest.h" 10 #import "CommonCrypto/CommonDigest.h"
11 #import "CNLivePlayerManager.h" 11 #import "CNLivePlayerManager.h"
12 -#import "CNLivePlayerConst.h"  
13 #import "CNLivePlayerUrl.h" 12 #import "CNLivePlayerUrl.h"
14 13
15 @implementation CNLivePlayerTools 14 @implementation CNLivePlayerTools
Example/CNLivePlayer/CNLiveAppDelegate.m
@@ -9,16 +9,16 @@ @@ -9,16 +9,16 @@
9 #import "CNLiveAppDelegate.h" 9 #import "CNLiveAppDelegate.h"
10 #import "CNLivePlayer.h" 10 #import "CNLivePlayer.h"
11 11
12 -#define KAppId @"60_irn9edco29"  
13 -#define KAppKey @"69fe70bda67e059286ad509d9f5377f815955645b52f94"  
14 -#define bundleID @"com.cnlive.video" 12 +#define CNLivePlayer_AppId @"60_irn9edco29"
  13 +#define CNLivePlayer_AppKey @"69fe70bda67e059286ad509d9f5377f815955645b52f94"
  14 +#define CNLivePlayer_BundleID @"com.cnlive.video"
15 15
16 @implementation CNLiveAppDelegate 16 @implementation CNLiveAppDelegate
17 17
18 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 18 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
19 { 19 {
20 // Override point for customization after application launch. 20 // Override point for customization after application launch.
21 - [CNLivePlayerManager setAppId:KAppId appKey:KAppKey isTestEnvironment:YES]; 21 + [CNLivePlayerManager setAppId:CNLivePlayer_AppId appKey:CNLivePlayer_AppKey isTestEnvironment:YES openCache:NO];
22 22
23 return YES; 23 return YES;
24 } 24 }
Example/CNLivePlayer/CNLivePlayerController.m
@@ -63,11 +63,11 @@ @@ -63,11 +63,11 @@
63 back.backgroundColor = [UIColor greenColor]; 63 back.backgroundColor = [UIColor greenColor];
64 [back addTarget:self action:@selector(backDidClicked) forControlEvents:UIControlEventTouchUpInside]; 64 [back addTarget:self action:@selector(backDidClicked) forControlEvents:UIControlEventTouchUpInside];
65 [self.view addSubview:back]; 65 [self.view addSubview:back];
66 - CNLivePlayerDownloader *dowa = [[CNLivePlayerDownloader alloc]initWithUrlString:@"http://wideo02.cnlive.com/video/data1/2017/0423/206473/800/c8ff347048414b7295cef882f8361073_206473_800.m3u8" progressBlock:^(float progress) {  
67 - NSLog(@"缓存进度中%f",progress);  
68 - }];  
69 - NSLog(@"缓存的url是:%@",dowa.urlString);  
70 - [dowa startDownload]; 66 +// CNLivePlayerDownloader *dowa = [[CNLivePlayerDownloader alloc]initWithUrlString:@"http://wideo02.cnlive.com/video/data1/2017/0423/206473/800/c8ff347048414b7295cef882f8361073_206473_800.m3u8" progressBlock:^(float progress) {
  67 +// NSLog(@"缓存进度中%f",progress);
  68 +// }];
  69 +// NSLog(@"缓存的url是:%@",dowa.urlString);
  70 +// [dowa startDownload];
71 71
72 // self.player = [[CNLivePlayer alloc] initWithContentURL:[NSURL URLWithString:@"http://wideo02.cnlive.com/video/data1/2017/0423/206473/800/c8ff347048414b7295cef882f8361073_206473_800.m3u8"]]; 72 // self.player = [[CNLivePlayer alloc] initWithContentURL:[NSURL URLWithString:@"http://wideo02.cnlive.com/video/data1/2017/0423/206473/800/c8ff347048414b7295cef882f8361073_206473_800.m3u8"]];
73 // self.player.view.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.width*9/16.0); 73 // self.player.view.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.width*9/16.0);
@@ -98,14 +98,12 @@ @@ -98,14 +98,12 @@
98 // 98 //
99 // }]; 99 // }];
100 NSLog(@"当时已播放的时间是:%f",self.player.currentPlaybackTime); 100 NSLog(@"当时已播放的时间是:%f",self.player.currentPlaybackTime);
101 - [_player setplay]  
102 - [_player setPlayerWithRate:@"4" authSuccess:^{ 101 + [_player setPlayerWithContentId:nil rate:@"4" authSuccess:^{
103 __strong typeof(self) strongSelf = weakSelf; 102 __strong typeof(self) strongSelf = weakSelf;
104 [strongSelf.player prepareToPlay]; 103 [strongSelf.player prepareToPlay];
105 strongSelf.player.currentPlaybackTime = 10; 104 strongSelf.player.currentPlaybackTime = 10;
106 -  
107 } authFailure:^(NSDictionary * _Nonnull errorInfo) { 105 } authFailure:^(NSDictionary * _Nonnull errorInfo) {
108 - 106 +
109 }]; 107 }];
110 108
111 } 109 }
Example/CNLivePlayer/CNLiveViewController.m
@@ -9,6 +9,7 @@ @@ -9,6 +9,7 @@
9 #import "CNLiveViewController.h" 9 #import "CNLiveViewController.h"
10 #import "CNLivePlayerController.h" 10 #import "CNLivePlayerController.h"
11 #import "CNLivePlayerDBTool.h" 11 #import "CNLivePlayerDBTool.h"
  12 +#import "CNLiveHTTPProxyService.h"
12 13
13 @interface CNLiveViewController () 14 @interface CNLiveViewController ()
14 15
@@ -22,6 +23,8 @@ @@ -22,6 +23,8 @@
22 for(CNLivePlayerDBModel *model in data){ 23 for(CNLivePlayerDBModel *model in data){
23 NSLog(@"%@---%@",model.contentId,model.url); 24 NSLog(@"%@---%@",model.contentId,model.url);
24 } 25 }
  26 + NSLog(@"--是否缓存--%d----",[[CNLiveHTTPProxyService manager]isCacheCompleteForUrl:[NSURL URLWithString:@"http://wideo02.cnlive.com/video/data1/2017/0423/206473/800/c8ff347048414b7295cef882f8361073_206473_800.m3u8"]]);
  27 +
25 28
26 } 29 }
27 - (void)viewDidLoad 30 - (void)viewDidLoad