Video sharing with thumbnail and play button, using UIActivityViewController in ios7? - uiactivityviewcontroller

Want to share video using UIActivityViewController with its thumbnail and playbutton icon.
I used .mp4 url but facebook shows url not thumbnail.
how to make possible to show video(thumbnail with play button) on Facebook without using following code, because it doesnt work.
ALAsset * asset = [[ALAsset alloc] init];
[asset setVideoAtPath:urlToVideoFile completionBlock:NULL];
NSArray * activityItems = #[asset];
UIActivityViewController * activityController = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:NULL]

The code which you have put is adding asset into array, don't put asset directly instead put url and try.

Related

Cloudinary images not showing up on IOS debug build

I am making an app on codename one using InteliJ and I have some cloudinary pictures that show up on the simulator but when I send an IOS debug build, the pictures do not show up.
I went to this link https://www.codenameone.com/blog/sizing-images-just-right-with-cloudinary.html and used the same method but it did not work. When I tried to show a local image on the debug build, it showed up but the cloudinary images did not, so the problem has to do with cloudinary, not images in general.
Here is my code:
Cloudinary cloudinary = new Cloudinary(ObjectUtils.asMap(
"cloud_name", NAME,
"api_key", API_KEY,
"api_secret", API_SECRET));
cloudinary.config.privateCdn = false;
ArrayList labels = new ArrayList();
for (Object url : images) {
Image img2 = cloudinary.url()
.type("fetch") // Says we are fetching an image
.format("jpg") // We want it to be a jpg
.new Transformation().crop("fill") // We crop the image to fill the given width/height
.width(hi.getWidth())
.height(hi.getWidth())
)
.image(encImage, (String) url);
// Add the image to a label and place it on the form.
labels.add(img2);
}
for (Object img : labels) {
Image newImg = (Image) img;
allImgs.addItem(newImg);
}
ImageViewer imgViewer = new ImageViewer();
imgViewer.setImageList(allImgs);
Again, I am not getting any error messages in the simulator and the images are showing up but they are not showing up in the IOS debug build. Please help.

How to play an attachment video from the timeline item

I want to insert a timelineitem with video attachment and if user selects a specific menu item, glass to play the video. I'm doing all from .net app like this, please correct me, if i'm doing wrong.
TimelineItem item = new TimelineItem()
item.MenuItems.Insert(0, new MenuItem(){Action="what is the action to use?";...});
request = Service.Timeline.Insert(item, attachment, contentType);
request.Upload();
I would like to know, do i need a menu item, if yes, what is the action i should use?
Currently i'm sending the video attachment, but there is no way to play the video.
Any help is greatly appreciated.
You don't need to specify any menuItems but your timeline item should not contain html content.
Make sure that your video is of a supported format: once it's inserted, and Glass has synced and fully downloaded the attached video, it should start playing right when you land on the item in your timeline.
This works using the QuickStart project for Java (mirror-java-starter-demo):
https://github.com/googleglass/mirror-quickstart-java
Replace the lines near line 119 in MainServlet.java with this:
URL url = new URL(req.getParameter("imageUrl"));
String contentType = req.getParameter("contentType");
url = new URL("http://localhost:8888/static/videos/video.mp4");
contentType = "video/mp4";
byte[] b = ByteStreams.toByteArray(url.openStream());
int i = b.length;
InputStream temp = url.openStream();
MirrorClient.insertTimelineItem(credential, timelineItem, contentType, temp);
Then run the project and click the "A Picture" button to upload a video from a new folder inside static called videos called video.mp4. I used a 10 second clip I recorded with glass (6.30 MB).
Note that when running with App Engine 1.76 on a windows machine I got this error when uploading, but changing to 1.80 made this issue go away:
Here is Windows metadata about the video that might be useful:
Depending on your network connection it might take a little bit for the video to show in your timeline, but mine plays.

Google maps sdk callout issue ios6

i am using googlemap sdk for ios 6 in my project
The problem i am facing is with Marker options
GMSMarkerOptions *londonOptions = [[GMSMarkerOptions alloc] init];
londonOptions.position = CLLocationCoordinate2DMake(51.500,-0.127);
londonOptions.title = nil;
londonOptions.snippet = nil;
[mapView_ addMarkerWithOptions:londonOptions];
Google states that if i set the title and snippet to nil then the marker would not show a callout if i tap on it.
but it does show an callout on tapping on it.
Has anyone faced this problem
Thanks in advance
Regards
Nitesh
I worked around it by returning an empty uiview :) but as share said, it is fixed now

How to get driving directions within my app iOS6

