|  | @@ -13,7 +13,6 @@
 | 
	
		
			
				|  |  |  #import "KSPlayerSliderView.h"
 | 
	
		
			
				|  |  |  #import "kSNewPlayer.h"
 | 
	
		
			
				|  |  |  #import "KSVideoPlayerView.h"
 | 
	
		
			
				|  |  | -#import "TZImageManager.h"
 | 
	
		
			
				|  |  |  #import "KSUploadManager.h"
 | 
	
		
			
				|  |  |  #import "KSAudioPlayAnimationView.h"
 | 
	
		
			
				|  |  |  #import "KSNewAlertView.h"
 | 
	
	
		
			
				|  | @@ -59,10 +58,6 @@
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  @property (nonatomic, strong) UIButton *showButton;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -@property (nonatomic, strong) PHAsset *videoAsset;
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -@property (nonatomic, strong) NSString *presentName;
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |  @property (nonatomic, strong) KSAudioPlayAnimationView *playAnimationView;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  @property (nonatomic, strong) NSTimer *timer;
 | 
	
	
		
			
				|  | @@ -107,8 +102,6 @@
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  @property (nonatomic, strong) NSString *videoCoverUrl; // 视频封面
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -@property (nonatomic, strong) dispatch_group_t uploadGroup;
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |  @end
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  @implementation KSMediaMergeView
 | 
	
	
		
			
				|  | @@ -118,10 +111,16 @@
 | 
	
		
			
				|  |  |      if (self) {
 | 
	
		
			
				|  |  |          self.hasModify = NO;
 | 
	
		
			
				|  |  |          [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(appEnterBackground) name:@"appEnterBackground" object:nil];
 | 
	
		
			
				|  |  | +        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(otherLogin) name:@"otherLogin" object:nil];
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |      return self;
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +- (void)otherLogin {
 | 
	
		
			
				|  |  | +    [self stopPlay];
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  - (void)appEnterBackground {
 | 
	
		
			
				|  |  |      [self stopPlay];
 | 
	
		
			
				|  |  |  }
 | 
	
	
		
			
				|  | @@ -323,6 +322,8 @@
 | 
	
		
			
				|  |  |              make.centerX.mas_equalTo(self.playerView.mas_centerX);
 | 
	
		
			
				|  |  |              make.top.mas_equalTo(self.animationView.mas_top).offset(86);
 | 
	
		
			
				|  |  |          }];
 | 
	
		
			
				|  |  | +        [self.animationView configWithImageWithUrl:self.coverImage];
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |      
 | 
	
		
			
				|  |  |      [self addSubview:self.playControlView];
 | 
	
	
		
			
				|  | @@ -653,6 +654,12 @@
 | 
	
		
			
				|  |  |              [baseCtrl.navigationController presentViewController:ctrl animated:YES completion:nil];
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |              break;
 | 
	
		
			
				|  |  | +        case PUBLISH_ACTION_CANCLE:
 | 
	
		
			
				|  |  | +        {
 | 
	
		
			
				|  |  | +            self.settingImage = nil;
 | 
	
		
			
				|  |  | +            self.videoCoverImage = nil;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +            break;
 | 
	
		
			
				|  |  |          default:
 | 
	
		
			
				|  |  |              break;
 | 
	
		
			
				|  |  |      }
 | 
	
	
		
			
				|  | @@ -665,52 +672,52 @@
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  - (void)updateWithCoverImage {
 | 
	
		
			
				|  |  |      
 | 
	
		
			
				|  |  | -    if (self.settingImage) {
 | 
	
		
			
				|  |  | -        [self uploadMusicCover];
 | 
	
		
			
				|  |  | -    }
 | 
	
		
			
				|  |  | -    if (self.videoCoverImage) {
 | 
	
		
			
				|  |  | -        [self uploadVideoCover];
 | 
	
		
			
				|  |  | -    }
 | 
	
		
			
				|  |  | -    
 | 
	
		
			
				|  |  | -    dispatch_group_notify(self.uploadGroup, dispatch_get_main_queue(), ^{
 | 
	
		
			
				|  |  | -        [self publishMusic];
 | 
	
		
			
				|  |  | -    });
 | 
	
		
			
				|  |  | +    [self uploadMusicCover];
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  - (void)uploadMusicCover {
 | 
	
		
			
				|  |  | -    dispatch_group_enter(self.uploadGroup);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    NSData *imgData = [UIImage turnsImaegDataByImage:self.settingImage];
 | 
	
		
			
				|  |  | -    NSString *fileName = @"musicCoverImg";
 | 
	
		
			
				|  |  | -    [[KSUploadManager shareInstance] configBucketName:@"klx"];
 | 
	
		
			
				|  |  | -    [[KSUploadManager shareInstance] uploadImage:imgData fileName:fileName successCallback:^(NSMutableArray * _Nonnull fileUrlArray) {
 | 
	
		
			
				|  |  | -        NSString *avatarUrl = [fileUrlArray lastObject];
 | 
	
		
			
				|  |  | -        self.coverImage = avatarUrl;
 | 
	
		
			
				|  |  | -        dispatch_group_leave(self.uploadGroup);
 | 
	
		
			
				|  |  | -    } faliure:^(NSError * _Nullable error, NSString *descMessaeg) {
 | 
	
		
			
				|  |  | -        if ([NSString isEmptyString:descMessaeg]) {
 | 
	
		
			
				|  |  | -            [LOADING_MANAGER MBShowAUTOHidingInWindow:descMessaeg];
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -        dispatch_group_leave(self.uploadGroup);
 | 
	
		
			
				|  |  | -    }];
 | 
	
		
			
				|  |  | +    if (self.settingImage) {
 | 
	
		
			
				|  |  | +        NSData *imgData = [UIImage turnsImaegDataByImage:self.settingImage];
 | 
	
		
			
				|  |  | +        NSString *fileName = @"musicCoverImg";
 | 
	
		
			
				|  |  | +        [[KSUploadManager shareInstance] configBucketName:@"klx"];
 | 
	
		
			
				|  |  | +        [[KSUploadManager shareInstance] uploadImage:imgData fileName:fileName successCallback:^(NSMutableArray * _Nonnull fileUrlArray) {
 | 
	
		
			
				|  |  | +            NSString *avatarUrl = [fileUrlArray lastObject];
 | 
	
		
			
				|  |  | +            self.coverImage = avatarUrl;
 | 
	
		
			
				|  |  | +            [self uploadVideoCover];
 | 
	
		
			
				|  |  | +        } faliure:^(NSError * _Nullable error, NSString *descMessaeg) {
 | 
	
		
			
				|  |  | +            if (![NSString isEmptyString:descMessaeg]) {
 | 
	
		
			
				|  |  | +                [LOADING_MANAGER MBShowAUTOHidingInWindow:descMessaeg];
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            [self uploadVideoCover];
 | 
	
		
			
				|  |  | +        }];
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +    else {
 | 
	
		
			
				|  |  | +        [self uploadVideoCover];
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  - (void)uploadVideoCover {
 | 
	
		
			
				|  |  | -    dispatch_group_enter(self.uploadGroup);
 | 
	
		
			
				|  |  | -    NSData *imgData = [UIImage turnsImaegDataByImage:self.videoCoverImage];
 | 
	
		
			
				|  |  | -    NSString *fileName = @"musicCoverImg";
 | 
	
		
			
				|  |  | -    [[KSUploadManager shareInstance] configBucketName:@"klx"];
 | 
	
		
			
				|  |  | -    [[KSUploadManager shareInstance] uploadImage:imgData fileName:fileName successCallback:^(NSMutableArray * _Nonnull fileUrlArray) {
 | 
	
		
			
				|  |  | -        NSString *avatarUrl = [fileUrlArray lastObject];
 | 
	
		
			
				|  |  | -        self.videoCoverUrl = avatarUrl;
 | 
	
		
			
				|  |  | -        dispatch_group_leave(self.uploadGroup);
 | 
	
		
			
				|  |  | -    } faliure:^(NSError * _Nullable error, NSString *descMessaeg) {
 | 
	
		
			
				|  |  | -        if ([NSString isEmptyString:descMessaeg]) {
 | 
	
		
			
				|  |  | -            [LOADING_MANAGER MBShowAUTOHidingInWindow:descMessaeg];
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -        dispatch_group_leave(self.uploadGroup);
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -    }];
 | 
	
		
			
				|  |  | +    if (self.videoCoverImage) {
 | 
	
		
			
				|  |  | +        NSData *imgData = [UIImage turnsImaegDataByImage:self.videoCoverImage];
 | 
	
		
			
				|  |  | +        NSString *fileName = @"musicCoverImg";
 | 
	
		
			
				|  |  | +        [[KSUploadManager shareInstance] configBucketName:@"klx"];
 | 
	
		
			
				|  |  | +        [[KSUploadManager shareInstance] uploadImage:imgData fileName:fileName successCallback:^(NSMutableArray * _Nonnull fileUrlArray) {
 | 
	
		
			
				|  |  | +            NSString *avatarUrl = [fileUrlArray lastObject];
 | 
	
		
			
				|  |  | +            self.videoCoverUrl = avatarUrl;
 | 
	
		
			
				|  |  | +            [self publishMusic];
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        } faliure:^(NSError * _Nullable error, NSString *descMessaeg) {
 | 
	
		
			
				|  |  | +            if (![NSString isEmptyString:descMessaeg]) {
 | 
	
		
			
				|  |  | +                [LOADING_MANAGER MBShowAUTOHidingInWindow:descMessaeg];
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            [self publishMusic];
 | 
	
		
			
				|  |  | +        }];
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +    else {
 | 
	
		
			
				|  |  | +        [self publishMusic];
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +    
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  - (void)refreshViewCoverImg:(NSMutableArray *)imageArray {
 | 
	
	
		
			
				|  | @@ -721,41 +728,50 @@
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  - (void)publishMusic {
 | 
	
		
			
				|  |  | +    CGFloat progress = 1.0/3;
 | 
	
		
			
				|  |  | +    CGFloat rate = 1.0/3;
 | 
	
		
			
				|  |  |      if (self.isVideoPlay) {
 | 
	
		
			
				|  |  | -        [LOADING_MANAGER showProgressLoading:@"视频合成中" progress:33];
 | 
	
		
			
				|  |  | +        [LOADING_MANAGER showProgressLoading:@"视频合成中..." progress:0];
 | 
	
		
			
				|  |  | +        
 | 
	
		
			
				|  |  |          [KSMediaEditor mixVideoWithRecordAudio:self.recordUrl recordVolume:self.recordPlayer.volume bgAudio:self.bgAudioUrl bgAudioVolume:self.bgPlayer.volume offsetTime:self.offsetTime videoUrlStr:self.videoUrl completion:^(NSString * _Nonnull outPath, BOOL isSuccess, NSString * _Nonnull desc) {
 | 
	
		
			
				|  |  | +            [LOADING_MANAGER showProgressLoading:@"视频合成中..." progress:progress];
 | 
	
		
			
				|  |  |              // 保存文件到指定文件夹
 | 
	
		
			
				|  |  |              if (isSuccess) {
 | 
	
		
			
				|  |  |                  self.filePath = outPath;
 | 
	
		
			
				|  |  |                  MJWeakSelf;
 | 
	
		
			
				|  |  | -                [self sendVideoActionWithUrl:outPath isFormal:YES success:^(NSString * _Nonnull uploadVideoUrl) {
 | 
	
		
			
				|  |  | -                    [weakSelf saveMusic:YES isFormal:YES fileUrl:uploadVideoUrl progress:66];
 | 
	
		
			
				|  |  | +                [self sendVideoActionWithUrl:outPath isFormal:YES startProgress:progress rate:rate success:^(NSString * _Nonnull uploadVideoUrl) {
 | 
	
		
			
				|  |  | +                    [weakSelf saveMusic:YES isFormal:YES fileUrl:uploadVideoUrl progress:progress*2];
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                  } failure:^(NSString * _Nonnull desc) {
 | 
	
		
			
				|  |  | -                    
 | 
	
		
			
				|  |  | +                    [LOADING_MANAGER MBShowAUTOHidingInWindow:@"上传失败"];
 | 
	
		
			
				|  |  |                  }];
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |              else {
 | 
	
		
			
				|  |  |                  [LOADING_MANAGER removeProgressLoading];
 | 
	
		
			
				|  |  | +                [LOADING_MANAGER MBShowAUTOHidingInWindow:@"视频合成失败"];
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          }];
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |      else {
 | 
	
		
			
				|  |  | -        [LOADING_MANAGER showProgressLoading:@"音频合成中..." progress:33];
 | 
	
		
			
				|  |  | +        [LOADING_MANAGER showProgressLoading:@"音频合成中..." progress:0];
 | 
	
		
			
				|  |  |          NSInteger realOffsetTime = self.offsetTime;
 | 
	
		
			
				|  |  |          [KSMediaEditor mixRecordAudio:self.recordUrl recordVolume:self.recordPlayer.volume bgAudio:self.bgAudioUrl bgAudioVolume:self.bgPlayer.volume offsetTime:realOffsetTime completion:^(NSString * _Nonnull outPath, BOOL isSuccess, NSString * _Nonnull desc) {
 | 
	
		
			
				|  |  |              // 保存文件到指定文件夹
 | 
	
		
			
				|  |  | +            [LOADING_MANAGER showProgressLoading:@"音频合成中..." progress:progress];
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |              if (isSuccess) {
 | 
	
		
			
				|  |  |                  self.filePath = outPath;
 | 
	
		
			
				|  |  |                  MJWeakSelf;
 | 
	
		
			
				|  |  | -                [self sendAudioWithPath:outPath isFormal:YES success:^(NSString *audioUrl) {
 | 
	
		
			
				|  |  | -                    [weakSelf saveMusic:NO isFormal:YES fileUrl:audioUrl progress:66];
 | 
	
		
			
				|  |  | +                [self sendAudioWithPath:outPath isFormal:YES startProgress:progress rate:rate success:^(NSString *audioUrl) {
 | 
	
		
			
				|  |  | +                    [weakSelf saveMusic:NO isFormal:YES fileUrl:audioUrl progress:progress*2];
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |                  } failure:^(NSString *desc) {
 | 
	
		
			
				|  |  | -                    [LOADING_MANAGER MBShowAUTOHidingInWindow:@"文件上传失败"];
 | 
	
		
			
				|  |  | +                    [LOADING_MANAGER MBShowAUTOHidingInWindow:@"上传失败"];
 | 
	
		
			
				|  |  |                  }];
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |              else {
 | 
	
		
			
				|  |  |                  [LOADING_MANAGER removeProgressLoading];
 | 
	
		
			
				|  |  | +                [LOADING_MANAGER MBShowAUTOHidingInWindow:@"音频合成失败"];
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          }];
 | 
	
		
			
				|  |  |      }
 | 
	
	
		
			
				|  | @@ -767,20 +783,24 @@
 | 
	
		
			
				|  |  |      if (self.isVideoPlay) {
 | 
	
		
			
				|  |  |          if (self.remoteVideoUrl) {
 | 
	
		
			
				|  |  |              // 保存草稿
 | 
	
		
			
				|  |  | -            [self saveMusic:YES isFormal:NO fileUrl:self.remoteVideoUrl needBack:needBack progress:33];
 | 
	
		
			
				|  |  | +            [LOADING_MANAGER showProgressLoading:@"正在保存草稿" progress:0 promptCompletion:^{
 | 
	
		
			
				|  |  | +                [self saveMusic:YES isFormal:NO fileUrl:self.remoteVideoUrl needBack:needBack progress:0.5];
 | 
	
		
			
				|  |  | +            }];
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          else {
 | 
	
		
			
				|  |  |              // 合成
 | 
	
		
			
				|  |  | -            [LOADING_MANAGER showProgressLoading:@"加载中..." progress:33];
 | 
	
		
			
				|  |  | +            [LOADING_MANAGER showProgressLoading:@"正在上传草稿" progress:0];
 | 
	
		
			
				|  |  |              MJWeakSelf;
 | 
	
		
			
				|  |  |              [KSMediaEditor mixRecordVideoWithAudio:self.recordUrl recordVolume:100 videoUrlStr:self.videoUrl completion:^(NSString * _Nonnull outPath, BOOL isSuccess, NSString * _Nonnull desc) {
 | 
	
		
			
				|  |  |                  if (isSuccess) {
 | 
	
		
			
				|  |  | -                    [self sendVideoActionWithUrl:outPath isFormal:NO success:^(NSString * _Nonnull uploadVideoUrl) {
 | 
	
		
			
				|  |  | +                    [self sendVideoActionWithUrl:outPath isFormal:NO startProgress:0 rate:0.5 success:^(NSString * _Nonnull uploadVideoUrl) {
 | 
	
		
			
				|  |  |                          // 保存草稿
 | 
	
		
			
				|  |  | -                        [weakSelf saveMusic:YES isFormal:NO fileUrl:uploadVideoUrl needBack:needBack progress:66];
 | 
	
		
			
				|  |  | +                        [weakSelf saveMusic:YES isFormal:NO fileUrl:uploadVideoUrl needBack:needBack progress:0.5];
 | 
	
		
			
				|  |  | +                        
 | 
	
		
			
				|  |  |                      } failure:^(NSString * _Nonnull desc) {
 | 
	
		
			
				|  |  |                          [LOADING_MANAGER MBShowAUTOHidingInWindow:@"上传失败"];
 | 
	
		
			
				|  |  |                      }];
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |                  else {
 | 
	
		
			
				|  |  |                      [LOADING_MANAGER MBShowAUTOHidingInWindow:@"上传失败"];
 | 
	
	
		
			
				|  | @@ -790,15 +810,19 @@
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |      else {
 | 
	
		
			
				|  |  |          if (self.remoteRecrodUrl) {
 | 
	
		
			
				|  |  | -            [self saveMusic:NO isFormal:NO fileUrl:self.remoteRecrodUrl needBack:needBack progress:33];
 | 
	
		
			
				|  |  | +            [LOADING_MANAGER showProgressLoading:@"正在保存草稿" progress:0 promptCompletion:^{
 | 
	
		
			
				|  |  | +                [self saveMusic:NO isFormal:NO fileUrl:self.remoteRecrodUrl needBack:needBack progress:0.5];
 | 
	
		
			
				|  |  | +            }];
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          else {
 | 
	
		
			
				|  |  |              MJWeakSelf;
 | 
	
		
			
				|  |  | -            [self sendAudioWithURLPath:self.recordUrl isFormal:NO success:^(NSString *audioUrl) {
 | 
	
		
			
				|  |  | -                
 | 
	
		
			
				|  |  | -                [weakSelf saveMusic:NO isFormal:NO fileUrl:audioUrl needBack:needBack progress:33];
 | 
	
		
			
				|  |  | +            [LOADING_MANAGER showProgressLoading:@"正在上传草稿" progress:0];
 | 
	
		
			
				|  |  | +            [self sendAudioWithURLPath:self.recordUrl isFormal:NO startProgress:0 rate:0.5 success:^(NSString *audioUrl) {
 | 
	
		
			
				|  |  | +                // 保存草稿
 | 
	
		
			
				|  |  | +                [weakSelf saveMusic:NO isFormal:NO fileUrl:audioUrl needBack:needBack progress:0.5];
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |              } failure:^(NSString *desc) {
 | 
	
		
			
				|  |  | -                [LOADING_MANAGER MBShowAUTOHidingInWindow:@"文件上传失败"];
 | 
	
		
			
				|  |  | +                [LOADING_MANAGER MBShowAUTOHidingInWindow:@"上传失败"];
 | 
	
		
			
				|  |  |              }];
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |      }
 | 
	
	
		
			
				|  | @@ -923,52 +947,18 @@
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -- (void)saveVideoURLToAsset:(NSURL *)videoUrl isFormal:(BOOL)isFormal callback:(void(^)(NSString *videoUrl))callback {
 | 
	
		
			
				|  |  | -    
 | 
	
		
			
				|  |  | -    [[TZImageManager manager] saveVideoWithUrl:videoUrl completion:^(PHAsset *asset, NSError *error) {
 | 
	
		
			
				|  |  | -        if (!error) {
 | 
	
		
			
				|  |  | -            self.videoAsset = asset;
 | 
	
		
			
				|  |  | -            dispatch_main_async_safe(^{
 | 
	
		
			
				|  |  | -                
 | 
	
		
			
				|  |  | -                if (callback) {
 | 
	
		
			
				|  |  | -                    [self uploadRecordVideoisFormal:isFormal Success:^(NSString *uploadVideoUrl) {
 | 
	
		
			
				|  |  | -                        callback(uploadVideoUrl);
 | 
	
		
			
				|  |  | -                        
 | 
	
		
			
				|  |  | -                    } failure:^(NSString *desc) {
 | 
	
		
			
				|  |  | -                        [LOADING_MANAGER MBShowAUTOHidingInWindow:@"上传视频失败"];
 | 
	
		
			
				|  |  | -                    }];
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -                
 | 
	
		
			
				|  |  | -            });
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -        else {
 | 
	
		
			
				|  |  | -            dispatch_main_async_safe(^{
 | 
	
		
			
				|  |  | -                [LOADING_MANAGER MBShowAUTOHidingInWindow:@"保存视频错误"];
 | 
	
		
			
				|  |  | -            });
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -    }];
 | 
	
		
			
				|  |  | -}
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -- (void)saveVideoToAsset:(NSString *)saveVideoUrl isFormal:(BOOL)isFormal callback:(void(^)(NSString *videoUrl))callback {
 | 
	
		
			
				|  |  | -    NSURL *fileUrl = [NSURL fileURLWithPath:saveVideoUrl];
 | 
	
		
			
				|  |  | -    [self saveVideoURLToAsset:fileUrl isFormal:isFormal callback:^(NSString *videoUrl) {
 | 
	
		
			
				|  |  | -        callback(videoUrl);
 | 
	
		
			
				|  |  | -    }];
 | 
	
		
			
				|  |  | -}
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -- (void)saveMusic:(BOOL)isVideo isFormal:(BOOL)isFormal fileUrl:(NSString *)fileUrl progress:(NSInteger)progress  {
 | 
	
		
			
				|  |  | +- (void)saveMusic:(BOOL)isVideo isFormal:(BOOL)isFormal fileUrl:(NSString *)fileUrl progress:(CGFloat)progress  {
 | 
	
		
			
				|  |  |      
 | 
	
		
			
				|  |  |      [self saveMusic:isVideo isFormal:isFormal fileUrl:fileUrl needBack:NO progress:progress];
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -- (void)saveMusic:(BOOL)isVideo isFormal:(BOOL)isFormal fileUrl:(NSString *)fileUrl needBack:(BOOL)needBack progress:(NSInteger)progress {
 | 
	
		
			
				|  |  | +- (void)saveMusic:(BOOL)isVideo isFormal:(BOOL)isFormal fileUrl:(NSString *)fileUrl needBack:(BOOL)needBack progress:(CGFloat)progress {
 | 
	
		
			
				|  |  |      NSString *type = isFormal ? @"FORMAL" : @"DRAFT";
 | 
	
		
			
				|  |  |      NSMutableDictionary *parm = [NSMutableDictionary dictionary];
 | 
	
		
			
				|  |  |      [parm setValue:@(self.offsetTime) forKey:@"offset"];
 | 
	
		
			
				|  |  |      [parm setValue:@(self.originalVolume) forKey:@"originalVolume"];
 | 
	
		
			
				|  |  |      [parm setValue:@(self.accompanyVolume) forKey:@"accompanyVolume"];
 | 
	
		
			
				|  |  |      self.jsonConfig = [parm mj_JSONString];
 | 
	
		
			
				|  |  | -    [LOADING_MANAGER showProgressLoading:@"加载中..." progress:progress];
 | 
	
		
			
				|  |  |      [KSNetworkingManager saveMusicMessage:KS_POST jsonConfig:self.jsonConfig img:self.coverImage videoUrl:fileUrl accompanyUrl:self.remoteBgAudioUrl desc:self.desc type:type musicPracticeRecordId:self.recordId videoImg:self.videoCoverUrl success:^(NSDictionary * _Nonnull dic) {
 | 
	
		
			
				|  |  |          if ([dic ks_integerValueForKey:@"code"] == 200) {
 | 
	
		
			
				|  |  |              if (isFormal) {
 | 
	
	
		
			
				|  | @@ -994,46 +984,18 @@
 | 
	
		
			
				|  |  |      }];
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -// 上传视频
 | 
	
		
			
				|  |  | -- (void)uploadRecordVideoisFormal:(BOOL)isFormal Success:(void(^)(NSString *uploadVideoUrl))success failure:(void(^)(NSString *desc))faliure {
 | 
	
		
			
				|  |  | -    if (self.videoAsset) {
 | 
	
		
			
				|  |  | -        if (self.videoAsset) {
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -            [[TZImageManager manager] getVideoOutputPathWithAsset:self.videoAsset presetName:self.presentName success:^(NSString *outputPath) {
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -                NSLog(@"视频导出到本地完成,沙盒路径为:%@",outputPath);
 | 
	
		
			
				|  |  | -                NSData *outputData = [NSData dataWithContentsOfURL:[NSURL fileURLWithPath:outputPath]]; //压缩后的视频
 | 
	
		
			
				|  |  | -                NSLog(@"导出后的视频:%@",[NSString stringWithFormat:@"%.2fM",(CGFloat)outputData.length/(1024*1024)]);
 | 
	
		
			
				|  |  | -                // 上传
 | 
	
		
			
				|  |  | -                dispatch_main_async_safe(^{
 | 
	
		
			
				|  |  | -                    [self sendVideoActionWithUrl:outputPath isFormal:isFormal success:success failure:faliure];
 | 
	
		
			
				|  |  | -                });
 | 
	
		
			
				|  |  | -                
 | 
	
		
			
				|  |  | -            } failure:^(NSString *errorMessage, NSError *error) {
 | 
	
		
			
				|  |  | -                dispatch_main_async_safe(^{
 | 
	
		
			
				|  |  | -                    faliure(@"视频导出失败");
 | 
	
		
			
				|  |  | -                });
 | 
	
		
			
				|  |  | -                NSLog(@"视频导出失败:%@,error:%@",errorMessage, error);
 | 
	
		
			
				|  |  | -                
 | 
	
		
			
				|  |  | -            }];
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -        else {
 | 
	
		
			
				|  |  | -            faliure(@"未找到视频资源");
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -    }
 | 
	
		
			
				|  |  | -    else {
 | 
	
		
			
				|  |  | -        faliure(@"未找到视频资源");
 | 
	
		
			
				|  |  | -    }
 | 
	
		
			
				|  |  | -}
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -- (void)sendVideoActionWithUrlPath:(NSURL *)fileUrl isFormal:(BOOL)isFormal success:(void (^)(NSString * _Nonnull uploadVideoUrl))success failure:(void (^)(NSString * _Nonnull desc))faliure {
 | 
	
		
			
				|  |  | +- (void)sendVideoActionWithUrlPath:(NSURL *)fileUrl isFormal:(BOOL)isFormal beginProgress:(CGFloat)beginProgress rate:(CGFloat)rate success:(void (^)(NSString * _Nonnull uploadVideoUrl))success failure:(void (^)(NSString * _Nonnull desc))faliure {
 | 
	
		
			
				|  |  |      NSString *tips = isFormal ? @"正在上传作品" : @"正在上传草稿";
 | 
	
		
			
				|  |  | -    [LOADING_MANAGER showProgressLoading:tips progress:66];
 | 
	
		
			
				|  |  | +    [LOADING_MANAGER showProgressLoading:tips progress:beginProgress];
 | 
	
		
			
				|  |  |      NSData *fileData = [NSData dataWithContentsOfURL:fileUrl];
 | 
	
		
			
				|  |  |      NSString *suffix = [NSString stringWithFormat:@".%@",[fileUrl pathExtension]];
 | 
	
		
			
				|  |  |      [[KSUploadManager shareInstance] configBucketName:@"klx"];
 | 
	
		
			
				|  |  |      [[KSUploadManager shareInstance] videoUpload:fileData fileName:@"video" fileSuffix:suffix progress:^(int64_t bytesWritten, int64_t totalBytes) {
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | +        // 显示进度
 | 
	
		
			
				|  |  | +        float progress = (bytesWritten*1.0 / totalBytes) * rate + beginProgress;
 | 
	
		
			
				|  |  | +        dispatch_main_async_safe(^{
 | 
	
		
			
				|  |  | +            [LOADING_MANAGER showProgressNoAnimationLoading:tips progress:progress];
 | 
	
		
			
				|  |  | +        });
 | 
	
		
			
				|  |  |      } successCallback:^(NSMutableArray * _Nonnull fileUrlArray) {
 | 
	
		
			
				|  |  |          dispatch_main_async_safe(^{
 | 
	
		
			
				|  |  |              NSString *fileUrl = [fileUrlArray lastObject];
 | 
	
	
		
			
				|  | @@ -1050,19 +1012,23 @@
 | 
	
		
			
				|  |  |      }];
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -- (void)sendVideoActionWithUrl:(NSString *)fileUrl isFormal:(BOOL)isFormal success:(void (^)(NSString * _Nonnull uploadVideoUrl))success failure:(void (^)(NSString * _Nonnull desc))faliure {
 | 
	
		
			
				|  |  | -    [self sendAudioWithURLPath:[NSURL fileURLWithPath:fileUrl] isFormal:isFormal success:success failure:faliure];
 | 
	
		
			
				|  |  | +- (void)sendVideoActionWithUrl:(NSString *)fileUrl isFormal:(BOOL)isFormal startProgress:(CGFloat)beginProgress rate:(CGFloat)rate success:(void (^)(NSString * _Nonnull uploadVideoUrl))success failure:(void (^)(NSString * _Nonnull desc))faliure {
 | 
	
		
			
				|  |  | +    [self sendVideoActionWithUrlPath:[NSURL fileURLWithPath:fileUrl] isFormal:isFormal beginProgress:beginProgress rate:rate success:success failure:faliure];
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -- (void)sendAudioWithURLPath:(NSURL *)fileUrl isFormal:(BOOL)isFormal success:(void(^)(NSString *audioUrl))success failure:(void(^)(NSString *desc))faliure {
 | 
	
		
			
				|  |  | +- (void)sendAudioWithURLPath:(NSURL *)fileUrl isFormal:(BOOL)isFormal startProgress:(CGFloat)beginProgress rate:(CGFloat)rate success:(void(^)(NSString *audioUrl))success failure:(void(^)(NSString *desc))faliure {
 | 
	
		
			
				|  |  |      NSString *tips = isFormal ? @"正在上传作品" : @"正在上传草稿";
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    [LOADING_MANAGER showProgressLoading:tips progress:66];
 | 
	
		
			
				|  |  | +    [LOADING_MANAGER showProgressLoading:tips progress:beginProgress];
 | 
	
		
			
				|  |  |      NSData *fileData = [NSData dataWithContentsOfURL:fileUrl];
 | 
	
		
			
				|  |  |      NSString *suffix = [NSString stringWithFormat:@".%@",[fileUrl pathExtension]];
 | 
	
		
			
				|  |  |      [[KSUploadManager shareInstance] configBucketName:@"klx"];
 | 
	
		
			
				|  |  |      [UPLOAD_MANAGER uploadFile:fileData fileName:@"evaluateAudio" fileSuffix:suffix progress:^(int64_t bytesWritten, int64_t totalBytes) {
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | +        // 显示进度
 | 
	
		
			
				|  |  | +        float progress = (bytesWritten*1.0 / totalBytes) * rate + beginProgress;
 | 
	
		
			
				|  |  | +        dispatch_main_async_safe(^{
 | 
	
		
			
				|  |  | +            [LOADING_MANAGER showProgressNoAnimationLoading:tips progress:progress];
 | 
	
		
			
				|  |  | +        });
 | 
	
		
			
				|  |  |      } successCallback:^(NSMutableArray * _Nonnull fileUrlArray) {
 | 
	
		
			
				|  |  |          NSString *fileUrl = [fileUrlArray lastObject];
 | 
	
		
			
				|  |  |          success(fileUrl);
 | 
	
	
		
			
				|  | @@ -1073,21 +1039,9 @@
 | 
	
		
			
				|  |  |      
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -- (void)sendAudioWithPath:(NSString *)filePath isFormal:(BOOL)isFormal success:(void(^)(NSString *audioUrl))success failure:(void(^)(NSString *desc))faliure {
 | 
	
		
			
				|  |  | +- (void)sendAudioWithPath:(NSString *)filePath isFormal:(BOOL)isFormal startProgress:(CGFloat)beginProgress rate:(CGFloat)rate success:(void(^)(NSString *audioUrl))success failure:(void(^)(NSString *desc))faliure {
 | 
	
		
			
				|  |  |      NSURL *fileUrl = [NSURL fileURLWithPath:filePath];
 | 
	
		
			
				|  |  | -    [self sendAudioWithURLPath:fileUrl isFormal:isFormal success:success failure:faliure];
 | 
	
		
			
				|  |  | -}
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -- (NSString *)presentName {
 | 
	
		
			
				|  |  | -    NSString *presentName = AVAssetExportPresetMediumQuality;
 | 
	
		
			
				|  |  | -    if ([[NSString deviceVersion] containsString:@"iPhone 12"]) {
 | 
	
		
			
				|  |  | -        
 | 
	
		
			
				|  |  | -        presentName =  AVAssetExportPreset640x480;
 | 
	
		
			
				|  |  | -    }
 | 
	
		
			
				|  |  | -    else {
 | 
	
		
			
				|  |  | -        presentName = AVAssetExportPresetMediumQuality;
 | 
	
		
			
				|  |  | -    }
 | 
	
		
			
				|  |  | -    return presentName;
 | 
	
		
			
				|  |  | +    [self sendAudioWithURLPath:fileUrl isFormal:isFormal startProgress:beginProgress rate:rate  success:success failure:faliure];
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  - (void)removeVideoWithPath:(NSString *)videoUrl {
 | 
	
	
		
			
				|  | @@ -1149,12 +1103,7 @@
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |      return _requestGroup;
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  | -- (dispatch_group_t)uploadGroup {
 | 
	
		
			
				|  |  | -    if (!_uploadGroup) {
 | 
	
		
			
				|  |  | -        _uploadGroup = dispatch_group_create();
 | 
	
		
			
				|  |  | -    }
 | 
	
		
			
				|  |  | -    return _uploadGroup;
 | 
	
		
			
				|  |  | -}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  - (KSNewAlertView *)alertView {
 | 
	
		
			
				|  |  |      if (!_alertView) {
 | 
	
		
			
				|  |  |          _alertView = [KSNewAlertView shareInstance];
 |