{"id":1578,"url":"https://github.com/rinov/YoutubeKit","last_synced_at":"2025-08-02T04:31:47.209Z","repository":{"id":28003741,"uuid":"104654623","full_name":"rinov/YoutubeKit","owner":"rinov","description":"YoutubeKit is a video player that fully supports Youtube IFrame API and YoutubeDataAPI for easily create a Youtube app","archived":false,"fork":false,"pushed_at":"2024-04-13T10:44:38.000Z","size":28225,"stargazers_count":595,"open_issues_count":9,"forks_count":116,"subscribers_count":18,"default_branch":"master","last_synced_at":"2024-04-24T19:02:36.196Z","etag":null,"topics":["api-wrapper","carthage","cocoapods","iframe-api","swift","swift-package-manager","video-player","youtube"],"latest_commit_sha":null,"homepage":"","language":"Swift","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/rinov.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"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,"publiccode":null,"codemeta":null}},"created_at":"2017-09-24T15:26:14.000Z","updated_at":"2024-06-18T20:02:59.459Z","dependencies_parsed_at":"2024-01-07T22:23:25.995Z","dependency_job_id":"1bfb8ef4-e89f-4b5d-afe6-8e6b04c1d7ae","html_url":"https://github.com/rinov/YoutubeKit","commit_stats":{"total_commits":86,"total_committers":14,"mean_commits":6.142857142857143,"dds":"0.32558139534883723","last_synced_commit":"13f427961aca6c883ce717c8c3e87cd05b7658e8"},"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rinov%2FYoutubeKit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rinov%2FYoutubeKit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rinov%2FYoutubeKit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rinov%2FYoutubeKit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rinov","download_url":"https://codeload.github.com/rinov/YoutubeKit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228438969,"owners_count":17920017,"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":["api-wrapper","carthage","cocoapods","iframe-api","swift","swift-package-manager","video-player","youtube"],"created_at":"2024-01-05T20:15:50.313Z","updated_at":"2025-08-02T04:31:47.170Z","avatar_url":"https://github.com/rinov.png","language":"Swift","readme":"# YoutubeKit\n\n`YoutubeKit` is a video player that fully supports `Youtube IFrame API` and `YoutubeDataAPI` to easily create Youtube applications.\n\n[![Swift](https://img.shields.io/badge/Swift-4-blue.svg)](https://img.shields.io/badge/Swift-4-blue.svg)\n[![Cocoapods](https://img.shields.io/badge/Cocoapods-compatible-brightgreen.svg)](https://img.shields.io/badge/Cocoapods-compatible-brightgreen.svg)\n[![Carthage](https://img.shields.io/badge/Carthage-compatible-brightgreen.svg)]((https://img.shields.io/badge/Carthage-compatible-brightgreen.svg))\n[![License](https://img.shields.io/badge/LICENSE-MIT-yellowgreen.svg)](https://img.shields.io/badge/LICENSE-MIT-yellowgreen.svg)\n\n## Important Referecens\n`YoutubeKit` is created based on the following references. If you are unsure whether it is a normal behavior or a bug, please check the following documents first.\n\n- [YoutubeDataAPI (V3)](https://developers.google.com/youtube/v3/docs/)\n\n- [Youtube IFrame Player API](https://developers.google.com/youtube/iframe_api_reference)\n\n## Example\n\nThis is an app using `YoutubeKit`. A simple video playback example is included into `Example`.\nYou can create these functions very easily by using `YoutubeKit`.\n\n|Example1|Example2|\n|:-:|:-:|\n|![Feed](https://github.com/rinov/Storage/blob/master/YoutubeKit/feed.gif)|![Comment](https://github.com/rinov/Storage/blob/master/YoutubeKit/comment.gif)|\n|Example3|Example4|\n|![Floating](https://github.com/rinov/Storage/blob/master/YoutubeKit/floating.gif)|![Rotate](https://github.com/rinov/Storage/blob/master/YoutubeKit/rotate.gif)|\n\n## What is YoutubeKit?\n`YoutubeKit` provides useful functions to create Youtube applications. It consists of the following two functions.\n\n- `YTSwiftyPlayer (WKWebView + HTML5 + IFrame API)`\n\n- `YoutubeDataAPI`\n\n## YTSwiftyPlayer\n`YTSwiftyPlayer` is a video player that supports Youtube IFrame API.\n\nFeatures:\n- High performance (Performance is 30% better than traditional UIWebView based player)\n- Low memory impact (maximum 70% off)\n- Type safe parameter interface(All IFrame API's parameters are supported as `VideoEmbedParameter`)\n\n## YoutubeDataAPI\nThis library supports `YoutubeDataAPI (v3)`. For the details is [Here](https://developers.google.com/youtube/v3/docs/).\n\nAvailable API lists:\n- Actitivty(list)\n- Actitivty(insert)\n- Caption(list)\n- Channel(list)\n- ChannelSections(list)\n- Comment(list)\n- CommentThreads(list)\n- GuideCategories(list)\n- PlaylistItems(list)\n- Playlists(list)\n- Search(list)\n- Subscriptions(list)\n- VideoAbuseReportReasons(list)\n- VideoCategories(list)\n- Videos(list)\n\n# Get Started\n\nPlayback the youtube video.\n\n```swift\nimport YoutubeKit\n\nfinal class VideoPlayerController: UIViewController {\n\n    private var player: YTSwiftyPlayer!\n\n    override func viewDidLoad() {\n        super.viewDidLoad()\n\n        // Create a new player\n        player = YTSwiftyPlayer(\n            frame: .zero,\n            playerVars: [\n                .playsInline(false),\n                .videoID(\"_6u6UrtXUEI\"),\n                .loopVideo(true),\n                .showRelatedVideo(false),\n                .autoplay(true)\n            ])\n\n        view = player\n        player.delegate = self\n\n        // Load video player\n        let playerPath = Bundle(for: ViewController.self).path(forResource: \"player\", ofType: \"html\")!\n        let htmlString = try! String(contentsOfFile: playerPath, encoding: .utf8)\n        player.loadPlayerHTML(htmlString)\n    }\n}\n\n```\n\n### YTSwiftyPlayerDelegate\n`YTSwiftyPlayerDelegate`  supports folowing delegate methods.\n\n```swift\nfunc playerReady(_ player: YTSwiftyPlayer)\nfunc player(_ player: YTSwiftyPlayer, didUpdateCurrentTime currentTime: Double)\nfunc player(_ player: YTSwiftyPlayer, didChangeState state: YTSwiftyPlayerState)\nfunc player(_ player: YTSwiftyPlayer, didChangePlaybackRate playbackRate: Double)\nfunc player(_ player: YTSwiftyPlayer, didReceiveError error: YTSwiftyPlayerError)\nfunc player(_ player: YTSwiftyPlayer, didChangeQuality quality: YTSwiftyVideoQuality)\nfunc apiDidChange(_ player: YTSwiftyPlayer)\nfunc youtubeIframeAPIReady(_ player: YTSwiftyPlayer)\nfunc youtubeIframeAPIFailedToLoad(_ player: YTSwiftyPlayer)\n```\n\n### Call IFrame API during playback.\n```swift\n// Pause the video.\nplayer.pauseVideo()\n\n// Seek after 15 seconds.\nplayer.seek(to: 15, allowSeekAhead: true)\n\n// Set a mute.\nplayer.mute()\n\n// Load another video.\nplayer.loadVideo(videoID: \"abcde\")\n```\n\n### Get video information using YoutubeDataAPI\nFirst, Get API key from [Here](https://console.developers.google.com/apis).\n\nNext, add this code in your AppDelegate.\n\n```swift\nfunc application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -\u003e Bool {\n\n    // Set your API key here\n    YoutubeKit.shared.setAPIKey(\"Your API key\")\n\n    return true\n}\n\n```\n\nAnd then you can use `YoutubeDataAPI` request like this.\n\n```swift\n// Get youtube chart ranking\nlet request = VideoListRequest(part: [.id, .statistics], filter: .chart)\n\n// Send a request.\nYoutubeAPI.shared.send(request) { result in\n    switch result {\n    case .success(let response):\n        print(response)\n    case .failed(let error):\n        print(error)\n    }\n}\n\n```\n\nExample of response here.\n\n```ruby\nVideoList(items: [YoutubeKit.Video(etag: \"\\\"A8kisgyDEbllhHF9ooXPFFrkc/nR6_A9oyIoLTJuucY_UXeasjYNU\\\"\",\nkind: \"youtube#video\",\nid: \"jeiDjeJgF0\",\ncontentDetails: nil,\nstatistics: Optional(YoutubeKit.Statistics.VideoList(dislikeCount: \"1631\", likeCount: \"60307\", commentCount: Optional(\"8675\"), favoriteCount: \"0\", viewCount: \"1259046\")),\nsnippet: nil,\nstatus: nil),\netag: \"\\\"J67fSnfblalhHF0foXPiFFrkc/TZGPJdE22-LilSv4-3VNoPw1cS4\\\"\",\nkind: \"youtube#videoListResponse\",\npageInfo: YoutubeKit.PageInfo(resultsPerPage: 5, totalResults: 200))\n```\n\n### Fetch the next page (Pagination)\n```swift\nvar nextPageToken: String?\n...\n\n// Send some request\nYoutubeAPI.shared.send(request) { [weak self] result in\n    switch result {\n    case .success(let response):\n\n        // Save nextPageToken\n        self?.nextPage = response.nextPageToken\n    case .failed(let error):\n        print(error)\n    }\n}\n...\n\n// Set nextPageToken\nlet request = VideoListRequest(part: [.id], filter: .chart, nextPageToken: nextPageToken)\n```\n\n### Authorization Request\nIf you want authorized request such as a getting your activity in Youtube, you set your access token before sending a request.\nTo use `GoogleSignIn`, you can easily get your access token.\n`pod 'GoogleSignIn'`\n\nFirst, add this code in your AppDelegate.\n\n```swift\nfunc application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -\u003e Bool {\n\n    // Set your access token for autheticate request\n    YoutubeKit.shared.setAccessToken(\"Your access token\")\n\n    return true\n}\n```\n\nAnd then you can use request requiring authorization, this is an example to get your Youtube activity.\n\n```swift\n// Get your Youtube activity\nlet request = ActivityListRequest(part: [.snippet], filter: .mine(true))\n\n// Send a request.\nYoutubeAPI.shared.send(request) { result in\n    switch result {\n    case .success(let video):\n        print(video)\n    case .failed(let error):\n        print(error)\n    }\n}\n```\n\n## Requirements\nXcode 16+\n\nSwift 6+\n\n## Installation\n\n### Swift Package Manager\nAdd the following to your Package.swift file:\n\n```swift\ndependencies: [\n    .package(url: \"https://github.com/rinov/YoutubeKit.git\", from: \"0.10.0\")\n]\n```\n\n### Cocoapods (Deprecated)\n\nSeelAlso: https://blog.cocoapods.org/CocoaPods-Specs-Repo/\n\n```\n$ pod repo update\n```\n\nAnd add this to your Podfile:\n\n\n```ruby\npod 'YoutubeKit'\n```\n\nand\n\n`$ pod install`\n\n### Carthage\nAdd this to your Cartfile:\n\n`github \"rinov/YoutubeKit\"`\n\nand\n\n`$ carthage update`\n\n\n## Author\n\nGithub: [https://github.com/rinov](https://github.com/rinov)\n\nTwitter: [https://twitter.com/rinov0321](https://twitter.com/rinov0321)\n\nEmail: rinov[at]rinov.jp\n\n## License\n\nYoutubeKit is available under the MIT license.\n","funding_links":[],"categories":["Media","HarmonyOS"],"sub_categories":["Video","Other free courses","Windows Manager"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frinov%2FYoutubeKit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frinov%2FYoutubeKit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frinov%2FYoutubeKit/lists"}