Kaynağa Gözat

1.bug修复
2.文件上传处理

huangxiaodong 2 yıl önce
ebeveyn
işleme
db8aaa5cfa
21 değiştirilmiş dosya ile 310 ekleme ve 83 silme
  1. 2 0
      创维盒子/双子星云手机/AppDelegate/Config/Notification.h
  2. 6 2
      创维盒子/双子星云手机/Class/Set/MySetViewController.m
  3. 69 5
      创维盒子/双子星云手机/Class/Set/uploadFile/PhotoPreviewViewController.m
  4. 1 0
      创维盒子/双子星云手机/Class/Set/uploadFile/model/TZAssetModel+imageData.h
  5. 7 0
      创维盒子/双子星云手机/Class/Set/uploadFile/model/TZAssetModel+imageData.m
  6. 2 1
      创维盒子/双子星云手机/Class/Set/uploadFile/model/uploadFileDataModel.h
  7. 2 0
      创维盒子/双子星云手机/Class/Set/uploadFile/photoView/AJPhotoGroupView.h
  8. 11 1
      创维盒子/双子星云手机/Class/Set/uploadFile/photoView/AJPhotoGroupView.m
  9. 2 0
      创维盒子/双子星云手机/Class/Set/uploadFile/photoView/photoPreViewBottomView.h
  10. 10 2
      创维盒子/双子星云手机/Class/Set/uploadFile/photoView/photoPreViewBottomView.m
  11. 8 1
      创维盒子/双子星云手机/Class/Set/uploadFile/photoView/uploadFileBottomView.m
  12. 2 0
      创维盒子/双子星云手机/Class/Set/uploadFile/photoView/uploadFileRecordBodyView.h
  13. 33 5
      创维盒子/双子星云手机/Class/Set/uploadFile/photoView/uploadFileRecordBodyView.m
  14. 13 10
      创维盒子/双子星云手机/Class/Set/uploadFile/photoView/uploadFileRecordCell.m
  15. 1 1
      创维盒子/双子星云手机/Class/Set/uploadFile/uploadFileManager/uploadFileManager.h
  16. 23 5
      创维盒子/双子星云手机/Class/Set/uploadFile/uploadFileManager/uploadFileManager.m
  17. 56 0
      创维盒子/双子星云手机/Class/Set/uploadFile/uploadFileRecordViewController.m
  18. 1 1
      创维盒子/双子星云手机/Class/Set/uploadFile/uploadImageOrVideoViewController.h
  19. 31 5
      创维盒子/双子星云手机/Class/Set/uploadFile/uploadImageOrVideoViewController.m
  20. 29 44
      创维盒子/双子星云手机/CloudPlayer/PlayerViewController+otherDelegate.mm
  21. 1 0
      创维盒子/双子星云手机/CloudPlayer/PlayerViewController.h

+ 2 - 0
创维盒子/双子星云手机/AppDelegate/Config/Notification.h

@@ -58,6 +58,8 @@
 
 /* 上传文件通知*/
 #define uploadFileBeginNotification                 @"uploadFileBeginNot"
+/*上传文件更新通知*/
+#define uploadFileRefreshNotification                 @"uploadFileRefreshNot"
 
 #define PlayerViewControlBtnTouchBeganNotification        @"PlayerViewControlBtnTouchBeganNotification"        // 云手机推流界面 控制按钮开始点击
 #define PlayerViewControlBtnTouchEndNotification          @"PlayerViewControlBtnTouchEndNotification"        /// // 云手机推流界面 控制按钮结束点击

+ 6 - 2
创维盒子/双子星云手机/Class/Set/MySetViewController.m

@@ -83,8 +83,12 @@
         
         if(tag ==2 || tag ==3){
             uploadImageOrVideoViewController *vc = [uploadImageOrVideoViewController new];
-            //vc.assetsFilter = [ALAssetsFilter allVideos];
-            //vc.assetsFilter = [ALAssetsFilter allPhotos];
+            if(tag ==2){
+                vc.isPhotoType = YES;
+            }
+            else{
+                vc.isPhotoType = NO;
+            }
             [self.navigationController pushViewController:vc animated:YES];
             
         }

+ 69 - 5
创维盒子/双子星云手机/Class/Set/uploadFile/PhotoPreviewViewController.m

@@ -8,6 +8,7 @@
 #import "PhotoPreviewViewController.h"
 #import "TZPhotoPreviewCell.h"
 #import "photoPreViewBottomView.h"
+#import "uploadFileRecordViewController.h"
 
 @interface PhotoPreviewViewController ()<UICollectionViewDataSource,UICollectionViewDelegate,UICollectionViewDelegateFlowLayout,UIScrollViewDelegate>
 @property (strong, nonatomic) UIButton *selectButton;
@@ -15,6 +16,9 @@
 @property (strong, nonatomic) photoPreViewBottomView *photoPreViewBottomV;
 
 @property (assign, nonatomic) BOOL canSetCurrentIndex;//
