Skip to content

codemancode/YTVimeoExtractor

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

YTVimeoExtractor

YTVimeoExtractor helps you get mp4 urls which can be use in iOS's native player. You can even choose between mobile, standard and high definition quality.

YTVimeoExtractor doesn't use UIWebView which makes it fast and clean.

Install

The preferred way of installation is via CocoaPods. Just add to your Podfile

pod 'YTVimeoExtractor'

and run pod install.

Alternatively you can just copy the YTVimeoExtractor folder to your project.

#import "YTVimeoExtractor.h"

Usage

Use the block based methods and pass it the video url and the desired quality

[YTVimeoExtractor fetchVideoURLFromURL:@"http://vimeo.com/58600663"
                               quality:YTVimeoVideoQualityMedium
                     completionHandler:^(NSURL *videoURL, NSError *error, YTVimeoVideoQuality quality) {
    if (error) {
    	// handle error
    	NSLog(@"Video URL: %@", [videoURL absoluteString]);
	} else {
		// run player
		self.playerViewController = [[MPMoviePlayerViewController alloc] initWithContentURL:videoURL];
    	[self.playerViewController.moviePlayer prepareToPlay];
    	[self presentViewController:self.playerViewController animated:YES completion:nil];
	}
}];

or create an instance of YTVimeoExtractor.

self.extractor = [[YTVimeoExtractor alloc] initWithURL:@"http://vimeo.com/58600663" quality:YTVimeoVideoQualityMedium];
self.extractor.delegate = self;
[self.extractor start];

and implement YTVimeoExtractor delegate methods in your ViewController.

- (void)vimeoExtractor:(YTVimeoExtractor *)extractor didSuccessfullyExtractVimeoURL:(NSURL *)videoURL withQuality:(YTVimeoVideoQuality)quality
{
    // handle success
}

- (void)vimeoExtractor:(YTVimeoExtractor *)extractor failedExtractingVimeoURLWithError:(NSError *)error;
{
    // handle error
}

If the Vimeo videos have domain-level restrictions and can only be played from particular domains, it's easy to add a referer:

[YTVimeoExtractor fetchVideoURLFromURL:@"http://vimeo.com/58600663"
                               quality:YTVimeoVideoQualityMedium
                               referer:@"http://www.mywebsite.com"
                     completionHandler:^(NSURL *videoURL, NSError *error, YTVimeoVideoQuality quality) {
    if (error) {
        // handle error
        NSLog(@"Video URL: %@", [videoURL absoluteString]);
    } else {
        // run player
        self.playerViewController = [[MPMoviePlayerViewController alloc] initWithContentURL:videoURL];
        [self.playerViewController.moviePlayer prepareToPlay];
        [self presentViewController:self.playerViewController animated:YES completion:nil];
    }
}];

Check the sample application for more details.

Requirements

YTVimeoExtractor requires iOS 5.0 and above as it is deployed for an ARC environment.

License

YTVimeoExtractor is licensed under the MIT License. See the LICENSE file for details.

About

Fetches Vimeo's mp4 URLs for iOS

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Objective-C 95.4%
  • Ruby 4.6%