|
@@ -27,6 +27,8 @@
|
|
|
|
|
|
@property (nonatomic, strong) NSString *presentName;
|
|
|
|
|
|
+@property (nonatomic, assign) BOOL isAborted;
|
|
|
+
|
|
|
@end
|
|
|
|
|
|
@implementation KSMediaManager
|
|
@@ -196,7 +198,10 @@
|
|
|
//
|
|
|
// NSLog(@"原视频大小:%@",[NSString stringWithFormat:@"%.2fM",(CGFloat)size/(1024*1024)]);
|
|
|
dispatch_main_sync_safe(^{
|
|
|
- [LOADING_MANAGER showCustomLoading:@"上传中..."];
|
|
|
+ self.isAborted = NO;
|
|
|
+ [LOADING_MANAGER showCancelCustomLoading:@"上传中..." cancel:^{
|
|
|
+ [self cacelCurrentTask];
|
|
|
+ }];
|
|
|
});
|
|
|
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
|
|
|
@@ -207,7 +212,7 @@
|
|
|
NSLog(@"导出后的视频:%@",[NSString stringWithFormat:@"%.2fM",(CGFloat)outputData.length/(1024*1024)]);
|
|
|
// Export completed, send video here, send by outputPath or NSData
|
|
|
// 导出完成,在这里写上传代码,通过路径或者通过NSData上传
|
|
|
- if (self.callback) {
|
|
|
+ if (self.callback && self.isAborted == NO) {
|
|
|
dispatch_main_sync_safe(^{
|
|
|
self.callback(outputPath, self.imageArray, self.imageAsset);
|
|
|
});
|
|
@@ -361,7 +366,10 @@
|
|
|
[tzImagePickerVc hideProgressHUD];
|
|
|
if (!error) {
|
|
|
dispatch_main_async_safe(^{
|
|
|
- [LOADING_MANAGER showCustomLoading:@"上传中..."];
|
|
|
+ self.isAborted = NO;
|
|
|
+ [LOADING_MANAGER showCancelCustomLoading:@"上传中..." cancel:^{
|
|
|
+ [self cacelCurrentTask];
|
|
|
+ }];
|
|
|
});
|
|
|
[[TZImageManager manager] getVideoOutputPathWithAsset:asset presetName:self.presentName success:^(NSString *outputPath) {
|
|
|
// NSData *data = [NSData dataWithContentsOfFile:outputPath];
|
|
@@ -373,7 +381,7 @@
|
|
|
NSLog(@"导出后的视频:%@",[NSString stringWithFormat:@"%.2fM",(CGFloat)outputData.length/(1024*1024)]);
|
|
|
// Export completed, send video here, send by outputPath or NSData
|
|
|
// 导出完成,在这里写上传代码,通过路径或者通过NSData上传
|
|
|
- if (self.callback) {
|
|
|
+ if (self.callback && self.isAborted == NO) {
|
|
|
self.callback(outputPath, self.imageArray, self.imageAsset);
|
|
|
}
|
|
|
|
|
@@ -447,4 +455,14 @@
|
|
|
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString] options:@{} completionHandler:nil];
|
|
|
}
|
|
|
|
|
|
+- (void)cacelCurrentTask {
|
|
|
+ self.isAborted = YES;
|
|
|
+ [UPLOAD_MANAGER cancelUploadCallback:^{
|
|
|
+ [self removeLoadHud];
|
|
|
+ }];
|
|
|
+}
|
|
|
+
|
|
|
+- (void)removeLoadHud {
|
|
|
+ [LOADING_MANAGER removeCustomLoading];
|
|
|
+}
|
|
|
@end
|