+
+
+@property (strong, nonatomic)TZVideoPreviewCell * curCell;
 @end
 
 @implementation PhotoPreviewViewController
@@ -25,6 +29,9 @@
     
     [self.view setBackgroundColor:[UIColor blackColor]];
     
+    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(videoPreviewCellDidPlayerFun) name:@"TZ_VIDEO_PLAY_NOTIFICATION" object:nil];
+    
+    
     [self.toolBar setHidden:YES];
     [self.navigationBar setHidden:YES];
     [self.navBarBGView setHidden:NO];
@@ -57,6 +64,9 @@
     [super viewWillDisappear:animated];
     ///黑色
     [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];
+    
+    [UIApplication sharedApplication].statusBarHidden = NO;
+    [self.curCell pausePlayerAndShowNaviBar];
 }
 
 #pragma mark 点击选中按钮
@@ -94,9 +104,32 @@
                     if (imageData) {
                         model.imageData = imageData;
                     }
-                
-                [self setDataToBottomViewFun];
+                if(model.type != TZAssetModelMediaTypeVideo){
+                    [self setDataToBottomViewFun];
+                }
             }];
+            
+            if(model.type == TZAssetModelMediaTypeVideo){
+                
+                PHVideoRequestOptions *options = [[PHVideoRequestOptions alloc] init];
+                options.version = PHVideoRequestOptionsVersionOriginal;
+                [[PHImageManager defaultManager] requestAVAssetForVideo:model.asset options:options resultHandler:^(AVAsset *asset, AVAudioMix *audioMix, NSDictionary *info) {
+                    if ([asset isKindOfClass:[AVURLAsset class]]) {
+                        
+                        AVURLAsset* urlAsset = (AVURLAsset*)asset;
+                        NSData *videoData = [NSData dataWithContentsOfURL:urlAsset.URL];
+//                        NSNumber *size;
+//                        [urlAsset.URL getResourceValue:&size forKey:NSURLFileSizeKey error:nil];
+//                        NSLog(@"size is %f",[size floatValue]/(1024.0*1024.0));
+                     
+                        
+                        model.videoData = videoData;
+                        [self setDataToBottomViewFun];
+                 }
+                }];
+
+            }
+
         }
     }
     
@@ -108,7 +141,10 @@
 #pragma mark 同步数据到底部
 - (void)setDataToBottomViewFun
 {
-    self.photoPreViewBottomV.indexPathsForSelectedItems = self.indexPathsForSelectedItems;
+    mainBlock(^{
+        self.photoPreViewBottomV.indexPathsForSelectedItems = self.indexPathsForSelectedItems;
+    });
+    
 }
 
 #pragma mark 刷新导航栏的UI
@@ -188,6 +224,11 @@
         make.bottom.mas_equalTo(0);
         make.height.mas_equalTo((60 + safeArea));
     }];
+    
+    KWeakSelf
+    bottomView.didClickUploadFile = ^{
+        [weakSelf gotoUploadFileRecordFun];
+    };
 }
 #pragma mark - UIScrollViewDelegate
 
@@ -262,6 +303,11 @@
     [cell setSingleTapGestureBlock:^{
         __strong typeof(weakSelf) strongSelf = weakSelf;
         //[strongSelf didTapPreviewCell];
+        
+        if([cell isKindOfClass:[TZVideoPreviewCell class]]){
+            weakSelf.curCell = cell;
+        }
+        
     }];
 
     return cell;
@@ -284,8 +330,26 @@
     return 0.0;
 }
 
-- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
-  
+- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
+
+}
+
+#pragma mark 跳转上传记录
+- (void)gotoUploadFileRecordFun
+{
+    [UIApplication sharedApplication].statusBarHidden = NO;
+    
+    uploadFileRecordViewController *vc = [uploadFileRecordViewController new];
+    [self.navigationController pushViewController:vc animated:YES];
     
+    [vc gotoUploadFile:_indexPathsForSelectedItems];
 }
+
+#pragma mark TZVideoPreviewCell视频播放
+- (void)videoPreviewCellDidPlayerFun
+{
+    //[UIApplication sharedApplication].statusBarHidden = NO;
+}
+
+
 @end

+ 1 - 0
创维盒子/双子星云手机/Class/Set/uploadFile/model/TZAssetModel+imageData.h

@@ -13,6 +13,7 @@ NS_ASSUME_NONNULL_BEGIN
 //NSLog(@"filename:%@",filename);
 @interface TZAssetModel (imageData)
 @property (nonatomic, retain) NSData *imageData;
+@property (nonatomic, retain) NSData *videoData;
 @end
 
 NS_ASSUME_NONNULL_END

+ 7 - 0
创维盒子/双子星云手机/Class/Set/uploadFile/model/TZAssetModel+imageData.m

