No description, website, or topics provided.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Example
SwiftyPlayer
.gitignore
.swift-version
.travis.yml
LICENSE
README.md
SwiftyPlayer.podspec
_Pods.xcodeproj

README.md

SwiftyPlayer

Platform Language License pod 1.3.1 Swift 4

TheMindStudios

A comfortable player used to manage the playback and timing of a media asset. Swift Player based on the AVPlayer and give to you a really comfortable interface for general player, timing and buffering state observations. You can easy create custom interface to control the player’s transport behavior such as its ability to play, pause, change the playback rate, and seek to various points in time within the media’s timeline. And you can also set AVPlayerViewControllerPlayer as default interface. You can use an SwiftyPlayer to play local and remote file-based media, such as QuickTime movies and MP3 audio files, as well as audiovisual media served using HTTP Live Streaming.

Features

  • Easy to use
  • Support all actions for player's control
  • General State Observations through methods of delegate
  • Timed State Observations through methods of delegate
  • Buffering State Observations through methods of delegate
  • Using all power AVPlayer
  • Ability to set AVPlayerViewController as default interface

Usage

  1. Import SwiftyPlayer module to your ViewController class
import SwiftyPlayer
  1. Instantiate and set playerLayer and videoGravity
let player = Player()
player.setPlayer(to: playerLayerView.playerLayer)
playerLayerView.playerLayer.videoGravity = .resizeAspect
  1. Set delegate and bufferingDelegate if need
player.delegate = self
player.bufferingDelegate = self
  1. Set the URL or AVPlayerItem or AVAsset to player
player.URL = playerURL
//or 
player.playerItem = playerItem
//or
player.asset = playerAsset
  1. Create a custom interface with controls and set relevant commands to SwiftyPlayer
@IBAction func play() {
    player.play()
}

@IBAction func pause() {
    player.pause()
}

@IBAction func didSlide(_ sender: UISlider) {
    player.seek(to: sender.value, shouldAutoPlay: true)
}
  1. Add a handler for PlayerDelegate if need
func player(_ player: Player, didUpdateTime timePlayed: Double) {
	// to handle timePlayed
	print(timePlayed)
}

func player(_ player: Player, didChangePlaybackState playbackState: PlaybackState) {
	// to handle playbackState
	print(playbackState)
}

func playerDidPlayToEnd(_ player: Player) {
	// to handle player's event
}

func playerDidUpdatePlayerItem(_ player: Player) {
	// to handle player's item
}
  1. Add a handler for PlayerBufferingDelegate if need
func player(_ player: Player, didChangeBufferingState bufferingState: BufferingState) {
	// to handle bufferingState
	print(bufferingState)
}

func playerDidUpdateBufferingProgress(_ player: Player) {
	// to handle bufferingProgress
	print(player.bufferingProgress)
}

Installation with CocoaPods

To install via CocoaPods add this lines to your Podfile. You need CocoaPods v. 1.3.1 or higher

$ gem install cocoapods

Podfile

To integrate SwiftyPlayer into your Xcode project using CocoaPods, specify it in your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
use_frameworks!

target 'TargetName' do
  pod 'SwiftyPlayer', '~> 1.0'
end

Then, run the following command:

$ pod install

License

SwiftyPlayer is available under the MIT license. See the LICENSE file for more info.