Player is a simple iOS video player library written in Swift.
- Looking for an obj-c video player? Check out PBJVideoPlayer (obj-c).
- Looking for a Swift camera library? Check out Next Level.
Features
- plays local media or streams remote media over HTTP
- customizable UI and user interaction
- no size restrictions
- orientation change support
- simple API
Quick Start
Player is available for installation using the Cocoa dependency manager CocoaPods. Alternatively, you can simply copy the Player.swift file into your Xcode project.
Xcode 8 & Swift 3
# CocoaPods pod "Player", "~> 0.2.0" post_install do |installer| installer.pods_project.targets.each do |target| target.build_configurations.each do |config| config.build_settings['SWIFT_VERSION'] = '3.0' end end end # Carthage github "piemonte/Player" ~> 0.2.0 # SwiftPM let package = Package( dependencies: [ .Package(url: "https://github.com/piemonte/Player", majorVersion: 0) ] )
Xcode 8 & Swift 2.3 or Xcode 7
# CocoaPods pod "Player", "~> 0.1.3" # Carthage github "piemonte/Player" ~> 0.1.3
Usage
The sample project provides an example of how to integrate Player, otherwise you can follow these steps.
Allocate and add the Player controller to your view hierarchy.
self.player = Player() self.player.delegate = self self.player.view.frame = self.view.bounds self.addChildViewController(self.player) self.view.addSubview(self.player.view) self.player.didMoveToParentViewController(self)
Provide the file path to the resource you would like to play locally or stream. Ensure you're including the file extension.
let videoUrl: NSURL = // file or http url self.player.setUrl(videoUrl)
play/pause/chill
self.player.playFromBeginning()
Adjust the fill mode for the video, if needed.
self.player.fillMode = “AVLayerVideoGravityResizeAspect”
Community
- Need help? Use Stack Overflow with the tag 'player-swift'.
- Questions? Use Stack Overflow with the tag 'player-swift'.
- Found a bug? Open an issue.
- Feature idea? Open an issue.
- Want to contribute? Submit a pull request.
Resources
- Swift Evolution
- AV Foundation Programming Guide
- Next Level, rad media capture in Swift
- PBJVision, iOS camera engine, features touch-to-record video, slow motion video, and photo capture
- PBJVideoPlayer, a simple iOS video player library, written in obj-c
License
Player is available under the MIT license, see the LICENSE file for more information.
