Skip to content

piemonte/Player

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ad1136b · Jun 20, 2018
Jun 20, 2018
Jun 20, 2018
Jun 20, 2018
Oct 8, 2017
Jun 20, 2018
Aug 9, 2016
Oct 9, 2017
Nov 15, 2017
Nov 27, 2014
Dec 14, 2015
Mar 5, 2015
Jun 20, 2018
Jun 20, 2018
Feb 3, 2017

Repository files navigation

Player

Build Status Platform Pod Version Carthage compatible Swift Version GitHub license

Overview

Player is a simple cross-platform video player library written in Swift.

⚠️ Warning: version 0.9 has breaking API changes. ⚠️

Looking for...

Features

  • plays local media or streams remote media over HTTP
  • customizable UI and user interaction
  • no size restrictions
  • orientation change support
  • simple API

Future Features

  • use AVPlayerViewController for iOS/tvOS platforms

Installation

Player is available for installation using the Cocoa dependency manager CocoaPods & Carthage. Alternatively, you can simply copy the Player.swift file into your Xcode project.

Using CocoaPods

pod "Player"

Need Swift 3? Use release 0.7.0

pod "Player", "~> 0.7.0"

Using Carthage

github "piemonte/Player"

Quick Start

The sample projects provide an example of how to integrate Player, otherwise you can follow these steps.

Create and add the Player to your view controller.

 let player = Player()
 player.playerDelegate = self
 player.playbackDelegate = self
 player.view.frame = view.bounds
 player.add(to: 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: URL = // file or http url
player.url = videoUrl

play/pause/chill

player.playFromBeginning()

Adjust the fill mode for the video, if needed.

 player.fillMode = .resizeAspectFit

The fill mode can be set to the following values:

.resizeAspectFit (default) Player

.resizeAspectFill Player

.resizeStretch (aka please don't. I mean look at the poor thing) Player

Display video playback progress, if desired. Note, all delegate methods are optional.

extension ViewController: PlayerPlaybackDelegate {

	public func playerPlaybackWillStartFromBeginning(player: Player) {}
    
    public func playerPlaybackDidEnd(player: Player) {}
    
    public func playerCurrentTimeDidChange(player: Player) {
        let currentProgress = Float(player.currentTime / player.maximumDuration)
        progressView.setProgress(currentProgress, animated: true)
    }
    
    public func playerPlaybackWillLoop(player: Player) {
        progressView.setProgress(0.0, animated: false)
    }
    
}

macOS

On the macOS platform, the player can display media controls.

player.controlsStyle = .floating

The controls' style can be set to the following:

.none

.inline (default) Player

.minimal Player

.floating Player

Documentation

You can find the docs here. Documentation is generated with jazzy and hosted on GitHub-Pages.

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. Do it yourself & PR when done 😅.
  • Want to contribute? Submit a pull request.

Used In

  • Cards — Awesome iOS 11 appstore cards written in swift 4.

Resources

License

Player is available under the MIT license, see the LICENSE file for more information.