All Projects → VeinGuo → Vgplayer

VeinGuo / Vgplayer

Licence: mit
📺 A simple iOS video player by Vein.

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Vgplayer

Fwplayer
A video player SDK for iOS, it is based on AVPlayer. https://se.linkedin.com/in/foks-huiwang, https://fokswang.wixsite.com/home
Stars: ✭ 321 (-16.19%)
Mutual labels:  player, avplayer, cocoapods, carthage
Bmplayer
A video player for iOS, based on AVPlayer, support the horizontal, vertical screen. support adjust volume, brightness and seek by slide, support subtitles.
Stars: ✭ 1,736 (+353.26%)
Mutual labels:  video-player, avplayer, carthage
Youtubekit
YoutubeKit is a video player that fully supports Youtube IFrame API and YoutubeDataAPI for easily create a Youtube app
Stars: ✭ 484 (+26.37%)
Mutual labels:  video-player, cocoapods, carthage
Kjplayerdemo
视频播放壳子:动态切换内核,支持边下边播边缓存的播放器方案,视频支持格式:mp4、m3u8、wav、avi,音频支持格式:midi、mp3
Stars: ✭ 60 (-84.33%)
Mutual labels:  player, video-player, avplayer
Swifty360player
iOS 360-degree video player streaming from an AVPlayer.
Stars: ✭ 118 (-69.19%)
Mutual labels:  avplayer, cocoapods, carthage
Swiftysound
SwiftySound is a simple library that lets you play sounds with a single line of code.
Stars: ✭ 995 (+159.79%)
Mutual labels:  player, cocoapods, carthage
React Native Ezplayer
EZPlayer component for react-native apps
Stars: ✭ 47 (-87.73%)
Mutual labels:  player, avplayer, carthage
Swifterswift
A handy collection of more than 500 native Swift extensions to boost your productivity.
Stars: ✭ 10,706 (+2695.3%)
Mutual labels:  open-source, cocoapods, carthage
Fradioplayer
A simple radio player framework for iOS, macOS, tvOS.
Stars: ✭ 183 (-52.22%)
Mutual labels:  player, avplayer, cocoapods
Ktvhttpcache
A powerful media cache framework.
Stars: ✭ 2,113 (+451.7%)
Mutual labels:  player, cocoapods, carthage
Sjvideoplayer
iOS VideoPlayer MediaPlayer video player media player 短视频播放器 可接入 ijkplayer aliplayer alivodplayer plplayer
Stars: ✭ 2,066 (+439.43%)
Mutual labels:  player, video-player, avplayer
Mobileplayer Ios
📱 🎥 A powerful and completely customizable media player for iOS
Stars: ✭ 2,931 (+665.27%)
Mutual labels:  player, video-player, cocoapods
Ezplayer
基于AVPlayer封装的视频播放器,功能丰富,快速集成,可定制性强,支持react-native。
Stars: ✭ 377 (-1.57%)
Mutual labels:  player, avplayer, carthage
Tbuiautotest
Generating UI test label automatically for iOS.
Stars: ✭ 333 (-13.05%)
Mutual labels:  cocoapods, carthage
Rxappstate
RxSwift extensions for UIApplicationDelegate methods to observe changes in your app's state
Stars: ✭ 328 (-14.36%)
Mutual labels:  cocoapods, carthage
Persei
Animated top menu for UITableView / UICollectionView / UIScrollView written in Swift
Stars: ✭ 3,395 (+786.42%)
Mutual labels:  cocoapods, carthage
Videojs Resolution Switcher
Resolution switcher adds the ability to select the video quality in video.js player.
Stars: ✭ 375 (-2.09%)
Mutual labels:  player, video-player
Maplebacon
🍁🥓 Lightweight and fast Swift library for image downloading, caching and transformations
Stars: ✭ 322 (-15.93%)
Mutual labels:  cocoapods, carthage
Sclalertview
Beautiful animated Alert View. Written in Objective-C
Stars: ✭ 3,426 (+794.52%)
Mutual labels:  cocoapods, carthage
Circularprogress
Circular progress indicator for your macOS app
Stars: ✭ 366 (-4.44%)
Mutual labels:  cocoapods, carthage

VGPlayer

Swift License MIT Platform Cocoapod Carthage compatible

Banners

Swift developed based on AVPlayer iOS player,support horizontal gestures Fast forward, pause, vertical gestures Support brightness and volume adjustment, support full screen, adaptive screen rotation direction.

中文介绍

Demonstration

demo1

demo2

demo3

Requirements

  • Swift 3
  • iOS 8.0+
  • Xcode 8

Features

  • [x] Support play local and network
  • [x] Background playback mode.
  • [x] Gesture Adjusts the volume and brightness as well as fast forward and backward.
  • [x] Support full screen
  • [x] Slide fast forward and backward
  • [x] Lock screen can also be rotated full screen
  • [x] Support replay media
  • [x] Support custom player view
  • [x] Support subtitle (format: srt & ass)
  • [x] Media Cache

TODO

  • [ ] Virtual reality

