浏览代码

1.断点续传完成

huangxiaodong 2 年之前
父节点
当前提交
ddbdc0af07

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

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

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

@@ -178,6 +178,15 @@
             cell.didClckSelectBut = ^(BOOL isSelect) {
                 [weakSelf selectModelOneByOne:model BySelect:isSelect];
             };
+            
+            cell.didTapPressClick = ^{
+                if(model.curUploadStateType == uploadStateUploading){
+                    [weakSelf handleUploadingStateTapFunBy:YES with:model];
+                }
+                else if(model.curUploadStateType == uploadStateSuspend){
+                    [weakSelf handleUploadingStateTapFunBy:NO with:model];
+                }
+            };
         }
     }
     
@@ -455,4 +464,17 @@
     }];
 }
 
+
+#pragma mark 处理上传中的 状态点击事件
+- (void)handleUploadingStateTapFunBy:(BOOL)isSuspendType with:(uploadFileDataModel*)model
+{
+    if (isSuspendType) {
+        [[uploadFileManager shareInstance] suspendUploadFileFun:NO];
+    }
+    else{
+        [[uploadFileManager shareInstance] reUploadFileFunBy:model];
+    }
+    
+}
+
 @end

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

@@ -18,6 +18,8 @@ NS_ASSUME_NONNULL_BEGIN
 @property (nonatomic,copy) void (^didLongPressClick)(void);
 //点击按钮
 @property (nonatomic,copy) void (^didClckSelectBut)(BOOL isSelect);
+//手势点击
+@property (nonatomic,copy) void (^didTapPressClick)(void);
 @end
 
 NS_ASSUME_NONNULL_END

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

@@ -8,7 +8,8 @@
 #import "uploadFileRecordCell.h"
 @interface uploadFileRecordCell ()
 @property(nonatomic,strong) UIImageView *fileImageView;
-@property(nonatomic,strong) UIImageView *upLoadStateImageView;
+@property(nonatomic,strong) UIButton *upLoadStateButton;
+
 @property (nonatomic, strong) UIButton *selectButton;
 
 @property(nonatomic,strong) UIView *progressBgView;
@@ -47,14 +48,15 @@
         make.bottom.mas_equalTo(-18);
     }];
     
-    _upLoadStateImageView = [[UIImageView alloc] init];
-    //_upLoadStateImageView.backgroundColor = [UIColor redColor];
-    [self.contentView addSubview:_upLoadStateImageView];
+    _upLoadStateButton = [[UIButton alloc] init];
+    //_upLoadStateButton.backgroundColor = [UIColor redColor];
+    [self.contentView addSubview:_upLoadStateButton];
+    [_upLoadStateButton addTarget:self action:@selector(tapClick:) forControlEvents:UIControlEventTouchUpInside];
     
