如何在IOS7中保存视频?

时间:2013-10-11 05:40:31

标签: iphone ios ios5 ios6 ios7

我使用以下代码将视频保存在照片库中,但它无法正常工作。

ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
if ([library videoAtPathIsCompatibleWithSavedPhotosAlbum:urlVideo])
{
    [library writeVideoAtPathToSavedPhotosAlbum:urlVideo completionBlock:^(NSURL *assetURL, NSError *error){
        dispatch_async(dispatch_get_main_queue(), ^{
            if (error) {
                [self ShowMessage:@"Failed to create movie ! It may be due to video quality,please try again/"  andTitle:@"ERROR:" andButtonTitle:@"Close"];
                 [self EnableView];
            }
            else {
                [self ShowMessage:@"Movie created successfully" andTitle:@"Movie Status" andButtonTitle:@"Ok"];
                [self EnableView];
                }
             });
         }];
}

我也使用了这种方法,但这种方法也无法在IOS7中保存视频

UISaveVideoAtPathToSavedPhotosAlbum (exportPath, [GlobalMethods sharedInstance], @selector(video:didFinishSavingWithError:contextInfo:), nil);

请告诉我是否需要在此方法中进行任何修改,或者是否有其他方法可以在IOS7中存储视频。提前谢谢。

1 个答案:

答案 0 :(得分:-1)

试试这种方式......

#pragma mark - ImagePicker Controller Delegate
-(void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingMediaWithInfo:(NSDictionary *)info
{
        NSString *sourcePath = [[info objectForKey:@"UIImagePickerControllerMediaURL"]relativePath];
    UISaveVideoAtPathToSavedPhotosAlbum(sourcePath,nil,nil,nil);
}

如果您有任何问题,请与我们联系