VDPlayer is a simple Video Player on iOS.
Support AVPlayer, VLC, IJKPlayer (under development), Multiple player kernels are available
Supports custom control panel
Modularity, on-demand integration
VDPlayer是一款简单的iOS视频播放器。
支持AVPlayer、VLC、IJKPlayer(开发中),多种内核选择
支持自定义控制面板
模块化,按需集成
- iOS 9.0+
- Swift 5
- Xcode 13.2.1
CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:
$ gem install cocoapods
To integrate VDPlayer into your Xcode project using CocoaPods, specify it in your Podfile
:
# required
pod 'VDPlayer'
# normal control pannel, optional
pod 'VDPlayer/ControllPannel'
# choose player, optional
pod 'VDPlayer/AVPlayer'
# pod 'VDPlayer/VLCPlayer'
# pod 'VDPlayer/IJKPlayer'
Then, run the following command:
$ pod install
import VDPlayer
class MyViewController: UIViewController {
private let assetURLs: [URL] = [URL(string: "https://www.apple.com/105/media/us/iphone-x/2017/01df5b43-28e4-4848-bf20-490c34a926a7/films/feature/iphone-x-feature-tpl-cc-us-20170912_1280x720h.mp4")!]
private lazy var playerControlView: VDPlayerControlView = {
let playerControlView = VDPlayerControlView()
playerControlView.setTitle("Title", coverURL: nil)
playerControlView.coverImage = UIImage(named: "cover")
return playerControlView
}()
private let width: CGFloat = UIScreen.main.bounds.size.width
private let height: CGFloat = ceil(UIScreen.main.bounds.size.width / 16.0 * 9.0)
private lazy var videoContainer: UIView = {
return UIView(frame: CGRect(x: 0, y: 0, width:width, height:height))
}()
override func viewDidLoad() {
super.viewDidLoad()
videoContainer.backgroundColor = .black
view.addSubview(videoContainer)
let playerManager = VDAVPlayerManager()
// let playerManager = VDVLCPlayerManager()
player = VDPlayer(playerControl: playerManager, container: videoContainer)
player?.controlView = playerControlView
player?.assetURLs = assetURLs
player?.orientationWillChange = { (player, isFullScreen) in
if let appDelegate = UIApplication.shared.delegate as? AppDelegate {
appDelegate.allowOrentitaionRotation = isFullScreen
}
}
player?.orientationDidChange = { [weak self](player, isFullScreen) in
self?.setNeedsStatusBarAppearanceUpdate()
if #available(iOS 11.0, *) {
self?.setNeedsUpdateOfHomeIndicatorAutoHidden()
}
}
player?.playerDidToEnd = { [weak self] (player) in
self?.player?.stop()
}
}
}
- vvard3n
VDPlayer is available under the GPLv2 license. See the LICENSE file for more info.