kikinteractive/VIMVideoPlayer

Name: VIMVideoPlayer

Owner: Kik Interactive

Description: A simple wrapper around the AVPlayer and AVPlayerLayer classes

Forked from: vimeo/VIMVideoPlayer

Created: 2016-07-14 11:24:59.0

Updated: 2017-05-21 17:35:01.0

Pushed: 2016-07-17 07:45:28.0

Homepage:

Size: 25534

Language: Objective-C

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

VIMVideoPlayer

VIMVideoPlayer is a simple wrapper around the AVPlayer and AVPlayerLayer classes.

Setup

Add the VIMVideoPlayerView and VIMVideoPlayer classes to your project.

Do this by including this repo as a git submodule or by using cocoapods:

d this to your podfile
et 'MyTarget' do
od 'VIMVideoPlayer', ?{CURRENT_POD_VERSION}?

Usage

Create a new VIMVideoPlayerView instance or set up an @IBOutlet:

utlet weak var videoPlayerView: VIMVideoPlayerView!



ride func viewDidLoad()

// Configure the player as needed
self.videoPlayerView.player.looping = true
self.videoPlayerView.player.disableAirplay()
self.videoPlayerView.setVideoFillMode(AVLayerVideoGravityResizeAspectFill)

self.videoPlayerView.delegate = self

Play a video:

sing an NSURL

et path = NSBundle.mainBundle().pathForResource("waterfall", ofType: "mp4")

self.videoPlayerView.player.setURL(NSURL(fileURLWithPath: path))



// Video file not found!



te: This must be a URL to an actual video resource (e.g. http://website.com/video.mp4 or .m3u8 etc.),
 cannot be a URL to a web page (e.g. https://vimeo.com/67069182),
e below for info on using VIMVideoPlayer to play Vimeo videos.


sing an AVPlayerItem

playerItem: AVPlayerItem = ...
.videoPlayerView.player.setPlayerItem(playerItem)
.videoPlayerView.player.play()

r using an AVAsset

asset: AVAsset = ...
.videoPlayerView.player.setAsset(asset)
.videoPlayerView.player.play()

Optionally implement the VIMVideoPlayerViewDelegate protocol methods:

ocol VIMVideoPlayerViewDelegate 
 
optional func videoPlayerViewIsReadyToPlayVideo(videoPlayerView: VIMVideoPlayerView!)
optional func videoPlayerViewDidReachEnd(videoPlayerView: VIMVideoPlayerView!)
optional func videoPlayerView(videoPlayerView: VIMVideoPlayerView!, timeDidChange cmTime: CMTime)
optional func videoPlayerView(videoPlayerView: VIMVideoPlayerView!, loadedTimeRangeDidChange duration: Float)
optional func videoPlayerViewPlaybackBufferEmpty(videoPlayerView: VIMVideoPlayerView!)
optional func videoPlayerViewPlaybackLikelyToKeepUp(videoPlayerView: VIMVideoPlayerView!)
optional func videoPlayerView(videoPlayerView: VIMVideoPlayerView!, didFailWithError error: NSError!)

See VIMVideoPlayer.h for additional configuration options.

Playing Vimeo Videos

Vimeo Pro members can access playback URLs for Vimeo videos using the Vimeo API. Playback URLs are only included in the response object if the requesting account is a Vimeo Pro account.

If you have a Vimeo Pro account, when you make a request to the Vimeo API for a video object the response object will contain a list of video files. These represent the various resolution video files available for this particular video. Each has a link. You can use the string value keyed to link to create an NSURL. You can pass this NSURL to VIMVideoPlayer for playback.

Check out this Stack Overflow question for additional info.

You can use the Vimeo iOS SDK to interact with the Vimeo API.

For full documentation on the Vimeo API go here.

Found an Issue?

Please file it in the git issue tracker.

Want to Contribute?

If you'd like to contribute, please follow our guidelines found in CONTRIBUTING.md.

License

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

Questions?

Tweet at us here: @vimeoapi.

Post on Stackoverflow with the tag vimeo-ios.

Get in touch here.

Interested in working at Vimeo? We're hiring!


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.