I have download the .mp4 file from sever to document directory and called the writeVideoAtPathToSavedPhotosAlbum method to save to gallery but its nor working.its throwing asset url nil.Can anyone plz help me with this issue
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *path = [documentsDirectory stringByAppendingPathComponent:@"test.mp4"];
NSURL *movieURL = [NSURL fileURLWithPath:path];
ALAssetsLibrary* library = [[ALAssetsLibrary alloc] init];
NSLog(@"Moview URL:%@",movieURL);
NSURL *url = [movieURL copy];
[library writeVideoAtPathToSavedPhotosAlbum:url
completionBlock:^(NSURL *assetURL, NSError *error)
{
NSLog(@"Asset Url:%@",assetURL);
if(!error) {
NSLog(@"\t ! Error");
NSLog(@"\t Error: %@", [error localizedDescription]);
NSLog(@"\t Error code %d", [error code]);
}
if(error != nil) {
NSLog(@"\t ERROR != NIL");
NSLog(@"\t Error - Image Failed To Save With Error: %@", [error localizedDescription]);
NSLog(@"\t Error code %d", [error code]);
}
if(error == nil) {
NSLog(@"\t ERROR == NIL");
}
}];