copy video to uipasteboard
Asked Answered
A

3

8

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.

Abscond answered 21/12, 2012 at 11:48 Comment(5)
convert the video to data and use it like image. Did you tried this ?Cryptograph
Yes I try it but can't get the result...Abscond
hey here something new for me and really nice question..Stradivarius
Ya but i think it is not possible through pasteboard...Abscond
Hi @Abscond I'm also working on similar type. Did you find any solution about how to solve this ??Tallia
T
-1

I have also faced the same issue in sending audio file from SMS. But sending video and audio from SMS is not possible with current SDK. You can do this by uploading that video to server and then send that uploaded URL.

How to programmatically send voicemail message on the iPhone?

Treasurehouse answered 21/12, 2012 at 12:15 Comment(1)
Note that Enea's answer is correct and the accepted answer is wrong. You can send video over SMS by copying to UIPasteboard as is asked in the original question. Tested and verified to be working on iOS 8+.Rambow
E
9
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

Ediva answered 29/10, 2014 at 6:8 Comment(1)
Hi @Enea, It was working good and I'm also do the same. But while converting to NSData and setData to pasteboard is really slow and taking some time. Do u have any idea how to boost it?Tallia
B
0

In Swift to copy video to UIPasteboard, assuming you already have a data variable with the movie's binary do :

import UniformTypeIdentifiers 

UIPasteboard.general.setData(data ?? Data(),forPasteboardType: UTType.mpeg4Movie.description)

This worked for me. To test, I copied from the app and then pasted to the iPhone notes app.

Bibliogony answered 11/9, 2022 at 20:13 Comment(0)
T
-1

I have also faced the same issue in sending audio file from SMS. But sending video and audio from SMS is not possible with current SDK. You can do this by uploading that video to server and then send that uploaded URL.

How to programmatically send voicemail message on the iPhone?

Treasurehouse answered 21/12, 2012 at 12:15 Comment(1)
Note that Enea's answer is correct and the accepted answer is wrong. You can send video over SMS by copying to UIPasteboard as is asked in the original question. Tested and verified to be working on iOS 8+.Rambow

© 2022 - 2024 — McMap. All rights reserved.