Giter Site home page Giter Site logo

xcdyoutubekit's Introduction

About

Build Status Coverage Status Platform Pod Version Carthage Compatibility License

XCDYouTubeKit is a YouTube video player for iOS and OS X.

Are you enjoying XCDYouTubeKit? You can say thank you with a tweet. I am also accepting donations. ;-)

Donate button

Requirements

  • Runs on iOS 5.0 and later
  • Runs on OS X 10.7 and later

Warning

XCDYouTubeKit is against the YouTube Terms of Service. The only official way of playing a YouTube video inside an app is with a web view and the iframe player API. Unfortunately, this is very slow and quite ugly, so I wrote this player to give users a better viewing experience.

Installation

XCDYouTubeKit is available through CocoaPods and Carthage.

CocoaPods:

pod "XCDYouTubeKit", "~> 2.1.1"

Carthage:

github "0xced/XCDYouTubeKit" ~> 2.1.1

Alternatively, you can manually use the provided static library on iOS or dynamic framework on OS X. In order to use the iOS static library, you must:

  1. Create a workspace (File → New → Workspace…)
  2. Add your project to the workspace
  3. Add the XCDYouTubeKit project to the workspace
  4. Drag and drop the libXCDYouTubeKit.a file referenced from XCDYouTubeKit → Products → libXCDYouTubeKit.a into the Link Binary With Libraries build phase of your app’s target.

These steps will ensure that #import <XCDYouTubeKit/XCDYouTubeKit.h> will work properly in your project.

Warning: If you use the iOS static library and you are targeting iOS 7, add the JavaScriptCore framework. If you are targeting iOS 5 or 6, you must add the following Other Linker Flags instead to your app:

-Wl,-U,_JSContextGetGlobalObject -Wl,-U,_JSEvaluateScript -Wl,-U,_JSGlobalContextCreate -Wl,-U,_JSGlobalContextRelease -Wl,-U,_JSObjectCallAsFunction -Wl,-U,_JSObjectGetPrototype -Wl,-U,_JSObjectIsFunction -Wl,-U,_JSObjectSetProperty -Wl,-U,_JSStringCopyCFString -Wl,-U,_JSStringCreateWithCFString -Wl,-U,_JSStringRelease -Wl,-U,_JSValueIsObject -Wl,-U,_JSValueIsString -Wl,-U,_JSValueMakeString -Wl,-U,_JSValueToStringCopy

See my JavaScriptCore framework availability on iOS answer on Stack Overflow for a complete explanation.

Usage

XCDYouTubeKit is fully documented.

iOS and OS X

NSString *videoIdentifier = @"EdeVaT-zZt4"; // A 11 characters YouTube video identifier
[[XCDYouTubeClient defaultClient] getVideoWithIdentifier:videoIdentifier completionHandler:^(XCDYouTubeVideo *video, NSError *error) {
	if (video)
	{
		// Do something with the `video` object
	}
	else
	{
		// Handle error
	}
}];

iOS only

On iOS, you can use the class XCDYouTubeVideoPlayerViewController the same way you use a MPMoviePlayerViewController, except you initialize it with a YouTube video identifier instead of a content URL.

Present the video in full-screen

XCDYouTubeVideoPlayerViewController *videoPlayerViewController = [[XCDYouTubeVideoPlayerViewController alloc] initWithVideoIdentifier:@"9bZkp7q19f0"];
[self presentMoviePlayerViewControllerAnimated:videoPlayerViewController];

Present the video in a non full-screen view

XCDYouTubeVideoPlayerViewController *videoPlayerViewController = [[XCDYouTubeVideoPlayerViewController alloc] initWithVideoIdentifier:@"9bZkp7q19f0"];
[videoPlayerViewController presentInView:self.videoContainerView];
[videoPlayerViewController.moviePlayer play];

See the demo project for more sample code.

Credits

The URL extraction algorithms in XCDYouTubeKit are inspired by the YouTube extractor module of the youtube-dl project.

Contact

Cédric Luthi

License

XCDYouTubeKit is available under the MIT license. See the LICENSE file for more information.

xcdyoutubekit's People

Contributors

0xced avatar javisoto avatar orkenstein avatar waynehartman avatar

Stargazers

 avatar  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.