[![CI Status](http://img.shields.io/travis/Denis Zamataev/DZVideoPlayerViewController.svg?style=flat)](https://travis-ci.org/Denis Zamataev/DZVideoPlayerViewController)
##What is it
iOS Video Player control, implemented with AVPlayer.
##Screenshots
##About
iOS Video Player control that features
- play online or offline videos
- playback controls: play, pause, toggle fullscreen, current time and left time labels
- progress indicator that shows downloaded amount and allows the user to rewind
- remote command center support
- remote control (headset) support
- background playback
- now playing info updates
- easy customization with Interface Builder
- has several styles to choose from
- default style is similiar to MPMoviePlayerViewController
This pod contains an Example project showing how to play local file and implement fullscreen expand and shrink transitioning.
You can find more example usage of this control here at OhMyTube github page.
Basic snippet to start with:
self.videoPlayerViewController.delegate = self;
self.videoPlayerViewController.videoURL = [NSURL URLWithString:@"http://distilleryvesper7-3.ak.instagram.com/fdc51d8ea73611e3a15612e740d32ce3_101.mp4"];
self.videoPlayerViewController.isBackgroundPlaybackEnabled = YES;
[self.videoPlayerViewController prepareAndPlayAutomatically:YES];
Implement DZVideoPlayerViewControllerDelegate
#pragma mark - <DZVideoPlayerViewControllerDelegate>
- (void)playerFailedToLoadAssetWithError:(NSError *)error {
}
- (void)playerDidPlay {
}
- (void)playerDidPause {
}
- (void)playerDidStop {
}
- (void)playerDidToggleFullscreen {
if (self.videoPlayerViewController.isFullscreen) {
// TODO: implement expand videoPlayerViewController to fullscreen
}
else {
// TODO: implement shrink videoPlayerViewController from fullscreen
}
}
- (void)playerDidPlayToEndTime {
}
- (void)playerFailedToPlayToEndTime {
}
- (void)playerPlaybackStalled {
}
- (void)playerGatherNowPlayingInfo:(NSMutableDictionary *)nowPlayingInfo {
// [nowPlayingInfo setObject:self.video.author forKey:MPMediaItemPropertyArtist];
[nowPlayingInfo setObject:self.video.title forKey:MPMediaItemPropertyTitle];
}
Version 0.2.* and above runs on iOS 8.0 and later. Version 0.1.* runs on iOS 7.0 and later.
There are at least 3 ways to customize this control.
- Create custom XIB and hook up the Outlets as they appear in default XIB (
DZVideoPlayerViewController.xib
). No need to hook actions, because they will be added programmatically in theDZVideoPlayerViewController
class. - Subclass
DZVideoPlayerViewController
and provide your overrides for different methods. - Manipulate views by their public properties. Set images for
playButton
andpauseButton
, change tint color onprogressIndicator
, hidefullscreenExpandButton
andfullscreenShrinkButton
if you don't want that feature.
Feel free to provide Pull Requests with custom XIBs you create. Good luck!
DZVideoPlayerViewController is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "DZVideoPlayerViewController"
Denis Zamataev, [email protected]
DZVideoPlayerViewController is available under the MIT license. See the LICENSE file for more info.