Logo

0x3d.Site

is designed for aggregating information.
Welcome
check repository here

PlayerView

[![CI Status](http://img.shields.io/travis/David Alejandro/PlayerView.svg?style=flat)](https://travis-ci.org/David Alejandro/PlayerView) Version License Platform

An elegant wraper API for AVPlayer to get events over Delegate so you dount need to use KVO

Installation

PlayerView is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "PlayerView"

CocoaPods

PlayerView is available through CocoaPods. To install it, simply add the following line to your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :iOS, '8.0'
use_frameworks!

pod 'PlayerView'

Carthage

Installation is also available using the dependency manager Carthage.

To integrate, add the following line to your Cartfile:

github "davidlondono/PlayerView" >= 0.2.7

Swift Package Manager

Installation can be done with the Swift Package Manager, add the following in your Package.swift :

import PackageDescription

let package = Package(
    name: "PlayerView",
    dependencies: [
        .Package(url: "https://github.com/davidlondono/PlayerView.git", majorVersion: 0),
    ]
)

Usage

To run the example project, clone the repo, and run pod install from the Example directory first.

Storyboard

Just add a view and add as a class on Identity inspector > Custom Class > Class, make sure to add Module if is imported externaly (Pod, Package manager ....)

import PlayerView
@IBOutlet var playerVideo: PlayerView!

Code

Just need to add de view as a normal View:

import PlayerView



let playerVideo = PlayerVideo()

//also could add frame:
// let playerVideo = PlayerVideo(frame: frame)
view.addSubView(playerVideo)


Control

//set aspect mode of video
//default AVLayerVideoGravityResizeAspectFill
playerVideo.fillMode = .ResizeAspect

//Set or Get the seconds of the current time of reproduction
//this will set to reproduce on 3.5 seconds
playerVideo.currentTime = 3.5

//define the time interval to get callback delegate of the current time of reproduction, default sends 60 times on 1 second
//default CMTimeMake(1, 60)
//this send the time one time per one second
playerVideo.interval = CMTimeMake(1, 1)

//set and get the speed of reproduction
//if speed is set to 0, the video will pause (same as playerVideo.pause())
//if speed is set to 1,0, the video will pause (same as playerVideo.play())
playerVideo.rate = 0.5

//play the video at rate 1.0
playerVideo.play()

// pause the video on current time
playerVideo.pause()


// stop the video on current time
playerVideo.stop()


// stop the video on current time
playerVideo.next()

//to set the url of Video
if let url = NSURL(string: "http://www.sample-videos.com/video/mp4/720/big_buck_bunny_720p_30mb.mp4") {
	playerVideo.url = url
    //or
    playerVideo.urls = [url]

    //add videos on queue
    playerVideo.addVideosOnQueue(urls: [url])
}

//Take a screenshot on time, and return time to ensure the tolerance of the image
//on 20.7 seconds
let(image1, time1) = playerVideo.screenshotTime(20.7)
//on actual time
let(image2, time2) = playerVideo.screenshotTime()


//on actual time
let image3 = playerVideo.screenshot()

//reset queue and observers
playerVideo.resetPlayer()

Delegate

you could get event data from the PlayerView, just implement the delegate all the functions are optionals

import PlayerView
import AVFoundation
	playerVideo.delegate = self

extension MyClass:PlayerViewDelegate {


	func playerVideo(player: PlayerView, statusPlayer: PlayerViewStatus, error: NSError?) {
        //got the status of the player
		//useful to know if is ready to play
		//if status is unknown then got the error
    }

	func playerVideo(player: PlayerView, statusItemPlayer: PlayerViewItemStatus, error: NSError?) {
		//some status got here first, this is the status of AVPlayerItem
		//useful to know if is ready to play
		//if status is unknown then got the error
	}

	func playerVideo(player: PlayerView, loadedTimeRanges: [PlayerviewTimeRange]) {
		//got the buffer of the video
		//to know the progress loaded

		//this will get the seconds of the end of the buffer
		//loadedTimeRanges.first!.end.seconds

	}

	func playerVideo(player: PlayerView, duration: Double) {
		//the player knows the duration of the video to reproduce on seconds
	}

	func playerVideo(player: PlayerView, currentTime: Double) {
		//executed using the playerVideo.interval
        //only executed when the is reproducing, on pause (rate == 1) this doesn't execute
		//default executed like 60 frames per seconds, so 60 times on a second
	}

	func playerVideo(player: PlayerView, rate: Float) {
		//if the speed of reproduction changed by pausing, playing or changing speed
	}

    func playerVideo(playerFinished player: PlayerView) {
        //when the video finishes the reproduction to the end
    }
}

Extra Info

<key>NSAppTransportSecurity</key>
<dict>
    <!--Include to allow all connections (DANGER)-->
    <key>NSAllowsArbitraryLoads</key>
<true/>
</dict>

Author

David Alejandro, [[email protected]](https://raw.githubusercontent.com/davidlondono/PlayerView/master/mailto:[email protected]?subject=PlayerView is Awesome)

License

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

Swift
Swift
Swift is Apple’s programming language for developing iOS, macOS, and watchOS applications. It’s fast, safe, and easy to learn, with features like type safety and memory management, enabling efficient app development.
GitHub - hirohisa/PageController: Infinite paging controller, scrolling through contents and title bar scrolls with a delay
GitHub - hirohisa/PageController: Infinite paging controller, scrolling through contents and title bar scrolls with a delay
GitHub - Quick/Nimble: A Matcher Framework for Swift and Objective-C
GitHub - Quick/Nimble: A Matcher Framework for Swift and Objective-C
GitHub - roberthein/BouncyLayout: Make. It. Bounce.
GitHub - roberthein/BouncyLayout: Make. It. Bounce.
GitHub - fjcaetano/RxWebSocket: Reactive WebSockets
GitHub - fjcaetano/RxWebSocket: Reactive WebSockets
GitHub - Kitura/Kitura: A Swift web framework and HTTP server.
GitHub - Kitura/Kitura: A Swift web framework and HTTP server.
GitHub - exyte/ProgressIndicatorView: An iOS progress indicator view library written in SwiftUI
GitHub - exyte/ProgressIndicatorView: An iOS progress indicator view library written in SwiftUI
GitHub - rolandleth/LTHRadioButton: A radio button with a pretty animation
GitHub - rolandleth/LTHRadioButton: A radio button with a pretty animation
GitHub - ashishkakkad8/AKSwiftSlideMenu: Slide Menu (Drawer) in Swift
GitHub - ashishkakkad8/AKSwiftSlideMenu: Slide Menu (Drawer) in Swift
GitHub - BastiaanJansen/toast-swift: Customizable Swift Toast view built with UIKit. 🍞
GitHub - BastiaanJansen/toast-swift: Customizable Swift Toast view built with UIKit. 🍞
GitHub - Jintin/Swimat: An Xcode formatter plug-in to format your swift code.
GitHub - Jintin/Swimat: An Xcode formatter plug-in to format your swift code.
GitHub - thoughtbot/Runes: Infix operators for monadic functions in Swift
GitHub - thoughtbot/Runes: Infix operators for monadic functions in Swift
GitHub - tid-kijyun/Kanna: Kanna(鉋) is an XML/HTML parser for Swift.
GitHub - tid-kijyun/Kanna: Kanna(鉋) is an XML/HTML parser for Swift.
GitHub - ParkGwangBeom/Windless: Windless makes it easy to implement invisible layout loading view.
GitHub - ParkGwangBeom/Windless: Windless makes it easy to implement invisible layout loading view.
GitHub - pkluz/PKHUD: A Swift based reimplementation of the Apple HUD (Volume, Ringer, Rotation,…) for iOS 8.
GitHub - pkluz/PKHUD: A Swift based reimplementation of the Apple HUD (Volume, Ringer, Rotation,…) for iOS 8.
GitHub - shtnkgm/ImageTransition: Library for smooth animation of images during transitions.
GitHub - shtnkgm/ImageTransition: Library for smooth animation of images during transitions.
GitHub - hyperoslo/Sugar: :coffee: Something sweet that goes great with your Cocoa
GitHub - hyperoslo/Sugar: :coffee: Something sweet that goes great with your Cocoa
GitHub - mukeshthawani/TriLabelView: A triangle shaped corner label view for iOS written in Swift.
GitHub - mukeshthawani/TriLabelView: A triangle shaped corner label view for iOS written in Swift.
GitHub - yonat/BatteryView: Simple battery shaped UIView
GitHub - yonat/BatteryView: Simple battery shaped UIView
GitHub - suzuki-0000/CountdownLabel: Simple countdown UILabel with morphing animation, and some useful function.
GitHub - suzuki-0000/CountdownLabel: Simple countdown UILabel with morphing animation, and some useful function.
GitHub - sindresorhus/DockProgress: Show progress in your app's Dock icon
GitHub - sindresorhus/DockProgress: Show progress in your app's Dock icon
GitHub - Yalantis/GuillotineMenu: Our Guillotine Menu Transitioning Animation implemented in Swift reminds a bit of a notorious killing machine.
GitHub - Yalantis/GuillotineMenu: Our Guillotine Menu Transitioning Animation implemented in Swift reminds a bit of a notorious killing machine.
GitHub - MrSkwiggs/Netswift: A type-safe, high-level networking solution for Swift apps
GitHub - MrSkwiggs/Netswift: A type-safe, high-level networking solution for Swift apps
GitHub - evermeer/AttributedTextView: Easiest way to create an attributed UITextView (with support for multiple links and from html)
GitHub - evermeer/AttributedTextView: Easiest way to create an attributed UITextView (with support for multiple links and from html)
GitHub - rosberry/texstyle: Format iOS attributed strings easily
GitHub - rosberry/texstyle: Format iOS attributed strings easily
GitHub - ra1028/DiffableDataSources: 💾 A library for backporting UITableView/UICollectionViewDiffableDataSource.
GitHub - ra1028/DiffableDataSources: 💾 A library for backporting UITableView/UICollectionViewDiffableDataSource.
GitHub - Mijick/PopupView: Popups presentation made simple (SwiftUI)
GitHub - Mijick/PopupView: Popups presentation made simple (SwiftUI)
GitHub - envoy/Embassy: Super lightweight async HTTP server library in pure Swift runs in iOS / MacOS / Linux
GitHub - envoy/Embassy: Super lightweight async HTTP server library in pure Swift runs in iOS / MacOS / Linux
GitHub - shima11/FlexiblePageControl: A flexible UIPageControl like Instagram.
GitHub - shima11/FlexiblePageControl: A flexible UIPageControl like Instagram.
GitHub - ChiliLabs/CHIOTPField: CHIOTPField is a set of textfields that can be used for One-time passwords, SMS codes, PIN codes, etc. Mady by @ChiliLabs - https://chililabs.io
GitHub - ChiliLabs/CHIOTPField: CHIOTPField is a set of textfields that can be used for One-time passwords, SMS codes, PIN codes, etc. Mady by @ChiliLabs - https://chililabs.io
GitHub - LeonardoCardoso/SectionedSlider: iOS 11 Control Center Slider
GitHub - LeonardoCardoso/SectionedSlider: iOS 11 Control Center Slider
Swift
More on Swift

Programming Tips & Tricks

Code smarter, not harder—insider tips and tricks for developers.

Error Solutions

Turn frustration into progress—fix errors faster than ever.

Shortcuts

The art of speed—shortcuts to supercharge your workflow.
  1. Collections 😎
  2. Frequently Asked Question's 🤯

Tools

available to use.

Made with ❤️

to provide resources in various ares.