Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

copy video to uipasteboard

I have successfully able to copy or add the image to pasteboard by using following code:

if (ver_float < 6.0)
{
    UIPasteboard *pasteboard;
    pasteboard = [UIPasteboard generalPasteboard];
    NSString *filePath =pathToImage;
    [pasteboard setImage:[UIImage imageWithContentsOfFile:filePath]];
}
else
{
    UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
    NSString *filePath =pathToImage;
    NSData *videoData = [NSData dataWithContentsOfFile:filePath];
    [pasteboard setData:videoData forPasteboardType:[UIPasteboardTypeListImage objectAtIndex:0]];

}

NSURL *urlstr = [NSURL URLWithString:@"sms:"];
[[UIApplication sharedApplication] openURL:urlstr];

But the app which I am making is based on both images and videos so that user will be able to send image/video via imessage or messagecomposer. But as I have convert the image into data and added into pasteboard. It is working succesfully and sending through imessage. But I also need to send video via imessage. If anyone has any idea about this please provide me some suggestion or solution.

I would be very thankful for the help.

like image 965
Vishal Avatar asked Dec 21 '12 11:12

Vishal


1 Answers

NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://pathto.mp4"]];
UIPasteboard *pasteBoard = [UIPasteboard generalPasteboard];
[pasteBoard setData:data forPasteboardType:@"public.mpeg-4"];

@"public.mpeg-4" from http://www.escape.gr/manuals/qdrop/UTI.html

like image 145
Enea G UnlimApps Avatar answered Oct 22 '22 22:10

Enea G UnlimApps