{"id":13505330,"url":"https://github.com/kingslay/KSPlayer","last_synced_at":"2025-03-29T23:31:15.498Z","repository":{"id":37664658,"uuid":"134537136","full_name":"kingslay/KSPlayer","owner":"kingslay","description":"A video player for iOS、macOS、tvOS、visionOS , based on AVPlayer and FFmpeg, support the horizontal, vertical screen. support adjust volume, brightness and seek by slide, SwiftUI, support subtitles.","archived":false,"fork":false,"pushed_at":"2025-03-19T11:10:16.000Z","size":106953,"stargazers_count":1167,"open_issues_count":14,"forks_count":222,"subscribers_count":29,"default_branch":"main","last_synced_at":"2025-03-22T22:01:34.230Z","etag":null,"topics":["audio-player","avplayer","ffmpeg","ios","macos","swift","swiftui","tvos","video-player","visionos"],"latest_commit_sha":null,"homepage":"https://apps.apple.com/app/tracyplayer/id6450770064","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kingslay.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"github":"kingslay","patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":null}},"created_at":"2018-05-23T08:21:06.000Z","updated_at":"2025-03-22T05:45:46.000Z","dependencies_parsed_at":"2023-02-19T08:15:34.618Z","dependency_job_id":"3d1c9a9a-6869-474e-88e2-4478abba3b00","html_url":"https://github.com/kingslay/KSPlayer","commit_stats":{"total_commits":701,"total_committers":17,"mean_commits":41.23529411764706,"dds":"0.059914407988587715","last_synced_commit":"8c4174446aff4573ae4c648ca9193cb09ecce151"},"previous_names":[],"tags_count":34,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kingslay%2FKSPlayer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kingslay%2FKSPlayer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kingslay%2FKSPlayer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kingslay%2FKSPlayer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kingslay","download_url":"https://codeload.github.com/kingslay/KSPlayer/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246254099,"owners_count":20747948,"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":["audio-player","avplayer","ffmpeg","ios","macos","swift","swiftui","tvos","video-player","visionos"],"created_at":"2024-08-01T00:01:02.890Z","updated_at":"2025-03-29T23:31:15.485Z","avatar_url":"https://github.com/kingslay.png","language":"Swift","readme":"![Build Status](https://img.shields.io/badge/build-%20passing%20-blue.svg)\n![Platform](https://img.shields.io/badge/Platform-%20iOS%20macOS%20tvOS%20visionOS%20-blue.svg)\n![License](https://img.shields.io/badge/license-GPL-blue.svg)\n# KSPlayer \n\nKSPlayer is a powerful media play framework for iOS, tvOS, macOS, xrOS, visionOS, Mac Catalyst, SwiftUI, Apple Silicon M1 .\n\nEnglish | [简体中文](./README_CN.md)\n\n## Features\nFunctional differences between GPL version and LGPL version\nFeature       | LGPL      | GPL     |\n| ----------- | ----------- | ----------- |\n|Dolby AC-4|✅|❌|\n|AV1 hardware decoding|✅|❌|\n|All demuxers, All decoders|✅|❌|\n|Record video clips at any time|✅|❌|\n|Smoothly Play 8K or 120 FPS Video|✅|❌|\n|Dovi P5 displays HDR (not overheating)|✅|❌|\n|Live streaming supports rewind viewing|✅|❌|\n|Picture in Picture supports subtitle display|✅|❌|\n|Annex-B async hardware decoding(Live Stream)|✅|❌|\n|Use the fonts in the video to render subtitles|✅|❌|\n|ISO Blu-ray disc playback on all Apple platforms|✅|❌|\n|Use memory cache for fast seek in short time range|✅|❌|\n|Cache data to Hard Drive,Preload data to Hard Drive|✅|❌|\n|Offline AI real-time subtitle generation and translation|✅|❌|\n|Full display of ass subtitles effect(Render as image using libass)|✅|❌|\n|Play videos in a small window in the App (resumable, supports tvos and ios)|✅|❌|\n|FFmpeg version|7.0.2|6.1.0|\n|Record video|✅|✅|\n|360° panorama video|✅|✅|\n|Picture in Picture|✅|✅|\n|Hardware accelerator|✅|✅|\n|Seamless loop playback|✅|✅|\n|De-interlace auto detect|✅|✅|\n|4k/HDR/HDR10/HDR10+/Dolby Vision|✅|✅|\n|Custom url protocols such as nfs/smb/UPnP |✅|✅|\n|Multichannel Audio/Spatial Audio|✅|✅|\n|Text subtitle/Image subtitle/Closed Captions|✅|✅|\n|Search Online Subtitles(shooter/assrt/opensubtitles)|✅|✅|\n|Low latency 4K live video streaming (less than 200ms on LAN)|✅|✅|\n|Automatically switch to multi-bitrate streams based on network|✅|✅|\n\n## The list of App using this SDK\nApp Store Link| Logo |\n| ----------- | ----------- |\n|[Alplayer](https://apps.apple.com/us/app/alplayer/id1660917007)||\n|[APTV](https://apps.apple.com/app/aptv/id1630403500)||\n|[homeTV IPTV Player](https://apps.apple.com/app/hometv-iptv-player/id1636701357)||\n|[IPTV +](https://apps.apple.com/app/iptv-my-smart-iptv-player/id1525121231)||\n|[LillyPlayer Video Player](https://apps.apple.com/app/lillyplayer-video-player/id1446967273)||\n|[SenPlayer](https://apps.apple.com/app/senplayer-hdr-media-player/id6443975850)||\n|[Smart IPTV](https://apps.apple.com/app/smart-iptv-tv-and-movies-ott/id1492738910)||\n|[Snappier IPTV](https://apps.apple.com/app/snappier-iptv/id1579702567)||\n|[Spatial Video Studio](https://apps.apple.com/app/id6523429904)||\n|[SWIPTV - IPTV Smart Player](https://apps.apple.com/app/swiptv-iptv-smart-player/id1658538188)||\n|[TracyPlayer](https://apps.apple.com/app/tracyplayer/id6450770064)||\n|[UHF - Love your IPTV](https://apps.apple.com/app/uhf-love-your-iptv/id6443751726)|![logo](https://uhf-web.vercel.app/uhfsponsor.png)|\n|[Zen IPTV](https://apps.apple.com/fr/app/zen-iptv/id6458223193)||\n\n\n\n## License\nKSPlayer defaults to the GPL license (requires open-sourcing your own project code), and we hope everyone will consciously respect the licensing agreement of the KSPlayer project. Additionally, there is a paid version that adopts the LGPL license (contact us). \n\nIf due to commercial reasons, you prefer not to adhere to the GPL license  or the LGPL license, you can contact us. Through our authorization, you can obtain a more flexible licensing agreement. Email: kingslay@icloud.com\n\n\n## Requirements\n\n- iOS 13+, macOS 10.15+, tvOS 13+, xrOS 1+\n\n## Demo\n\n```bash\ncd Demo\npod install\n```\n- Open Demo/Demo.xcworkspace with Xcode.\n\n## Quick Start\n\n#### CocoaPods\n\nMake sure to use the latest version **cocoapods 1.10.1+**, which can be installed using the command `brew install cocoapods`\n\n```ruby\ntarget 'ProjectName' do\n    use_frameworks!\n    pod 'KSPlayer',:git =\u003e 'https://github.com/kingslay/KSPlayer.git', :branch =\u003e 'main'\n    pod 'DisplayCriteria',:git =\u003e 'https://github.com/kingslay/KSPlayer.git', :branch =\u003e 'main'\n    pod 'FFmpegKit',:git =\u003e 'https://github.com/kingslay/FFmpegKit.git', :branch =\u003e 'main'\n    pod 'Libass',:git =\u003e 'https://github.com/kingslay/FFmpegKit.git', :branch =\u003e 'main'\nend\n```\n\n### Swift Package Manager\n\n```swift\ndependencies: [\n    .package(url: \"https://github.com/kingslay/KSPlayer.git\", .branch(\"main\"))\n]\n```\n\n## Usage\n\n#### Initialization\n\n```swift\nKSOptions.secondPlayerType = KSMEPlayer.self\nplayerView = IOSVideoPlayerView()\nview.addSubview(playerView)\nplayerView.translatesAutoresizingMaskIntoConstraints = false\nNSLayoutConstraint.activate([\n    playerView.topAnchor.constraint(equalTo: view.readableContentGuide.topAnchor),\n    playerView.leftAnchor.constraint(equalTo: view.leftAnchor),\n    playerView.rightAnchor.constraint(equalTo: view.rightAnchor),\n    playerView.bottomAnchor.constraint(equalTo: view.bottomAnchor),\n])\nplayerView.backBlock = { [unowned self] in\n    if UIApplication.shared.statusBarOrientation.isLandscape {\n        self.playerView.updateUI(isLandscape: false)\n    } else {\n        self.navigationController?.popViewController(animated: true)\n    }\n}\n```\n\n#### Setting up a regular video\n\n```swift\nplayerView.set(url:URL(string: \"http://baobab.wdjcdn.com/14525705791193.mp4\")!)\nplayerView.set(resource: KSPlayerResource(url: url, name: name!, cover: URL(string: \"http://img.wdjimg.com/image/video/447f973848167ee5e44b67c8d4df9839_0_0.jpeg\"), subtitleURL: URL(string: \"http://example.ksplay.subtitle\")))\n```\n\n#### Multi-definition, with cover video\n\n```swift\nlet res0 = KSPlayerResourceDefinition(url: URL(string: \"http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4\")!,\n                                      definition: \"高清\")\nlet res1 = KSPlayerResourceDefinition(url: URL(string: \"http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4\")!,\n                                      definition: \"标清\")\n   \nlet asset = KSPlayerResource(name: \"Big Buck Bunny\",\n                             definitions: [res0, res1],\n                             cover: URL(string: \"https://upload.wikimedia.org/wikipedia/commons/thumb/c/c5/Big_buck_bunny_poster_big.jpg/848px-Big_buck_bunny_poster_big.jpg\"))\nplayerView.set(resource: asset)\n```\n\n#### Setting up an HTTP header\n\n```swift\nlet options = KSOptions()\noptions.appendHeader([\"Referer\":\"https:www.xxx.com\"])\nlet definition = KSPlayerResourceDefinition(url: URL(string: \"http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4\")!,\n                                            definition: \"高清\",\n                                            options: options)\nlet asset = KSPlayerResource(name: \"Video Name\",\n                             definitions: [definition])\nplayerView.set(resource: asset)\n```\n\n#### Listening status change\n\n```swift\n// Listen to play time change\nplayerView.playTimeDidChange = { (currentTime: TimeInterval, totalTime: TimeInterval) in\n    print(\"playTimeDidChange currentTime: \\(currentTime) totalTime: \\(totalTime)\")\n}\n\n// Delegates\npublic protocol PlayerControllerDelegate: class {\n    func playerController(state: KSPlayerState)\n    func playerController(currentTime: TimeInterval, totalTime: TimeInterval)\n    func playerController(finish error: Error?)\n    func playerController(maskShow: Bool)\n    func playerController(action: PlayerButtonType)\n    // `bufferedCount: 0` indicates first time loading\n    func playerController(bufferedCount: Int, consumeTime: TimeInterval)\n}\n```\n\n## Advanced Usage\n\n- ### Inherits PlayerView's custom play logic and UI.\n\n  ```swift\n  class CustomVideoPlayerView: IOSVideoPlayerView {\n      override func updateUI(isLandscape: Bool) {\n          super.updateUI(isLandscape: isLandscape)\n          toolBar.playbackRateButton.isHidden = true\n      }\n  \n      override func onButtonPressed(type: PlayerButtonType, button: UIButton) {\n          if type == .landscape {\n              // Your own button press behaviour here\n          } else {\n              super.onButtonPressed(type: type, button: button)\n          }\n      }\n  }\n  ```\n\n  \n\n- ### Selecting Tracks\n\n  ```swift\n     override open func player(layer: KSPlayerLayer, state: KSPlayerState) {\n          super.player(layer: layer, state: state)\n          if state == .readyToPlay, let player = layer.player {\n              let tracks = player.tracks(mediaType: .audio)\n              let track = tracks[1]\n              /// the name of the track\n              let name = track.name\n              /// the language of the track\n              let language = track.language\n              /// selecting the one\n              player.select(track: track)\n          }\n     }\n  ```\n\n- ### Set the properties in KSOptions\n\n  ```swift\n  open class KSOptions {\n    /// 最低缓存视频时间\n    @Published\n    public var preferredForwardBufferDuration = KSOptions.preferredForwardBufferDuration\n    /// 最大缓存视频时间\n    public var maxBufferDuration = KSOptions.maxBufferDuration\n    /// 是否开启秒开\n    public var isSecondOpen = KSOptions.isSecondOpen\n    /// 开启精确seek\n    public var isAccurateSeek = KSOptions.isAccurateSeek\n    /// Applies to short videos only\n    public var isLoopPlay = KSOptions.isLoopPlay\n    /// 是否自动播放，默认false\n    public var isAutoPlay = KSOptions.isAutoPlay\n    /// seek完是否自动播放\n    public var isSeekedAutoPlay = KSOptions.isSeekedAutoPlay\n    /*\n     AVSEEK_FLAG_BACKWARD: 1\n     AVSEEK_FLAG_BYTE: 2\n     AVSEEK_FLAG_ANY: 4\n     AVSEEK_FLAG_FRAME: 8\n     */\n    public var seekFlags = Int32(0)\n    // ffmpeg only cache http\n    public var cache = false\n    public var outputURL: URL?\n    public var display = DisplayEnum.plane\n    public var avOptions = [String: Any]()\n    public var formatContextOptions = [String: Any]()\n    public var decoderOptions = [String: Any]()\n    public var probesize: Int64?\n    public var maxAnalyzeDuration: Int64?\n    public var lowres = UInt8(0)\n    public var startPlayTime: TimeInterval = 0\n    public var startPlayRate: Float = 1.0\n    public var registerRemoteControll: Bool = true // 默认支持来自系统控制中心的控制\n    public var referer: String?\n    public var userAgent: String?\n      // audio\n    public var audioFilters = [String]()\n    public var syncDecodeAudio = false\n    // sutile\n    public var autoSelectEmbedSubtitle = true\n    public var subtitleDisable = false\n    public var isSeekImageSubtitle = false\n    // video\n    public var videoDelay = 0.0 // s\n    public var autoDeInterlace = false\n    public var autoRotate = true\n    public var destinationDynamicRange: DynamicRange?\n    public var videoAdaptable = true\n    public var videoFilters = [String]()\n    public var syncDecodeVideo = false\n    public var hardwareDecode = KSOptions.hardwareDecode\n    public var asynchronousDecompression = true\n    public var videoDisable = false\n    public var canStartPictureInPictureAutomaticallyFromInline = true\n  }\n\n  ```\n\n\n## Effect\n\n![gif](./Demo/demo.gif)\n\n## Developments and Tests\n\nAny contributing and pull requests are warmly welcome. However, before you plan to implement some features or try to fix an uncertain issue, it is recommended to open a discussion first. It would be appreciated if your pull requests could build and with all tests green. :)\n\n\n## Backers \u0026 Sponsors\n\nOpen-source projects cannot live long without your help. If you find KSPlayer to be useful, please consider supporting this \nproject by becoming a sponsor. \n\nBecome a sponsor through [GitHub Sponsors](https://github.com/sponsors/kingslay/). :heart:\n\nYour user icon or company logo shows up this with a link to your home page. \nName| Logo |\n| ----------- | ----------- |\n|[UnknownCoder807](https://github.com/UnknownCoder807)||\n|[skrew](https://github.com/skrew)||\n|[Kimentanm](https://github.com/Kimentanm)||\n|[byMohamedali](https://github.com/byMohamedali)||\n|[nakiostudio](https://github.com/nakiostudio)|![logo](https://uhf-web.vercel.app/uhfsponsor.png)|\n|[CodingByJerez](https://github.com/CodingByJerez)||\n|[andrefmsilva](https://github.com/andrefmsilva)||\n|[romaingyh](https://github.com/romaingyh)||\n|[FantasyKingdom](https://github.com/FantasyKingdom)||\n|[aart-rainey](https://github.com/aart-rainey)||\n|[nihalahmed](https://github.com/nihalahmed)||\n|[HatimDa](https://github.com/HatimDa)||\n|[johnil](https://github.com/johnil)||\n|[scorebreak](https://github.com/scorebreak)||\n|[nsplay1990](https://github.com/nsplay1990)||\n\n\nThanks to [nightfall708](https://github.com/nightfall708) for sponsoring a mac mini\n\nThanks to [cdguy](https://github.com/cdguy) [UnknownCoder807](https://github.com/UnknownCoder807) [skrew](https://github.com/skrew) and LillyPlayer community for sponsoring a LG S95QR Sound Bar \n\nThanks to [skrew](https://github.com/skrew) and LillyPlayer community for sponsoring a 2022 Apple TV 4K\n\n## Communication\n\nIf you have a business cooperation project or want to initiate a paid consultation, you can contact me via email\n\n- Email : kingslay@icloud.com\n\n![1](./Documents/Sponsors.jpg)\n\n","funding_links":["https://github.com/sponsors/kingslay","https://github.com/sponsors/kingslay/"],"categories":["Swift","HarmonyOS","Prototypes","Uncategorized","Libraries"],"sub_categories":["Windows Manager","Github Repos","Uncategorized","Media"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkingslay%2FKSPlayer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkingslay%2FKSPlayer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkingslay%2FKSPlayer/lists"}