-
Notifications
You must be signed in to change notification settings - Fork 627
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
187 changed files
with
12,576 additions
and
1,101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
@@ -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. |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Oops, something went wrong.