Skip to content

VDPlayer is a customizable Video Player on iOS. Support AVPlayer, VLC, IJKPlayer (under development) , Supports custom control panel, Modularity, on-demand integration

License

Notifications You must be signed in to change notification settings

vvard3n/VDPlayer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

65 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

VDPlayer

CI Status Version License Platform

VDPlayer is a simple Video Player on iOS.
⚠️This is an early version, not yet fully functional.⚠️
Support AVPlayer, VLC, IJKPlayer (under development), Multiple player kernels are available
Supports custom control panel
Modularity, on-demand integration

VDPlayer是一款简单的iOS视频播放器。
⚠️这是一个早期版本,功能尚不完整。⚠️
支持AVPlayer、VLC、IJKPlayer(开发中),多种内核选择
支持自定义控制面板
模块化,按需集成

Requirements

  • iOS 9.0+

Build On

  • Swift 5
  • Xcode 13.2.1

Installation

CocoaPods

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

Usage

Quick Start

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()
        }
    }

}

Author

  • vvard3n

License

VDPlayer is available under the GPLv2 license. See the LICENSE file for more info.

About

VDPlayer is a customizable Video Player on iOS. Support AVPlayer, VLC, IJKPlayer (under development) , Supports custom control panel, Modularity, on-demand integration

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published