Skip to content

Instantly share code, notes, and snippets.

@jayeshk
Last active November 25, 2016 17:09
Show Gist options
  • Save jayeshk/1a66a71ca8576b132b521502bf2c78b6 to your computer and use it in GitHub Desktop.
Save jayeshk/1a66a71ca8576b132b521502bf2c78b6 to your computer and use it in GitHub Desktop.
Save resource video file to photo library using asset library.
NSURL* videoURL = [[NSBundle mainBundle] URLForResource:@"demo-clip" withExtension:@"mp4"];;
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
ALAssetsLibraryWriteVideoCompletionBlock completionBlock =
^(NSURL *savedURL, NSError *error) {
if (error) {
NSLog( @"Error while saving video Photo Library: %@", error );
} else {
NSLog( @"Successfuly saved video to Photo Library %@", savedURL.absoluteString);
}
};
if ([library videoAtPathIsCompatibleWithSavedPhotosAlbum:videoURL])
{
[library writeVideoAtPathToSavedPhotosAlbum:videoURL completionBlock:completionBlock];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment