{"id":13751668,"url":"https://github.com/wxxsw/VideoPlayer","last_synced_at":"2025-05-09T18:31:53.666Z","repository":{"id":38202623,"uuid":"196777426","full_name":"wxxsw/VideoPlayer","owner":"wxxsw","description":"📽 A video player for SwiftUI, support for caching, preload and custom control view. SwiftUI 视频播放器，支持边下边播、预加载、自定义控制层","archived":false,"fork":false,"pushed_at":"2023-08-16T12:25:45.000Z","size":4815,"stargazers_count":671,"open_issues_count":22,"forks_count":105,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-11-14T02:02:22.936Z","etag":null,"topics":["avplayer","player","swift","swiftui","videoplayer"],"latest_commit_sha":null,"homepage":"https://github.com/wxxsw/VideoPlayer","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/wxxsw.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}},"created_at":"2019-07-14T00:18:25.000Z","updated_at":"2024-11-13T01:57:01.000Z","dependencies_parsed_at":"2024-01-18T08:43:54.984Z","dependency_job_id":"34c603c2-0040-4e5f-a4f6-6d8e6b50c8ef","html_url":"https://github.com/wxxsw/VideoPlayer","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wxxsw%2FVideoPlayer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wxxsw%2FVideoPlayer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wxxsw%2FVideoPlayer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wxxsw%2FVideoPlayer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wxxsw","download_url":"https://codeload.github.com/wxxsw/VideoPlayer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224876977,"owners_count":17384699,"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":["avplayer","player","swift","swiftui","videoplayer"],"created_at":"2024-08-03T09:00:51.517Z","updated_at":"2024-11-16T04:31:24.107Z","avatar_url":"https://github.com/wxxsw.png","language":"Swift","funding_links":[],"categories":["Video","HarmonyOS","🌎 by the community"],"sub_categories":["Content","Windows Manager"],"readme":"![VideoPlayer](https://github.com/wxxsw/VideoPlayer/blob/master/Images/logo.png)\n\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://developer.apple.com/swift\"\u003e\u003cimg src=\"https://img.shields.io/badge/language-Swift%205-f48041.svg?style=flat\"\u003e\u003c/a\u003e\n\u003ca href=\"https://developer.apple.com/swiftui\"\u003e\u003cimg src=\"https://img.shields.io/badge/framework-SwiftUI-blue.svg?style=flat\"\u003e\u003c/a\u003e\n\u003ca href=\"https://developer.apple.com/ios\"\u003e\u003cimg src=\"https://img.shields.io/badge/platform-iOS%2013%2b-blue.svg?style=flat\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/apple/swift-package-manager\"\u003e\u003cimg src=\"https://img.shields.io/badge/SPM-compatible-4BC51D.svg?style=flat\"\u003e\u003c/a\u003e\n\u003ca href=\"https://codebeat.co/projects/github-com-wxxsw-videoplayer-master\"\u003e\u003cimg alt=\"codebeat badge\" src=\"https://codebeat.co/badges/030d7cd9-f1ed-46b0-b6cc-90928ef7c941\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/wxxsw/VideoPlayer/blob/master/LICENSE\"\u003e\u003cimg src=\"http://img.shields.io/badge/license-MIT-lightgrey.svg?style=flat\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\u003cbr/\u003e\n\n- [Features](#features)\n- [QuickStart](#quick-start)\n- [Advances](#advances)\n- [Installation](#installation)\n- [Requirements](#requirements)\n- [License](#license)\n\n\n## Demo\n\n![Screenshot](https://github.com/wxxsw/VideoPlayer/blob/master/Images/screenshot.png)\n\n1. Clone or download the project.\n2. In the terminal, run `swift package resolve`.\n3. Open `VideoPlayer.xcodeproj` and run `Demo` target.\n\n## Features\n\n- [x] Fully customizable UI.\n- [x] Plays local media or streams remote media over HTTP.\n- [x] Built-in caching mechanism to support playback while downloading.\n- [x] Can preload multiple videos at any time.\n- [x] Support seek to duration.\n- [x] Simple API.\n\n## Quick Start\n\n```swift\nstruct ContentView : View {\n    @State private var play: Bool = true\n    \n    var body: some View {\n        VideoPlayer(url: someVideoURL, play: $play)\n    }\n}\n```\n\n## Advances\n\n```swift\nstruct ContentView : View {  \n    @State private var autoReplay: Bool = true \n    @State private var mute: Bool = false      \n    @State private var play: Bool = true       \n    @State private var time: CMTime = .zero  \n    \n    var body: some View {\n        VideoPlayer(url: someVideoURL, play: $play, time: $time)\n            .autoReplay(autoReplay)\n            .mute(mute)\n            .onBufferChanged { progress in\n                // Network loading buffer progress changed\n            }\n            .onPlayToEndTime { \n                // Play to the end time.\n            }\n            .onReplay { \n                // Replay after playing to the end. \n            }\n            .onStateChanged { state in \n                switch state {\n                case .loading:\n                    // Loading...\n                case .playing(let totalDuration):\n                    // Playing...\n                case .paused(let playProgress, let bufferProgress):\n                    // Paused...\n                case .error(let error):\n                    // Error...\n                }\n            }\n    }\n}\n```\n\n### Preload\n\nSet the video urls to be preload queue. Preloading will automatically cache a short segment of the beginning of the video and decide whether to start or pause the preload based on the buffering of the currently playing video.\n```swift\nVideoPlayer.preload(urls: [URL])\n```\n\nSet the preload size, the default value is 1024 * 1024, unit is byte.\n```swift\nVideoPlayer.preloadByteCount = 1024 * 1024 // = 1M\n```\n\n### Cache\n\nGet the total size of the video cache.\n```swift\nlet size = VideoPlayer.calculateCachedSize()\n```\n\nClean up all caches.\n```swift\nVideoPlayer.cleanAllCache()\n```\n\n## Installation\n\n### Swift Package Manager\n\n1. Select `Xcode -\u003e File -\u003e Swift Packages -\u003e Add Package Dependency...` \n2. Enter `https://github.com/wxxsw/VideoPlayer`.\n3. Click `Next`, then select the version, complete.\n\n## Requirements\n\n- iOS 13+\n- Xcode 11+\n- Swift 5+\n\n## Thanks\n\nBanner Design by [@aduqin](https://dribbble.com/aduqin)\n\n## License\n\nVideoPlayer is released under the MIT license. [See LICENSE](https://github.com/wxxsw/VideoPlayer/blob/master/LICENSE) for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwxxsw%2FVideoPlayer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwxxsw%2FVideoPlayer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwxxsw%2FVideoPlayer/lists"}