{"id":1577,"url":"https://github.com/VeinGuo/VGPlayer","last_synced_at":"2025-08-02T04:32:10.369Z","repository":{"id":43612111,"uuid":"94118586","full_name":"VeinGuo/VGPlayer","owner":"VeinGuo","description":"📺  A simple iOS video player by Vein.","archived":true,"fork":false,"pushed_at":"2019-08-17T07:08:37.000Z","size":49674,"stargazers_count":397,"open_issues_count":35,"forks_count":101,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-07-29T03:57:35.575Z","etag":null,"topics":["avplayer","background-playback","carthage","cocoapods","custom-player","ios","ios-swift","open-source","player","swift","video-player"],"latest_commit_sha":null,"homepage":"https://github.com/VeinGuo/VGPlayer","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/VeinGuo.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":"2017-06-12T16:42:03.000Z","updated_at":"2025-06-30T20:31:19.000Z","dependencies_parsed_at":"2022-09-13T11:20:32.712Z","dependency_job_id":null,"html_url":"https://github.com/VeinGuo/VGPlayer","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/VeinGuo/VGPlayer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VeinGuo%2FVGPlayer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VeinGuo%2FVGPlayer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VeinGuo%2FVGPlayer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VeinGuo%2FVGPlayer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/VeinGuo","download_url":"https://codeload.github.com/VeinGuo/VGPlayer/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VeinGuo%2FVGPlayer/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268334615,"owners_count":24233793,"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","status":"online","status_checked_at":"2025-08-02T02:00:12.353Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["avplayer","background-playback","carthage","cocoapods","custom-player","ios","ios-swift","open-source","player","swift","video-player"],"created_at":"2024-01-05T20:15:50.285Z","updated_at":"2025-08-02T04:32:09.269Z","avatar_url":"https://github.com/VeinGuo.png","language":"Swift","funding_links":[],"categories":["Media","Video Players \u0026 Playback Libraries","Libs","HarmonyOS","Video [🔝](#readme)"],"sub_categories":["Video","Mobile Players","Other free courses","Windows Manager"],"readme":"## VGPlayer\n\n![Swift](https://img.shields.io/badge/Swift-3.0-orange.svg)\n[![License MIT](https://img.shields.io/badge/license-MIT-green.svg?style=flat)](https://github.com/VeinGuo/VGPlayer/blob/master/LICENSE)\n[![Platform](https://img.shields.io/cocoapods/p/Pastel.svg?style=flat)](https://github.com/VeinGuo/VGPlayer)\n[![Cocoapod](https://img.shields.io/badge/pod-v0.2.0-blue.svg)](http://cocoadocs.org/docsets/VGPlayer/0.2.0/)\n[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)\n\n![Banners](https://github.com/VeinGuo/VGPlayer/blob/master/Image/Banners.png)\n\nSwift developed based on AVPlayer iOS player,support horizontal gestures Fast forward, pause, vertical gestures Support brightness and volume adjustment, support full screen, adaptive screen rotation direction.\n\n[中文介绍](http://www.jianshu.com/p/1680978e1a7e)\n\n## Demonstration\n![demo1](https://github.com/VeinGuo/VGPlayer/blob/master/Image/demo1.gif)\n\n![demo2](https://github.com/VeinGuo/VGPlayer/blob/master/Image/demo2.gif)\n\n![demo3](http://ojaltanzc.bkt.clouddn.com/vgplayer_embed_in_cell.gif)\n\n## Requirements\n-\tSwift 3\n-\tiOS 8.0+\n-\tXcode 8\n\n## Features\n- [x] Support play local and network \n- [x] Background playback mode.\n- [x] Gesture Adjusts the volume and brightness as well as fast forward and backward.\n- [x] Support full screen\n- [x] Slide fast forward and backward\n- [x] Lock screen can also be rotated full screen\n- [x] Support replay media\n- [x] Support custom player view\n- [x] Support subtitle (format: srt \u0026 ass)\n- [x] Media Cache\n\n## TODO\n- [ ] Virtual reality\n\n## Update\n- 2017-6-13 v0.0.1\n- 2017-6-17 Support subtitle (format: srt \u0026 ass) v0.0.2\n- 2017-7-1 Media Cache v0.1.0\n- 2017-7-3 \tfix some compiler warning, support carthage. v0.1.1\n- 2017-7-11 fix all compiler warning. v0.1.2\n- 2017-7-16 fix URL resolution error. v0.1.3\n- 2017-8-10 \n  - fix iOS 9 can't play\n  - fix exit Full Screen frame error\n  - player slider thumb add highted\n  - example add \u003cembed to cell\u003e demo\n- 2017-9-6 v0.1.5\n\t- fix url param praser\n\t- fix pause play error \n- 2017-9-21 v0.2.0\n\t- clean code\n\t- convert to swift4\n\n## Usage\n### Play Video\n```swift\n// init \nself.player = VGPlayer(URL: url)\n// or\nself.player.replaceVideo(url)\n```\n\n### Custom player view\n- Subclass VGPlayerView\n- Alloc VGPlaye when set up\n\n```swift\nlet playeView = VGCustomPlayerView()\nself.player = VGPlayer(playerView: playeView)\n\n// customPlayerView\nclass VGCustomPlayerView: VGPlayerView {\n    var playRate: Float = 1.0\n    var rateButton = UIButton(type: .custom)\n    \n    override func configurationUI() {\n        super.configurationUI()\n        self.topView.backgroundColor = #colorLiteral(red: 0, green: 0, blue: 0, alpha: 0.09701412671)\n        self.bottomView.backgroundColor = #colorLiteral(red: 0, green: 0, blue: 0, alpha: 0.09701412671)\n        self.topView.addSubview(rateButton)\n        rateButton.snp.makeConstraints { (make) in\n            make.left.equalTo(titleLabel.snp.right).offset(10)\n            make.centerY.equalTo(closeButton)\n        }\n        rateButton.tintColor = #colorLiteral(red: 1, green: 1, blue: 1, alpha: 1)\n        rateButton.setTitle(\"x1.0\", for: .normal)\n        rateButton.titleLabel?.font   = UIFont.boldSystemFont(ofSize: 12.0)\n        rateButton.addTarget(self, action: #selector(onRateButton), for: .touchUpInside)\n        rateButton.isHidden = false\n    }\n\n// .....more\n\n```\n\n### AutoLayout use [SnapKit](https://github.com/SnapKit/SnapKit)\n\n```swift\n\t\t\tself.player.replaceVideo(url)\n        view.addSubview(self.player.displayView)\n        \n        self.player.play()\n        self.player.backgroundMode = .proceed\n        self.player.delegate = self\n        self.player.displayView.delegate = self\n        self.player.displayView.titleLabel.text = \"China NO.1\"\n        self.player.displayView.snp.makeConstraints { [weak self] (make) in\n            guard let strongSelf = self else { return }\n            make.top.left.right.equalToSuperview()\n            make.height.equalTo(strongSelf.view.snp.width).multipliedBy(3.0/4.0) // you can 9.0/16.0\n        }\n```\n### Media Cache  (Reference: [VIMediaCache](https://github.com/vitoziv/VIMediaCache))\n- VGPlayer Cache Reference VIMediaCache implementation.\n- AVAssetResourceLoader to control AVPlayer download media data.\n- Cache usage range request data, you can cancel the download, fragment cache\n- If you use Simulator debugging, you can view the VGPlayer cache file in the Simulator cache\n![test](http://ojaltanzc.bkt.clouddn.com/MediaCache_test.png)\n\n- Usage:\n\n```Swift\n// Settings maxCacheSize\nVGPlayerCacheManager.shared.cacheConfig.maxCacheSize = 160000000\n\n// Setting maxCacheAge   default one weak\nVGPlayerCacheManager.shared.cacheConfig.maxCacheAge = 60 * 60 * 24 * 7\n\n// clean all cache\nVGPlayerCacheManager.shared.cleanAllCache()\n\n// clean old disk cache. \n// This is an async operation.\nVGPlayerCacheManager.shared.cleanOldFiles { }\n\n```\n\n\n### Background playback\n- Project setting\n\n![backgroundModes](https://github.com/VeinGuo/VGPlayer/blob/master/Image/backgroundModes.png)\n\n- AppDelegate settings\n\n```Swift\n    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -\u003e Bool {\n        // Override point for customization after application launch.\n        do\n        {\n            try AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayback)\n        }\n        catch let error as NSError\n        {\n            print(error)\n        }\n        return true\n    }\n```\n\n- VGPlayer Background playback mode to proceed\n\n```swift\nself.player.backgroundMode = .proceed\n```\n\n### Delegate methods optional\n```swift\n// player delegate\n    // play state\n    func vgPlayer(_ player: VGPlayer, stateDidChange state: VGPlayerState)\n    // playe Duration\n    func vgPlayer(_ player: VGPlayer, playerDurationDidChange currentDuration: TimeInterval, totalDuration: TimeInterval)\n    // buffer state\n    func vgPlayer(_ player: VGPlayer, bufferStateDidChange state: VGPlayerBufferstate)\n    // buffered Duration\n    func vgPlayer(_ player: VGPlayer, bufferedDidChange bufferedDuration: TimeInterval, totalDuration: TimeInterval)\n    // play error\n    func vgPlayer(_ player: VGPlayer, playerFailed error: VGPlayerError)\n    \n    \n// player view delegate\n    /// fullscreen\n    func vgPlayerView(_ playerView: VGPlayerView, willFullscreen fullscreen: Bool)\n    /// close play view\n    func vgPlayerView(didTappedClose playerView: VGPlayerView)\n    /// displaye control\n    func vgPlayerView(didDisplayControl playerView: VGPlayerView)\n    \n```\n## Installation\n- Download VGPlayer. Move to your project.\n\n### Cocoapods\n\n\n**Swift 4**\n```\nuse_frameworks!\npod 'VGPlayer', '~\u003e 0.2.0'\n```\n\n**Swift 3**\n```\nuse_frameworks!\npod 'VGPlayer', '~\u003e 0.1.5'\n```\n\n### Carthage\n\n```\ngithub \"VeinGuo/VGPlayer\"\n```\nRun carthage update. to build the framework and drag the built `VGPlayer.framework` and `SnapKit.framework` into your Xcode project.\n\n## Reference\n- https://techblog.toutiao.com/2017/03/28/fullscreen/\n- https://developer.apple.com/library/content/qa/qa1668/_index.html\n- https://developer.apple.com/documentation/avfoundation\n- https://stackoverflow.com/questions/808503/uibutton-making-the-hit-area-larger-than-the-default-hit-area/13977921\n- https://gist.github.com/onevcat/2d1ceff1c657591eebde\n- Media Cache  [VIMediaCache](https://github.com/vitoziv/VIMediaCache)\n- https://mp.weixin.qq.com/s/v1sw_Sb8oKeZ8sWyjBUXGA\n\n\n## License\nMIT\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FVeinGuo%2FVGPlayer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FVeinGuo%2FVGPlayer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FVeinGuo%2FVGPlayer/lists"}