VGPlayer
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
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
- 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
Custom player view
- Subclass VGPlayerView
- Alloc VGPlaye when set up
AutoLayout use SnapKit
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
-
Usage:
Background playback
- Project setting
- AppDelegate settings
- VGPlayer Background playback mode to proceed
Delegate methods optional
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
- https://techblog.toutiao.com/2017/03/28/fullscreen/
- https://developer.apple.com/library/content/qa/qa1668/_index.html
- https://developer.apple.com/documentation/avfoundation
- https://stackoverflow.com/questions/808503/uibutton-making-the-hit-area-larger-than-the-default-hit-area/13977921
- https://gist.github.com/onevcat/2d1ceff1c657591eebde
- Media Cache VIMediaCache
- https://mp.weixin.qq.com/s/v1sw_Sb8oKeZ8sWyjBUXGA
License
MIT