3

I was able to save the captured photo to the library or photo album by using this codes:

navigator.device.capture.captureImage(captureSuccess, captureError, 
{limit:25,destinationType : Camera.DestinationType.FILE_URI,saveToPhotoAlbum:true});

However, I also want to save the captured video as well, but I have tried and had no success. I am using this below code:

navigator.device.capture.captureVideo(captureSuccess, captureError, {limit:1, duration:60,destinationType : Camera.DestinationType.FILE_URI,saveToPhotoAlbum:true });

I am using Phonegap 3.0.0 and currently focusing on iOS app and Android apl.

sean.nuon
  • 116
  • 1
  • 8

2 Answers2

4

I got this working now for iOS and Cordova 2.9. (Test on iOS7).

All I have to do is to:

  • Remove comment the from this method (processVideo)

    -(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");
    }
    // create MediaFile object
    NSDictionary* fileDict = [self getMediaDictionaryFromPath:moviePath ofType:nil];
    NSArray* fileArray = [NSArray arrayWithObject:fileDict];
    
    return [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsArray:fileArray];
    

    }

Note: They tell that don't need it, it should automatically get saved. But for my case, it did not get saved.

  • Rebuild the Cordova library
  • After rebuild, if you have some issues with linker, do remove arm64, arm7s architecture from Valid Architecture from Build Setting of your project.
  • And then you got your video saved.

I got hint from : https://groups.google.com/forum/#!topic/phonegap/hN09oEYF0lk

sean.nuon
  • 116
  • 1
  • 8
0

Change this to

navigator.device.capture.captureVideo(captureSuccess, captureError, {limit:1, duration:60,destinationType : Camera.DestinationType.FILE_URI,saveToPhotoAlbum:true });

to

navigator.device.capture.captureVideo(captureSuccess, captureError, {limit: 1,duration:60});

Secondly limit property is not supported in IOS. For more details you can check the phonegap link

Divesh Salian
  • 1,457
  • 17
  • 30
  • Thanks! Let me try to change and test it. – sean.nuon Jan 04 '14 at 03:13
  • Hi Divesh Salian. I have changed to navigator.device.capture.captureVideo(captureSuccess, captureError, {}); // removing all options, but it still did not save to camera roll. – sean.nuon Jan 06 '14 at 09:45
  • is your camera getting opened ? If yes do u get any error after completing the recording? – Divesh Salian Jan 06 '14 at 09:57
  • Everything worked fine. The camera opened, I captured and transferred to server successfully. The only problem is it does not save to camera roll. I tested on iOS >=6. – sean.nuon Jan 06 '14 at 12:04
  • Get the video path... make use of some file explorer and check whether that file exist... [Check](http://stackoverflow.com/questions/20066036/how-to-use-phonegap-2-9-0-camera-and-store-in-android-device/20066497#20066497) the last comment for my answer might be you getting the same problem – Divesh Salian Jan 06 '14 at 12:15
  • I try to find but did not see (maybe in Android is working, but in iOS I could not find the captured video). But I will try to debug the video path to know where is it. – sean.nuon Jan 06 '14 at 12:36