{"id":788,"url":"https://github.com/0xced/XCDYouTubeKit","last_synced_at":"2025-08-02T05:33:10.157Z","repository":{"id":46605077,"uuid":"10132053","full_name":"0xced/XCDYouTubeKit","owner":"0xced","description":"YouTube video player for iOS, tvOS and macOS","archived":false,"fork":false,"pushed_at":"2024-04-08T15:21:05.000Z","size":105096,"stargazers_count":2925,"open_issues_count":51,"forks_count":626,"subscribers_count":127,"default_branch":"master","last_synced_at":"2024-11-30T13:38:04.589Z","etag":null,"topics":["player","video","youtube"],"latest_commit_sha":null,"homepage":"","language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/0xced.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2013-05-17T20:59:57.000Z","updated_at":"2024-11-28T06:56:12.000Z","dependencies_parsed_at":"2024-04-23T19:18:19.372Z","dependency_job_id":null,"html_url":"https://github.com/0xced/XCDYouTubeKit","commit_stats":{"total_commits":1303,"total_committers":19,"mean_commits":68.57894736842105,"dds":0.3369148119723715,"last_synced_commit":"23f765941b36d6d28215ab81a37af1039d29138b"},"previous_names":["0xced/xcdyoutubevideoplayerviewcontroller"],"tags_count":54,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xced%2FXCDYouTubeKit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xced%2FXCDYouTubeKit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xced%2FXCDYouTubeKit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xced%2FXCDYouTubeKit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/0xced","download_url":"https://codeload.github.com/0xced/XCDYouTubeKit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227703188,"owners_count":17806918,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["player","video","youtube"],"created_at":"2024-01-05T20:15:31.334Z","updated_at":"2024-12-06T09:30:30.130Z","avatar_url":"https://github.com/0xced.png","language":"Objective-C","funding_links":["https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=MGEPRSNQFMV3W"],"categories":["Video","Objective-C","Apple TV","Objective-C  Stars 1000以内排名整理"],"sub_categories":["Other free courses","Getting Started"],"readme":"## About\n\n[![Build Status](https://img.shields.io/circleci/project/0xced/XCDYouTubeKit/develop.svg?style=flat)](https://circleci.com/gh/0xced/XCDYouTubeKit)\n[![Coverage Status](https://img.shields.io/codecov/c/github/0xced/XCDYouTubeKit/develop.svg?style=flat)](https://codecov.io/gh/0xced/XCDYouTubeKit/branch/develop)\n[![Platform](https://img.shields.io/cocoapods/p/XCDYouTubeKit.svg?style=flat)](http://cocoadocs.org/docsets/XCDYouTubeKit/)\n[![Pod Version](https://img.shields.io/cocoapods/v/XCDYouTubeKit.svg?style=flat)](https://cocoapods.org/pods/XCDYouTubeKit)\n[![Carthage Compatibility](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage/)\n[![Swift Package Manager Compatibility](https://img.shields.io/badge/Swift%20Package%20Manager-compatible-brightgreen)](ttps://swift.org/package-manager/)\n[![License](https://img.shields.io/cocoapods/l/XCDYouTubeKit.svg?style=flat)](LICENSE)\n\n**XCDYouTubeKit** is a YouTube video player for iOS, tvOS and macOS.\n\n\u003cimg src=\"Screenshots/XCDYouTubeVideoPlayerViewController.png\" width=\"480\" height=\"320\"\u003e\n\nAre 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. ;-)\n\n[![Donate button](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=MGEPRSNQFMV3W)\n\n## Requirements\n\n- Runs on iOS 8.0 and later\n- Runs on macOS 10.9 and later\n- Runs on tvOS 9.0 and later\n\n## Warning\n\nXCDYouTubeKit is against the YouTube [Terms of Service](https://www.youtube.com/t/terms). The only *official* way of playing a YouTube video inside an app is with a web view 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.\n\n## Installation\n\nXCDYouTubeKit is available through [CocoaPods](https://cocoapods.org/), [Carthage](https://github.com/Carthage/Carthage) and [Swift Package Manager](https://swift.org/package-manager/).\n\nCocoaPods:\n\n```ruby\npod \"XCDYouTubeKit\", \"~\u003e 2.15\"\n```\n\nCarthage:\n\n```objc\ngithub \"0xced/XCDYouTubeKit\" ~\u003e 2.15\n```\n\nSwift Package Manager:\n\nAdd `XCDYouTubeKit` to the dependencies value of your `Package.swift`\n\n```swift\ndependencies: [\n\t.package(url: \"https://github.com/0xced/XCDYouTubeKit.git\", from: \"2.15.0\")\n]\n```\n\nAlternatively, you can manually use the provided static library or dynamic framework. In order to use the static library, you must:\n\n1. Create a workspace (File → New → Workspace…)\n2. Add your project to the workspace\n3. Add the XCDYouTubeKit project to the workspace\n4. 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.\n\nThese steps will ensure that `#import \u003cXCDYouTubeKit/XCDYouTubeKit.h\u003e` will work properly in your project.\n\n## Usage\n\nXCDYouTubeKit is [fully documented](http://cocoadocs.org/docsets/XCDYouTubeKit/).\n\n### iOS 8.0+ \u0026 tvOS (AVPlayerViewController)\n\n```objc \nAVPlayerViewController *playerViewController = [AVPlayerViewController new];\n[self presentViewController:playerViewController animated:YES completion:nil];\n\n__weak AVPlayerViewController *weakPlayerViewController = playerViewController;\n[[XCDYouTubeClient defaultClient] getVideoWithIdentifier:videoIdentifier completionHandler:^(XCDYouTubeVideo * _Nullable video, NSError * _Nullable error) {\n    if (video)\n    {\n        NSDictionary *streamURLs = video.streamURLs;\n        NSURL *streamURL = streamURLs[XCDYouTubeVideoQualityHTTPLiveStreaming] ?: streamURLs[@(XCDYouTubeVideoQualityHD720)] ?: streamURLs[@(XCDYouTubeVideoQualityMedium360)] ?: streamURLs[@(XCDYouTubeVideoQualitySmall240)];\n        weakPlayerViewController.player = [AVPlayer playerWithURL:streamURL];\n        [weakPlayerViewController.player play];\n    }\n    else\n    {\n        [self dismissViewControllerAnimated:YES completion:nil];\n    }\n}];\n```\n\n### iOS, tvOS and macOS\n\n```objc\nNSString *videoIdentifier = @\"9bZkp7q19f0\"; // A 11 characters YouTube video identifier\n[[XCDYouTubeClient defaultClient] getVideoWithIdentifier:videoIdentifier completionHandler:^(XCDYouTubeVideo *video, NSError *error) {\n\tif (video)\n\t{\n\t\t// Do something with the `video` object\n\t}\n\telse\n\t{\n\t\t// Handle error\n\t}\n}];\n```\n\n### iOS 8.0\n\nOn 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.\n\n#### Present the video in full-screen\n\n```objc\n- (void) playVideo\n{\n\tXCDYouTubeVideoPlayerViewController *videoPlayerViewController = [[XCDYouTubeVideoPlayerViewController alloc] initWithVideoIdentifier:@\"9bZkp7q19f0\"];\n\t[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayerPlaybackDidFinish:) name:MPMoviePlayerPlaybackDidFinishNotification object:videoPlayerViewController.moviePlayer];\n\t[self presentMoviePlayerViewControllerAnimated:videoPlayerViewController];\n}\n\n- (void) moviePlayerPlaybackDidFinish:(NSNotification *)notification\n{\n\t[[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification object:notification.object];\n\tMPMovieFinishReason finishReason = [notification.userInfo[MPMoviePlayerPlaybackDidFinishReasonUserInfoKey] integerValue];\n\tif (finishReason == MPMovieFinishReasonPlaybackError)\n\t{\n\t\tNSError *error = notification.userInfo[XCDMoviePlayerPlaybackDidFinishErrorUserInfoKey];\n\t\t// Handle error\n\t}\n}\n\n```\n\n#### Present the video in a non full-screen view\n\n```objc\nXCDYouTubeVideoPlayerViewController *videoPlayerViewController = [[XCDYouTubeVideoPlayerViewController alloc] initWithVideoIdentifier:@\"9bZkp7q19f0\"];\n[videoPlayerViewController presentInView:self.videoContainerView];\n[videoPlayerViewController.moviePlayer play];\n```\n\nSee the demo project for more sample code.\n\n## Logging\n\nSince version 2.2.0, XCDYouTubeKit produces logs. XCDYouTubeKit supports [CocoaLumberjack](https://github.com/CocoaLumberjack/CocoaLumberjack) but does not require it.\n\nSee the `XCDYouTubeLogger` class [documentation](http://cocoadocs.org/docsets/XCDYouTubeKit/) for more information.\n\n## Credits\n\nThe URL extraction 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.\n\n## Contact\n\nCédric Luthi\n\n- http://github.com/0xced\n- http://twitter.com/0xced\n\n## License\n\nXCDYouTubeKit is available under the MIT license. See the [LICENSE](LICENSE) file for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F0xced%2FXCDYouTubeKit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F0xced%2FXCDYouTubeKit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F0xced%2FXCDYouTubeKit/lists"}