@@ -16,4 +16,11 @@
 - (NSString *)imageData {
     return objc_getAssociatedObject(self, @selector(imageData));
 }
+
+- (void)setVideoData:(NSData *)videoData {
+    objc_setAssociatedObject(self, @selector(videoData), videoData, OBJC_ASSOCIATION_RETAIN);
+}
+- (NSString *)videoData {
+    return objc_getAssociatedObject(self, @selector(videoData));
+}
 @end

+ 2 - 1
创维盒子/双子星云手机/Class/Set/uploadFile/model/uploadFileDataModel.h

@@ -28,9 +28,10 @@ typedef enum{
 //目前上传用到的字段有
 @property (nonatomic, copy)  NSString *filename;
 @property (nonatomic, retain) NSData *_Nullable imageData;
+@property (nonatomic, retain) NSData *_Nullable videoData;
 @property (nonatomic, assign)  uploadStateType curUploadStateType;
 @property (nonatomic, assign)  uploadFileType curUploadFileType;
-@property (nonatomic, assign)  NSInteger didUploadBytes;//已经上传的字节数
+@property (nonatomic, assign)  long didUploadBytes;//已经上传的字节数
 @end
 
 NS_ASSUME_NONNULL_END

+ 2 - 0
创维盒子/双子星云手机/Class/Set/uploadFile/photoView/AJPhotoGroupView.h

@@ -33,6 +33,8 @@
 //委托
 @property (weak, nonatomic) id<AJPhotoGroupViewProtocol> my_delegate;
 
+@property (nonatomic,assign) BOOL isPhotoType;//是否为选择图片类型
+
 //选中相册的索引
 @property (nonatomic) NSInteger selectIndex;
 

+ 11 - 1
创维盒子/双子星云手机/Class/Set/uploadFile/photoView/AJPhotoGroupView.m

@@ -51,7 +51,17 @@
 - (void)setupGroup {
     [self.albumGroups removeAllObjects];
     
-    [[TZImageManager manager] getAllAlbums:NO allowPickingImage:YES needFetchAssets:NO completion:^(NSArray<TZAlbumModel *> *models) {
+    BOOL canGetVideo = NO;
+    BOOL canGetPhoto = NO;
+    
+    if(_isPhotoType){
+        canGetPhoto = YES;
+    }
+    else{
+        canGetVideo = YES;
+    }
+    
+    [[TZImageManager manager] getAllAlbums:canGetVideo allowPickingImage:canGetPhoto needFetchAssets:NO completion:^(NSArray<TZAlbumModel *> *models) {
         
         self->_albumGroups = [[NSMutableArray alloc] initWithArray:models];
         [self dataReload];

+ 2 - 0
创维盒子/双子星云手机/Class/Set/uploadFile/photoView/photoPreViewBottomView.h

@@ -13,6 +13,8 @@ NS_ASSUME_NONNULL_BEGIN
 @interface photoPreViewBottomView : UIView
 //选中的项
 @property (nonatomic, strong) NSMutableArray *indexPathsForSelectedItems;
+//点击上传
+@property (nonatomic,copy) void (^didClickUploadFile)(void);
 @end
 
 NS_ASSUME_NONNULL_END

+ 10 - 2
创维盒子/双子星云手机/Class/Set/uploadFile/photoView/photoPreViewBottomView.m

@@ -111,7 +111,12 @@
     NSUInteger allImageData = 0;
     
     for (TZAssetModel* model in _indexPathsForSelectedItems) {
-        allImageData += [model.imageData length];
+        if(model.type == TZAssetModelMediaTypeVideo){
+            allImageData += [model.videoData length];
+        }
+        else{
+            allImageData += [model.imageData length];
+        }
     }
     
     allImageData /= 1024;
@@ -164,7 +169,10 @@
 #pragma mark 按钮点击
 - (void)didClickButFun:(UIButton*)but
 {
-    
+    if(_didClickUploadFile)
+    {
+        _didClickUploadFile();
+    }
 }
 
 @end

+ 8 - 1
创维盒子/双子星云手机/Class/Set/uploadFile/photoView/uploadFileBottomView.m

@@ -111,7 +111,14 @@
     NSUInteger allImageData = 0;
     
     for (TZAssetModel* model in _indexPathsForSelectedItems) {
-        allImageData += [model.imageData length];
+        
+        if(model.type == TZAssetModelMediaTypeVideo){
+            allImageData += [model.videoData length];
+        }
+        else{
+            allImageData += [model.imageData length];
+        }
+        
     }
     
     allImageData /= 1024;

+ 2 - 0
创维盒子/双子星云手机/Class/Set/uploadFile/photoView/uploadFileRecordBodyView.h

@@ -14,6 +14,8 @@ NS_ASSUME_NONNULL_BEGIN
 @property (nonatomic,copy) void (^didScrollFun)(NSInteger index);
 @property(nonatomic,assign) NSInteger selectIndex;// 从1开始
 @property (nonatomic, strong) NSMutableArray *allDataArr;
+
+- (void)RefreshDataWithUploadingArr:(NSMutableArray* _Nullable)uploadingArr withDoneArr:(NSMutableArray* _Nullable)doneArr withfailArr:(NSMutableArray* _Nullable)failArr;
 @end
 
 NS_ASSUME_NONNULL_END

+ 33 - 5
创维盒子/双子星云手机/Class/Set/uploadFile/photoView/uploadFileRecordBodyView.m

@@ -197,14 +197,15 @@
 {
     _allDataArr = allDataArr;
     
-    //刷新数据
-    [self reloadAllDataFun];
+    mainBlock(^{
+        //刷新数据
+        [self reloadAllDataFun];
+    });
 }
 
 #pragma mark 熟悉全部数据
 - (void)reloadAllDataFun
 {
-    mainBlock(^{
         NSArray *subViews = [self->_bgScrollV subviews];
         
         for (UITableView *tableView in subViews) {
@@ -212,8 +213,35 @@
                 [tableView reloadData];
             }
         }
-    });
-    
 }
 
+- (void)RefreshDataWithUploadingArr:(NSMutableArray* _Nullable)uploadingArr withDoneArr:(NSMutableArray* _Nullable)doneArr withfailArr:(NSMutableArray* _Nullable)failArr
+{
+    if(uploadingArr){
+        UITableView *curTabview = [self->_bgScrollV viewWithTag:10];
+        
+        if([curTabview isKindOfClass:[UITableView class]]){
+            [_allDataArr replaceObjectAtIndex:0 withObject:uploadingArr];
+            [curTabview reloadData];
+        }
+    }
+    
+    if(doneArr){
+        UITableView *curTabview = [self->_bgScrollV viewWithTag:11];
+        
+        if([curTabview isKindOfClass:[UITableView class]]){
+            [_allDataArr replaceObjectAtIndex:1 withObject:doneArr];
+            [curTabview reloadData];
+        }
+    }
+    
+    if(failArr){
+        UITableView *curTabview = [self->_bgScrollV viewWithTag:12];
+        
+        if([curTabview isKindOfClass:[UITableView class]]){
+            [_allDataArr replaceObjectAtIndex:2 withObject:failArr];
+            [curTabview reloadData];
+        }
+    }
+}
 @end

+ 13 - 10
创维盒子/双子星云手机/Class/Set/uploadFile/photoView/uploadFileRecordCell.m

@@ -60,6 +60,7 @@
     _progressBgView = [[UIView alloc] init];
     _progressBgView.backgroundColor = [UIColor hwColor:@"#F9F9F9" alpha:1.0];
     _progressBgView.layer.cornerRadius = 1.5;
+    _progressBgView.layer.masksToBounds = YES;
     [self.contentView addSubview:_progressBgView];
     
     [_progressBgView mas_makeConstraints:^(MASConstraintMaker *make) {
@@ -90,10 +91,9 @@
     _glayer.locations = @[@(0), @(1.0f)];
     [_progressSelectView.layer addSublayer:_glayer];
     
-//    CGRect frame = CGRectMake(0, 0, 100, 3);
-//    _progressSelectView.frame = frame;
-//    _glayer.frame = frame;
-    
+    CGRect frame = CGRectMake(0, 0, SCREEN_W, 2);
+    //_progressSelectView.frame = frame;
+    _glayer.frame = frame;
     
     _fileNamelabel = [[UILabel alloc] init];
     _fileNamelabel.font = [UIFont boldSystemFontOfSize:16.0];
@@ -137,6 +137,8 @@
 
 - (void)setCurUploadFileDataModel:(uploadFileDataModel *)curUploadFileDataModel
 {
+    HLog(@"hhhhhhh  %@ %ld %ld",curUploadFileDataModel.bg_id,curUploadFileDataModel.curUploadStateType,curUploadFileDataModel.didUploadBytes);
+    
     _fileImageView.image = [UIImage imageWithData:curUploadFileDataModel.imageData];
     _fileSpeedlabel.hidden = YES;
     
@@ -158,9 +160,13 @@
     _fileNamelabel.text = curUploadFileDataModel.filename;
     
     //进度设置
-    CGRect frame = _progressBgView.frame;
+    CGRect frame = CGRectMake(0, 0, SCREEN_W - 15*2 - 34*2, 2);
     
     NSInteger totalSize = [curUploadFileDataModel.imageData length];
+    if(curUploadFileDataModel.curUploadFileType == uploadFileTypeVideo){
+        totalSize = [curUploadFileDataModel.videoData length];
+    }
+    
     CGFloat curProgress = curUploadFileDataModel.didUploadBytes/(totalSize*1.0);
     
     if(curProgress > 1){
@@ -168,11 +174,8 @@
     }
     
     frame.size.width =  frame.size.width * curProgress;
-    
-    [UIView animateWithDuration:0.1 animations:^{
-        self->_progressSelectView.frame = frame;
-        self->_glayer.frame = frame;
-    }];
+    _progressSelectView.frame = frame;
+    //_glayer.frame = frame;
     
     NSString * totalSizeStr = nil;
     NSInteger totalSize_k = totalSize / 1024;

+ 1 - 1
创维盒子/双子星云手机/Class/Set/uploadFile/uploadFileManager/uploadFileManager.h

@@ -31,7 +31,7 @@ NS_ASSUME_NONNULL_BEGIN
 - (void)uploadFileDoneFun;
 
 //修改文件上传的状态
-- (void)changeUploadFileState:(uploadStateType)curUploadStateType withDidUploadBytes:(NSInteger)didUpLoadBytes complete:(custom_complete_B)complete;
+- (void)changeUploadFileState:(uploadStateType)curUploadStateType withDidUploadBytes:(long)didUpLoadBytes complete:(custom_complete_B)complete;
 @end
 
 NS_ASSUME_NONNULL_END

+ 23 - 5
创维盒子/双子星云手机/Class/Set/uploadFile/uploadFileManager/uploadFileManager.m

@@ -40,6 +40,7 @@ static uploadFileManager * cur_uploadFileShareInstance = nil;
     for (TZAssetModel * model in indexPathsForSelectedItems) {
         uploadFileDataModel * curModel = [uploadFileDataModel new];
         curModel.imageData = model.imageData;
+        curModel.videoData = model.videoData;
         curModel.filename = [model.asset valueForKey:@"filename"];
         curModel.curUploadStateType = uploadStateWait;
         
@@ -96,8 +97,17 @@ static uploadFileManager * cur_uploadFileShareInstance = nil;
 }
 
 //修改文件上传的状态
-- (void)changeUploadFileState:(uploadStateType)curUploadStateType withDidUploadBytes:(NSInteger)didUpLoadBytes  complete:(custom_complete_B)complete
+- (void)changeUploadFileState:(uploadStateType)curUploadStateType withDidUploadBytes:(long)didUpLoadBytes  complete:(custom_complete_B)complete
 {
+    _curUploadFileDataModel.curUploadStateType = curUploadStateType;
+    _curUploadFileDataModel.didUploadBytes = didUpLoadBytes;
+    
+    [[NSNotificationCenter defaultCenter] postNotificationName:uploadFileRefreshNotification object:_curUploadFileDataModel];
+    
+    if(curUploadStateType == uploadStateUploading){
+        return;
+    }
+   
     
     //NSNumber * numberUploadState = nil;
     NSString* where = nil;
@@ -121,13 +131,15 @@ static uploadFileManager * cur_uploadFileShareInstance = nil;
             curModel.curUploadStateType = curUploadStateType;
             curModel.didUploadBytes = didUpLoadBytes;
             
+            if(curUploadStateType == uploadStateDone){
+                curModel.videoData = [NSData new];
+                HLog(@"");
+            }
+            
             [curModel bg_saveOrUpdateAsync:^(BOOL isSuccess) {
                 HLog(@"%@ 写入 %@", self->_curUploadFileDataModel.filename, isSuccess ? @"成功":@"失败");
             }];
             
-            if(curUploadStateType == uploadStateDone){
-                HLog(@"");
-            }
         }
         
         complete(YES);
@@ -138,7 +150,13 @@ static uploadFileManager * cur_uploadFileShareInstance = nil;
 
 - (void)uploadFileDoneFun
 {
-    [self changeUploadFileState:uploadStateDone withDidUploadBytes:[_curUploadFileDataModel.imageData length] complete:^(BOOL isSuccess) {
+    long totalSizeByte = [_curUploadFileDataModel.imageData length];
+    
+    if(_curUploadFileDataModel.curUploadFileType == uploadFileTypeVideo){
+        totalSizeByte = [_curUploadFileDataModel.videoData length];
+    }
+    
+    [self changeUploadFileState:uploadStateDone withDidUploadBytes:totalSizeByte complete:^(BOOL isSuccess) {
         [self->_fileModelDataArr removeObject:self->_curUploadFileDataModel];
          
         if(self->_fileModelDataArr.count > 0){

+ 56 - 0
创维盒子/双子星云手机/Class/Set/uploadFile/uploadFileRecordViewController.m

@@ -27,6 +27,9 @@
     // Do any additional setup after loading the view.
     
     //[self.view setBackgroundColor:HWF5F7FAColor];
+    
+    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(uploadFileRefreshFun:)  name:uploadFileRefreshNotification  object:nil];
+    
     [self.view setBackgroundColor:[UIColor whiteColor]];
     
     self.titleLabel.text = NSLocalizedString(@"my_set_no_File_upload_record",nil) ;
@@ -124,4 +127,57 @@
 
 }
 
+
+- (void)uploadFileRefreshFun:(NSNotification*)not
+{
+    uploadFileDataModel *uploadFileDataMod = [not object];
+    HLog(@"%@",uploadFileDataMod);
+    
+    if(_allDataArr.count == 3 && [uploadFileDataMod isKindOfClass:[uploadFileDataModel class]] ){
+        
+        NSMutableArray *curArr = _allDataArr[0];
+        
+        NSInteger index = 0;
+        for (uploadFileDataModel*mod in curArr) {
+            HLog(@"bg_id:%@ ?=? %@",mod.bg_id,uploadFileDataMod.bg_id);
+            
+            if(mod.bg_id.integerValue == uploadFileDataMod.bg_id.integerValue){
+                
+                if(uploadFileDataMod.curUploadStateType == uploadStateDone){
+                    [curArr removeObject:mod];
+                    
+                    NSMutableArray *doneArr = _allDataArr[1];
+                    [doneArr insertObject:uploadFileDataMod atIndex:0];
+                }
+                else if(uploadFileDataMod.curUploadStateType == uploadStateFail){
+                    [curArr removeObject:mod];
+                    
+                    NSMutableArray *failArr = _allDataArr[2];
+                    [failArr insertObject:uploadFileDataMod atIndex:0];
+                }
+                else{
+                    [curArr replaceObjectAtIndex:index withObject:uploadFileDataMod];
+                }
+                
+                break;
+            }
+            
+            index++;
+        }
+        
+        //精准刷新
+        if(uploadFileDataMod.curUploadStateType == uploadStateDone){
+            [self.uploadFileRecordBodyV RefreshDataWithUploadingArr:_allDataArr[0] withDoneArr:_allDataArr[1] withfailArr:nil];
+        }
+        else if(uploadFileDataMod.curUploadStateType == uploadStateFail){
+            [self.uploadFileRecordBodyV RefreshDataWithUploadingArr:_allDataArr[0] withDoneArr:nil withfailArr:_allDataArr[2]];
+        }
+        else{
+            [self.uploadFileRecordBodyV RefreshDataWithUploadingArr:_allDataArr[0] withDoneArr:nil withfailArr:nil];
+        }
+    }
+   
+    //self.uploadFileRecordBodyV.allDataArr = _allDataArr;
+    
+}
 @end

+ 1 - 1
创维盒子/双子星云手机/Class/Set/uploadFile/uploadImageOrVideoViewController.h

@@ -18,7 +18,7 @@ NS_ASSUME_NONNULL_BEGIN
 
 //选中的项 TZAssetModel
 @property (nonatomic, strong) NSMutableArray *indexPathsForSelectedItems;
-
+@property (nonatomic,assign) BOOL isPhotoType;//是否为选择图片类型
 @end
 
 NS_ASSUME_NONNULL_END

+ 31 - 5
创维盒子/双子星云手机/Class/Set/uploadFile/uploadImageOrVideoViewController.m

@@ -55,7 +55,7 @@
     [self initBaselUIFun];
     
     _isNotAllowed = YES;
-    _maximumNumberOfSelection = 3;
+    _maximumNumberOfSelection = 30;
     _minimumNumberOfSelection = 0;
     _multipleSelection = YES;
     
@@ -215,6 +215,7 @@
 - (void)setupGroupView {
     AJPhotoGroupView *photoGroupView = [[AJPhotoGroupView alloc] init];
     photoGroupView.my_delegate = self;
+    photoGroupView.isPhotoType = _isPhotoType;
     [self.view insertSubview:photoGroupView belowSubview:self.navBarBGView];
     self.photoGroupView = photoGroupView;
     photoGroupView.hidden = YES;
@@ -408,15 +409,37 @@
         
         if(!model.imageData)
         {
-            
             [[PHImageManager defaultManager] requestImageDataForAsset:model.asset options:nil resultHandler:^(NSData * _Nullable imageData, NSString * _Nullable dataUTI, UIImageOrientation orientation, NSDictionary * _Nullable info) {
                     // 直接得到最终的 NSData 数据
                     if (imageData) {
                         model.imageData = imageData;
                     }
-                
-                [self setDataToBottomViewFun];
+                if(model.type != TZAssetModelMediaTypeVideo){
+                    [self setDataToBottomViewFun];
+                }
             }];
+            
+            if(model.type == TZAssetModelMediaTypeVideo){
+                
+                PHVideoRequestOptions *options = [[PHVideoRequestOptions alloc] init];
+                options.version = PHVideoRequestOptionsVersionOriginal;
+                [[PHImageManager defaultManager] requestAVAssetForVideo:model.asset options:options resultHandler:^(AVAsset *asset, AVAudioMix *audioMix, NSDictionary *info) {
+                    if ([asset isKindOfClass:[AVURLAsset class]]) {
+                        
+                        AVURLAsset* urlAsset = (AVURLAsset*)asset;
+                        NSData *videoData = [NSData dataWithContentsOfURL:urlAsset.URL];
+//                        NSNumber *size;
+//                        [urlAsset.URL getResourceValue:&size forKey:NSURLFileSizeKey error:nil];
+//                        NSLog(@"size is %f",[size floatValue]/(1024.0*1024.0));
+                     
+                        
+                        model.videoData = videoData;
+                        [self setDataToBottomViewFun];
+                 }
+                }];
+
+            }
+
         }
     }
     
@@ -427,7 +450,10 @@
 #pragma mark 同步数据到底部
 - (void)setDataToBottomViewFun
 {
-    self.uploadFileBottomV.indexPathsForSelectedItems = self.indexPathsForSelectedItems;
+    mainBlock(^{
+        self.uploadFileBottomV.indexPathsForSelectedItems = self.indexPathsForSelectedItems;
+    });
+    
 }
 
 #pragma mark - getter/setter

+ 29 - 44
创维盒子/双子星云手机/CloudPlayer/PlayerViewController+otherDelegate.mm

@@ -30,7 +30,7 @@
 - (void)beginGotoUploadFileFun:(NSNotification *)notification
 {
     uploadFileDataModel *uploadFileDataMod = [notification object];
-    HLog(@"%@",uploadFileDataMod);
+    //HLog(@"%@",uploadFileDataMod);
     self.curUploadFileDataMod = uploadFileDataMod;
     
     if(![uploadFileDataMod isKindOfClass:[uploadFileDataMod class]]){
@@ -142,10 +142,16 @@
     if(!self.taskUid){
         self.taskUid = [iTools getTaskUidStr];
         self.fileName = self.curUploadFileDataMod.filename;
-        self.AllFileData = self.curUploadFileDataMod.imageData;
+        if(self.curUploadFileDataMod.curUploadFileType == uploadFileTypeVideo){
+            self.AllFileData = self.curUploadFileDataMod.videoData;
+        }
+        else{
+            self.AllFileData = self.curUploadFileDataMod.imageData;
+        }
+        
         self.indexOfUploadFlie = 0;
         
-        HLog(@"%@  %@",self.taskUid,self.fileName);
+        //HLog(@"%@  %@",self.taskUid,self.fileName);
         //self.cutFileDataArr = [self fileCutPartsBy:self.AllFileData];
     }
     
@@ -165,7 +171,7 @@
 {
     if(self.indexOfUploadFlie < self.cutFileDataArr.count -1) {
         
-        NSInteger didUploadSize = (self.indexOfUploadFlie+1) * (8*1024);
+        NSInteger didUploadSize = (self.indexOfUploadFlie+1) * (self.cutFileEachPieceSzie);
         
         [[uploadFileManager shareInstance] changeUploadFileState:uploadStateUploading withDidUploadBytes:didUploadSize complete:^(BOOL isSuccess) {
 
@@ -188,19 +194,6 @@
     }
 }
 
-//- (int)getBCC:(NSData*)data
-//{
-//    int bcc = 0;
-//    for (int i = 0; i < [data length]; i++) {
-//        Byte buffer;
-//        [data getBytes:&buffer range:NSMakeRange(i, 1)];
-//        bcc = (UInt8) (bcc ^ buffer);
-//
-//        //HLog(@"bcc 222 %d",bcc);
-//    }
-//
-//    return bcc;
-//}
 
 - (Byte)getBCC:(NSData *)data {
     Byte bcc = 0;
@@ -211,15 +204,6 @@
     return bcc;
 }
 
-//int getbcc(UInt8 *data, int length) {
-//    int bcc = 0;
-//    for (int i = 0; i < length; i++) {
-//        bcc = (UInt8) (bcc ^ data[i]);
-//    }
-//
-//    return bcc;
-//}
-
 
 #pragma mark 文件切片
 -(NSMutableArray *)fileCutPartsBy:(NSData*)curData withDidUpLoadSize:(NSInteger)didLoadSize{
@@ -228,7 +212,8 @@
     
     NSUInteger allLength = data.length;
     
-    NSUInteger subs = 8*1024;//4096;//要切片的大小,我这里设置的是4096字节
+    NSUInteger subs = 100*1024;//4096;//要切片的大小,我这里设置的是4096字节
+    self.cutFileEachPieceSzie = subs;
     
     NSInteger index = 0;//起始位置
     
@@ -249,7 +234,7 @@
             
             index++;
             
-            NSLog(@"%@",NSStringFromRange(range));
+            //NSLog(@"%@",NSStringFromRange(range));
             
             [dataArray addObject:[data subdataWithRange:range]];
             
@@ -259,7 +244,7 @@
             
             NSRange range = NSMakeRange(index*subs, allLength);
             
-            NSLog(@"%@",NSStringFromRange(range));
+            //NSLog(@"%@",NSStringFromRange(range));
             
             [dataArray addObject:[data subdataWithRange:range]];
 
@@ -269,7 +254,7 @@
         
     } while (allLength>0);
     
-    NSLog(@"%@",dataArray);//最后得到切片的结果,数组里面是NSData对象
+    //NSLog(@"%@",dataArray);//最后得到切片的结果,数组里面是NSData对象
 
     return dataArray;
 }
@@ -307,44 +292,44 @@
  */
 - (void)upLoadFileFun
 {
-    HLog(@"上传文件%ld/%ld",self.indexOfUploadFlie +1,self.cutFileDataArr.count);
+    //HLog(@"上传文件%ld/%ld",self.indexOfUploadFlie +1,self.cutFileDataArr.count);
     //data
     NSData *curData = self.cutFileDataArr[self.indexOfUploadFlie];
-    HLog(@"headData:%@",curData);
+    //HLog(@"headData:%@",curData);
     
     //head
     unsigned char headNum = 104;
     NSData *headData = [NSMutableData dataWithBytes:&headNum length:sizeof(headNum)];
-    HLog(@"headData:%@",headData);
+    //HLog(@"headData:%@",headData);
     
     //msgType
     //unsigned char msgType = 12;
     unsigned char msgType = 15;
     NSData *msgTypeData = [NSMutableData dataWithBytes:&msgType length:sizeof(msgType)];
-    HLog(@"msgTypeData:%@",msgTypeData);
+    //HLog(@"msgTypeData:%@",msgTypeData);
     
     //taskId
     NSData *taskIdData = [self.taskUid dataUsingEncoding:NSUTF8StringEncoding];
-    HLog(@"taskIdData:%@",taskIdData);
+    //HLog(@"taskIdData:%@",taskIdData);
     
     //datalen
     int datalenNum = int([curData length] +(4+4));
     //NSData *datalenData = [NSData dataWithBytes:&datalenNum length:sizeof(datalenNum)];
     NSData *datalenData = [self int2Data:datalenNum];
-    HLog(@"datalenData %@",datalenData);
+    //HLog(@"datalenData %@",datalenData);
     
     
     //curNum
     int curNum = (int)self.indexOfUploadFlie;
     //NSData *curNumData = [NSData dataWithBytes:&curNum length:sizeof(curNum)];
     NSData * curNumData = [self int2Data:curNum];
-    HLog(@"curNumData:%@",curNumData);
+    //HLog(@"curNumData:%@",curNumData);
     
     //totalNum
     int totalNum = (int)self.cutFileDataArr.count;
     //NSData *totalNumData = [NSData dataWithBytes:&totalNum length:sizeof(totalNum)];
     NSData * totalNumData = [self int2Data:totalNum];
-    HLog(@"totalNumData:%@",totalNumData);
+    //HLog(@"totalNumData:%@",totalNumData);
     
 
     NSMutableData *checkBCCData = [NSMutableData new];
@@ -356,20 +341,20 @@
     [checkBCCData appendData:curData];
     
     int length = [curData length];
-    HLog(@"curData length %d",length);
+    //HLog(@"curData length %d",length);
     
     Byte bccCheck = [self getBCC:checkBCCData];
-    HLog(@"bcc 000 %d",bccCheck);
+    //HLog(@"bcc 000 %d",bccCheck);
     
     //bcc校验
     char bccNum = (char)bccCheck;
     NSData *bccData = [NSMutableData dataWithBytes:&bccNum length:sizeof(bccNum)];
-    HLog(@"%@",bccData);
+    //HLog(@"%@",bccData);
     
     //end
     unsigned char endNum = 22;
     NSData *endData = [NSMutableData dataWithBytes:&endNum length:sizeof(endNum)];
-    HLog(@"%@",endData);
+    //HLog(@"%@",endData);
     
     NSMutableData *sendData = [NSMutableData new];
     [sendData appendData:headData];
@@ -377,9 +362,9 @@
     [sendData appendData:bccData];
     [sendData appendData:endData];
     
-    HLog(@"sendData length %ld",[sendData length]);
+    //HLog(@"sendData length %ld",[sendData length]);
     [self.commandChannelManager rc_sendData:sendData];
-    HLog(@"文件上传sendData %@",sendData);
+    //HLog(@"文件上传sendData %@",sendData);
 }
 
 @end

+ 1 - 0
创维盒子/双子星云手机/CloudPlayer/PlayerViewController.h

@@ -100,6 +100,7 @@
 @property (nonatomic, strong) NSData * _Nullable AllFileData;
 @property (nonatomic, strong) NSMutableArray * _Nullable cutFileDataArr;
 @property (nonatomic, assign) NSInteger indexOfUploadFlie;
+@property (nonatomic, assign) NSInteger cutFileEachPieceSzie;
 @property (nonatomic, strong) uploadFileDataModel *curUploadFileDataMod;
 /**
  * @brief 云手机类型  VIP星动云手机  SVIP星曜云手机  STAR 唔即云手机