Commit a7c4531effe122c7bb54e1de256b46c88097bb12
1 parent
3388a46a
播放器加载状态
Showing
8 changed files
with
139 additions
and
95 deletions
LiveVideoCloud.xcodeproj/project.pbxproj
| ... | ... | @@ -86,7 +86,6 @@ |
| 86 | 86 | 8178D44A1F02045500AA78A4 /* CNBarrageManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 8178D4351F02045500AA78A4 /* CNBarrageManager.m */; }; |
| 87 | 87 | 8178D44B1F02045500AA78A4 /* CNBarrageView.m in Sources */ = {isa = PBXBuildFile; fileRef = 8178D4371F02045500AA78A4 /* CNBarrageView.m */; }; |
| 88 | 88 | 8178D4511F02045500AA78A4 /* LVCPlayer.m in Sources */ = {isa = PBXBuildFile; fileRef = 8178D4431F02045500AA78A4 /* LVCPlayer.m */; }; |
| 89 | - 8178D4521F02045500AA78A4 /* LVCPlayerLoadingView.m in Sources */ = {isa = PBXBuildFile; fileRef = 8178D4451F02045500AA78A4 /* LVCPlayerLoadingView.m */; }; | |
| 90 | 89 | 8178D4531F02045500AA78A4 /* LVCRequestFailedView.m in Sources */ = {isa = PBXBuildFile; fileRef = 8178D4471F02045500AA78A4 /* LVCRequestFailedView.m */; }; |
| 91 | 90 | 8178D4571F0204D600AA78A4 /* LVCTelevisioController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8178D4561F0204D600AA78A4 /* LVCTelevisioController.m */; }; |
| 92 | 91 | 8178D4611F02060B00AA78A4 /* LVCChatView.m in Sources */ = {isa = PBXBuildFile; fileRef = 8178D45A1F02060B00AA78A4 /* LVCChatView.m */; }; |
| ... | ... | @@ -96,8 +95,8 @@ |
| 96 | 95 | 8178D4681F021C4500AA78A4 /* TelevisionData.json in Resources */ = {isa = PBXBuildFile; fileRef = 8178D4671F021C4500AA78A4 /* TelevisionData.json */; }; |
| 97 | 96 | 8178D46B1F021ED800AA78A4 /* LVCTelevisionModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 8178D46A1F021ED800AA78A4 /* LVCTelevisionModel.m */; }; |
| 98 | 97 | 8178D46E1F0225E500AA78A4 /* LVCTelevisionCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 8178D46D1F0225E500AA78A4 /* LVCTelevisionCell.m */; }; |
| 98 | + 8178D4711F0239AD00AA78A4 /* LVCPlayerLoadingView.m in Sources */ = {isa = PBXBuildFile; fileRef = 8178D4701F0239AD00AA78A4 /* LVCPlayerLoadingView.m */; }; | |
| 99 | 99 | 81A483081E88B6140097A80A /* UIView+ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 81A483071E88B6140097A80A /* UIView+ViewController.m */; }; |
| 100 | - 81DFC4261F0113B40029BCB3 /* JsonFile.json in Resources */ = {isa = PBXBuildFile; fileRef = 81DFC4251F0113B40029BCB3 /* JsonFile.json */; }; | |
| 101 | 100 | 81F1C8381E8BBDDA0085C2B8 /* MHPagingScrollView.m in Sources */ = {isa = PBXBuildFile; fileRef = 81F1C8371E8BBDDA0085C2B8 /* MHPagingScrollView.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; |
| 102 | 101 | 81F1C8401E8BC5CC0085C2B8 /* NSArray+Safety.m in Sources */ = {isa = PBXBuildFile; fileRef = 81F1C83F1E8BC5CC0085C2B8 /* NSArray+Safety.m */; }; |
| 103 | 102 | 81FB5B3C1E7A6FFC00F98E1D /* SevenSwitch.m in Sources */ = {isa = PBXBuildFile; fileRef = 81FB5B3B1E7A6FFC00F98E1D /* SevenSwitch.m */; }; |
| ... | ... | @@ -466,8 +465,6 @@ |
| 466 | 465 | 8178D4371F02045500AA78A4 /* CNBarrageView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CNBarrageView.m; sourceTree = "<group>"; }; |
| 467 | 466 | 8178D4421F02045500AA78A4 /* LVCPlayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LVCPlayer.h; sourceTree = "<group>"; }; |
| 468 | 467 | 8178D4431F02045500AA78A4 /* LVCPlayer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LVCPlayer.m; sourceTree = "<group>"; }; |
| 469 | - 8178D4441F02045500AA78A4 /* LVCPlayerLoadingView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LVCPlayerLoadingView.h; sourceTree = "<group>"; }; | |
| 470 | - 8178D4451F02045500AA78A4 /* LVCPlayerLoadingView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LVCPlayerLoadingView.m; sourceTree = "<group>"; }; | |
| 471 | 468 | 8178D4461F02045500AA78A4 /* LVCRequestFailedView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LVCRequestFailedView.h; sourceTree = "<group>"; }; |
| 472 | 469 | 8178D4471F02045500AA78A4 /* LVCRequestFailedView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LVCRequestFailedView.m; sourceTree = "<group>"; }; |
| 473 | 470 | 8178D4551F0204D600AA78A4 /* LVCTelevisioController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LVCTelevisioController.h; sourceTree = "<group>"; }; |
| ... | ... | @@ -485,9 +482,10 @@ |
| 485 | 482 | 8178D46A1F021ED800AA78A4 /* LVCTelevisionModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LVCTelevisionModel.m; sourceTree = "<group>"; }; |
| 486 | 483 | 8178D46C1F0225E500AA78A4 /* LVCTelevisionCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LVCTelevisionCell.h; sourceTree = "<group>"; }; |
| 487 | 484 | 8178D46D1F0225E500AA78A4 /* LVCTelevisionCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LVCTelevisionCell.m; sourceTree = "<group>"; }; |
| 485 | + 8178D46F1F0239AD00AA78A4 /* LVCPlayerLoadingView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LVCPlayerLoadingView.h; sourceTree = "<group>"; }; | |
| 486 | + 8178D4701F0239AD00AA78A4 /* LVCPlayerLoadingView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LVCPlayerLoadingView.m; sourceTree = "<group>"; }; | |
| 488 | 487 | 81A483061E88B6140097A80A /* UIView+ViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIView+ViewController.h"; sourceTree = "<group>"; }; |
| 489 | 488 | 81A483071E88B6140097A80A /* UIView+ViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIView+ViewController.m"; sourceTree = "<group>"; }; |
| 490 | - 81DFC4251F0113B40029BCB3 /* JsonFile.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = JsonFile.json; sourceTree = "<group>"; }; | |
| 491 | 489 | 81F1C8361E8BBDDA0085C2B8 /* MHPagingScrollView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MHPagingScrollView.h; sourceTree = "<group>"; }; |
| 492 | 490 | 81F1C8371E8BBDDA0085C2B8 /* MHPagingScrollView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MHPagingScrollView.m; sourceTree = "<group>"; }; |
| 493 | 491 | 81F1C83E1E8BC5CC0085C2B8 /* NSArray+Safety.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSArray+Safety.h"; sourceTree = "<group>"; }; |
| ... | ... | @@ -1153,8 +1151,8 @@ |
| 1153 | 1151 | 8178D4431F02045500AA78A4 /* LVCPlayer.m */, |
| 1154 | 1152 | 8178D46C1F0225E500AA78A4 /* LVCTelevisionCell.h */, |
| 1155 | 1153 | 8178D46D1F0225E500AA78A4 /* LVCTelevisionCell.m */, |
| 1156 | - 8178D4441F02045500AA78A4 /* LVCPlayerLoadingView.h */, | |
| 1157 | - 8178D4451F02045500AA78A4 /* LVCPlayerLoadingView.m */, | |
| 1154 | + 8178D46F1F0239AD00AA78A4 /* LVCPlayerLoadingView.h */, | |
| 1155 | + 8178D4701F0239AD00AA78A4 /* LVCPlayerLoadingView.m */, | |
| 1158 | 1156 | 8178D4461F02045500AA78A4 /* LVCRequestFailedView.h */, |
| 1159 | 1157 | 8178D4471F02045500AA78A4 /* LVCRequestFailedView.m */, |
| 1160 | 1158 | ); |
| ... | ... | @@ -2038,7 +2036,6 @@ |
| 2038 | 2036 | isa = PBXGroup; |
| 2039 | 2037 | children = ( |
| 2040 | 2038 | 8178D4671F021C4500AA78A4 /* TelevisionData.json */, |
| 2041 | - 81DFC4251F0113B40029BCB3 /* JsonFile.json */, | |
| 2042 | 2039 | D25BF88C1E7F7F77007FB138 /* Images */, |
| 2043 | 2040 | D25BF88B1E7F7F77007FB138 /* Fonts */, |
| 2044 | 2041 | D25BF88D1E7F7F77007FB138 /* Sound */, |
| ... | ... | @@ -2321,7 +2318,6 @@ |
| 2321 | 2318 | buildActionMask = 2147483647; |
| 2322 | 2319 | files = ( |
| 2323 | 2320 | D2029C971E6EADE10027CD92 /* Info.plist in Resources */, |
| 2324 | - 81DFC4261F0113B40029BCB3 /* JsonFile.json in Resources */, | |
| 2325 | 2321 | D2575C7F1E76A4F300E3A8FC /* NHPlaneViews.xib in Resources */, |
| 2326 | 2322 | D2575C7B1E76A4F300E3A8FC /* NHCarViews.xib in Resources */, |
| 2327 | 2323 | D25BF8901E7F7F8F007FB138 /* UGCLoading.jpeg in Resources */, |
| ... | ... | @@ -2454,7 +2450,6 @@ |
| 2454 | 2450 | D2029CA61E6EADE10027CD92 /* MJRefreshHeader.m in Sources */, |
| 2455 | 2451 | D2029CC41E6EADE10027CD92 /* UIImageView+WebCache.m in Sources */, |
| 2456 | 2452 | 4B45CE801EB86A590079AFB7 /* idAndPwdView.m in Sources */, |
| 2457 | - 8178D4521F02045500AA78A4 /* LVCPlayerLoadingView.m in Sources */, | |
| 2458 | 2453 | D23BBDC41EF8FB99002FE0B8 /* LVCMainHorizontalCollectionViewCell.m in Sources */, |
| 2459 | 2454 | 8178D4251F02043500AA78A4 /* LVCLivePlayerController.m in Sources */, |
| 2460 | 2455 | D236967E1E7F9E4100E4BF71 /* GiftPayButton.m in Sources */, |
| ... | ... | @@ -2582,6 +2577,7 @@ |
| 2582 | 2577 | D23BBDC11EF8F513002FE0B8 /* LVCBqWqXgModel.m in Sources */, |
| 2583 | 2578 | D2029CCF1E6EADE10027CD92 /* SearchHttp.m in Sources */, |
| 2584 | 2579 | 810B65001E779B1F00133E15 /* MASConstraintMaker.m in Sources */, |
| 2580 | + 8178D4711F0239AD00AA78A4 /* LVCPlayerLoadingView.m in Sources */, | |
| 2585 | 2581 | D245715C1E83A62B00AA85D6 /* BounceView.m in Sources */, |
| 2586 | 2582 | D2029D021E6EAE2E0027CD92 /* UIImage+ScaleImageSize.m in Sources */, |
| 2587 | 2583 | D2029BCC1E6EADD70027CD92 /* BaseView.m in Sources */, | ... | ... |
LiveVideoCloud/AppCustoms/Main/ZXTabBarController.m
| ... | ... | @@ -52,7 +52,7 @@ |
| 52 | 52 | - (void)createUI |
| 53 | 53 | { |
| 54 | 54 | [self setupOneChildViewController:[[ZXNavigationController alloc]initWithRootViewController:[[LVCVodPlayerListController alloc]init]] title:@"" image:@"ic_home" selectedImage:@"ic_home_sel"]; |
| 55 | - [self setupOneChildViewController:[[ZXNavigationController alloc]initWithRootViewController:[[UIViewController alloc]init]] title:@"" image:@"ic_live_tv" selectedImage:@"ic_live_tv_sel"]; | |
| 55 | + [self setupOneChildViewController:[[ZXNavigationController alloc]initWithRootViewController:[[LVCTelevisioController alloc]init]] title:@"" image:@"ic_live_tv" selectedImage:@"ic_live_tv_sel"]; | |
| 56 | 56 | [self setupOneChildViewController:[[ZXNavigationController alloc]initWithRootViewController:[[LVCUGCLiveListController alloc]init]] title:@"" image:@"ic_videocam" selectedImage:@"ic_videocam_sel"]; |
| 57 | 57 | [self setupOneChildViewController:[[ZXNavigationController alloc]initWithRootViewController:[[LVCMineViewController alloc]init]] title:@"" image:@"ic_person" selectedImage:@"ic_person_sel"]; |
| 58 | 58 | } | ... | ... |
LiveVideoCloud/AppDelegate/AppDelegate.m
LiveVideoCloud/Classes/Sections/PGCSections/Controller/LVCTelevisioController.m
| ... | ... | @@ -9,6 +9,7 @@ |
| 9 | 9 | #import "LVCTelevisioController.h" |
| 10 | 10 | #import "LVCTelevisionModel.h" |
| 11 | 11 | #import "LVCTelevisionCell.h" |
| 12 | +#import "LVCLivePlayerController.h" | |
| 12 | 13 | |
| 13 | 14 | @interface LVCTelevisioController ()<UITableViewDelegate, UITableViewDataSource> |
| 14 | 15 | { |
| ... | ... | @@ -26,6 +27,7 @@ |
| 26 | 27 | // Do any additional setup after loading the view. |
| 27 | 28 | self.view.backgroundColor = [UIColor whiteColor]; |
| 28 | 29 | self.navigationItem.title = @"直播"; |
| 30 | + | |
| 29 | 31 | _channelsModelArray = [[NSMutableArray alloc] init]; |
| 30 | 32 | |
| 31 | 33 | [self.view addSubview:self.tableView]; |
| ... | ... | @@ -67,6 +69,8 @@ |
| 67 | 69 | if (!cell) { |
| 68 | 70 | cell = [tableView dequeueReusableCellWithIdentifier:cellId]; |
| 69 | 71 | } |
| 72 | + cell.selectionStyle = UITableViewCellSelectionStyleNone; | |
| 73 | + | |
| 70 | 74 | LVCTelevisionModel *model = [_channelsModelArray objectAtIndex:indexPath.row]; |
| 71 | 75 | cell.model = model; |
| 72 | 76 | return cell; |
| ... | ... | @@ -74,7 +78,14 @@ |
| 74 | 78 | } |
| 75 | 79 | |
| 76 | 80 | - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { |
| 77 | - | |
| 81 | + | |
| 82 | + LVCTelevisionModel *model = _channelsModelArray[indexPath.row]; | |
| 83 | + self.hidesBottomBarWhenPushed = YES; | |
| 84 | + LVCLivePlayerController *playVC = [[LVCLivePlayerController alloc] init]; | |
| 85 | + playVC.model = model; | |
| 86 | + self.navigationController.navigationBar.hidden = YES; | |
| 87 | + [self.navigationController pushViewController:playVC animated:YES]; | |
| 88 | + self.hidesBottomBarWhenPushed = NO; | |
| 78 | 89 | } |
| 79 | 90 | |
| 80 | 91 | #pragma mark - | ... | ... |
LiveVideoCloud/Classes/Sections/PGCSections/View/LVCPlayer.m
| ... | ... | @@ -13,6 +13,7 @@ |
| 13 | 13 | @interface LVCPlayer ()<UIGestureRecognizerDelegate,LVCPlayerLoadingViewDelegate> |
| 14 | 14 | { |
| 15 | 15 | LVCTelevisionModel *_model; |
| 16 | + BOOL _noInternet; | |
| 16 | 17 | } |
| 17 | 18 | |
| 18 | 19 | @property (nonatomic, strong) CNLiveMoviePlayerController *player; |
| ... | ... | @@ -44,6 +45,7 @@ |
| 44 | 45 | [self initPlayerWithModel:model]; |
| 45 | 46 | |
| 46 | 47 | [self addSubview:self.contentView]; |
| 48 | + [self.contentView addSubview:self.loadingView]; | |
| 47 | 49 | [self.contentView addSubview:self.bottomBgView]; |
| 48 | 50 | [self.contentView addSubview:self.topBgView]; |
| 49 | 51 | [self.bottomBgView addSubview:self.playOrPauseBtn]; |
| ... | ... | @@ -51,7 +53,6 @@ |
| 51 | 53 | [self.topBgView addSubview:self.titleLab]; |
| 52 | 54 | [self.topBgView addSubview:self.barrageSwitch]; |
| 53 | 55 | [self addSubview:self.backBtn]; |
| 54 | - [self.contentView addSubview:self.loadingView]; | |
| 55 | 56 | [self.contentView addSubview:self.editBtn]; |
| 56 | 57 | [self.contentView addGestureRecognizer:self.singleTap]; |
| 57 | 58 | |
| ... | ... | @@ -66,6 +67,8 @@ |
| 66 | 67 | { |
| 67 | 68 | /* |
| 68 | 69 | */ |
| 70 | + [self.loadingView setLVCPlayerStatus:LVCPlayerStatusStartLoading]; | |
| 71 | + | |
| 69 | 72 | NSString *channelId = [NSString stringWithFormat:@"82_%@",model.mediaId]; |
| 70 | 73 | _player = [[CNLiveMoviePlayerController alloc] initLivePlayWithChannelId:channelId anchorStatus:NO authSuccess:^{ |
| 71 | 74 | [self addObservers]; |
| ... | ... | @@ -212,7 +215,7 @@ |
| 212 | 215 | #pragma mark - LVCPlayerLoadingViewDelegate |
| 213 | 216 | - (void)retryBtnClick |
| 214 | 217 | { |
| 215 | - [_loadingView startLoading]; | |
| 218 | + [_loadingView setLVCPlayerStatus:LVCPlayerStatusStartLoading]; | |
| 216 | 219 | [_player reload:nil]; |
| 217 | 220 | } |
| 218 | 221 | |
| ... | ... | @@ -252,6 +255,12 @@ |
| 252 | 255 | name:MPMoviePlayerPlaybackStateDidChangeNotification |
| 253 | 256 | object:nil]; |
| 254 | 257 | |
| 258 | + //网络状态改变 | |
| 259 | + [[NSNotificationCenter defaultCenter] addObserver:self | |
| 260 | + selector:@selector(moviePlayerNetworkStatusChange:) | |
| 261 | + name:MPMoviePlayerNetworkStatusChangeNotification | |
| 262 | + object:nil]; | |
| 263 | + | |
| 255 | 264 | [[NSNotificationCenter defaultCenter] addObserver:self |
| 256 | 265 | selector:@selector(appResignActive:) |
| 257 | 266 | name:UIApplicationWillResignActiveNotification |
| ... | ... | @@ -267,10 +276,13 @@ |
| 267 | 276 | { |
| 268 | 277 | if (_player) { |
| 269 | 278 | MPMovieLoadState loadState = _player.loadState; |
| 270 | - if ((loadState & MPMovieLoadStatePlaythroughOK) != 0) { | |
| 279 | + if ((loadState & MPMovieLoadStatePlaythroughOK) != 0) { //加载完成 | |
| 280 | + [_loadingView setLVCPlayerStatus:LVCPlayerStatusStopLoading]; | |
| 281 | + | |
| 271 | 282 | NSLog(@"loadStateDidChange: MPMovieLoadStatePlaythroughOK: %d\n", (int)loadState); |
| 272 | 283 | |
| 273 | - } else if ((loadState & MPMovieLoadStateStalled) != 0) { | |
| 284 | + } else if ((loadState & MPMovieLoadStateStalled) != 0) { //视频正在加载中 | |
| 285 | + [_loadingView setLVCPlayerStatus:LVCPlayerStatusStartLoading]; | |
| 274 | 286 | NSLog(@"loadStateDidChange: MPMovieLoadStateStalled: %d\n", (int)loadState); |
| 275 | 287 | |
| 276 | 288 | } else { |
| ... | ... | @@ -284,28 +296,13 @@ |
| 284 | 296 | if (_player) { |
| 285 | 297 | int reason = [[[notification userInfo] valueForKey:MPMoviePlayerPlaybackDidFinishReasonUserInfoKey] intValue]; |
| 286 | 298 | if (MPMovieFinishReasonPlaybackError == reason) { |
| 287 | - _loadingView.hidden = NO; | |
| 299 | + if (_noInternet) { | |
| 300 | + [_loadingView setLVCPlayerStatus:LVCPlayerStatusNoNetwork]; | |
| 301 | + } else { | |
| 302 | + [_loadingView setLVCPlayerStatus:LVCPlayerStatusStopError]; | |
| 303 | + } | |
| 288 | 304 | } else { |
| 289 | - _loadingView.hidden = YES; | |
| 290 | - } | |
| 291 | - | |
| 292 | - switch (reason) | |
| 293 | - { | |
| 294 | - case MPMovieFinishReasonPlaybackEnded: | |
| 295 | - NSLog(@"playbackStateDidChange: MPMovieFinishReasonPlaybackEnded: %d\n", reason); | |
| 296 | - break; | |
| 297 | - | |
| 298 | - case MPMovieFinishReasonUserExited: | |
| 299 | - NSLog(@"playbackStateDidChange: MPMovieFinishReasonUserExited: %d\n", reason); | |
| 300 | - break; | |
| 301 | - | |
| 302 | - case MPMovieFinishReasonPlaybackError: | |
| 303 | - NSLog(@"playbackStateDidChange: MPMovieFinishReasonPlaybackError: %d\n", reason); | |
| 304 | - break; | |
| 305 | - | |
| 306 | - default: | |
| 307 | - NSLog(@"playbackPlayBackDidFinish: ???: %d\n", reason); | |
| 308 | - break; | |
| 305 | + [_loadingView setLVCPlayerStatus:LVCPlayerStatusStopLoading]; | |
| 309 | 306 | } |
| 310 | 307 | } |
| 311 | 308 | } |
| ... | ... | @@ -323,68 +320,66 @@ |
| 323 | 320 | |
| 324 | 321 | if (_player.playbackState == MPMoviePlaybackStatePlaying) { |
| 325 | 322 | _playOrPauseBtn.selected = YES; |
| 326 | - _loadingView.hidden = YES; | |
| 323 | + [_loadingView setLVCPlayerStatus:LVCPlayerStatusStopLoading]; | |
| 324 | + } else if (_player.playbackState == MPMoviePlaybackStateSeekingForward || _player.playbackState == MPMoviePlaybackStateSeekingBackward) { | |
| 325 | + [_loadingView setLVCPlayerStatus:LVCPlayerStatusStartLoading]; | |
| 327 | 326 | } else { |
| 328 | 327 | _playOrPauseBtn.selected = NO; |
| 329 | 328 | } |
| 330 | 329 | |
| 331 | 330 | NSLog(@"moviePlayBackStateDidChange : %ld",(long)_player.playbackState); |
| 331 | + | |
| 332 | + } | |
| 333 | +} | |
| 334 | + | |
| 335 | +//网络状态监听 | |
| 336 | +- (void)moviePlayerNetworkStatusChange:(NSNotification *)notify { | |
| 337 | + int currStatus = [[[notify userInfo] valueForKey:MPMoviePlayerCurrNetworkStatusUserInfoKey] intValue]; | |
| 338 | + int lastStatus = [[[notify userInfo] valueForKey:MPMoviePlayerLastNetworkStatusUserInfoKey] intValue]; | |
| 339 | + | |
| 340 | + if (currStatus == CNLiveNotReachable) { | |
| 341 | + _noInternet = YES; | |
| 342 | + } else { | |
| 343 | + _noInternet = NO; | |
| 344 | + } | |
| 345 | + | |
| 346 | + NSLog(@"network reachable change from %@ to %@\n", [self netStatus2Str:lastStatus], [self netStatus2Str:currStatus]); | |
| 347 | +} | |
| 332 | 348 | |
| 333 | - /* | |
| 334 | - switch (_player.playbackState) { | |
| 335 | - case MPMoviePlaybackStateStopped: { | |
| 336 | - | |
| 337 | - [self changePlayBtnStatus:NO]; | |
| 338 | - NSLog(@"moviePlayBackStateDidChange : MPMoviePlaybackStateStopped"); | |
| 339 | - break; | |
| 340 | - } | |
| 341 | - case MPMoviePlaybackStatePlaying: { | |
| 342 | - [self changePlayBtnStatus:YES]; | |
| 343 | - NSLog(@"moviePlayBackStateDidChange : MPMoviePlaybackStatePlaying"); | |
| 344 | - break; | |
| 345 | - } | |
| 346 | - case MPMoviePlaybackStatePaused: | |
| 347 | - [self changePlayBtnStatus:NO]; | |
| 348 | - NSLog(@"moviePlayBackStateDidChange : MPMoviePlaybackStatePaused"); | |
| 349 | - break; | |
| 350 | - case MPMoviePlaybackStateInterrupted: | |
| 351 | - [self changePlayBtnStatus:NO]; | |
| 352 | - NSLog(@"moviePlayBackStateDidChange : MPMoviePlaybackStateInterrupted"); | |
| 353 | - break; | |
| 354 | - case MPMoviePlaybackStateSeekingForward: | |
| 355 | - [self changePlayBtnStatus:NO]; | |
| 356 | - NSLog(@"moviePlayBackStateDidChange : MPMoviePlaybackStateSeekingForward"); | |
| 357 | - break; | |
| 358 | - case MPMoviePlaybackStateSeekingBackward: | |
| 359 | - [self changePlayBtnStatus:NO]; | |
| 360 | - NSLog(@"moviePlayBackStateDidChange : MPMoviePlaybackStateSeekingBackward"); | |
| 361 | - break; | |
| 362 | - default: | |
| 363 | - [self changePlayBtnStatus:NO]; | |
| 364 | - NSLog(@"moviePlayBackStateDidChange : %ld", _player.playbackState); | |
| 365 | - break; | |
| 366 | - } | |
| 367 | - */ | |
| 349 | +- (NSString *) netStatus2Str:(CNLiveNetworkStatus)networkStatus{ | |
| 350 | + NSString *netString = nil; | |
| 351 | + | |
| 352 | + if(networkStatus == CNLiveNotReachable){ | |
| 353 | + netString = @"NO INTERNET"; | |
| 354 | + } else if(networkStatus == CNLiveReachableViaWiFi) { | |
| 355 | + netString = @"WIFI"; | |
| 356 | + } else if(networkStatus == CNLiveReachableViaWWAN) { | |
| 357 | + netString = @"WWAN"; | |
| 358 | + } else { | |
| 359 | + netString = @"Unknown"; | |
| 368 | 360 | } |
| 361 | + return netString; | |
| 369 | 362 | } |
| 370 | 363 | |
| 371 | 364 | - (void)appResignActive:(NSNotification *)noti |
| 372 | 365 | { |
| 373 | - [_player pause]; | |
| 366 | + if (_player.playbackState == MPMoviePlaybackStatePlaying) { | |
| 367 | + [_player pause]; | |
| 368 | + } | |
| 374 | 369 | } |
| 375 | 370 | |
| 376 | 371 | - (void)appBecomeActive:(NSNotification *)noti |
| 377 | 372 | { |
| 378 | - [_player play]; | |
| 373 | + if (_player.playbackState == MPMoviePlaybackStatePaused) { | |
| 374 | + [_player play]; | |
| 375 | + } | |
| 379 | 376 | } |
| 380 | 377 | |
| 381 | 378 | #pragma mark - |
| 382 | 379 | #pragma mark - public |
| 383 | 380 | - (void)stopPlaying |
| 384 | 381 | { |
| 385 | - if (_player.isPlaying) { | |
| 386 | - [_player stop]; | |
| 387 | - } | |
| 382 | + [_player stop]; | |
| 388 | 383 | _player = nil; |
| 389 | 384 | |
| 390 | 385 | if (_timer) { |
| ... | ... | @@ -430,9 +425,7 @@ |
| 430 | 425 | }]; |
| 431 | 426 | |
| 432 | 427 | [self.loadingView mas_makeConstraints:^(MASConstraintMaker *make) { |
| 433 | - make.center.equalTo(self.contentView); | |
| 434 | - make.width.mas_equalTo(100); | |
| 435 | - make.height.mas_equalTo(80); | |
| 428 | + make.top.left.right.bottom.equalTo(self); | |
| 436 | 429 | }]; |
| 437 | 430 | |
| 438 | 431 | [self.backBtn mas_makeConstraints:^(MASConstraintMaker *make) { |
| ... | ... | @@ -617,6 +610,7 @@ |
| 617 | 610 | { |
| 618 | 611 | if (!_loadingView) { |
| 619 | 612 | _loadingView = [[LVCPlayerLoadingView alloc] init]; |
| 613 | + _loadingView.delegate = self; | |
| 620 | 614 | } |
| 621 | 615 | return _loadingView; |
| 622 | 616 | } | ... | ... |
LiveVideoCloud/Classes/Sections/PGCSections/View/LVCPlayerLoadingView.h
| ... | ... | @@ -8,6 +8,13 @@ |
| 8 | 8 | |
| 9 | 9 | #import <UIKit/UIKit.h> |
| 10 | 10 | |
| 11 | +typedef NS_ENUM(NSUInteger, LVCPlayerStatus) { | |
| 12 | + LVCPlayerStatusStartLoading = 0, | |
| 13 | + LVCPlayerStatusStopLoading, | |
| 14 | + LVCPlayerStatusStopError, | |
| 15 | + LVCPlayerStatusNoNetwork | |
| 16 | +}; | |
| 17 | + | |
| 11 | 18 | @protocol LVCPlayerLoadingViewDelegate <NSObject> |
| 12 | 19 | |
| 13 | 20 | - (void)retryBtnClick; //点击重试 |
| ... | ... | @@ -18,6 +25,8 @@ |
| 18 | 25 | |
| 19 | 26 | @property (nonatomic, assign) id<LVCPlayerLoadingViewDelegate> delegate; |
| 20 | 27 | |
| 28 | +- (void)setLVCPlayerStatus:(LVCPlayerStatus)status; | |
| 29 | + | |
| 21 | 30 | - (void)startLoading; //开始加载 |
| 22 | 31 | |
| 23 | 32 | - (void)stopLoading; //停止加载 | ... | ... |
LiveVideoCloud/Classes/Sections/PGCSections/View/LVCPlayerLoadingView.m
| ... | ... | @@ -57,6 +57,41 @@ |
| 57 | 57 | _loadingLab.hidden = YES; |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | +- (void)setLVCPlayerStatus:(LVCPlayerStatus)status { | |
| 61 | + | |
| 62 | + switch (status) { | |
| 63 | + case LVCPlayerStatusStartLoading: | |
| 64 | + _loadingLab.text = @"努力加载中..."; | |
| 65 | + [_loadingView startAnimating]; | |
| 66 | + _retryBtn.hidden = YES; | |
| 67 | + _loadingLab.hidden = NO; | |
| 68 | + break; | |
| 69 | + | |
| 70 | + case LVCPlayerStatusStopLoading: | |
| 71 | + _loadingLab.hidden = YES; | |
| 72 | + [_loadingView stopAnimating]; | |
| 73 | + _retryBtn.hidden = YES; | |
| 74 | + break; | |
| 75 | + | |
| 76 | + case LVCPlayerStatusStopError: | |
| 77 | + _loadingLab.text = @"抱歉,播放异常,请重试"; | |
| 78 | + [_loadingView stopAnimating]; | |
| 79 | + _retryBtn.hidden = NO; | |
| 80 | + _loadingLab.hidden = NO; | |
| 81 | + break; | |
| 82 | + | |
| 83 | + case LVCPlayerStatusNoNetwork: | |
| 84 | + _loadingLab.text = @"网络连接中断,请确认网络连接后重试"; | |
| 85 | + [_loadingView stopAnimating]; | |
| 86 | + _retryBtn.hidden = NO; | |
| 87 | + _loadingLab.hidden = NO; | |
| 88 | + break; | |
| 89 | + | |
| 90 | + default: | |
| 91 | + break; | |
| 92 | + } | |
| 93 | +} | |
| 94 | + | |
| 60 | 95 | #pragma mark - |
| 61 | 96 | #pragma mark - action |
| 62 | 97 | - (void)retryBtnAction |
| ... | ... | @@ -73,23 +108,22 @@ |
| 73 | 108 | { |
| 74 | 109 | |
| 75 | 110 | [self.loadingView mas_makeConstraints:^(MASConstraintMaker *make) { |
| 76 | - make.centerX.mas_equalTo(self.width/2); | |
| 77 | - make.top.mas_equalTo(0); | |
| 78 | - }]; | |
| 79 | - | |
| 80 | - [self.loadingLab mas_makeConstraints:^(MASConstraintMaker *make) { | |
| 81 | - make.left.mas_equalTo(0); | |
| 82 | - make.top.mas_equalTo(40); | |
| 83 | - make.width.equalTo(self); | |
| 84 | - make.height.mas_equalTo(40); | |
| 111 | + make.centerY.equalTo(self).offset(-20); | |
| 112 | + make.centerX.equalTo(self); | |
| 85 | 113 | }]; |
| 86 | 114 | |
| 87 | 115 | [self.retryBtn mas_makeConstraints:^(MASConstraintMaker *make) { |
| 88 | 116 | make.width.mas_equalTo(70); |
| 89 | - make.height.mas_equalTo(40); | |
| 90 | - make.center.equalTo(self); | |
| 117 | + make.height.mas_equalTo(35); | |
| 118 | + make.centerY.equalTo(self).offset(-20); | |
| 119 | + make.centerX.equalTo(self); | |
| 91 | 120 | }]; |
| 92 | 121 | |
| 122 | + [self.loadingLab mas_makeConstraints:^(MASConstraintMaker *make) { | |
| 123 | + make.left.right.mas_equalTo(0); | |
| 124 | + make.top.equalTo(self.loadingView.hidden ? self.loadingView.mas_bottom : self.retryBtn.mas_bottom).with.offset(15); | |
| 125 | + make.height.mas_equalTo(30); | |
| 126 | + }]; | |
| 93 | 127 | } |
| 94 | 128 | |
| 95 | 129 | #pragma mark - |
| ... | ... | @@ -119,11 +153,11 @@ |
| 119 | 153 | if (!_retryBtn) { |
| 120 | 154 | _retryBtn = [UIButton buttonWithType:UIButtonTypeCustom]; |
| 121 | 155 | [_retryBtn setTitle:@"重试" forState:UIControlStateNormal]; |
| 122 | - [_retryBtn setTitleColor:[UIColor yellowColor] forState:UIControlStateNormal]; | |
| 156 | + [_retryBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; | |
| 123 | 157 | _retryBtn.hidden = YES; |
| 124 | 158 | _retryBtn.layer.cornerRadius = 10; |
| 125 | 159 | _retryBtn.layer.masksToBounds = YES; |
| 126 | - _retryBtn.layer.borderColor = [UIColor yellowColor].CGColor; | |
| 160 | + _retryBtn.layer.borderColor = [UIColor whiteColor].CGColor; | |
| 127 | 161 | _retryBtn.layer.borderWidth = 1; |
| 128 | 162 | [_retryBtn addTarget:self action:@selector(retryBtnAction) forControlEvents:UIControlEventTouchUpInside]; |
| 129 | 163 | } | ... | ... |
LiveVideoCloud/Resource/JsonFile.json deleted
100644 → 0
| 1 | -{"banner":[{"mediaId":"88da3d45ad2f2745c586ea51b32b2121a6","subTitle":"大型现代原创木偶剧《飞吧 丹顶鹤》","title":"原创木偶剧飞吧丹顶鹤","picType":"small","img":"http://y1.cnliveimg.com:8080/image/itv/2016/0601/da3d45ad2f2745c586ea51b32b2121a6_100.jpg","docID":"618405","vipFlag":"0","type":"program","url":"http://www.cnlive.com/liveshow/v_gyytqnbqgu.html"},{"mediaId":"liveshow","subTitle":"最打动人心的主题音乐故事访谈","title":"liveshow直播:我的音乐故事","picType":"small","img":"http://yweb3.cnliveimg.com/img/cnlive/160129105318359_583.jpg","docID":"408481","vipFlag":"0","type":"live","url":"http://live.cnlive.com/liveshow.html"},{"mediaId":"vhd","subTitle":"热点大事件,萌宠陪你开心唠!体验不一样的资讯直播,戳这里!","title":"侃侃总动员","picType":"small","img":"http://yweb1.cnliveimg.com/img/cnlive/160323165036485_383.jpg","docID":"411530","vipFlag":"0","type":"live","url":"http://live.cnlive.com/vhd.html"}],"marquee":[{"mediaId":"dongnanweishi","subTitle":"海峡西岸经济区主流媒体","title":"东南卫视","picType":"small","img":"http://y1.cnliveimg.com:8080/img/cnlive/public/141110143521312_163.jpg","docID":"410681","vipFlag":"0","type":"live","url":"http://live.cnlive.com/dongnanweishi.html"}],"channels":[{"cid":"live_/tctv/","title":"自主特色直播","channelType":"H","programs":[{"mediaId":"61ca3833365f4fe2975c7db183b61892","subTitle":"互动直播测试","title":"侃侃总动员","desc":"主持人与虚拟萌物合作直播","picType":"small","currentPlay":"神秘原始部落制木乃伊","img":"http://yweb1.cnliveimg.com/img/cnlive/160118114000423_284.jpg","docID":"573134","vipFlag":"0","type":"album","itemId":"581018","url":"http://www.cnlive.com/news/v_gu3tgmjtgq.html","nextPlay":"地球上最热的地狱盐矿"},{"mediaId":"xbxjy","subTitle":"小笨熊教育","title":"小笨熊教育","desc":"为3至12岁儿童精心打造优质的教育频道,包含经典古诗学习,国学教育智力培养,行为教育,文化教育,行为规范、安全教育等内容,其中也不少的精彩的童话故事和家长和儿童之间可以互动的亲子互动内容。节目高清流畅,内容全部正向有趣,是目前最好的儿童教育频道。","picType":"small","currentPlay":"不小心割破手指该怎么办","img":"http://yweb2.cnliveimg.com/cnlive/public/160530111952623_945.jpg","docID":"617301","vipFlag":"0","type":"live","itemId":"595600","url":"http://live.cnlive.com/xbxjy.html","nextPlay":"上下楼梯要注意什么"},{"mediaId":"liveshow","subTitle":"最打动人心的主题音乐故事访谈","title":"LiveShow","desc":"最震撼的演唱会直播、最打动人心的主题音乐故事访谈、最搞笑的剧场话剧直播!","picType":"small","currentPlay":"20151020我的音乐故事音乐小神兽汪苏泷","img":"http://yweb0.cnliveimg.com/cnlive/public/150417133551285_693.png","docID":"408481","vipFlag":"0","type":"live","itemId":"581019","url":"http://live.cnlive.com/liveshow.html","nextPlay":"20151113摇滚男孩王晓天做客音乐故事!"},{"mediaId":"news","subTitle":"","title":"快新闻","desc":"时政、社会、财经、文体、奇趣等快新闻,最热门、最新鲜、最快捷,互动直达!","picType":"small","currentPlay":"南非已开始退出国际刑事法院","img":"http://yweb1.cnliveimg.com/img/cnlive/160121113653827_867.png","docID":"285697","vipFlag":"0","type":"live","itemId":"581021","url":"http://live.cnlive.com/news.html","nextPlay":"少年宿舍坠楼而亡疑在校受辱"},{"mediaId":"eyule","subTitle":"","title":"e娱乐","desc":"热辣娱文、新鲜速递、聊电影、说大片,特色直播精彩呈现!","picType":"small","currentPlay":"网络博主斥港媒为谢霆锋洗白","img":"http://yweb2.cnliveimg.com/img/cnlive/160121113659992_585.png","docID":"408480","vipFlag":"0","type":"live","itemId":"581022","url":"http://live.cnlive.com/eyule.html","nextPlay":"袁姗姗陈晓面对潜规则超淡定"},{"mediaId":"chaotiyu","subTitle":"","title":"潮体育","desc":"赛事直播、最新体坛资讯,全方位扫描热点体坛人物、绝色花边!","picType":"small","currentPlay":"情暖你我2017爱在马城","img":"http://yweb3.cnliveimg.com/img/cnlive/160121113706887_696.png","docID":"285698","vipFlag":"0","type":"live","itemId":"581023","url":"http://live.cnlive.com/chaotiyu.html","nextPlay":"策马扬鞭!欢聚“乐在马城”"},{"mediaId":"xuanhanyu","subTitle":"韩剧韩片韩综 有你想看的!","title":"炫韩娱","desc":"韩国动态、思密达帮帮团、搞笑综艺等,第一知晓韩国娱乐动态,尽在炫韩娱直播频道!","picType":"small","currentPlay":"尹施允被鬼吓金赛纶霸气镇场","img":"http://yweb0.cnliveimg.com/cnlive/public/150417133341123_878.png","docID":"408487","vipFlag":"0","type":"live","itemId":"581024","url":"http://live.cnlive.com/xuanhanyu.html","nextPlay":"Eric徐贤真约会玩绑架被抓!"},{"mediaId":"inyuetai","subTitle":"音乐爱好者的完美聚集地","title":"in乐台","desc":"新歌抢线、MV鉴赏、明星访谈,明星亲临现场诉说音乐故事。大咖们邀你一起感受听觉上的饕餮盛宴。","picType":"small","currentPlay":"新单《WeDontTalkAnymore》","img":"http://yweb1.cnliveimg.com/cnlive/public/150417144750615_185.png","docID":"285696","vipFlag":"0","type":"live","itemId":"581025","url":"http://live.cnlive.com/inyuetai.html","nextPlay":"酷玩《AHeadFullOfDreams》"}]},{"cid":"live_/CIBN/","title":"CIBN","channelType":"H","programs":[{"mediaId":"cibn_lvyou","subTitle":"荟聚全球当红明星,最新的音乐资讯","title":"CIBN嗨播","desc":"荟聚全球当红明星,最新的音乐资讯,劲爆的演唱会现场,包罗万象的热门音乐排行榜,足不出户悦享饕餮音乐盛宴。","picType":"small","currentPlay":"夏季音乐季《梦幻与激情》","img":"http://yweb0.cnliveimg.com/cnlive/public/170428170445759_292.jpg","docID":"427049","vipFlag":"0","type":"live","itemId":"689292","url":"http://live.cnlive.com/cibn_lvyou.html","nextPlay":"SNH48 GROUP 2017年度大型青春励志纪录片《我心翱翔》"},{"mediaId":"cibn_dianying","subTitle":"CIBN电影频道","title":"CIBN电影频道","desc":"","picType":"small","currentPlay":"电话谋杀案","img":"http://yweb2.cnliveimg.com/img/cnlive/160120143835091_965.jpg","docID":"427031","vipFlag":"0","type":"live","itemId":"421082","url":"http://live.cnlive.com/cibn_dianying.html","nextPlay":"内心引力 预告片"},{"mediaId":"cibn_weidianying","subTitle":"CIBN微电影","title":"CIBN微电影","desc":"","picType":"small","currentPlay":"二次元 10 探店 拉面 上","img":"http://yweb3.cnliveimg.com/img/cnlive/160120143842769_360.jpg","docID":"427050","vipFlag":"0","type":"live","itemId":"421083","url":"http://live.cnlive.com/cibn_weidianying.html","nextPlay":"脂肪君-02-人鱼线"},{"mediaId":"cibn_rebo","subTitle":"CIBN热播剧场","title":"CIBN热播剧场","desc":"","picType":"small","currentPlay":"一粒红尘10","img":"http://yweb1.cnliveimg.com/img/cnlive/160120143857458_721.jpg","docID":"427032","vipFlag":"0","type":"live","itemId":"421085","url":"http://live.cnlive.com/cibn_rebo.html","nextPlay":"碧生源常箐茶"},{"mediaId":"cibn_jilu","subTitle":"CIBN纪录","title":"CIBN纪录","desc":"","picType":"small","currentPlay":"赞比西河 生命之源","img":"http://yweb2.cnliveimg.com/img/cnlive/160120143906855_603.jpg","docID":"427048","vipFlag":"0","type":"live","itemId":"421086","url":"http://live.cnlive.com/cibn_jilu.html","nextPlay":"CAN TV 广告片"},{"mediaId":"cibn_zongyi","subTitle":"CIBN综艺","title":"CIBN综艺","desc":"","picType":"small","currentPlay":"金古珍藏 频道宣传片","img":"http://yweb3.cnliveimg.com/img/cnlive/160120143913782_912.jpg","docID":"427046","vipFlag":"0","type":"live","itemId":"421087","url":"http://live.cnlive.com/cibn_zongyi.html","nextPlay":"匠作之传播善与美的白瓷菩萨造像"}]}],"errorMessage":"数据加载成功","errorCode":"0"} | |
| 2 | 0 | \ No newline at end of file |