我可以使用以下代码将捕获的照片保存到图库或相册中:
navigator.device.capture.captureImage(captureSuccess, captureError,
{limit:25,destinationType : Camera.DestinationType.FILE_URI,saveToPhotoAlbum:true});
不过,我也想把截取的视频也保存下来,但是我试过了,没有成功。我正在使用下面的代码:
navigator.device.capture.captureVideo(captureSuccess, captureError, {limit:1, duration:60,destinationType : Camera.DestinationType.FILE_URI,saveToPhotoAlbum:true });
我正在使用 Phonegap 3.0.0,目前专注于 iOS 应用程序和 Android apl。
最佳答案
我现在可以在 iOS 和 Cordova 2.9 上使用它了。 (在 iOS7 上测试)。
我所要做的就是:
从此方法 (processVideo) 中删除注释
-(CDVPluginResult*)processVideo:(NSString*)moviePath forCallbackId:(NSString*)callbackId { //将电影保存到相册(仅适用于 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];
注意: 他们告诉不需要它,它应该会自动保存。但就我而言,它没有得到保存。
- 重建 Cordova 库
- 重建后,如果您的链接器存在一些问题,请从您项目的build设置的有效架构中删除 arm64、arm7s 架构。
- 然后您就保存了视频。
我从 : https://groups.google.com/forum/#!topic/phonegap/hN09oEYF0lk 得到提示
关于android - 使用 phonegap 'captureVideo' 捕获视频后将视频保存到库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20902234/