Skip to content

How To for iOS

eternalstorms edited this page Jul 18, 2012 · 11 revisions
Clone this wiki locally

Sample Project

iOS Sample Project, ~3MB (Please be aware that the sample project might not have the newest ESSVideoShare framework imported.)

How To use ESSVideoShare on iOS

From the ESSVideoShare.framework project, copy all files that are enclosed in a folder labeled "Both Mac / iOS" or "iOS" to your iOS project. The full list:

OAuth folder
ESSVimeo.h
ESSVimeo.m
ESSVimeoiOSViewController.h
ESSVimeoiOSViewController.m
ESSVimeoiOSView_iPhone.xib
ESSVimeoiOSView_iPad.xib
ESSFlickr.h
ESSFlickr.m
ESSFlickriOSViewController.h
ESSFlickriOSViewController.m
ESSFlickriOSView_iPhone.xib
ESSFlickriOSView_iPad.xib
ESSYouTube.h
ESSYouTube.m
ESSYouTubeiOSViewController.h
ESSYouTubeiOSViewController.m
ESSYouTubeiOSView_iPhone.xib
ESSYouTubeiOSView_iPad.xib
ESSFacebook.h
ESSFacebook.m
ESSFacebookiOSViewController.h
ESSFacebookiOSViewController.m
ESSFacebookiOSLoginView_iPhone.xib
ESSFacebookiOSLoginView_iPad.xib
Localizable.strings

To use these, you need to import them into your project's header files like this:

#import "ESSVimeo.h"
#import "ESSFlickr.h"
#import "ESSYouTube.h"
#import "ESSFacebook.h"

From this point on, everything is basically the same as in the OS X Lion How-To, except for the delegate methods.

Before you can start uploading to YouTube, Vimeo, Facebook and Flickr, you'll have to get API access for each service you'd like to use.

Links to get API Access to YouTube, Vimeo, Facebook and Flickr

YouTube API Access

Vimeo API Access - Link only works when already logged in to Vimeo

Facebook API Access

Flickr API Access

The Code

Once you have the appropriate API keys for the services you'd like to use, you can start using ESSVideoShare.framework.

There are four classes you can use:

ESSYouTube
ESSVimeo
ESSFacebook
ESSFlickr

ESSYouTube

Initialize a ESSYouTube object

id delegate = self;
NSString *youTubeAPIKey = @"yourAPIKey";
ESSYouTube *youTube = [[ESSYouTube alloc] initWithDelegate:delegate
                                                developerKey:youTubeAPIKey];

Now on to implementing the delegate methods. In your delegate's interface declaration, add ESSYouTubeDelegate.
There are two methods:

- (UIViewController *)ESSYouTubeNeedsCurrentViewControllerToAttachTo:(ESSYouTube *)youtube
{
    return self; //assuming self is the current view controller
}

and

- (void)ESSYouTubeDidFinish:(ESSYouTube *)youtube
{
    //this gets called whenever the user clicks on Cancel
    //it is also called when the user clicks on Done after the upload has finished.
    //usually, what you want to do here is just autorelease youtube if you don't keep a pointer to the youtube object yourself
    [youtube autorelease];
}

Once you've implemented the delegate methods, you can finally start an upload session:

NSURL *urlToVideoOnHardDisk = [NSURL fileURLWithPath:@"/path/to/the/video.mp4"];
[youTube uploadVideoAtURL:urlToVideoOnHardDisk];

That's it. The rest is done by the framework and the user.
In a similar fashion, we'll continue

ESSVimeo

Initialize the ESSVimeo object

id delegate = self;
NSString *vimeoAPIKey = @"yourVimeoAPIKey";
NSString *vimeoAPISecret = @"yourVimeoAPISecret";
ESSVimeo *vimeo = [[ESSVimeo alloc] initWithAPIKey:vimeoAPIKey
                                                secret:vimeoAPISecret
                                   canUploadToPlusOnly:NO
                                              delegate:delegate];

Something you will notice is the BOOL you have to pass into canUploadToPlusOnly:. If your API key can only upload for users who have Vimeo PLUS accounts, pass YES. If your API key can upload to free Vimeo accounts as well, pass NO.

Again, implement the necessary delegate methods. In your delegate's interface declaration, add ESSVimeoDelegate.
The methods are:

- (UIViewController *)ESSVimeoNeedsViewControllerToAttachTo:(ESSVimeo *)uploader
{
    return self; //assuming self is the current view controller
}  

and

- (void)ESSVimeoFinished:(ESSVimeo *)uploader
{
    //this gets called whenever the user clicks on Cancel
    //it is also called when the user clicks on Done after the upload has finished.
    //usually, what you want to do here is just autorelease youtube if you don't keep a pointer to the vimeo object yourself
    [uploader autorelease];
}

And to start the upload session:

NSURL *urlToVideoOnHardDisk = [NSURL fileURLWithPath:@"/path/to/the/video.mp4"];
[vimeo uploadVideoAtURL:urlToVideoOnHardDisk];

That's it. The rest is taken care of by the framework and the user.
Let's continue with

ESSFacebook

By now, I think you get the hang of it:

id delegate = self;
NSString *facebookAppID = @"yourFacebookAppID";
NSString *facebookAppSecret = @"yourFacebookAppSecret";
ESSFacebook *facebook = [[ESSFacebook alloc] initWithDelegate:delegate appID:facebookAppID appSecret:facebookAppSecret];

In your delegate's interface declaration, add ESSFacebookDelegate.
Implement the two delegate methods:

- (UIViewController *)ESSFacebookNeedsCurrentViewControllerToAttachTo:(ESSFacebook *)facebook
{
    return self; //assuming self is the current view controller
}

- (void)ESSFacebookDidFinish:(ESSFacebook *)fb
{
    //this gets called whenever the user clicks on Cancel
    //it is also called when the user clicks on Done after the upload has finished.
    //usually, what you want to do here is just autorelease youtube if you don't keep a pointer to the facebook object yourself
    [fb autorelease];
}

And to start the upload session:

NSURL *urlToVideoOnHardDisk = [NSURL fileURLWithPath:@"/path/to/the/video.mp4"];
[facebook uploadVideoAtURL:urlToVideoOnHardDisk];

As before, the rest is taken care of by the framework and the user.

On to the last part:

ESSFlickr

Initialize the object:

id delegate = self;
NSString *flickrAppKey = @"yourFlickrAppKey";
NSString *flickrAppSecret = @"yourFlickrAppSecret";
ESSFlickr *flickr = [[ESSFlickr alloc] initWithDelegate:self applicationKey:flickrAppKey applicationSecret:flickrAppSecret];

In your delegate's interface declaration, add ESSFlickrDelegate.
Implement the delegate methods:

- (UIViewController *)ESSFlickrNeedsViewController:(ESSFlickr *)flickr
{
    return self; //assuming self is the current view controller
}

and

- (void)ESSFlickrDidFinish:(ESSFlickr *)flickr
{
    //this gets called whenever the user clicks on Cancel
    //it is also called when the user clicks on Done after the upload has finished.
    //usually, what you want to do here is just autorelease youtube if you don't keep a pointer to the flickr object yourself
    [flickr autorelease];
}

And start the upload session like so:

NSURL *urlToVideoOnHardDisk = [NSURL fileURLWithPath:@"/path/to/the/video.mp4"];
[flickr uploadVideoAtURL:urlToVideoOnHardDisk];
Something went wrong with that request. Please try again.