Skip to content

How To for OS X Lion

eternalstorms edited this page Jul 18, 2012 · 4 revisions

Sample Project

OS X Lion Sample Project, ~250KB (Please be aware that the sample project might not have the newest ESSVideoShare framework imported.)

How To Use ESSVideoShare.framework

  1. In your project

    #import <ESSVideoShare/ESSVideoShare.h>

  2. Make sure you copy the ESSVideoShare framework to your app bundle's framework folder in a build copy phase

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:

- (NSWindow *)ESSYouTubeNeedsWindowToAttachTo:(ESSYouTube *)youtube
{
    //ESSYouTube will show a window as a sheet, attached to the window you return here.
    //Not returning a window might result in unexpected behavior.
    return self.window;
}

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:

- (NSWindow *)ESSVimeoNeedsWindowToAttachWindowTo:(ESSVimeo *)uploader
{
	//ESSVimeo will show a window as a sheet, attached to the window you return here.
    //Not returning a window might result in unexpected behavior.
	return self.window;
}  

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:

- (NSWindow *)ESSFacebookNeedsWindowToAttachTo:(ESSFacebook *)facebook
{
	//ESSFacebook will show a window as a sheet, attached to the window you return here.
    //Not returning a window might result in unexpected behavior.
	return self.window;
}

- (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:

- (NSWindow *)ESSFlickrNeedsWindowToAttachTo:(ESSFlickr *)flickr
{
	//ESSFacebook will show a window as a sheet, attached to the window you return here.
    //Not returning a window might result in unexpected behavior.
	return self.window;
}

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];