Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Saving a Video to the Photo Library - iPhone SDK

Is there any way for me to save a video in the Documents directory to the Photos Library? I have the link of the video in the documents directory, I just don't know how to save it to the Photos app.

Thanks,

Kevin

like image 988
lab12 Avatar asked Dec 21 '22 22:12

lab12


2 Answers

If you are saving it in a local directory first, then you can save it as..

    ALAssetsLibrary *assetLibrary = [[ALAssetsLibrary alloc] init];
    [assetLibrary writeVideoAtPathToSavedPhotosAlbum:url completionBlock:^(NSURL *assetURL, NSError *error){
        if(error) {
           NSLog(@"error while saving to camera roll %@",[error localizedDescription]);        
        } else {
            //For removing the back up copy from the documents directory           
            NSError *removeError = nil;
            [[NSFileManager defaultManager] removeItemAtURL:url error:&removeError];
            NSLog(@"%@",[removeError localizedDescription]);
        }
    }];
like image 74
Gokul Avatar answered Dec 30 '22 10:12

Gokul


Use the UISaveVideoAtPathToSavedPhotosAlbum function.

like image 42
Kris Markel Avatar answered Dec 30 '22 10:12

Kris Markel