I am getting an error where the UIVideoEditorController is unable to find a video URL that has been loaded using a UIImagePicker and stored in an dictionary.
I am using the following but the canEditVideoAtPath is returning false for the following url:
file:///private/var/mobile/Containers/Data/Application/83449852-2DC2-42AB-9FFA-C2C7931380C4/tmp/trim.28F7EE00-9F2E-4421-8E2B-8A70789CAFDE.MOV
Any idea why the following code would not work?
NSLog(#"%#",[[self.movieArray objectAtIndex:[sender tag]] objectForKey:#"MovieURL"]);
NSString *videoPath = [NSString stringWithFormat:#"%#",[[self.movieArray objectAtIndex:[sender tag]] objectForKey:#"MovieURL"]];
UIVideoEditorController *editorController = [[UIVideoEditorController alloc] init];
if([UIVideoEditorController canEditVideoAtPath:videoPath]){
editorController.videoPath = [NSString stringWithFormat:#"%#",[[self.movieArray objectAtIndex:[sender tag]] objectForKey:#"MovieURL"]];
editorController.delegate = self;
editorController.videoQuality = UIImagePickerControllerQualityTypeHigh;
self.popoverController = [[UIPopoverController alloc] initWithContentViewController:editorController];
self.popoverController.delegate = self;
[self.popoverController presentPopoverFromRect:((UIButton *)sender).bounds inView:sender permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}
I get the error messages
The requested URL was not found on this server
remove file:// from the path string
Try using -(NSString *)path. The absolute URL won't work.
[[[self.movieArray objectAtIndex:[sender tag]] objectForKey:#"MovieURL"] path]
Related
I want to share image and video on face book wall using sdk.
I use following code to share image
FBSDKSharePhoto *photo = [[FBSDKSharePhoto alloc] init];
photo.image = [UIImage imageNamed:#"Classic-Guitar.jpg"];
photo.userGenerated = YES;
FBSDKSharePhotoContent *content = [[FBSDKSharePhotoContent alloc] init];
content.photos = #[photo];
FBSDKShareDialog *shareCodeDialog;
shareCodeDialog = [FBSDKShareDialog new];
[shareCodeDialog setDelegate:self];
[shareCodeDialog setShareContent:content];
[shareCodeDialog setFromViewController:self];
[shareCodeDialog show];
Using this code i am able to post image on wall, but while sending video i am using following code
NSURL *videoURL = [[NSURL URLWithString:#"https://www.youtube.com/watch?v=rSAiSTkVMfs"] absoluteURL];
FBSDKShareVideo *video = [[FBSDKShareVideo alloc] init];
video.videoURL = videoURL;
FBSDKShareVideoContent *content = [[FBSDKShareVideoContent alloc] init];
content.video = video;
FBSDKShareDialog *shareCodeDialog;
shareCodeDialog = [FBSDKShareDialog new];
[shareCodeDialog setDelegate:self];
[shareCodeDialog setShareContent:content];
[shareCodeDialog setFromViewController:self];
[shareCodeDialog show];
but it not getting posted gives and error in delegate saying
Error Domain=com.facebook.sdk.share Code=2 "The operation couldn’t be completed. (com.facebook.sdk.share error 2.)" UserInfo=0x16d95990 {com.facebook.sdk:FBSDKErrorArgumentValueKey=https://www.youtube.com/watch?v=rSAiSTkVMfs, com.facebook.sdk:FBSDKErrorArgumentNameKey=videoURL, com.facebook.sdk:FBSDKErrorDeveloperMessageKey=Invalid value for videoURL: https://www.youtube.com/watch?v=rSAiSTkVMfs}
The videoURL property has to be an asset URL (one you get from UIImagePickerController) and not a local file URL/web URL (see https://developers.facebook.com/docs/sharing/ios#videos)
If you want to share a YouTube video (or any video available on a website), use FBSDKShareLinkContent instead (see https://developers.facebook.com/docs/sharing/ios#links)
I am trying to upload a video to Whatsapp with an ALAsset URL, but it is loading the video when I share it using UIActivityViewController
ALAssetsLibrary *assetLibrary=[[ALAssetsLibrary alloc] init];
[assetLibrary assetForURL:self.videoURL resultBlock:^(ALAsset *asset) {
NSArray *objectsToShare = #[asset.defaultRepresentation.url];
FrodoInstagramActivity *instagramActivity = [[FrodoInstagramActivity alloc] init];
UIActivityViewController *activityVC = [[UIActivityViewController alloc]
initWithActivityItems:objectsToShare applicationActivities:#[instagramActivity]];
[self presentViewController:activityVC animated:YES completion:nil];
} failureBlock:nil];
Try this noh, "Movie" Your video which saved to local directory from video asset.
NSString * savePath = [NSHomeDirectory() stringByAppendingPathComponent:#"Documents/whatsAppTmp.wam"];
savePath = [[NSBundle mainBundle] pathForResource:#"Movie" ofType:#"m4v"];
_documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:savePath]];
_documentInteractionController.UTI = #"net.whatsapp.movie";
_documentInteractionController.delegate = (id)self;
[_documentInteractionController presentOpenInMenuFromRect:CGRectMake(0, 0, 0, 0) inView:self.view animated: YES];
Save your asset locally, and get the local URL. Pass that URL path on the above code. Let's see.
Dont create each file locally for each video, just use the same file name for all videos and replace videos. And delete the video from local, after successfully uploaded. This might help.
I have also face this problem with sharing the link on whatsapp.
In whatsapp sharing was restrit to number of characters.
Please share url and text with maximum 150 characters.
then say what happen.
happy coding :)
I have scenario which fetching json requests from API and parse it on view. But if API pushes xml link, i need to start xml parse task with AFNetworking. After parsing xml, i am passing xml as parameter(NSData) in to another class method which i am assigning child values with NSXMLParser, after parsing has finished :
-(void)parserDidEndDocument:(NSXMLParser *)parser
{
ViewController *VS = [[VC alloc] init];
[VC vastXMLReturn:vastXMLDictionary rollType:rollType];
}
After sending parameters in ViewController following method is responsible to play video;
-(void)vastXMLReturn:(NSDictionary *)xml rollType:(NSString *)roll
{
NSLog(#"XML responses = %#",xml);
//NSString *mediaDuration = [xml objectForKey:#"mediaDuration"];
NSString *mediaFilePath = [xml objectForKey:#"mediaFilePath"];
//NSArray *trackingLists = [xml objectForKey:#"trackingLinks"];
advertisementURL = [NSURL URLWithString:roll];
[self playVideo:advertisementURL initial_time:0];
}
In PlayVideo Method
-(void)playVideo:(NSURL *)videoURL initial_time:(NSTimeInterval)playerTime
{
theMoviPlayer = [[MPMoviePlayerController alloc] initWithContentURL:videoURL];
theMoviPlayer.controlStyle = MPMovieControlStyleNone;
[self performSelector:#selector(closeButtonForVideoPlayer) withObject:nil afterDelay:5.0];
theMoviPlayer.movieSourceType = MPMovieSourceTypeFile;
theMoviPlayer.view.transform = CGAffineTransformConcat(theMoviPlayer.view.transform, CGAffineTransformMakeRotation(M_PI_2));
[self.view addSubview:theMoviPlayer.view];
//[theMoviPlayer.moviePlayer requestThumbnailImagesAtTimes:#[ #4.3f ] timeOption:MPMovieTimeOptionExact];
[theMoviPlayer setFullscreen:YES animated:YES];
}
The real problem is after [theMoviPlayer setFullscreen:YES animated:YES]; line, breakpoint jumps in viewDidLoad method which is should not happen because the process will be starting in that method again and program terminates error.
What should i have to do for preventing goes in viewDidLoad method ?
Best Regards
Thanks to a couple other posts here , I've successfully be able to use the Instagram iPhone hooks to open Instagram and present it with a photo successfully from my application.
(I've made my ViewController class a delegate of UIDocumentInteractionController, and alloc/init'ed a nonatomic/retain property of UIDocumentInteractionController...
However, the key that I put into my NSDictionary that I place in the document controller annotation property will not seem to carry over to Instagram - the caption area is just empty.
How do I deal with this?
Here is my method:
- (void) uploadImageToInstagram:(UIImage *)imageToUpload {
NSLog(#"postToInstagramInBackground");
NSURL *instagramURL = [NSURL URLWithString:#"instagram://app"];
if ([[UIApplication sharedApplication] canOpenURL:instagramURL]) {
// Upscale to 612x612
imageToUpload = [self upscaleImage:imageToUpload];
// Get JPG + IGO Format
NSString *savePath = [NSHomeDirectory() stringByAppendingPathComponent:#"Documents/generate.igo"];
[UIImageJPEGRepresentation(imageToUpload, 1.0) writeToFile:savePath atomically:YES];
// Paths
NSURL *imageURL = [NSURL fileURLWithPath:savePath];
NSURL *igImageHookFile = [[NSURL alloc] initWithString:[[NSString alloc] initWithFormat:#"file://%#",savePath]];
// Setup DocController
self.docController.UTI = #"com.instagram.photo";
self.docController = [self setupControllerWithURL:igImageHookFile usingDelegate:self];
self.docController.annotation = [NSDictionary dictionaryWithObject:#"MyApp" forKey:self.caption.text];
[self.docController setURL:imageURL];
[self.docController presentOpenInMenuFromRect:CGRectZero inView:self.view animated:YES ];
}
else {
NSLog(#"Instagram not installed in this device!\nTo share image please install Instagram.");
}
}
There are a few methods that are called here that I haven't included, one that upscales the image to make sure its 612x612, and one setups the file url for the document controller.
Proper syntax should be
self.docController.annotation = [NSDictionary dictionaryWithObject:self.caption.text forKey:#"InstagramCaption"];
I've imported last version of MWPhotoBrowser classes in my project, but when the browser load images form web the app crashes. In implementation i use the same code founded in demo project, if i show local images it's all ok. This is my implementation:
[galleryPhotosArray addObject:[MWPhoto photoWithImage:[UIImage imageNamed:#"Blue_Screen_iPhone.png"]]];
[galleryPhotosArray addObject:[MWPhoto photoWithImage:[UIImage imageNamed:#"Logo_iPhone.png"]]];
[galleryPhotosArray addObject:[MWPhoto photoWithURL:[NSURL URLWithString:#"http://www.cellulare.it/wp-content/uploads/2013/09/apple1.png"]]];
MWPhotoBrowser *browser = [[MWPhotoBrowser alloc] initWithDelegate:self];
browser.displayActionButton = YES;
browser.displayNavArrows = NO;
browser.wantsFullScreenLayout = YES;
browser.zoomPhotosToFill = YES;
[browser setCurrentPhotoIndex:0];
[self.navigationController pushViewController:browser animated:YES];
[browser release];
so i add two local images and a random image from google images. The app crashes in two points, sometimes in SDWebImageDownloaderOperation.m in this line:
self.connection = [NSURLConnection.alloc initWithRequest:self.request delegate:self startImmediately:NO];
the second point is in SDImageCache.m file, in - (NSString *)cachePathForKey:(NSString *)key inPath:(NSString *)path method
Somebody has this issues?
My error, i've only added ARC support to SDWebImage files.