Skip to content

Commit

Permalink
Merge branch 'release/2.0.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
0xced committed Jun 4, 2014
2 parents 5dded8e + b4687be commit c7fb185
Show file tree
Hide file tree
Showing 187 changed files with 12,576 additions and 1,101 deletions.
8 changes: 8 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
language: objective-c
install: gem install xcpretty --no-rdoc --no-ri --no-document --quiet
script:
- export LC_CTYPE=en_US.UTF-8
- set -o pipefail
- xcodebuild test -project XCDYouTubeKit.xcodeproj -scheme 'XCDYouTubeKit iOS' -destination 'platform=iOS Simulator,name=iPhone Retina (4-inch)' | xcpretty -c
- xcodebuild test -project XCDYouTubeKit.xcodeproj -scheme 'XCDYouTubeKit iOS' -destination 'platform=iOS Simulator,name=iPhone Retina (4-inch 64-bit)' | xcpretty -c
- xcodebuild test -project XCDYouTubeKit.xcodeproj -scheme 'XCDYouTubeKit OS X' | xcpretty -c
17 changes: 16 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
#### Version 2.0.0

* Project renamed to `XCDYouTubeKit`.
* Support for protected video. (#6, #11, #12, #21, #27, #31, #33)
* OS X compatibility thanks to the new `XCDYouTubeClient` class. (#14, #18)
* OS X dynamic framework target
* Support for live videos. (#34)
* Unit tested.
* [Fully documented](http://cocoadocs.org/docsets/XCDYouTubeKit/).
* Support for iOS 8 beta.
* Improved demo projects.
* New OS X demo project.
* New settings screen on iOS for background playback and audio session category.
* Demonstrates how to use the notifications to fill the *Now Playing Info Center*.

#### Version 1.1.2

* Adaptation to YouTube API change. (#19)
Expand All @@ -18,6 +33,6 @@
* Error reporting is more accurate, especially for VEVO videos. (#6)
* `prepareToPlay` is not automatically called, it’s the programmer responsibility to call it if appropriate.

#### Version 1.0
#### Version 1.0.0

* Initial version
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2013 Cédric Luthi
Copyright (c) 2013-2014 Cédric Luthi

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
65 changes: 54 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,74 @@
## About

**XCDYouTubeVideoPlayerViewController** is a YouTube video player for iPhone and iPad.
[![build status](https://travis-ci.org/0xced/XCDYouTubeVideoPlayerViewController.svg)](https://travis-ci.org/0xced/XCDYouTubeVideoPlayerViewController)

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

<img src="Screenshots/XCDYouTubeVideoPlayerViewController.png" width="480" height="320">

To the best of my knowledge, the only *official* way of playing a YouTube video on iOS is with a UIWebView and the [iframe player API](https://developers.google.com/youtube/iframe_api_reference). Unfortunately, this is very slow and quite ugly, so I wrote XCDYouTubeVideoPlayerViewController which gives the user a better viewing experience.
To the best of my knowledge, the only *official* way of playing a YouTube video on iOS is with a UIWebView and the [iframe player API](https://developers.google.com/youtube/iframe_api_reference). Unfortunately, this is very slow and quite ugly, so I wrote this player to give users a better viewing experience.

XCDYouTubeVideoPlayerViewController uses progressive download, so remember that some restrictions apply if you submit your app to the App Store, as stated in
Except for live videos, the player uses progressive download. Remember that some restrictions apply if you submit your app to the App Store, as stated in
[HTTP Live Streaming — Requirements for Apps](https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/StreamingMediaGuide/UsingHTTPLiveStreaming/UsingHTTPLiveStreaming.html#//apple_ref/doc/uid/TP40008332-CH102-SW5):
> **Warning**: iOS apps submitted for distribution in the App Store must conform to these requirements.
>
> If your app delivers video over cellular networks, and the video exceeds either 10 minutes duration or 5 MB of data in a five minute period, you are required to use HTTP Live Streaming. (Progressive download may be used for smaller clips.)
Are you enjoying XCDYouTubeKit? You can say thank you with [a tweet](https://twitter.com/intent/tweet?text=%400xced%20Thank%20you%20for%20XCDYouTubeKit%2E). I am also accepting donations. ;-)

<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="MGEPRSNQFMV3W">
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="PayPal donate button">
</form>

## Requirements

- Runs on iOS 5.0 and later
- Must be compiled with ARC
- Runs on OS X 10.7 and later

## Installation

XCDYouTubeVideoPlayerViewController is available through CocoaPods.
XCDYouTubeKit is available through CocoaPods.

Alternatively, you can manually use the provided static library on iOS or dynamic framework on OS X.

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:

Alternatively, you can install it manually:
```
-Wl,-U,_JSEvaluateScript -Wl,-U,_JSGlobalContextCreate -Wl,-U,_JSGlobalContextRelease -Wl,-U,_JSObjectCallAsFunction -Wl,-U,_JSObjectIsFunction -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](http://stackoverflow.com/questions/23514579/javascriptcore-framework-availability-on-ios/23514580#23514580) answer on Stack Overflow for a complete explanation.

1. Copy the `XCDYouTubeVideoPlayerViewController.h` and `XCDYouTubeVideoPlayerViewController.m` files in your project.
2. Add `MediaPlayer.framework` and `AVFoundation.framework` in your project.

## Usage

Use `XCDYouTubeVideoPlayerViewController` the same way you use a `MPMoviePlayerViewController`, except you initialize it with a YouTube video identifier instead of a content URL.
XCDYouTubeKit is [fully documented](http://cocoadocs.org/docsets/XCDYouTubeKit/).

```
#import <XCDYouTubeKit/XCDYouTubeKit.h>`
```

### iOS and OS X

```objc
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
Expand All @@ -47,14 +87,17 @@ XCDYouTubeVideoPlayerViewController *videoPlayerViewController = [[XCDYouTubeVid
See the demo project for more sample code.
## Credits
The URL exctraction algorithms in *XCDYouTubeKit* are inspired by the [YouTube extractor](https://github.com/rg3/youtube-dl/blob/master/youtube_dl/extractor/youtube.py) module of the *youtube-dl* project.
## Contact
Cédric Luthi
- http://github.com/0xced
- http://twitter.com/0xced
- [email protected]
## License
XCDYouTubeVideoPlayerViewController is available under the MIT license. See the LICENSE file for more information.
XCDYouTubeKit is available under the MIT license. See the [LICENSE](LICENSE) file for more information.
10 changes: 10 additions & 0 deletions XCDYouTubeKit Demo.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions XCDYouTubeKit Demo/OS X Demo/AppDelegate.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//
// Copyright (c) 2014 Cédric Luthi. All rights reserved.
//

@interface AppDelegate : NSObject <NSApplicationDelegate>

@property (assign) IBOutlet NSWindow *window;
@property (assign) IBOutlet AVPlayerView *playerView;
@property (assign) IBOutlet NSProgressIndicator *progressIndicator;

@end
37 changes: 37 additions & 0 deletions XCDYouTubeKit Demo/OS X Demo/AppDelegate.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//
// Copyright (c) 2014 Cédric Luthi. All rights reserved.
//

#import "AppDelegate.h"

@implementation AppDelegate

- (void) applicationDidFinishLaunching:(NSNotification *)aNotification
{
[[NSUserDefaults standardUserDefaults] registerDefaults:@{ @"VideoIdentifier": @"EdeVaT-zZt4" }];
}

- (IBAction) playVideo:(id)sender
{
self.playerView.player = nil;

[self.progressIndicator startAnimation:sender];
[[XCDYouTubeClient defaultClient] getVideoWithIdentifier:[sender stringValue] completionHandler:^(XCDYouTubeVideo *video, NSError *error) {
[self.progressIndicator stopAnimation:sender];

if (video)
{
NSDictionary *streamURLs = video.streamURLs;
NSURL *url = streamURLs[XCDYouTubeVideoQualityHTTPLiveStreaming] ?: streamURLs[@(XCDYouTubeVideoQualityHD720)] ?: streamURLs[@(XCDYouTubeVideoQualityMedium360)] ?: streamURLs[@(XCDYouTubeVideoQualitySmall240)];
AVPlayer *player = [AVPlayer playerWithURL:url];
self.playerView.player = player;
[player play];
}
else
{
[[NSAlert alertWithError:error] runModal];
}
}];
}

@end
Loading

0 comments on commit c7fb185

Please sign in to comment.