{"id":13906409,"url":"https://github.com/wxxsw/GSPlayer","last_synced_at":"2025-07-18T04:31:22.231Z","repository":{"id":38802862,"uuid":"57098698","full_name":"wxxsw/GSPlayer","owner":"wxxsw","description":"⏯ Video player, support for caching, preload, fullscreen transition and custom control view. 视频播放器，支持边下边播、预加载、全屏转场和自定义控制层","archived":false,"fork":false,"pushed_at":"2024-09-09T03:42:06.000Z","size":180,"stargazers_count":433,"open_issues_count":44,"forks_count":101,"subscribers_count":10,"default_branch":"master","last_synced_at":"2024-11-21T02:08:13.570Z","etag":null,"topics":["player","swift","video","videocache"],"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/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,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-04-26T04:49:25.000Z","updated_at":"2024-11-17T13:07:13.000Z","dependencies_parsed_at":"2023-12-14T05:28:48.257Z","dependency_job_id":"2c035128-317e-4de1-a11c-c56fe7e4ede5","html_url":"https://github.com/wxxsw/GSPlayer","commit_stats":{"total_commits":77,"total_committers":9,"mean_commits":8.555555555555555,"dds":0.4545454545454546,"last_synced_commit":"aa6dad7943d52f5207f7fcc2ad3e4274583443b8"},"previous_names":[],"tags_count":30,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wxxsw%2FGSPlayer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wxxsw%2FGSPlayer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wxxsw%2FGSPlayer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wxxsw%2FGSPlayer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wxxsw","download_url":"https://codeload.github.com/wxxsw/GSPlayer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226344639,"owners_count":17610180,"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","swift","video","videocache"],"created_at":"2024-08-06T23:01:35.187Z","updated_at":"2024-11-25T14:31:29.976Z","avatar_url":"https://github.com/wxxsw.png","language":"Swift","readme":"![GSPlayer](https://github.com/wxxsw/GSPlayer/blob/master/ScreenShots/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-swift5-f48041.svg?style=flat\"\u003e\u003c/a\u003e\n\u003ca href=\"https://developer.apple.com/ios\"\u003e\u003cimg src=\"https://img.shields.io/badge/platform-iOS10+|macOS-blue.svg?style=flat\"\u003e\u003c/a\u003e\n\u003ca href=\"http://cocoadocs.org/docsets/GSPlayer\"\u003e\u003cimg src=\"https://img.shields.io/badge/Cocoapods-compatible-4BC51D.svg?style=flat\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/wxxsw/GSPlayer/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\n## Features\n\n- [x] Fully customizable UI.\n- [x] Easy to use API and callbacks.\n- [x] Built-in caching mechanism to support playback while downloading (mp4).\n- [x] Can preload multiple videos at any time.\n- [x] Can be embedded into UITableView and UICollectionView.\n- [x] Provide full screen transition.\n- [ ] Complete Demo.\n\n## Quick Start\n\n1. Add `VideoPlayerView` to the interface.\n```swift\nlet playerView = VideoPlayerView()\nview.addSubview(playerView)\n\n// Or in IB, specify the type of custom View as VideoPlayerView.\n```\n\n2. Play Video.\n```swift\nplayerView.play(for: someURL)\n```\n\n3. Pause/Resume Video.\n```swift\nif playerView.state == .playing {\n    playerView.pause(reason: .userInteraction)\n} else {\n    playerView.resume()\n}\n```\n\n4. Update control UI based on playback status.\n```swift\nplayerView.stateDidChanged = { state in\n    switch state {\n    case .none:\n        print(\"none\")\n    case .error(let error):\n        print(\"error - \\(error.localizedDescription)\")\n    case .loading:\n        print(\"loading\")\n    case .paused(let playing, let buffering):\n        print(\"paused - progress \\(Int(playing * 100))% buffering \\(Int(buffering * 100))%\")\n    case .playing:\n        print(\"playing\")\n    }\n}\n```\n\n## Documents\n\n### Cache\n\nGet the total size of the video cache.\n```swift\nVideoCacheManager.calculateCachedSize()\n```\n\nClean up all caches.\n```swift\nVideoCacheManager.cleanAllCache()\n```\n\n### Preload\n\nSet the video URL to be preloaded. 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\nVideoPreloadManager.shared.set(waiting: [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### Fullscreen\n\nSee demo.\n\n### PlayerView\n\n#### Property\n\nAn object that manages a player's visual output.\n```swift\npublic let playerLayer: AVPlayerLayer { get }\n```\n\nGet current video status.\n```swift\npublic enum State {\n\n    /// None\n    case none\n\n    /// From the first load to get the first frame of the video\n    case loading\n\n    /// Playing now\n    case playing\n\n    /// Pause, will be called repeatedly when the buffer progress changes\n    case paused(playing: Double, buffering: Double)\n\n    /// An error occurred and cannot continue playing\n    case error(NSError)\n}\n\npublic var state: State { get }\n```\n\nThe reason the video was paused.\n```swift\npublic enum PausedReason {\n\n    /// Pause because the player is not visible, stateDidChanged is not called when the buffer progress changes\n    case hidden\n\n    /// Pause triggered by user interaction, default behavior\n    case userInteraction\n\n    /// Waiting for resource completion buffering\n    case waitingKeepUp\n}\n\npublic var pausedReason: PausedReason { get }\n```\n\nNumber of replays.\n```swift\npublic var replayCount: Int { get }\n```\n\nPlayed progress, value range 0-1.\n```swift\npublic var playing: Double { get }\n```\n\nPlayed length in seconds.\n```swift\npublic var currentDuration: Double { get }\n```\n\nBuffered progress, value range 0-1.\n```swift\npublic var buffering: Double { get }\n```\n\nBuffered length in seconds.\n```swift\npublic var currentBufferDuration: Double { get }\n```\n\nTotal video duration in seconds.\n```swift\npublic var totalDuration: Double { get }\n```\n\nThe total watch time of this video, in seconds.\n```swift\npublic var watchDuration: Double { get }\n```\n\nWhether the video is muted, only for this instance.\n```swift\npublic var isMuted: Bool { get set }\n```\n\nVideo volume, only for this instance.\n```swift\npublic var volume: Double { get set }\n```\n\n#### Callback\n\nPlayback status changes, such as from play to pause.\n```swift\npublic var stateDidChanged: ((State) -\u003e Void)?\n```\n\nReplay after playing to the end.\n```swift\npublic var replay: (() -\u003e Void)?\n```\n\n#### Method\n\nPlay a video of the specified url.\n```swift\nfunc play(for url: URL)\n```\n\nPause video.\n```swift\nfunc pause(reason: PausedReason)\n```\n\nContinue playing video.\n```swift\nfunc resume()\n```\n\n## Installation\n\nGSPlayer is available through [CocoaPods](https://cocoapods.org). To install\nit, simply add the following line to your Podfile:\n\n```ruby\npod 'GSPlayer'\n```\n\n## Contribution\n\n### Issue\n\nIf you find a bug or need a help, you can [create a issue](https://github.com/wxxsw/GSPlayer/issues/new)\n\n### Pull Request\n\nWe are happy to accept pull requests :D. But please make sure it's needed by most developers and make it simple to use. If you are not sure, create an issue and we can discuss it before you get to coding.\n\n## License\n\nThe MIT License (MIT)\n","funding_links":[],"categories":["HarmonyOS","OOM-Leaks-Crash","Video Players \u0026 Playback Libraries"],"sub_categories":["Windows Manager","Player","Mobile Players"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwxxsw%2FGSPlayer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwxxsw%2FGSPlayer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwxxsw%2FGSPlayer/lists"}