{"id":15037349,"url":"https://github.com/brikerman/bmplayer","last_synced_at":"2025-05-14T21:06:09.903Z","repository":{"id":37484341,"uuid":"57292099","full_name":"BrikerMan/BMPlayer","owner":"BrikerMan","description":"A video player for iOS, based on AVPlayer, support the horizontal, vertical screen. support adjust volume, brightness and seek by slide, support subtitles. ","archived":false,"fork":false,"pushed_at":"2024-04-23T07:46:03.000Z","size":25190,"stargazers_count":1992,"open_issues_count":120,"forks_count":426,"subscribers_count":38,"default_branch":"master","last_synced_at":"2025-05-14T05:12:00.694Z","etag":null,"topics":["avplayer","carthage","ios-swift","swift","swift3","swift4","swift5","video-player"],"latest_commit_sha":null,"homepage":"https://eliyar.biz","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/BrikerMan.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-28T10:13:42.000Z","updated_at":"2025-05-14T04:10:24.000Z","dependencies_parsed_at":"2022-07-12T16:19:04.750Z","dependency_job_id":"eabf5d32-d038-49f0-817e-1fa81aae1fc3","html_url":"https://github.com/BrikerMan/BMPlayer","commit_stats":{"total_commits":274,"total_committers":28,"mean_commits":9.785714285714286,"dds":0.3029197080291971,"last_synced_commit":"64137affea5b25958b63036ff3e6598796b48c39"},"previous_names":[],"tags_count":40,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BrikerMan%2FBMPlayer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BrikerMan%2FBMPlayer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BrikerMan%2FBMPlayer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BrikerMan%2FBMPlayer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BrikerMan","download_url":"https://codeload.github.com/BrikerMan/BMPlayer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254227611,"owners_count":22035669,"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","carthage","ios-swift","swift","swift3","swift4","swift5","video-player"],"created_at":"2024-09-24T20:34:24.093Z","updated_at":"2025-05-14T21:06:09.868Z","avatar_url":"https://github.com/BrikerMan.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"## BMPlayer\n\n![Swift 2.2-5.0](https://img.shields.io/badge/Swift-2.2--5.0-brightgreen.svg?style=flat)\n[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)\n[![Version](https://img.shields.io/cocoapods/v/BMPlayer.svg?style=flat)](http://cocoapods.org/pods/BMPlayer)\n[![License](https://img.shields.io/cocoapods/l/BMPlayer.svg?style=flat)](http://cocoapods.org/pods/BMPlayer)\n[![Platform](https://img.shields.io/cocoapods/p/BMPlayer.svg?style=flat)](http://cocoapods.org/pods/BMPlayer)\n[![Weibo](https://img.shields.io/badge/%E5%BE%AE%E5%8D%9A-%40%E8%89%BE%E5%8A%9B%E4%BA%9A%E5%B0%94-yellow.svg?style=flat)](http://weibo.com/536445669)\n[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2FBrikerMan%2FBMPlayer.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2FBrikerMan%2FBMPlayer?ref=badge_shield)\n\nA video player for iOS, based on AVPlayer, support the horizontal, vertical screen. support adjust volume, brightness and seek by slide, support subtitles.\n\n[中文说明](https://github.com/BrikerMan/BMPlayer/blob/master/README.zh.md)\n\n## Features\n\n- [x] Support for horizontal and vertical play mode\n- [x] Support play online URL and local file\n- [x] Adjust brightness by slide vertical at left side of screen\n- [x] Adjust volume by slide vertical at right side of screen\n- [x] Slide horizontal to fast forward and rewind\n- [x] Support multi-definition video\n- [x] Custom playrate\n- [x] Add Http header and other options to AVURLAsset\n- [x] Easy to customize\n- [x] Supporting show local and online subtitles\n- [x] [Swift 5](https://developer.apple.com/swift/)\n\n## Requirements\n\n- iOS 10.0+\n- Xcode 10.0+\n- Swift 4+\n\n## Supporting the project\n\n**You can support the project by checking out our sponsor page. It takes only one click:**\n\n\u003ca href=\"https://tracking.gitads.io/?repo=BMPlayer\"\u003e\n  \u003cimg alt=\"Sponsor banner\" src=\"https://images.gitads.io/BMPlayer\" /\u003e\n\u003c/a\u003e\n\u003cbr\u003e\u003ci\u003eThis advert was placed by \u003ca href=\"https://tracking.gitads.io/?repo=BMPlayer\"\u003eGitAds\u003c/a\u003e \u003c/i\u003e\n\n## Installation\n\n### CocoaPods\n\n| Swift     | podfile                      |\n| --------- | ---------------------------- |\n| Swift 5.0 | `pod 'BMPlayer', '~\u003e 1.3.0'` |\n| Swift 4.2 | `pod 'BMPlayer', '~\u003e 1.2.0'` |\n| Swift 4.0 | `pod 'BMPlayer', '~\u003e 1.0.0'` |\n| Swift 3.0 | `pod 'BMPlayer', '~\u003e 0.9.1'` |\n| Swift 2.2 | `pod 'BMPlayer', '~\u003e 0.3.3'` |\n\n**To test the experimental caching support with [VIMediaCache](https://github.com/vitoziv/VIMediaCache), use**\n\n```swift\npod 'BMPlayer/CacheSupport', :git =\u003e 'https://github.com/BrikerMan/BMPlayer.git'\n```\n### Swift Pakage Manager \n```swift\n 'https://github.com/BrikerMan/BMPlayer.git'\n```\n\n### Carthage\n\nAdd `BMPlayer` in your Cartfile.\n\n```txt\ngithub \"BrikerMan/BMPlayer\"\n```\n\nRun carthage to build the framework and drag the built BMPlayer.framework into your Xcode project.\n\n### Demo\n\nrun `pod install` at `Example` folder before run the demo.\n\n## Usage （Support IB and code）\n\n### Set status bar color\n\nPlease add the `View controller-based status bar appearance` field in info.plist and change it to NO\n\n### IB usage\nDirect drag IB to UIView, the aspect ratio for the 16:9 constraint (priority to 750, lower than the 1000 line), the code section only needs to achieve. See more detail on the demo.\n\n```swift\nimport BMPlayer\n\nplayer.playWithURL(URL(string: url)!)\n\nplayer.backBlock = { [unowned self] (isFullScreen) in\n    if isFullScreen == true { return }\n    let _ = self.navigationController?.popViewController(animated: true)\n}\n\n```\n\n### Code implementation by [SnapKit](https://github.com/SnapKit/SnapKit)\n\n```swift\nimport BMPlayer\n\nplayer = BMPlayer()\nview.addSubview(player)\nplayer.snp.makeConstraints { (make) in\n    make.top.equalTo(self.view).offset(20)\n    make.left.right.equalTo(self.view)\n    // Note here, the aspect ratio 16:9 priority is lower than 1000 on the line, because the 4S iPhone aspect ratio is not 16:9\n    make.height.equalTo(player.snp.width).multipliedBy(9.0/16.0).priority(750)\n}\n// Back button event\nplayer.backBlock = { [unowned self] (isFullScreen) in\n    if isFullScreen == true { return }\n    let _ = self.navigationController?.popViewController(animated: true)\n}\n```\n\n### Set video url\n\n```swift\nlet asset = BMPlayerResource(url: URL(string: \"http://baobab.wdjcdn.com/14525705791193.mp4\")!,\n                             name: \"风格互换：原来你我相爱\")\nplayer.setVideo(resource: asset)\n```\n\n### multi-definition video with cover\n\n```swift\nlet res0 = BMPlayerResourceDefinition(url: URL(string: \"http://baobab.wdjcdn.com/1457162012752491010143.mp4\")!,\n                                      definition: \"高清\")\nlet res1 = BMPlayerResourceDefinition(url: URL(string: \"http://baobab.wdjcdn.com/1457162012752491010143.mp4\")!,\n                                      definition: \"标清\")\n\nlet asset = BMPlayerResource(name: \"周末号外丨中国第一高楼\",\n                             definitions: [res0, res1],\n                             cover: URL(string: \"http://img.wdjimg.com/image/video/447f973848167ee5e44b67c8d4df9839_0_0.jpeg\"))\n\nplayer.setVideo(resource: asset)\n```\n\n### Add HTTP header for request\n\n```swift\nlet header = [\"User-Agent\":\"BMPlayer\"]\nlet options = [\"AVURLAssetHTTPHeaderFieldsKey\":header]\n\nlet definition = BMPlayerResourceDefinition(url: URL(string: \"http://baobab.wdjcdn.com/1457162012752491010143.mp4\")!,\n                                            definition: \"高清\",\n                                            options: options)\n\nlet asset = BMPlayerResource(name: \"Video Name\",\n                             definitions: [definition])\n```\n\n### Listening to player state changes\nSee more detail from the Example project\n#### Block\n```swift\n//Listen to when the player is playing or stopped\nplayer?.playStateDidChange = { (isPlaying: Bool) in\n    print(\"playStateDidChange \\(isPlaying)\")\n}\n\n//Listen to when the play time changes\nplayer?.playTimeDidChange = { (currentTime: TimeInterval, totalTime: TimeInterval) in\n    print(\"playTimeDidChange currentTime: \\(currentTime) totalTime: \\(totalTime)\")\n}\n```\n\n#### Delegate\n```swift\nprotocol BMPlayerDelegate {\n    func bmPlayer(player: BMPlayer ,playerStateDidChange state: BMPlayerState) { }\n    func bmPlayer(player: BMPlayer ,loadedTimeDidChange loadedDuration: TimeInterval, totalDuration: TimeInterval)  { }\n    func bmPlayer(player: BMPlayer ,playTimeDidChange currentTime : TimeInterval, totalTime: TimeInterval)  { }\n    func bmPlayer(player: BMPlayer ,playerIsPlaying playing: Bool)  { }\n}\n```\n## Customize player\nNeeds to change before the player alloc.\n\n```swift\n// should print log, default false\nBMPlayerConf.allowLog = false\n// should auto play, default true\nBMPlayerConf.shouldAutoPlay = true\n// main tint color, default whiteColor\nBMPlayerConf.tintColor = UIColor.whiteColor()\n// options to show header view (which include the back button, title and definition change button) , default .Always，options: .Always, .HorizantalOnly and .None\nBMPlayerConf.topBarShowInCase = .Always\n// loader type, see detail：https://github.com/ninjaprox/NVActivityIndicatorView\nBMPlayerConf.loaderType  = NVActivityIndicatorType.BallRotateChase\n// enable setting the brightness by touch gesture in the player\nBMPlayerConf.enableBrightnessGestures = true\n// enable setting the volume by touch gesture in the player\nBMPlayerConf.enableVolumeGestures = true\n// enable setting the playtime by touch gesture in the player\nBMPlayerConf.enablePlaytimeGestures = true\n\n```\n\n## Advanced Customize\n- Subclass `BMPlayerControlView` to create your personal control UI, check the Example.\n- Use the `BMPlayerLayer` with your own player control view.\n\n## Demonstration\n![gif](https://github.com/BrikerMan/resources/raw/master/BMPlayer/demo.gif)\n\n## Reference:\nThis project heavily reference the Objective-C version of this project [ZFPlayer](https://github.com/renzifeng/ZFPlayer), thanks for the generous help of ZFPlayer's author.\n\n## Contact me：\n- Blog: https://eliyar.biz\n- Email: eliyar917@gmail.com\n\n## Contributors\n- [Albert Young](https://github.com/cedared)\n- [tooodooo](https://github.com/tooodooo)\n- [Ben Bahrenburg](https://github.com/benbahrenburg)\n- [MangoMade](https://github.com/MangoMade)\n- [iblacksun](https://github.com/iblacksun)\n\nYou are welcome to fork and submit pull requests.\n\n## License\nBMPlayer is available under the MIT license. See the LICENSE file for more info.\n\n\n[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2FBrikerMan%2FBMPlayer.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2FBrikerMan%2FBMPlayer?ref=badge_large)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrikerman%2Fbmplayer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbrikerman%2Fbmplayer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrikerman%2Fbmplayer/lists"}