A video player for iOS、macOS、tvOS、visionOS , based on AVPlayer and FFmpeg, support HLG、HDR10、 HDR10+、Dolby Vision、Dolby Atmos、Text/Image subtitle.
See the code
KSPlayer is a powerful media play framework for iOS, macCatalyst, macOS, tvOS, xrOS, visionOS. based on AVPlayer and FFmpeg, support HLG、HDR10、 HDR10+、Dolby Vision、Dolby Atmos、Text/Image subtitle.
English | 简体中文
If you have a commercial project that requires a custom player, or would like to receive a paid consultation, please email me.
KSPlayer 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 available under the LGPL license. You can check this post for details on the licensing options or send me an email. If I don't reply to your email, feel free to @mention me in this post.
If 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.
Differences between GPL version and LGPL version.
| Module | GPL Version | LGPL Version |
|---|---|---|
| KSPlayer | Dynamic Binary, only macOS、iSimulator、tvOS | Source code, all Apple platforms |
| KSPlayerUI | Source code, all Apple platforms | Source code, all Apple platforms |
| MPVPlayer | Source code, all Apple platforms | Source code, all Apple platforms |
To experience the paid features, you can download the app from the App Store. App Store Link Test Flight Link
This table does not list all licensed apps. If you would like to have your app listed above, please send me an email.
| App Store Link | Logo |
|---|---|
| APTV | |
| homeTV IPTV Player | |
| Interlace Player | |
| IPTV + | |
| LillyPlayer Video Player | |
| MyKroko | |
| SeeTV | |
| SenPlayer | |
| Smart IPTV | |
| Snappier IPTV | |
| StreamX | |
| SWIPTV - IPTV Smart Player | |
| UHF - Love your IPTV | |
| Zen IPTV |
dependencies: [
.package(url: "https://github.com/kingslay/KSPlayer.git", .branch("main"))
]
import KSPlayer
import KSPlayerUI
KSOptions.secondPlayerType = KSMEPlayer.self
playerView = IOSVideoPlayerView()
view.addSubview(playerView)
playerView.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
playerView.topAnchor.constraint(equalTo: view.readableContentGuide.topAnchor),
playerView.leftAnchor.constraint(equalTo: view.leftAnchor),
playerView.rightAnchor.constraint(equalTo: view.rightAnchor),
playerView.bottomAnchor.constraint(equalTo: view.bottomAnchor),
])
playerView.backBlock = { [unowned self] in
if UIApplication.shared.statusBarOrientation.isLandscape {
self.playerView.updateUI(isLandscape: false)
} else {
self.navigationController?.popViewController(animated: true)
}
}
import KSPlayer
import KSPlayerUI
playerView.set(url:URL(string: "http://baobab.wdjcdn.com/14525705791193.mp4")!)
playerView.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")))
import KSPlayer
import KSPlayerUI
let res0 = KSPlayerResourceDefinition(url: URL(string: "http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4")!,
definition: "高清")
let res1 = KSPlayerResourceDefinition(url: URL(string: "http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4")!,
definition: "标清")
let asset = KSPlayerResource(name: "Big Buck Bunny",
definitions: [res0, res1],
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"))
playerView.set(resource: asset)
import KSPlayer
import KSPlayerUI
let options = KSOptions()
options.appendHeader(["Referer":"https:www.xxx.com"])
let definition = KSPlayerResourceDefinition(url: URL(string: "http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4")!,
definition: "高清",
options: options)
let asset = KSPlayerResource(name: "Video Name",
definitions: [definition])
playerView.set(resource: asset)
import KSPlayer
import KSPlayerUI
// Listen to play time change
playerView.playTimeDidChange = { (currentTime: TimeInterval, totalTime: TimeInterval) in
print("playTimeDidChange currentTime: \(currentTime) totalTime: \(totalTime)")
}
// Delegates
public protocol PlayerControllerDelegate: class {
func playerController(state: KSPlayerState)
func playerController(currentTime: TimeInterval, totalTime: TimeInterval)
func playerController(finish error: Error?)
func playerController(maskShow: Bool)
func playerController(action: PlayerButtonType)
// `bufferedCount: 0` indicates first time loading
func playerController(bufferedCount: Int, consumeTime: TimeInterval)
}
import KSPlayer
import KSPlayerUI
class CustomVideoPlayerView: IOSVideoPlayerView {
override func updateUI(isLandscape: Bool) {
super.updateUI(isLandscape: isLandscape)
toolBar.playbackRateButton.isHidden = true
}
override func onButtonPressed(type: PlayerButtonType, button: UIButton) {
if type == .landscape {
// Your own button press behaviour here
} else {
super.onButtonPressed(type: type, button: button)
}
}
}
import KSPlayer
import KSPlayerUI
override open func player(layer: KSPlayerLayer, state: KSPlayerState) {
super.player(layer: layer, state: state)
if state == .readyToPlay, let player = layer.player {
let tracks = player.tracks(mediaType: .audio)
let track = tracks[1]
/// the name of the track
let name = track.name
/// the language of the track
let language = track.language
/// selecting the one
player.select(track: track)
}
}

Any 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. :)
Open-source projects cannot live long without your help. If you find KSPlayer to be useful, please consider supporting this project by becoming a sponsor.
Become a sponsor through GitHub Sponsors. ❤️
Your user icon or company logo shows up this with a link to your home page.
Thanks to nightfall708 for sponsoring a mac mini
Thanks to cdguy UnknownCoder807 skrew and LillyPlayer community for sponsoring a LG S95QR Sound Bar
Thanks to skrew and LillyPlayer community for sponsoring a 2022 Apple TV 4K
Thanks to bgoncal for sponsoring a HomePod mini

