简体   繁体   中英

how to save video in IOS7?

I used the following code to save video in the photo library,but it is not working 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];
                }
             });
         }];
}

I used this method also,but this method also fails to save video in IOS7

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

Please let me know if is there any modification that needs to be made in this method only or is there any other method for storing video in IOS7. Thanks in advance.

Try this way...

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

Let me know if you have any problem

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM