Commit 414ef4dd55fb0e402308616bc4e9c7f91ce38508

Authored by zhangxiaowen
1 parent 553be0d1

no message

CNLivePlayer/Classes/Player/CNLivePlayer.m
@@ -326,23 +326,12 @@ NSString * const CNLiveHostStatusChangedNotification = @"CNLiveAnchorStatusChang @@ -326,23 +326,12 @@ NSString * const CNLiveHostStatusChangedNotification = @"CNLiveAnchorStatusChang
326 if(!strongSelf){ 326 if(!strongSelf){
327 return ; 327 return ;
328 } 328 }
329 - strongSelf.videoUrl = model.url;  
330 - if(!strongSelf.player){  
331 - NSString *proxyUrl = [[CNLiveHTTPProxyService manager] getProxyUrl:strongSelf.videoUrl];  
332 - strongSelf.player = [[KSYMoviePlayerController alloc] initWithContentURL:[NSURL URLWithString:PLAYER_OpenCache?proxyUrl:strongSelf.videoUrl]];  
333 - [strongSelf.view addSubview:strongSelf.player.view];  
334 - strongSelf.player.view.frame = strongSelf.view.bounds;  
335 - strongSelf.player.view.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;  
336 - strongSelf.player.shouldEnableKSYStatModule = NO;  
337 - if (PLAYER_TestEnvironment) {  
338 - NSLog(@"CNLivePlayer-->缓存数据,播放器初始化成功,可以对播放器进行设置并准备播放");  
339 - }  
340 -  
341 - }else{  
342 - [strongSelf.player reset:YES];  
343 - [strongSelf.player setUrl:[NSURL URLWithString:strongSelf.videoUrl]];  
344 - 329 + [strongSelf createPlayerWithUrl:model.url];
  330 +
  331 + if (PLAYER_TestEnvironment) {
  332 + NSLog(@"CNLivePlayer-->缓存数据,播放器初始化成功,可以对播放器进行设置并准备播放");
345 } 333 }
  334 +
346 authSuccessBlock ? authSuccessBlock() : nil; 335 authSuccessBlock ? authSuccessBlock() : nil;
347 336
348 }); 337 });
@@ -384,6 +373,25 @@ NSString * const CNLiveHostStatusChangedNotification = @"CNLiveAnchorStatusChang @@ -384,6 +373,25 @@ NSString * const CNLiveHostStatusChangedNotification = @"CNLiveAnchorStatusChang
384 373
385 } 374 }
386 375
  376 +//根据url创建播放器
  377 +- (void)createPlayerWithUrl:(NSString *)url {
  378 + self.videoUrl = url;
  379 + if(!self.player){
  380 + NSString *proxyUrl = [[CNLiveHTTPProxyService manager] getProxyUrl:self.videoUrl];
  381 + self.player = [[KSYMoviePlayerController alloc] initWithContentURL:[NSURL URLWithString:PLAYER_OpenCache?proxyUrl:self.videoUrl]];
  382 + [self.view addSubview:self.player.view];
  383 + self.player.view.frame = self.view.bounds;
  384 + self.player.view.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
  385 + self.player.shouldEnableKSYStatModule = NO;
  386 +
  387 + }else{
  388 + [self.player reset:YES];
  389 + [self.player setUrl:[NSURL URLWithString:self.videoUrl]];
  390 +
  391 + }
  392 +
  393 +}
  394 +
