Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
kalpan-prompt committed Jun 5, 2018
1 parent 3a0e273 commit 5eefa3c
Showing 1 changed file with 1 addition and 26 deletions.
27 changes: 1 addition & 26 deletions ios/src/ImageCropPicker.m
Original file line number Diff line number Diff line change
Expand Up @@ -463,12 +463,10 @@ - (void)showActivityIndicator:(void (^)(UIActivityIndicatorView*, UIView*))handl
[self.loadingLabel setFont:[UIFont boldSystemFontOfSize:18]];
[loadingView addSubview:self.loadingLabel];

// PS :- Created Cancel Button
// create Cancel Button

self.btnCancel = [[UIButton alloc]initWithFrame:CGRectMake(0, loadingView.frame.size.height-50, loadingView.frame.size.width, 50)];

[self.btnCancel addTarget:self action:@selector(btnCancelAction:) forControlEvents:UIControlEventTouchUpInside];

[self.btnCancel setTitle:@"Cancel" forState:UIControlStateNormal];
[self.btnCancel setTitle:@"Cancel" forState:UIControlStateSelected];
[self.btnCancel setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
Expand Down Expand Up @@ -510,23 +508,15 @@ - (void) getVideoAssetFromCamera:(AVURLAsset*)avAsset fileExtension:(NSString *)
if ([compatiblePresets containsObject:AVAssetExportPresetLowQuality])
{
AVAssetExportSession *exportSession = [[AVAssetExportSession alloc]initWithAsset:avAsset presetName:AVAssetExportPresetPassthrough];
// save to temp directory

NSString *strFileName = [[[NSUUID UUID] UUIDString] stringByAppendingString:[NSString stringWithFormat:@".%@",fileExtension]];
NSString *filePath = [[self getTmpDirectory] stringByAppendingString:strFileName];


NSURL *outputURL = [NSURL fileURLWithPath:filePath];

exportSession.outputURL = outputURL;
NSLog(@"videopath of your file = %@",filePath); // PATH OF YOUR FILE
exportSession.outputFileType = AVFileTypeMPEG4;

[exportSession exportAsynchronouslyWithCompletionHandler:^{

if ([exportSession status] == AVAssetExportSessionStatusCompleted) {
AVAsset *compressedAsset = [AVAsset assetWithURL:outputURL];

AVAssetTrack *videoTrack = [[compressedAsset tracksWithMediaType:AVMediaTypeVideo] firstObject];
NSNumber *filesize = nil;
[outputURL getResourceValue:&filesize forKey:NSURLFileSizeKey error:nil];
Expand All @@ -545,9 +535,7 @@ - (void) getVideoAssetFromCamera:(AVURLAsset*)avAsset fileExtension:(NSString *)
withModificationDate:[NSDate date]];
completion(video);
}

}];

}
} @catch(NSException *e) {

Expand All @@ -569,28 +557,19 @@ - (void) getVideoAsset:(PHAsset*)forAsset completion:(void (^)(NSDictionary* ima
});
};


// PS :- get Video File Name with Extension and Mime Type from PHAsset Object
NSString *mimeType = @"";
NSString *filename = [forAsset valueForKey:@"filename"];
NSString *fileExtension = [filename pathExtension];

NSString *strFileName = filename;
//NSString *strFileName = [[[NSUUID UUID] UUIDString] stringByAppendingString:[NSString stringWithFormat:@".%@",fileExtension]];

CFStringRef UTI = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, (__bridge CFStringRef)[filename pathExtension], NULL);
CFStringRef MIMETYPE = UTTypeCopyPreferredTagWithClass(UTI, kUTTagClassMIMEType);

CFRelease(UTI);
if (MIMETYPE) {
mimeType = (NSString *)CFBridgingRelease(MIMETYPE);
}

//NSString *strFileName = filename;
NSString *filePath = [[self getTmpDirectory] stringByAppendingString:strFileName];
NSFileManager *fileManager = [NSFileManager defaultManager];


if ([fileManager fileExistsAtPath:filePath]){
NSError *error;
BOOL success = [fileManager removeItemAtPath:filePath error:&error];
Expand All @@ -600,7 +579,6 @@ - (void) getVideoAsset:(PHAsset*)forAsset completion:(void (^)(NSDictionary* ima
}
}


NSURL *outputURL = [NSURL fileURLWithPath:filePath];
// Get compression presets
NSString *presetKey = [self.options valueForKey:@"compressVideoPreset"];
Expand All @@ -612,7 +590,6 @@ - (void) getVideoAsset:(PHAsset*)forAsset completion:(void (^)(NSDictionary* ima
preset = AVAssetExportPresetMediumQuality;
}


PHImageRequestID imageRequest = [self.manager requestExportSessionForVideo:forAsset
options:options
exportPreset:preset
Expand Down Expand Up @@ -645,8 +622,6 @@ - (void) getVideoAsset:(PHAsset*)forAsset completion:(void (^)(NSDictionary* ima
}
else{
completion(nil);
NSLog(@"Padam");
NSLog(exportSession.error.localizedDescription);
}
}];
}];
Expand Down

0 comments on commit 5eefa3c

Please sign in to comment.