Update

  • 2017-6-13 v0.0.1
  • 2017-6-17 Support subtitle (format: srt & ass) v0.0.2
  • 2017-7-1 Media Cache v0.1.0
  • 2017-7-3 fix some compiler warning, support carthage. v0.1.1
  • 2017-7-11 fix all compiler warning. v0.1.2
  • 2017-7-16 fix URL resolution error. v0.1.3
  • 2017-8-10
    • fix iOS 9 can't play
    • fix exit Full Screen frame error
    • player slider thumb add highted
    • example add demo
  • 2017-9-6 v0.1.5
    • fix url param praser
    • fix pause play error
  • 2017-9-21 v0.2.0
    • clean code
    • convert to swift4

Usage

Play Video

// init 
self.player = VGPlayer(URL: url)
// or
self.player.replaceVideo(url)

Custom player view

  • Subclass VGPlayerView
  • Alloc VGPlaye when set up
let playeView = VGCustomPlayerView()
self.player = VGPlayer(playerView: playeView)

// customPlayerView
class VGCustomPlayerView: VGPlayerView {
    var playRate: Float = 1.0
    var rateButton = UIButton(type: .custom)
    
    override func configurationUI() {
        super.configurationUI()
        self.topView.backgroundColor = #colorLiteral(red: 0, green: 0, blue: 0, alpha: 0.09701412671)
        self.bottomView.backgroundColor = #colorLiteral(red: 0, green: 0, blue: 0, alpha: 0.09701412671)
        self.topView.addSubview(rateButton)
        rateButton.snp.makeConstraints { (make) in
            make.left.equalTo(titleLabel.snp.right).offset(10)
            make.centerY.equalTo(closeButton)
        }
        rateButton.tintColor = #colorLiteral(red: 1, green: 1, blue: 1, alpha: 1)
        rateButton.setTitle("x1.0", for: .normal)
        rateButton.titleLabel?.font   = UIFont.boldSystemFont(ofSize: 12.0)
        rateButton.addTarget(self, action: #selector(onRateButton), for: .touchUpInside)
        rateButton.isHidden = false
    }

// .....more

AutoLayout use SnapKit

			self.player.replaceVideo(url)
        view.addSubview(self.player.displayView)
        
        self.player.play()
        self.player.backgroundMode = .proceed
        self.player.delegate = self
        self.player.displayView.delegate = self
        self.player.displayView.titleLabel.text = "China NO.1"
        self.player.displayView.snp.makeConstraints { [weak self] (make) in
            guard let strongSelf = self else { return }
            make.top.left.right.equalToSuperview()
            make.height.equalTo(strongSelf.view.snp.width).multipliedBy(3.0/4.0) // you can 9.0/16.0
        }

Media Cache (Reference: VIMediaCache)

  • VGPlayer Cache Reference VIMediaCache implementation.

  • AVAssetResourceLoader to control AVPlayer download media data.

  • Cache usage range request data, you can cancel the download, fragment cache

  • If you use Simulator debugging, you can view the VGPlayer cache file in the Simulator cache test

  • Usage:

// Settings maxCacheSize
VGPlayerCacheManager.shared.cacheConfig.maxCacheSize = 160000000

// Setting maxCacheAge   default one weak
VGPlayerCacheManager.shared.cacheConfig.maxCacheAge = 60 * 60 * 24 * 7

// clean all cache
VGPlayerCacheManager.shared.cleanAllCache()

// clean old disk cache. 
// This is an async operation.
VGPlayerCacheManager.shared.cleanOldFiles { }

Background playback

  • Project setting

backgroundModes

  • AppDelegate settings
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.
        do
        {
            try AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayback)
        }
        catch let error as NSError
        {
            print(error)
        }
        return true
    }
  • VGPlayer Background playback mode to proceed
self.player.backgroundMode = .proceed

Delegate methods optional

// player delegate
    // play state
    func vgPlayer(_ player: VGPlayer, stateDidChange state: VGPlayerState)
    // playe Duration
    func vgPlayer(_ player: VGPlayer, playerDurationDidChange currentDuration: TimeInterval, totalDuration: TimeInterval)
    // buffer state
    func vgPlayer(_ player: VGPlayer, bufferStateDidChange state: VGPlayerBufferstate)
    // buffered Duration
    func vgPlayer(_ player: VGPlayer, bufferedDidChange bufferedDuration: TimeInterval, totalDuration: TimeInterval)
    // play error
    func vgPlayer(_ player: VGPlayer, playerFailed error: VGPlayerError)
    
    
// player view delegate
    /// fullscreen
    func vgPlayerView(_ playerView: VGPlayerView, willFullscreen fullscreen: Bool)
    /// close play view
    func vgPlayerView(didTappedClose playerView: VGPlayerView)
    /// displaye control
    func vgPlayerView(didDisplayControl playerView: VGPlayerView)
    

Installation

  • Download VGPlayer. Move to your project.

Cocoapods

Swift 4

use_frameworks!
pod 'VGPlayer', '~> 0.2.0'

Swift 3

use_frameworks!
pod 'VGPlayer', '~> 0.1.5'

Carthage

github "VeinGuo/VGPlayer"

Run carthage update. to build the framework and drag the built VGPlayer.framework and SnapKit.framework into your Xcode project.

Reference

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].