Commit 5a8369c0a5cb580b69603b594b2246fc41c05cef

Authored by yinqiaojuan
1 parent a01ebdf5

0.0.5 修改上拉下拉视频从新播放问题

CNLiveWitnessVideoModule.podspec
@@ -8,7 +8,7 @@ @@ -8,7 +8,7 @@
8 8
9 Pod::Spec.new do |s| 9 Pod::Spec.new do |s|
10 s.name = 'CNLiveWitnessVideoModule' 10 s.name = 'CNLiveWitnessVideoModule'
11 - s.version = '0.0.4' 11 + s.version = '0.0.5'
12 s.summary = '目击者视频播放功能' 12 s.summary = '目击者视频播放功能'
13 13
14 # This description is used to generate tags and improve search results. 14 # This description is used to generate tags and improve search results.
CNLiveWitnessVideoModule/Classes/Controller/CNBWitnessListController.m
@@ -73,10 +73,10 @@ NSString * const kIdentifier = @"CNBWitnessListCell"; @@ -73,10 +73,10 @@ NSString * const kIdentifier = @"CNBWitnessListCell";
73 [_dataSource addObject:witnessModel]; 73 [_dataSource addObject:witnessModel];
74 } 74 }
75 }else { 75 }else {
76 - NSDictionary *dic = list[currentIndex]; 76 + _currentPlayIndex = 0;
  77 + NSDictionary *dic = list[_currentPlayIndex];
77 CNBWitnessListModel *witnessModel = [CNBWitnessListModel mj_objectWithKeyValues:dic]; 78 CNBWitnessListModel *witnessModel = [CNBWitnessListModel mj_objectWithKeyValues:dic];
78 [_dataSource addObject:witnessModel]; 79 [_dataSource addObject:witnessModel];
79 - _currentPlayIndex = 0;  
80 } 80 }
81 _pageIndex = pageNum + 1; 81 _pageIndex = pageNum + 1;
82 _isHaveNext = @"1"; 82 _isHaveNext = @"1";
@@ -403,7 +403,7 @@ NSString * const kIdentifier = @"CNBWitnessListCell"; @@ -403,7 +403,7 @@ NSString * const kIdentifier = @"CNBWitnessListCell";
403 #pragma mark - scrollViewDelegate 403 #pragma mark - scrollViewDelegate
404 - (void)scrollViewDidScroll:(UIScrollView *)scrollView { 404 - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
405 NSInteger currentIndex = round(scrollView.contentOffset.y / KScreenHeight); 405 NSInteger currentIndex = round(scrollView.contentOffset.y / KScreenHeight);
406 - if (currentIndex != self.currentPlayIndex && !self.isRefreshMore) { 406 + if (currentIndex != self.currentPlayIndex && !self.isRefreshMore && [self.type isEqualToString:@"0"]) {
407 [self.videoPlayerManager resetPlayer]; 407 [self.videoPlayerManager resetPlayer];
408 self.currentPlayIndex = currentIndex; 408 self.currentPlayIndex = currentIndex;
409 if (!self.isRefreshMore && [self.isHaveNext isEqualToString:@"1"]) { 409 if (!self.isRefreshMore && [self.isHaveNext isEqualToString:@"1"]) {
@@ -415,26 +415,29 @@ NSString * const kIdentifier = @"CNBWitnessListCell"; @@ -415,26 +415,29 @@ NSString * const kIdentifier = @"CNBWitnessListCell";
415 } 415 }
416 - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView { 416 - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
417 NSLog(@"播放下一个"); 417 NSLog(@"播放下一个");
418 - if (self.currentPlayIndex >= 0 && self.dataSource.count > self.currentPlayIndex) {  
419 - if ([CNLiveNetworking isNetworking]) {  
420 - if ([CNLiveNetworking isWiFiNetwork]) {  
421 - [self playIndex:self.currentPlayIndex isAutoPlay:YES];  
422 - }else if ([CNLiveNetworking isWWANNetwork]) {  
423 - BOOL isAgress4G = [[NSUserDefaults standardUserDefaults] objectForKey:@"isAgress4G"];  
424 - if (isAgress4G) { 418 + if ([self.type isEqualToString:@"0"]) {
  419 + if (self.currentPlayIndex >= 0 && self.dataSource.count > self.currentPlayIndex) {
  420 + if ([CNLiveNetworking isNetworking]) {
  421 + if ([CNLiveNetworking isWiFiNetwork]) {
425 [self playIndex:self.currentPlayIndex isAutoPlay:YES]; 422 [self playIndex:self.currentPlayIndex isAutoPlay:YES];
  423 + }else if ([CNLiveNetworking isWWANNetwork]) {
  424 + BOOL isAgress4G = [[NSUserDefaults standardUserDefaults] objectForKey:@"isAgress4G"];
  425 + if (isAgress4G) {
  426 + [self playIndex:self.currentPlayIndex isAutoPlay:YES];
  427 + }else {
  428 + [self playIndex:self.currentPlayIndex isAutoPlay:NO];
  429 + }
426 }else { 430 }else {
427 [self playIndex:self.currentPlayIndex isAutoPlay:NO]; 431 [self playIndex:self.currentPlayIndex isAutoPlay:NO];
428 } 432 }
429 - }else {  
430 - [self playIndex:self.currentPlayIndex isAutoPlay:NO];  
431 } 433 }
432 } 434 }
433 } 435 }
  436 +
434 } 437 }
435 - (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate { 438 - (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate {
436 CGFloat currentIndex = scrollView.contentOffset.y / KScreenHeight; 439 CGFloat currentIndex = scrollView.contentOffset.y / KScreenHeight;
437 - if(fabs(currentIndex - self.currentPlayIndex)>1) { 440 + if((fabs(currentIndex - self.currentPlayIndex)>1) && [self.type isEqualToString:@"0"]) {
438 [self.videoPlayerManager resetPlayer]; 441 [self.videoPlayerManager resetPlayer];
439 } 442 }
440 } 443 }
Example/CNLiveWitnessVideoModule/CNLIVEViewController.m
@@ -35,7 +35,7 @@ @@ -35,7 +35,7 @@
35 } 35 }
36 - (void)setUPCollectionView { 36 - (void)setUPCollectionView {
37 UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc]init]; 37 UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc]init];
38 - CGFloat itemWidth = (KScreenWidth - 40) / 3; 38 + CGFloat itemWidth = (KScreenWidth - 60) / 3;
39 39
40 //设置单元格大小 40 //设置单元格大小
41 layout.itemSize = CGSizeMake(itemWidth, itemWidth); 41 layout.itemSize = CGSizeMake(itemWidth, itemWidth);