diff --git a/src/ios/CDVCapture.h b/src/ios/CDVCapture.h index c7433a41..66311659 100644 --- a/src/ios/CDVCapture.h +++ b/src/ios/CDVCapture.h @@ -49,8 +49,10 @@ typedef NSUInteger CDVCaptureError; { CDVImagePicker* pickerController; BOOL inUse; + BOOL saveToGallery; } @property BOOL inUse; +@property BOOL saveToGallery; - (void)captureAudio:(CDVInvokedUrlCommand*)command; - (void)captureImage:(CDVInvokedUrlCommand*)command; - (CDVPluginResult*)processImage:(UIImage*)image type:(NSString*)mimeType forCallbackId:(NSString*)callbackId; diff --git a/src/ios/CDVCapture.m b/src/ios/CDVCapture.m index 24e111f4..4c1ba8a5 100644 --- a/src/ios/CDVCapture.m +++ b/src/ios/CDVCapture.m @@ -76,6 +76,7 @@ - (void)viewWillAppear:(BOOL)animated { @implementation CDVCapture @synthesize inUse; +@synthesize saveToGallery; - (void)pluginInitialize { @@ -220,6 +221,14 @@ - (void)captureVideo:(CDVInvokedUrlCommand*)command options = [NSDictionary dictionary]; } + // option to save video to gallery or not + NSNumber* saveToGallery = [options objectForKey:@"saveToGallery"]; + if([saveToGallery intValue] == 1) { + self.saveToGallery = YES; + } else { + self.saveToGallery = NO; + } + // options could contain limit, duration and mode // taking more than one video (limit) is only supported if provide own controls via cameraOverlayView property NSNumber* duration = [options objectForKey:@"duration"]; @@ -280,14 +289,15 @@ - (void)captureVideo:(CDVInvokedUrlCommand*)command - (CDVPluginResult*)processVideo:(NSString*)moviePath forCallbackId:(NSString*)callbackId { // save the movie to photo album (only avail as of iOS 3.1) - - /* don't need, it should automatically get saved - NSLog(@"can save %@: %d ?", moviePath, UIVideoAtPathIsCompatibleWithSavedPhotosAlbum(moviePath)); - if (&UIVideoAtPathIsCompatibleWithSavedPhotosAlbum != NULL && UIVideoAtPathIsCompatibleWithSavedPhotosAlbum(moviePath) == YES) { - NSLog(@"try to save movie"); - UISaveVideoAtPathToSavedPhotosAlbum(moviePath, nil, nil, nil); - NSLog(@"finished saving movie"); - }*/ + if(self.saveToGallery == YES) { + NSLog(@"can save %@: %d ?", moviePath, UIVideoAtPathIsCompatibleWithSavedPhotosAlbum(moviePath)); + if (&UIVideoAtPathIsCompatibleWithSavedPhotosAlbum != NULL && UIVideoAtPathIsCompatibleWithSavedPhotosAlbum(moviePath) == YES) { + NSLog(@"try to save movie"); + UISaveVideoAtPathToSavedPhotosAlbum(moviePath, nil, nil, nil); + NSLog(@"finished saving movie"); + } + } + // create MediaFile object NSDictionary* fileDict = [self getMediaDictionaryFromPath:moviePath ofType:nil]; NSArray* fileArray = [NSArray arrayWithObject:fileDict];