26 followers · starred Apr 2025
694 followers · starred Nov 2023
178 followers · starred Jun 2026
590 followers · starred Apr 2022
A video player for iOS、macOS、tvOS、visionOS , based on AVPlayer and FFmpeg, support HLG、HDR10、 HDR10+、Dolby Vision、Dolby Atmos、Text/Image subtitle.
See the code
KSPlayer is a powerful media play framework for iOS, macCatalyst, macOS, tvOS, xrOS, visionOS. based on AVPlayer and FFmpeg, support HLG、HDR10、 HDR10+、Dolby Vision、Dolby Atmos、Text/Image subtitle.
English | 简体中文
If you have a commercial project that requires a custom player, or would like to receive a paid consultation, please email me.
KSPlayer 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 available under the LGPL license. You can check this post for details on the licensing options or send me an email. If I don't reply to your email, feel free to @mention me in this post.
If 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.
Differences between GPL version and LGPL version.
| Module | GPL Version | LGPL Version |
|---|---|---|
| KSPlayer | Dynamic Binary, only macOS、iSimulator、tvOS | Source code, all Apple platforms |
| KSPlayerUI | Source code, all Apple platforms | Source code, all Apple platforms |
| MPVPlayer | Source code, all Apple platforms | Source code, all Apple platforms |
To experience the paid features, you can download the app from the App Store. App Store Link Test Flight Link
This table does not list all licensed apps. If you would like to have your app listed above, please send me an email.
| App Store Link | Logo |
|---|---|
| APTV | |
| homeTV IPTV Player | |
| Interlace Player | |
| IPTV + | |
| LillyPlayer Video Player | |
| MyKroko | |
| SeeTV | |
| SenPlayer | |
| Smart IPTV | |
| Snappier IPTV | |
| StreamX | |
| SWIPTV - IPTV Smart Player | |
| UHF - Love your IPTV | |
| Zen IPTV |
dependencies: [
.package(url: "https://github.com/kingslay/KSPlayer.git", .branch("main"))
]
import KSPlayer
import KSPlayerUI
KSOptions.secondPlayerType = KSMEPlayer.self
playerView = IOSVideoPlayerView()
view.addSubview(playerView)
playerView.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
playerView.topAnchor.constraint(equalTo: view.readableContentGuide.topAnchor),
playerView.leftAnchor.constraint(equalTo: view.leftAnchor),
playerView.rightAnchor.constraint(equalTo: view.rightAnchor),
playerView.bottomAnchor.constraint(equalTo: view.bottomAnchor),
])
playerView.backBlock = { [unowned self] in
if UIApplication.shared.statusBarOrientation.isLandscape {
self.playerView.updateUI(isLandscape: false)
} else {
self.navigationController?.popViewController(animated: true)
}
}
import KSPlayer
import KSPlayerUI
playerView.set(url:URL(string: "http://baobab.wdjcdn.com/14525705791193.mp4")!)
playerView.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")))
import KSPlayer
import KSPlayerUI
let res0 = KSPlayerResourceDefinition(url: URL(string: "http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4")!,
definition: "高清")
let res1 = KSPlayerResourceDefinition(url: URL(string: "http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4")!,
definition: "标清")
let asset = KSPlayerResource(name: "Big Buck Bunny",
definitions: [res0, res1],
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"))
playerView.set(resource: asset)
import KSPlayer
import KSPlayerUI
let options = KSOptions()
options.appendHeader(["Referer":"https:www.xxx.com"])
let definition = KSPlayerResourceDefinition(url: URL(string: "http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4")!,
definition: "高清",
options: options)
let asset = KSPlayerResource(name: "Video Name",
definitions: [definition])
playerView.set(resource: asset)
import KSPlayer
import KSPlayerUI
// Listen to play time change
playerView.playTimeDidChange = { (currentTime: TimeInterval, totalTime: TimeInterval) in
print("playTimeDidChange currentTime: \(currentTime) totalTime: \(totalTime)")
}
// Delegates
public protocol PlayerControllerDelegate: class {
func playerController(state: KSPlayerState)
func playerController(currentTime: TimeInterval, totalTime: TimeInterval)
func playerController(finish error: Error?)
func playerController(maskShow: Bool)
func playerController(action: PlayerButtonType)
// `bufferedCount: 0` indicates first time loading
func playerController(bufferedCount: Int, consumeTime: TimeInterval)
}
import KSPlayer
import KSPlayerUI
class CustomVideoPlayerView: IOSVideoPlayerView {
override func updateUI(isLandscape: Bool) {
super.updateUI(isLandscape: isLandscape)
toolBar.playbackRateButton.isHidden = true
}
override func onButtonPressed(type: PlayerButtonType, button: UIButton) {
if type == .landscape {
// Your own button press behaviour here
} else {
super.onButtonPressed(type: type, button: button)
}
}
}
import KSPlayer
import KSPlayerUI
override open func player(layer: KSPlayerLayer, state: KSPlayerState) {
super.player(layer: layer, state: state)
if state == .readyToPlay, let player = layer.player {
let tracks = player.tracks(mediaType: .audio)
let track = tracks[1]
/// the name of the track
let name = track.name
/// the language of the track
let language = track.language
/// selecting the one
player.select(track: track)
}
}

Any 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. :)
Open-source projects cannot live long without your help. If you find KSPlayer to be useful, please consider supporting this project by becoming a sponsor.
Become a sponsor through GitHub Sponsors. ❤️
Your user icon or company logo shows up this with a link to your home page.
Thanks to nightfall708 for sponsoring a mac mini
Thanks to cdguy UnknownCoder807 skrew and LillyPlayer community for sponsoring a LG S95QR Sound Bar
Thanks to skrew and LillyPlayer community for sponsoring a 2022 Apple TV 4K
Thanks to bgoncal for sponsoring a HomePod mini

26 followers · starred Apr 2025
694 followers · starred Nov 2023
178 followers · starred Jun 2026
590 followers · starred Apr 2022