PlayerKit
PlayerKit is a modular video player system.
Motivation
Vimeo supports various types of video and playback (360 video, Chromecast, etc.). PlayerKit allows the app to create, utilize, and interact with mutliple types of players in an abstract way.
Goals
- Provide a common interface for creating different types of players that implement a common API and delegate callback strategy
- Allow players to define their capabilities using protocol conformance
- Provide an example player for playing regular videos
Example
To run the example project, clone the repo, and run pod install from the Example directory first.
Requirements
- iOS 8.0+ / tvOS 9.0+
- Swift 2.3
Installation
PlayerKit is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "PlayerKit"
Usage
Using RegularPlayer
RegularPlayer is an implementation of Player used to play regular videos.
To play a video:
let player = RegularPlayer()
view.addSubview(player.view) // RegularPlayer conforms to `ProvidesView`, so we can add its view
player.set(asset: AVURLAsset(URL: "https://example.com/video.mp4"))
player.play()
Optionally, an object can conform to PlayerDelegate to recieve updates from the player and perform actions such as UI updates.
player.delegate = delegate
Creating New Types of Players
New types of players can be constructed by creating objects that conform to the Player protocol and call the delgate methods when appropriate.
Author
Gavin King, gavin@vimeo.com
License
PlayerKit is available under the MIT license. See the LICENSE file for more info.