I am using Apple Map's in my app and on my view i want to show the driving direction from the user location to the current location that i have on the view, now i just want all this inside my app only i.e i can show the driving direction's on the mapview, I have tried using the apple map application but after i make call to it from my application it takes me to apple's map application where i get the driving direction's but i can not return back into my application so i am thinking that i can do something in my application itself so that i can get the driving directions on my current view itself ..
NSString* addr = [NSString stringWithFormat:#"http://maps.apple.com/maps?daddr=%1.6f,%1.6f&saddr=%1.6f,%1.6f",coordinate.latitude,coordinate.longitude,mapView.userLocation.coordinate.latitude,mapView.userLocation.coordinate.longitude];
NSURL* url = [[NSURL alloc] initWithString:[addr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
[[UIApplication sharedApplication] openURL:url];
this code takes me to the apple's map app from my native app but i can't return directly back to my app.is there a possible solution so that i can move back to my APP AFTER GETTING THE DRIVING DIRECTIONS ?? (webview didnot work for me.can i add a back button on apple's app or what ).Please help.... Thanks a lot !!
Or Please can any one suggest me a better code for implementing so that i can do all of that in my application only ?
I want an in-app map depicting the navigation routes and driving directions...
This is not the way to achieve the directions,
I have made a sample for you which covers all the iOS versions, New Google Maps and the iOS 6 tom tom maps as well.
Here it is:
if([[[UIDevice currentDevice] systemVersion] compare:#"6.0" options:NSNumericSearch] == NSOrderedDescending){
//6.0 or above
NSString *Destinationlatlong =[NSString stringWithFormat:#"%#,%#",your.latitude,your.longitude];
NSString* addr = [NSString stringWithFormat:#"comgooglemaps://?saddr=%f,%f&daddr=%#",[AppDelegate zDelegate].location.coordinate.latitude,[AppDelegate zDelegate].location.coordinate.longitude, Destinationlatlong];
addr=[addr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSURL* url = [[[NSURL alloc] initWithString:addr]autorelease];
// NSLog(#"url %#",url);
if ([[UIApplication sharedApplication]canOpenURL:url]) {
[[UIApplication sharedApplication] openURL:url];
}else{
CLLocationCoordinate2D coords =
CLLocationCoordinate2DMake([your.latitude doubleValue],[your.longitude doubleValue]);
MKPlacemark *placeMark = [[MKPlacemark alloc]
initWithCoordinate:coords addressDictionary:nil];
MKMapItem *destination = [[MKMapItem alloc]initWithPlacemark:placeMark];
[destination openInMapsWithLaunchOptions:nil];
}
}else{
NSString *Destinationlatlong =[NSString stringWithFormat:#"%#,%#",your.latitude,your.longitude];
NSString* addr = [NSString stringWithFormat:#"http://maps.google.com/maps?saddr=Current+Location&daddr=%#",Destinationlatlong];
addr=[addr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSURL* url = [[[NSURL alloc] initWithString:addr]autorelease];
// NSLog(#"url %#",url);
if ([[UIApplication sharedApplication]canOpenURL:url]) {
[[UIApplication sharedApplication] openURL:url];
}else{
UIAlertView *alert=[[[UIAlertView alloc] initWithTitle:#"Warning!" message:#"Device does not support this functionality" delegate:nil cancelButtonTitle:#"Okay" otherButtonTitles: nil]autorelease] ;
[alert show];
}
}
This should get you started. In short, get driving instruction from google api in json, parse it, and display it on your own map using MKPolyline
http://iosguy.com/2012/05/22/tracing-routes-with-mapkit/

NSURL to File Path Monotouch

I am new to iphone development. I am writing my app in Mono touch.
I am trying to get a photo from the asset library which I can do successfully however I get the path as a URL "assets-library://asset/asset.JPG". I want to do a FileStream read which asks for a filepath. How can I convert NSURL to a file path?
I used asset.DefaultRepresentation.Url.AbsoluteString which gives the following filePath:
assets-library://asset/asset.JPG?id=1000000001&ext=JPG
then when it hits the FileStream(filePath, FileMode.Open, FileAccess.Read) it gives an exception stating that Could not find part of the path.
Please Help:)
The url you get from the assets library is not a file path. It is a url to a resource in the assets library, so you cannot use FileStream to read its data.
If the asset is an image, you can get its contents to an NSData object like this:
UIImage image = UIImage.FromImage(asset.DefaultRepresentation.GetImage());
NSData data = image.AsJPEG();
You can use two different static methods to load an image. FromImage and FromBundle. The first is asynchronous. The latter is synchronous (when an image is loaded the it is cashed by iOS). Both take the path to your image.
When you use these methods, property image must be set to content property. Right click on image, property -> set build action to content.

Resources