I want to capture a video and after that share it on some social networking sites and email so i have captured video and saved that onto photo album now i don't know how can i share that captured/saved video please suggest something for this, here is my code for captured video storing..:-
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
NSString *tempFilePath = [[info objectForKey:UIImagePickerControllerMediaURL] path];
// NSLog(@"dictionary info %@", info);
if ( UIVideoAtPathIsCompatibleWithSavedPhotosAlbum(tempFilePath))
{
// Copy it to the camera roll.
UISaveVideoAtPathToSavedPhotosAlbum(tempFilePath, self, @selector(video:didFinishSavingWithError:contextInfo:), tempFilePath);
NSURL *videoURL = [info objectForKey:UIImagePickerControllerMediaURL];
NSData *videoData = [NSData dataWithContentsOfURL:videoURL];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
vidPath = [documentsDirectory stringByAppendingFormat:@"/vid1.mp4"];
[vidPath retain];
BOOL success = [videoData writeToFile:vidPath atomically:NO];
NSLog(@"Written file on path success? , %@\n", (success ? @"YES" : @"NO"));
[picker dismissModalViewControllerAnimated:YES];
}
}
Update
i have tried this code to generate tiny url for sharing the video but it's not working :(
NSString *apiEndpoint = [NSString stringWithFormat:@"http://tinyurl.com/api-create.php?url=%@",vidPath];
[apiEndpoint retain];
shortURL = [NSString stringWithContentsOfURL:[NSURL URLWithString:apiEndpoint]
encoding:NSASCIIStringEncoding
error:nil];
[shortURL retain];
here i'll be able to store video on photo gallery and document directory now i want to share that so how to do that? Please help!