|
@@ -558,7 +558,7 @@
|
|
|
- (void)showPublishAlert {
|
|
|
self.publishAlert = [MusicPublistAlert shareInstance];
|
|
|
self.publishAlert.musicName.text = [NSString returnNoNullStringWithString:self.songName];
|
|
|
- [self.publishAlert.musicImage sd_setImageWithURL:[NSURL URLWithString:[self.coverImage getUrlEndcodeString]] placeholderImage:[UIImage imageNamed:@"pub_music_placeholder"]];
|
|
|
+ [self.publishAlert.musicImage sd_setImageWithURL:[NSURL URLWithString:[self.coverImage getUrlEndcodeString]] placeholderImage:[UIImage imageNamed:@"music_placeholder"]];
|
|
|
self.publishAlert.userName.text = [NSString returnNoNullStringWithString:UserDefault(NicknameKey)];
|
|
|
MJWeakSelf;
|
|
|
[self.publishAlert chooseAction:^(PUBLISH_ACTION type) {
|
|
@@ -588,9 +588,10 @@
|
|
|
self.mediaManager.maxPhotoNumber = 1;
|
|
|
self.mediaManager.baseCtrl = [self findViewController];
|
|
|
|
|
|
- self.mediaManager.needCropImage = NO;
|
|
|
+ self.mediaManager.needCropImage = YES;
|
|
|
MJWeakSelf;
|
|
|
[self.mediaManager noAlertCallback:^(NSString * _Nullable videoUrl, NSMutableArray * _Nullable imageArray, NSMutableArray * _Nullable imageAsset) {
|
|
|
+ // 裁剪
|
|
|
[weakSelf refreshViewCoverImg:imageArray];
|
|
|
}];
|
|
|
[self.mediaManager pushImagePickerController];
|
|
@@ -604,7 +605,7 @@
|
|
|
- (void)updateWithCoverImage:(UIImage *)image {
|
|
|
NSData *imgData = [UIImage turnsImaegDataByImage:image];
|
|
|
NSString *fileName = @"musicCoverImg";
|
|
|
- [UPLOAD_MANAGER configBucketName:@"daya"];
|
|
|
+ [[KSUploadManager shareInstance] configBucketName:@"klx"];
|
|
|
[[KSUploadManager shareInstance] uploadImage:imgData fileName:fileName successCallback:^(NSMutableArray * _Nonnull fileUrlArray) {
|
|
|
NSString *avatarUrl = [fileUrlArray lastObject];
|
|
|
self.coverImage = avatarUrl;
|
|
@@ -626,23 +627,26 @@
|
|
|
|
|
|
- (void)publishMusic {
|
|
|
if (self.isVideoPlay) {
|
|
|
- [LOADING_MANAGER showCustomLoading:@"视频合成中..."];
|
|
|
+ [LOADING_MANAGER showProgressLoading:@"视频合成中" progress:33];
|
|
|
[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) {
|
|
|
// 保存文件到指定文件夹
|
|
|
if (isSuccess) {
|
|
|
self.filePath = outPath;
|
|
|
MJWeakSelf;
|
|
|
- [self saveVideoToAsset:outPath isFormal:YES callback:^(NSString *videoUrl) {
|
|
|
- [weakSelf saveMusic:YES isFormal:YES fileUrl:videoUrl];
|
|
|
+ [self sendVideoActionWithUrl:outPath isFormal:YES success:^(NSString * _Nonnull uploadVideoUrl) {
|
|
|
+ [weakSelf saveMusic:YES isFormal:YES fileUrl:uploadVideoUrl];
|
|
|
+
|
|
|
+ } failure:^(NSString * _Nonnull desc) {
|
|
|
+
|
|
|
}];
|
|
|
}
|
|
|
else {
|
|
|
- [LOADING_MANAGER removeCustomLoading];
|
|
|
+ [LOADING_MANAGER removeProgressLoading];
|
|
|
}
|
|
|
}];
|
|
|
}
|
|
|
else {
|
|
|
- [LOADING_MANAGER showCustomLoading:@"音频合成中..."];
|
|
|
+ [LOADING_MANAGER showProgressLoading:@"音频合成中..." progress:33];
|
|
|
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) {
|
|
|
// 保存文件到指定文件夹
|
|
@@ -656,7 +660,7 @@
|
|
|
}];
|
|
|
}
|
|
|
else {
|
|
|
- [LOADING_MANAGER removeCustomLoading];
|
|
|
+ [LOADING_MANAGER removeProgressLoading];
|
|
|
}
|
|
|
}];
|
|
|
}
|
|
@@ -671,21 +675,19 @@
|
|
|
[self saveMusic:YES isFormal:NO fileUrl:self.remoteVideoUrl needBack:needBack];
|
|
|
}
|
|
|
else {
|
|
|
- [LOADING_MANAGER showCustomLoading:@"正在上传草稿"];
|
|
|
- [KSMediaEditor mixRecordVideoWithAudio:self.recordUrl recordVolume:1 videoUrlStr:self.videoUrl completion:^(NSString * _Nonnull outPath, BOOL isSuccess, NSString * _Nonnull desc) {
|
|
|
- if (isSuccess) {
|
|
|
- MJWeakSelf;
|
|
|
- [self saveVideoToAsset:outPath isFormal:NO callback:^(NSString *videoUrl) {
|
|
|
- // 保存草稿
|
|
|
- [weakSelf saveMusic:YES isFormal:NO fileUrl:videoUrl needBack:needBack];
|
|
|
- }];
|
|
|
- }
|
|
|
- else {
|
|
|
- [LOADING_MANAGER removeCustomLoading];
|
|
|
-
|
|
|
- }
|
|
|
+ MJWeakSelf;
|
|
|
+ /*
|
|
|
+ [self saveVideoURLToAsset:self.videoUrl isFormal:NO callback:^(NSString *videoUrl) {
|
|
|
+ // 保存草稿
|
|
|
+ [weakSelf saveMusic:YES isFormal:NO fileUrl:videoUrl needBack:needBack];
|
|
|
+ }];
|
|
|
+ */
|
|
|
+ [self sendVideoActionWithUrlPath:self.videoUrl isFormal:NO success:^(NSString * _Nonnull uploadVideoUrl) {
|
|
|
+ // 保存草稿
|
|
|
+ [weakSelf saveMusic:YES isFormal:NO fileUrl:uploadVideoUrl needBack:needBack];
|
|
|
+ } failure:^(NSString * _Nonnull desc) {
|
|
|
+ [LOADING_MANAGER MBShowAUTOHidingInWindow:@"上传失败"];
|
|
|
}];
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
@@ -868,17 +870,16 @@
|
|
|
[parm setValue:@(self.originalVolume) forKey:@"originalVolume"];
|
|
|
[parm setValue:@(self.accompanyVolume) forKey:@"accompanyVolume"];
|
|
|
self.jsonConfig = [parm mj_JSONString];
|
|
|
- [LOADING_MANAGER showCustomLoading:@"加载中..."];
|
|
|
+ [LOADING_MANAGER showProgressLoading:@"加载中..." progress:66];
|
|
|
[KSNetworkingManager saveMusicMessage:KS_POST jsonConfig:self.jsonConfig img:self.coverImage videoUrl:fileUrl accompanyUrl:self.remoteBgAudioUrl desc:self.desc type:type musicPracticeRecordId:self.recordId success:^(NSDictionary * _Nonnull dic) {
|
|
|
- [LOADING_MANAGER removeCustomLoading];
|
|
|
if ([dic ks_integerValueForKey:@"code"] == 200) {
|
|
|
if (isFormal) {
|
|
|
- [LOADING_MANAGER KSShowMsg:@"发布成功" promptCompletion:^{
|
|
|
+ [LOADING_MANAGER KSShowProgressMsg:@"发布成功" promptCompletion:^{
|
|
|
[self removeView];
|
|
|
}];
|
|
|
}
|
|
|
else {
|
|
|
- [LOADING_MANAGER KSShowMsg:@"保存成功" promptCompletion:^{
|
|
|
+ [LOADING_MANAGER KSShowProgressMsg:@"保存成功" promptCompletion:^{
|
|
|
self.hasModify = NO;
|
|
|
if (needBack) {
|
|
|
[self removeViewTips:NO];
|
|
@@ -887,10 +888,11 @@
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
+ [LOADING_MANAGER removeProgressLoading];
|
|
|
[LOADING_MANAGER MBShowAUTOHidingInWindow:MESSAGEKEY];
|
|
|
}
|
|
|
} faliure:^(NSError * _Nonnull error) {
|
|
|
- [LOADING_MANAGER removeCustomLoading];
|
|
|
+ [LOADING_MANAGER removeProgressLoading];
|
|
|
}];
|
|
|
}
|
|
|
|
|
@@ -906,7 +908,7 @@
|
|
|
NSLog(@"导出后的视频:%@",[NSString stringWithFormat:@"%.2fM",(CGFloat)outputData.length/(1024*1024)]);
|
|
|
// 上传
|
|
|
dispatch_main_async_safe(^{
|
|
|
- [self sendVideoActionWith:outputPath isFormal:isFormal success:success failure:faliure];
|
|
|
+ [self sendVideoActionWithUrl:outputPath isFormal:isFormal success:success failure:faliure];
|
|
|
});
|
|
|
|
|
|
} failure:^(NSString *errorMessage, NSError *error) {
|
|
@@ -926,23 +928,16 @@
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-- (void)sendVideoActionWith:(NSString *)fileUrl isFormal:(BOOL)isFormal success:(void (^)(NSString * _Nonnull))success failure:(void (^)(NSString * _Nonnull))faliure {
|
|
|
+- (void)sendVideoActionWithUrlPath:(NSURL *)fileUrl isFormal:(BOOL)isFormal success:(void (^)(NSString * _Nonnull uploadVideoUrl))success failure:(void (^)(NSString * _Nonnull desc))faliure {
|
|
|
NSString *tips = isFormal ? @"正在上传作品" : @"正在上传草稿";
|
|
|
- [LOADING_MANAGER showCustomLoading:tips];
|
|
|
- NSData *fileData = [NSData dataWithContentsOfURL:[NSURL fileURLWithPath:fileUrl]];
|
|
|
+ [LOADING_MANAGER showProgressLoading:tips progress:66];
|
|
|
+ NSData *fileData = [NSData dataWithContentsOfURL:fileUrl];
|
|
|
NSString *suffix = [NSString stringWithFormat:@".%@",[fileUrl pathExtension]];
|
|
|
- [UPLOAD_MANAGER configBucketName:@"daya"];
|
|
|
+ [[KSUploadManager shareInstance] configBucketName:@"klx"];
|
|
|
[[KSUploadManager shareInstance] videoUpload:fileData fileName:@"video" fileSuffix:suffix progress:^(int64_t bytesWritten, int64_t totalBytes) {
|
|
|
- // 显示进度
|
|
|
- int progress = (int)(bytesWritten / totalBytes * 100);
|
|
|
- __block NSString *tipsMessage = [NSString stringWithFormat:@"%@\n%d%%",tips,progress];
|
|
|
- dispatch_main_async_safe(^{
|
|
|
- [LOADING_MANAGER.loadingView setDisplayText:tipsMessage];
|
|
|
- });
|
|
|
+
|
|
|
} successCallback:^(NSMutableArray * _Nonnull fileUrlArray) {
|
|
|
dispatch_main_async_safe(^{
|
|
|
- [LOADING_MANAGER removeCustomLoading];
|
|
|
NSString *fileUrl = [fileUrlArray lastObject];
|
|
|
success(fileUrl);
|
|
|
});
|
|
@@ -950,33 +945,31 @@
|
|
|
|
|
|
} faliure:^(NSError * _Nullable error, NSString * _Nullable descMessaeg) {
|
|
|
dispatch_main_async_safe(^{
|
|
|
- [LOADING_MANAGER removeCustomLoading];
|
|
|
+ [LOADING_MANAGER removeProgressLoading];
|
|
|
faliure(descMessaeg);
|
|
|
});
|
|
|
|
|
|
}];
|
|
|
}
|
|
|
|
|
|
+- (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)sendAudioWithURLPath:(NSURL *)fileUrl isFormal:(BOOL)isFormal success:(void(^)(NSString *audioUrl))success failure:(void(^)(NSString *desc))faliure {
|
|
|
NSString *tips = isFormal ? @"正在上传作品" : @"正在上传草稿";
|
|
|
|
|
|
- [LOADING_MANAGER showCustomLoading:tips];
|
|
|
+ [LOADING_MANAGER showProgressLoading:tips progress:66];
|
|
|
NSData *fileData = [NSData dataWithContentsOfURL:fileUrl];
|
|
|
NSString *suffix = [NSString stringWithFormat:@".%@",[fileUrl pathExtension]];
|
|
|
- [UPLOAD_MANAGER configBucketName:@"daya"];
|
|
|
+ [UPLOAD_MANAGER configBucketName:@"klx"];
|
|
|
[UPLOAD_MANAGER uploadFile:fileData fileName:@"evaluateAudio" fileSuffix:suffix progress:^(int64_t bytesWritten, int64_t totalBytes) {
|
|
|
- // 显示进度
|
|
|
- int progress = (int)(bytesWritten / totalBytes * 100);
|
|
|
- __block NSString *tipsMessage = [NSString stringWithFormat:@"%@\n%d%%",tips,progress];
|
|
|
- dispatch_main_async_safe(^{
|
|
|
- [LOADING_MANAGER.loadingView setDisplayText:tipsMessage];
|
|
|
- });
|
|
|
+
|
|
|
} successCallback:^(NSMutableArray * _Nonnull fileUrlArray) {
|
|
|
- [LOADING_MANAGER removeCustomLoading];
|
|
|
NSString *fileUrl = [fileUrlArray lastObject];
|
|
|
success(fileUrl);
|
|
|
} faliure:^(NSError * _Nullable error, NSString * _Nullable descMessaeg) {
|
|
|
- [LOADING_MANAGER removeCustomLoading];
|
|
|
+ [LOADING_MANAGER removeProgressLoading];
|
|
|
faliure(descMessaeg);
|
|
|
}];
|
|
|
|