387 #pragma mark - 鉴权 395 #pragma mark - 鉴权
388 - (void)authenticateSuccess:(AuthSuccessBlock)authSuccessBlock failure:(AuthFailureBlock)authFailureBlock { 396 - (void)authenticateSuccess:(AuthSuccessBlock)authSuccessBlock failure:(AuthFailureBlock)authFailureBlock {
389 397
@@ -477,26 +485,14 @@ NSString * const CNLiveHostStatusChangedNotification = @"CNLiveAnchorStatusChang @@ -477,26 +485,14 @@ NSString * const CNLiveHostStatusChangedNotification = @"CNLiveAnchorStatusChang
477 if(!strongSelf){ 485 if(!strongSelf){
478 return ; 486 return ;
479 } 487 }
480 - strongSelf.videoUrl = videoURL;  
481 - if(!strongSelf.player){  
482 - NSString *proxyUrl = [[CNLiveHTTPProxyService manager] getProxyUrl:strongSelf.videoUrl];  
483 - strongSelf.player = [[KSYMoviePlayerController alloc] initWithContentURL:[NSURL URLWithString:PLAYER_OpenCache?proxyUrl:strongSelf.videoUrl]];  
484 - [strongSelf.view addSubview:strongSelf.player.view];  
485 - strongSelf.player.view.frame = strongSelf.view.bounds;  
486 - strongSelf.player.view.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;  
487 - strongSelf.player.shouldEnableKSYStatModule = NO;  
488 -  
489 - [CNLivePlayerTools statSDKWithContentId:strongSelf->_activityId ? strongSelf->_activityId : strongSelf->_contentId idName:strongSelf->_idName];  
490 -  
491 - if (PLAYER_TestEnvironment) {  
492 - NSLog(@"CNLivePlayer-->请求数据,点播播放器初始化成功,可以对播放器进行设置并准备播放");  
493 - }  
494 -  
495 - }else{  
496 - [strongSelf.player reset:YES];  
497 - [strongSelf.player setUrl:[NSURL URLWithString:strongSelf.videoUrl]];  
498 - 488 + [strongSelf createPlayerWithUrl:videoURL];
  489 +
  490 + [CNLivePlayerTools statSDKWithContentId:strongSelf->_activityId ? strongSelf->_activityId : strongSelf->_contentId idName:strongSelf->_idName];
  491 +
  492 + if (PLAYER_TestEnvironment) {
  493 + NSLog(@"CNLivePlayer-->请求数据,点播播放器初始化成功,可以对播放器进行设置并准备播放");
499 } 494 }
  495 +
500 if (authSuccessBlock) { 496 if (authSuccessBlock) {
501 authSuccessBlock(); 497 authSuccessBlock();
502 } 498 }
@@ -561,26 +557,14 @@ NSString * const CNLiveHostStatusChangedNotification = @"CNLiveAnchorStatusChang @@ -561,26 +557,14 @@ NSString * const CNLiveHostStatusChangedNotification = @"CNLiveAnchorStatusChang
561 if(!strongSelf){ 557 if(!strongSelf){
562 return ; 558 return ;
563 } 559 }
564 - strongSelf.videoUrl = url;  
565 - if(!strongSelf.player){  
566 - NSString *proxyUrl = [[CNLiveHTTPProxyService manager] getProxyUrl:strongSelf.videoUrl];  
567 - strongSelf.player = [[KSYMoviePlayerController alloc] initWithContentURL:[NSURL URLWithString:PLAYER_OpenCache?proxyUrl:strongSelf.videoUrl]];  
568 - [strongSelf.view addSubview:strongSelf.player.view];  
569 - strongSelf.player.view.frame = strongSelf.view.bounds;  
570 - strongSelf.player.view.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;  
571 - strongSelf.player.shouldEnableKSYStatModule = NO;  
572 -  
573 - [CNLivePlayerTools statSDKWithContentId:strongSelf->_activityId ? strongSelf->_activityId : strongSelf->_contentId idName:strongSelf->_idName];  
574 -  
575 - if (PLAYER_TestEnvironment) {  
576 - NSLog(@"CNLivePlayer-->请求数据,直播播放器初始化成功,可以对播放器进行设置并准备播放");  
577 - }  
578 -  
579 - }else{  
580 - [strongSelf.player reset:YES];  
581 - [strongSelf.player setUrl:[NSURL URLWithString:strongSelf.videoUrl]];  
582 - 560 + [strongSelf createPlayerWithUrl:url];
  561 +
  562 + [CNLivePlayerTools statSDKWithContentId:strongSelf->_activityId ? strongSelf->_activityId : strongSelf->_contentId idName:strongSelf->_idName];
  563 +
  564 + if (PLAYER_TestEnvironment) {
  565 + NSLog(@"CNLivePlayer-->请求数据,直播播放器初始化成功,可以对播放器进行设置并准备播放");
583 } 566 }
  567 +
584 if (authSuccessBlock) { 568 if (authSuccessBlock) {
585 authSuccessBlock(); 569 authSuccessBlock();
586 } 570 }
@@ -790,6 +774,11 @@ NSString * const CNLiveHostStatusChangedNotification = @"CNLiveAnchorStatusChang @@ -790,6 +774,11 @@ NSString * const CNLiveHostStatusChangedNotification = @"CNLiveAnchorStatusChang
790 } 774 }
791 } 775 }
792 776
  777 +
  778 +- (void)mediaCacheErrorDidChanged:(NSNotification *)notification {
  779 +
  780 +}
  781 +
793 - (void)receiveMessage:(NSNotification *)noti { 782 - (void)receiveMessage:(NSNotification *)noti {
794 783
795 if (!noti.userInfo[@"message"]) return; 784 if (!noti.userInfo[@"message"]) return;
Example/CNLivePlayer/CNLiveAppDelegate.m
@@ -18,7 +18,7 @@ @@ -18,7 +18,7 @@
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:CNLivePlayer_AppId appKey:CNLivePlayer_AppKey isTestEnvironment:YES openCache:YES]; 21 + [CNLivePlayerManager setAppId:CNLivePlayer_AppId appKey:CNLivePlayer_AppKey isTestEnvironment:NO];
22 22
23 return YES; 23 return YES;
24 } 24 }