-    [_upLoadStateImageView mas_makeConstraints:^(MASConstraintMaker *make) {
-        make.right.mas_equalTo(-15);
-        make.width.mas_equalTo(34);
-        make.height.mas_equalTo(34);
+    [_upLoadStateButton mas_makeConstraints:^(MASConstraintMaker *make) {
+        make.right.mas_equalTo(-5);
+        make.width.mas_equalTo(50);
+        make.height.mas_equalTo(50);
         make.bottom.mas_equalTo(-18);
     }];
     
@@ -70,8 +72,8 @@
         [but mas_makeConstraints:^(MASConstraintMaker *make) {
             make.width.mas_equalTo(30);
             make.height.mas_equalTo(30);
-            make.centerX.mas_equalTo(_upLoadStateImageView.mas_centerX);
-            make.centerY.mas_equalTo(_upLoadStateImageView.mas_centerY);
+            make.centerX.mas_equalTo(_upLoadStateButton.mas_centerX);
+            make.centerY.mas_equalTo(_upLoadStateButton.mas_centerY);
         }];
         
         self.selectButton = but;
@@ -85,7 +87,7 @@
     
     [_progressBgView mas_makeConstraints:^(MASConstraintMaker *make) {
         make.left.mas_equalTo(_fileImageView.mas_right).offset(10);
-        make.right.mas_equalTo(_upLoadStateImageView.mas_left).offset(-10);
+        make.right.mas_equalTo(_upLoadStateButton.mas_left).offset(-10);
         make.height.mas_equalTo(2);
         make.centerY.mas_equalTo(0);
     }];
@@ -122,7 +124,7 @@
     
     [_fileNamelabel mas_makeConstraints:^(MASConstraintMaker *make) {
         make.left.mas_equalTo(_fileImageView.mas_right).offset(10);
-        make.right.mas_equalTo(_upLoadStateImageView.mas_left).offset(-10);
+        make.right.mas_equalTo(_upLoadStateButton.mas_left).offset(-10);
         make.height.mas_equalTo(19);
         make.bottom.mas_equalTo(_progressBgView.mas_top).offset(-3);
     }];
@@ -148,7 +150,7 @@
     [self.contentView addSubview:_fileSpeedlabel];
     
     [_fileSpeedlabel mas_makeConstraints:^(MASConstraintMaker *make) {
-        make.right.mas_equalTo(_upLoadStateImageView.mas_left).offset(-10);
+        make.right.mas_equalTo(_upLoadStateButton.mas_left).offset(-10);
         make.left.mas_equalTo(_progressBgView.mas_centerX);
         make.height.mas_equalTo(15);
         make.top.mas_equalTo(_progressBgView.mas_bottom).offset(3);
@@ -192,23 +194,27 @@
 
 - (void)setCurUploadFileDataModel:(uploadFileDataModel *)curUploadFileDataModel
 {
+    _curUploadFileDataModel = curUploadFileDataModel;
     //HLog(@"hhhhhhh  %@ %ld %ld",curUploadFileDataModel.bg_id,curUploadFileDataModel.curUploadStateType,curUploadFileDataModel.didUploadBytes);
     
     _fileImageView.image = [UIImage imageWithData:curUploadFileDataModel.imageData];
     _fileSpeedlabel.hidden = YES;
     
     if(curUploadFileDataModel.curUploadStateType == uploadStateWait){
-        _upLoadStateImageView.image = [UIImage imageNamed:@"uploadFile_wait"];
+        //_upLoadStateButton.image = [UIImage imageNamed:@"uploadFile_wait"];
+        [_upLoadStateButton setImage:[UIImage imageNamed:@"uploadFile_wait"] forState:UIControlStateNormal];
     }
     else if(curUploadFileDataModel.curUploadStateType == uploadStateUploading){
-        _upLoadStateImageView.image = [UIImage imageNamed:@"uploadFile_suspend"];
+        //_upLoadStateButton.image = [UIImage imageNamed:@"uploadFile_suspend"];
+        [_upLoadStateButton setImage:[UIImage imageNamed:@"uploadFile_suspend"] forState:UIControlStateNormal];
         _fileSpeedlabel.hidden = NO;
     }
     else if(curUploadFileDataModel.curUploadStateType == uploadStateSuspend){
-        _upLoadStateImageView.image = [UIImage imageNamed:@"uploadFile_start"];
+        //_upLoadStateButton.image = [UIImage imageNamed:@"uploadFile_start"];
+        [_upLoadStateButton setImage:[UIImage imageNamed:@"uploadFile_start"] forState:UIControlStateNormal];
     }
     else{
-        _upLoadStateImageView.hidden = YES;
+        _upLoadStateButton.hidden = YES;
         _progressBgView.hidden = YES;
     }
     
@@ -224,6 +230,8 @@
     
     CGFloat curProgress = curUploadFileDataModel.didUploadBytes/(totalSize*1.0);
     
+    HLog(@"hxdhxdddddddd %@ -- %f -- %ld",curUploadFileDataModel.bg_id,curProgress,curUploadFileDataModel.didUploadBytes );
+    
     if(curProgress > 1){
         curProgress = 1;
     }
@@ -294,4 +302,27 @@
         _didClckSelectBut(but.selected);
     }
 }
+
+- (void)tapClick:(UIButton*)but{
+    if(_didTapPressClick){
+        _didTapPressClick();
+    }
+    
+    if(_curUploadFileDataModel.curUploadStateType == uploadStateUploading){
+        [_upLoadStateButton setImage:[UIImage imageNamed:@"uploadFile_start"] forState:UIControlStateNormal];
+        
+    }
+    else if(_curUploadFileDataModel.curUploadStateType == uploadStateSuspend){
+       
+        [_upLoadStateButton setImage:[UIImage imageNamed:@"uploadFile_suspend"] forState:UIControlStateNormal];
+    }
+    
+    
+    but.userInteractionEnabled = NO;
+    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
+        but.userInteractionEnabled = YES;
+    });
+    HLog(@"hxdhxdddddddd");
+}
+
 @end

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

@@ -39,7 +39,7 @@
     [deleteBut mas_makeConstraints:^(MASConstraintMaker *make) {
         make.left.mas_equalTo(0);
         make.right.mas_equalTo(0);
-        make.bottom.mas_equalTo(0);
+        make.height.mas_equalTo(60);
         make.top.mas_equalTo(0);
     }];
 }

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

