Giter VIP home page Giter VIP logo

ytvimeoextractor's Introduction

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.

ytvimeoextractor's People

Contributors

cstigler avatar kmonaghan avatar lilfaf avatar modnovolyk avatar runmad avatar sbl avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.