{"id":44947442,"url":"https://github.com/globulus/swiftui-youtube-player","last_synced_at":"2026-02-18T10:00:30.639Z","repository":{"id":42004803,"uuid":"411999509","full_name":"globulus/swiftui-youtube-player","owner":"globulus","description":"YouTube player for SwiftUI","archived":false,"fork":false,"pushed_at":"2022-04-19T06:46:36.000Z","size":3126,"stargazers_count":13,"open_issues_count":1,"forks_count":5,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-24T13:34:50.766Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/globulus.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}},"created_at":"2021-09-30T09:18:23.000Z","updated_at":"2023-12-19T10:46:20.000Z","dependencies_parsed_at":"2022-08-12T02:01:18.889Z","dependency_job_id":null,"html_url":"https://github.com/globulus/swiftui-youtube-player","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/globulus/swiftui-youtube-player","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/globulus%2Fswiftui-youtube-player","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/globulus%2Fswiftui-youtube-player/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/globulus%2Fswiftui-youtube-player/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/globulus%2Fswiftui-youtube-player/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/globulus","download_url":"https://codeload.github.com/globulus/swiftui-youtube-player/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/globulus%2Fswiftui-youtube-player/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29575343,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-18T08:38:15.585Z","status":"ssl_error","status_checked_at":"2026-02-18T08:38:14.917Z","response_time":162,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":[],"created_at":"2026-02-18T10:00:20.757Z","updated_at":"2026-02-18T10:00:30.628Z","avatar_url":"https://github.com/globulus.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SwiftUI YouTube Player for iOS and MacOS\n\nFully functional, SwiftUI-ready YouTube player for iOS 14+ and MacOS 11+. Actions and state are both delivered via SwiftUI `@Binding`s, meaking it dead-easy to integrate into any existing SwiftUI View.\n\n![Preview iOS](https://github.com/globulus/swiftui-youtube-player/blob/main/Images/preview_ios.gif?raw=true)\n\n## Installation\n\nThis component is distributed as a **Swift package**. Just add this repo's URL to XCode:\n\n```text\nhttps://github.com/globulus/swiftui-youtube-player\n```\n\n## How to use\n\n* Pass the **config** parameter to optionally set various player properties:\n  + `playInline`\n  + `allowsControls`\n  + `showInfo`\n * The **action** binding is used to control the player - whichever action you want it to perform, just set the variable's value to it. Available actions:\n   + `idle` - does nothing and can be used as the default value.\n   + `load(URLRequest)` - loads the video from the provided URL.\n   + `loadID(String)` - loads the video based on its YouTube ID.\n   + `loadPlaylistId(String)` - loads a playlist based on its YouTube ID.\n   + `mute`\n   + `unmute`\n   + `play`\n   + `pause`\n   + `stop`\n   + `clear`\n   + `seek(Float, Bool` - seeks the given position in the video.\n   + `duration` - evaluates the video's duration and updates the state.\n   + `currentTime` - evaluates the current play time and updates the state.\n   + `previous`\n   + `next`\n * The **state** binding reports back the current state of the player. Available data:\n   + `ready` - `true` if the player is ready to play a video.\n   + `status` - `unstarted, ended, playing, paused, buffering, queued`\n   + `quality` - `small, medium, large, hd720, hd1080, highResolution`\n   + `duration` -  will be set after the `duration` action is invoked.\n   + `currentTime` -  will be set after the `currentTime` action is invoked.\n   + `error` - set if an error ocurred while playing the video, `nil` otherwise.\n   \n## Sample code\n\n```swift\nimport SwiftUIYouTubePlayer\n\nstruct YouTubeTest: View {\n    @State private var action = YouTubePlayerAction.idle\n    @State private var state = YouTubePlayerState.empty\n    \n    private var buttonText: String {\n        switch state.status {\n        case .playing:\n            return \"Pause\"\n        case .unstarted,  .ended, .paused:\n            return \"Play\"\n        case .buffering, .queued:\n            return \"Wait\"\n        }\n    }\n    private var infoText: String {\n        \"Q: \\(state.quality)\"\n    }\n    \n    var body: some View {\n        VStack {\n            HStack {\n                Button(\"Load\") {\n                    action = .loadID(\"v1PBptSDIh8\")\n                }\n                Button(buttonText) {\n                    if state.status != .playing {\n                        action = .play\n                    } else {\n                        action = .pause\n                    }\n                }\n                Text(infoText)\n                Button(\"Prev\") {\n                    action = .previous\n                }\n                Button(\"Next\") {\n                    action = .next\n                }\n            }\n            YouTubePlayer(action: $action, state: $state)\n            Spacer()\n        }\n    }\n}\n```\n\n## Recipe\n\nFor a more detailed description of the code, [visit this recipe](https://swiftuirecipes.com/blog/swiftui-play-youtube-video). Check out [SwiftUIRecipes.com](https://swiftuirecipes.com) for more **SwiftUI recipes**!\n\n## Acknowledgements\n\n * The component internally uses [SwiftUI WebView](https://github.com/globulus/swiftui-webview) to render YouTube content.\n * Most functionality was inspired by the [Swift YouTube Player](https://github.com/gilesvangruisen/Swift-YouTube-Player) component.\n\n## Changelog\n\n* 1.0.2 - Fixed player vars, code cleanup.\n* 1.0.1 - Update to work with SwiftUIWebView 1.0.5.\n* 1.0.0 - Initial release.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fglobulus%2Fswiftui-youtube-player","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fglobulus%2Fswiftui-youtube-player","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fglobulus%2Fswiftui-youtube-player/lists"}