Description
XCDYouTubeKit is a popular open-source Objective-C library that allows you to easily integrate YouTube video playback and downloading capabilities into your iOS applications. It provides a simple and intuitive API for interacting with YouTube videos, handling video playback, and extracting video metadata.
Installation
To add XCDYouTubeKit to your project, follow these steps:
- Open your project in Xcode.
- Go to the File menu and select Swift Packages and then Add Package Dependency.
- Enter the following repository URL:
https://github.com/0xced/XCDYouTubeKit.git
- Select the appropriate version or branch you want to use and click Next.
- Choose the target where you want to add XCDYouTubeKit and click Finish.
Usage
To use XCDYouTubeKit in your application, follow these steps:
- Import the XCDYouTubeKit module:
- Create an instance of
XCDYouTubeVideoPlayerViewController
: - Present or push the view controller to display the video player:
- To extract video metadata, use the
XCDYouTubeClient
class:
// Swift
import XCDYouTubeKit
// Objective-C
@import XCDYouTubeKit;
// Swift
let videoPlayerViewController = XCDYouTubeVideoPlayerViewController(videoIdentifier: "VIDEO_ID")
// Objective-C
XCDYouTubeVideoPlayerViewController *videoPlayerViewController = [[XCDYouTubeVideoPlayerViewController alloc] initWithVideoIdentifier:@"VIDEO_ID"];
// Swift
present(videoPlayerViewController, animated: true, completion: nil)
// Objective-C
[self presentViewController:videoPlayerViewController animated:YES completion:nil];
// Swift
XCDYouTubeClient.default().getVideoWithIdentifier("VIDEO_ID") { (video, error) in
if let video = video {
// Use video object here
} else if let error = error {
// Handle error here
}
}
// Objective-C
[[XCDYouTubeClient defaultClient] getVideoWithIdentifier:@"VIDEO_ID" completionHandler:^(XCDYouTubeVideo * _Nullable video, NSError * _Nullable error) {
if (video) {
// Use video object here
} else if (error) {
// Handle error here
}
}];
Additional Features
The XCDYouTubeKit library also provides additional features and functionality, including:
- Downloading YouTube videos
- Handling YouTube playlists
- Accessing closed captions and subtitles
- Customizing the video player interface
- And much more! Refer to the official XCDYouTubeKit GitHub repository for detailed documentation and examples.
Requirements
XCDYouTubeKit has the following requirements:
- iOS 10.0 or later
- Xcode 10.2 or later
- Swift 4.2 or later
- Objective-C
Conclusion
XCDYouTubeKit is a powerful and user-friendly library for integrating YouTube video playback and downloading capabilities into your iOS applications. With its easy-to-use API and extensive features, you can provide a seamless and immersive video experience for your users.
We hope this documentation helps you get started with XCDYouTubeKit. For more information, refer to the official XCDYouTubeKit GitHub repository and the provided examples. Happy coding!