@@ -23,9 +23,14 @@ NS_ASSUME_NONNULL_BEGIN
 //排队等待上传的文件列表
 @property (nonatomic, strong) NSMutableArray * _Nullable fileModelDataArr;
 @property (nonatomic, strong) uploadFileDataModel *curUploadFileDataModel;//当前上传的文件
+@property (nonatomic, assign) BOOL  isSuspendType;
 
 //把TZAssetModel 转成 我们需要上传的model
 - (NSMutableArray*)handlTZAssetModelToUploadFileDataFunBy:(NSMutableArray*)indexPathsForSelectedItems;
+//暂停上传
+- (void)suspendUploadFileFun:(BOOL)isSuspendAll;
+//某个文件重新上传
+- (void)reUploadFileFunBy:(uploadFileDataModel*)model;
 
 //文件上传完成
 - (void)uploadFileDoneFun;

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

@@ -91,6 +91,8 @@ static uploadFileManager * cur_uploadFileShareInstance = nil;
 
 - (void)beginUploadFileFun
 {
+    _isSuspendType = NO;
+    
     _curUploadFileDataModel = _fileModelDataArr.firstObject;
     
     [[NSNotificationCenter defaultCenter] postNotificationName:uploadFileBeginNotification object:_curUploadFileDataModel];
@@ -102,7 +104,9 @@ static uploadFileManager * cur_uploadFileShareInstance = nil;
     _curUploadFileDataModel.curUploadStateType = curUploadStateType;
     _curUploadFileDataModel.didUploadBytes = didUpLoadBytes;
     
-    [[NSNotificationCenter defaultCenter] postNotificationName:uploadFileRefreshNotification object:_curUploadFileDataModel];
+    if(!_isSuspendType){
+        [[NSNotificationCenter defaultCenter] postNotificationName:uploadFileRefreshNotification object:_curUploadFileDataModel];
+    }
     
     if(curUploadStateType == uploadStateUploading){
         return;
@@ -124,7 +128,7 @@ static uploadFileManager * cur_uploadFileShareInstance = nil;
 //    }
     
     where = [NSString stringWithFormat:@"where %@=%@ ",bg_sqlKey(@"bg_id"),bg_sqlValue(_curUploadFileDataModel.bg_id)];
-    HLog(@"ffff:%@",_curUploadFileDataModel.bg_id);
+    //HLog(@"ffff:%@",_curUploadFileDataModel.bg_id);
     
     [uploadFileDataModel bg_findAsync:upLoadFile_image_tableName where:where complete:^(NSArray * _Nullable array) {
         for (uploadFileDataModel * curModel in array) {
@@ -148,6 +152,26 @@ static uploadFileManager * cur_uploadFileShareInstance = nil;
 
 }
 
+//暂停上传完成
+- (void)suspendUploadFileFun:(BOOL)isSuspendAll
+{
+//    if(isSuspendAll){
+//
+//    }
+    
+    _isSuspendType = YES;
+    
+    [[NSNotificationCenter defaultCenter] postNotificationName:uploadFileSuspendNotification object:nil];
+}
+
+//某个文件重新上传
+- (void)reUploadFileFunBy:(uploadFileDataModel*)model
+{
+    _fileModelDataArr = [NSMutableArray new];
+    [_fileModelDataArr addObject:model];
+    [self beginUploadFileFun];
+}
+
 - (void)uploadFileDoneFun
 {
     long totalSizeByte = [_curUploadFileDataModel.imageData length];

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

@@ -17,6 +17,7 @@ NS_ASSUME_NONNULL_BEGIN
 - (void)CommonAlertCancelBtnClickPressed;
 
 - (void)beginGotoUploadFileFun:(NSNotification *)notification;
+- (void)suspendUploadFileFun:(NSNotification *)notification;
 
 - (void)applyUploadFileServiceResponseFun:(NSDictionary *)dataDict;
 - (void)upLoadFileFunServiceResponseFun:(NSDictionary *)dataDict;

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

@@ -29,6 +29,8 @@
 #pragma mark 监听文件开始的的通知
 - (void)beginGotoUploadFileFun:(NSNotification *)notification
 {
+    self.isSuspendUploadType = NO;
+    
     uploadFileDataModel *uploadFileDataMod = [notification object];
     //HLog(@"%@",uploadFileDataMod);
     self.curUploadFileDataMod = uploadFileDataMod;
@@ -169,6 +171,17 @@
 #pragma mark 处理上传过程
 - (void)handleUploadingFun
 {
+    if(self.isSuspendUploadType){
+        //暂停
+        self.taskUid = nil;
+        NSInteger didUploadSize = (self.indexOfUploadFlie+1) * (self.cutFileEachPieceSzie);
+        [[uploadFileManager shareInstance] changeUploadFileState:uploadStateSuspend withDidUploadBytes:didUploadSize complete:^(BOOL isSuccess) {
+
+        }];
+        
+        return;
+    }
+    
     if(self.indexOfUploadFlie < self.cutFileDataArr.count -1) {
         
         NSInteger didUploadSize = (self.indexOfUploadFlie+1) * (self.cutFileEachPieceSzie);
@@ -213,6 +226,7 @@
     NSUInteger allLength = data.length;
     
     NSUInteger subs = 100*1024;//4096;//要切片的大小,我这里设置的是4096字节
+    //NSUInteger subs = 8*1024;//4096;//要切片的大小,我这里设置的是4096字节
     self.cutFileEachPieceSzie = subs;
     
     NSInteger index = 0;//起始位置
@@ -222,6 +236,12 @@
             //出错了
             return [NSMutableArray new];
         }
+        else{
+//            index = didLoadSize/subs;
+//            allLength = allLength - didLoadSize;
+            
+            self.indexOfUploadFlie = didLoadSize/subs;
+        }
     }
 
     NSMutableArray *dataArray =[NSMutableArray new];
@@ -254,7 +274,7 @@
         
     } while (allLength>0);
     
-    //NSLog(@"%@",dataArray);//最后得到切片的结果,数组里面是NSData对象
+    HLog(@"dataArray leng:%ld",dataArray.count);//最后得到切片的结果,数组里面是NSData对象
 
     return dataArray;
 }
@@ -367,4 +387,9 @@
     //HLog(@"文件上传sendData %@",sendData);
 }
 
+- (void)suspendUploadFileFun:(NSNotification *)notification
+{
+    self.isSuspendUploadType = YES;
+}
+
 @end

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

@@ -102,6 +102,8 @@
 @property (nonatomic, assign) NSInteger indexOfUploadFlie;
 @property (nonatomic, assign) NSInteger cutFileEachPieceSzie;
 @property (nonatomic, strong) uploadFileDataModel *curUploadFileDataMod;
+@property (nonatomic, assign) BOOL isSuspendUploadType;
+
 /**
  * @brief 云手机类型  VIP星动云手机  SVIP星曜云手机  STAR 唔即云手机
  */

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

@@ -1591,6 +1591,9 @@ NSDate *lastVideoTome;/*上一帧数据时间*/
 
 - (void)fristConnectNeedGiveAMsgFun{
     
+    //test code
+    return;
+    
     if([self isPlayerViewIsTopVCFun]){
         //等下再发
         dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
@@ -2048,7 +2051,7 @@ BOOL inReconnect = NO;
             }
             
             //重启后重连 出来的 不显示
-            if(!self->_isRebootIngType && !self->_isResetingType){
+            if(!self->_isRebootIngType && !self->_isResetingType && ![self isPlayerViewIsTopVCFun]){
                 /*链接失败*/
                 [[iToast makeText:NSLocalizedString(@"player_link_fail_tip",nil)] show];
             }
@@ -2203,6 +2206,8 @@ BOOL inReconnect = NO;
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(setShowPwdVCTypeFun) name:ShowPwdVCNotification object:nil];
     
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(beginGotoUploadFileFun:) name:uploadFileBeginNotification object:nil];
+    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(suspendUploadFileFun:) name:uploadFileSuspendNotification object:nil];
+    
 }
 
 - (void)removeNSNotification

+ 1 - 1
创维盒子/双子星云手机/CloudPlayer/View/PlayerView.m

@@ -67,7 +67,7 @@ ShowImageViewDelegate>{
                   inRect:CGRectMake(0, 0, glkshowImageView.drawableWidth, glkshowImageView.drawableHeight)
                 fromRect:[ciImage extent]];
     
-    //[self->glkshowImageView display];
+    [self->glkshowImageView display];
 }
 
 - (void)showIMage