Skip to content

Latest commit

 

History

History
159 lines (115 loc) · 5.55 KB

README.md

File metadata and controls

159 lines (115 loc) · 5.55 KB

ZFPlayer

A simple video player for iOS, based on AVPlayer. Support the vertical, horizontal screen(lock screen direction). Support adjust volume, brigtness and video progress.

中文说明  ZFPlayer剖析

Features

  • Support for horizontal and vertical play mode, in horizontal mode can also lock the screen direction
  • Support play with online URL and local file
  • Support in TableviewCell playing video
  • Adjust brightness by slide vertical at left side of screen
  • Adjust volume by slide vertical at right side of screen
  • Slide horizontal to fast forward and rewind
  • Full screen mode to drag the slider control progress, display video preview
  • Download
  • Toggle video resolution

Requirements

  • iOS 8+
  • Xcode 8+

Statistics

What App using ZFPlayer, and on AppStore, please tell me, help me to statistics.

Component

Installation

CocoaPods

pod 'ZFPlayer'

Then, run the following command:

$ pod install

Usage (Support IB and code)

Set status bar color

Please add the "View controller-based status bar appearance" field in info.plist and change it to NO

IB usage

Direct drag IB to UIView, the aspect ratio for the 16:9 constraint (priority to 750, lower than the 1000 line), the code section only needs to achieve

self.playerView.videoURL = self.videoURL;
// Back button event
__weak typeof(self) weakSelf = self;
self.playerView.goBackBlock = ^{
	[weakSelf.navigationController popViewControllerAnimated:YES];
};
Code implementation (Masonry) usage
self.playerView = [[ZFPlayerView alloc] init];
[self.view addSubview:self.playerView];
[self.playerView mas_makeConstraints:^(MASConstraintMaker *make) {
 	make.top.equalTo(self.view).offset(20);
 	make.left.right.equalTo(self.view);
	// Note here, the aspect ratio 16:9 priority is lower than 1000 on the line, because the 4S iPhone aspect ratio is not 16:9
    make.height.equalTo(self.playerView.mas_width).multipliedBy(9.0f/16.0f).with.priority(750);
}];
self.playerView.videoURL = self.videoURL;
// Back button event
__weak typeof(self) weakSelf = self;
self.playerView.goBackBlock = ^{
	[weakSelf.navigationController popViewControllerAnimated:YES];
};
Set the fill mode for the video
 // you can set the fill mode of the video, the default settings (ZFPlayerLayerGravityResizeAspect: wait for a proportional fill, until a dimension reaches the area boundary).
 self.playerView.playerLayerGravity = ZFPlayerLayerGravityResizeAspect;
Is there a breakpoint download function
 // Default is to close the breakpoint download function, such as the need for this feature set here
 self.playerView.hasDownload = YES;
Play video from XX seconds
// Play video from XX seconds
self.playerView.seekTime = 15;
Automatically play the video,not automatically play by default
// Automatically play the video
[self.playerView autoPlayTheVideo];
Set the video placeholderImage (need to set the video URL before)
// Here is the name of the picture
self.playerView.placeholderImageName = @"...";

Picture demonstration

Picture effect

Sound adjustment demonstration

Brightness adjustment demonstration

Progress adjustment demonstration

Reference link:


Swift Player:

See the BMPlayer please, thanks the BMPlayer author's open source.

Swift project ZFZhiHuDaily:

I recently written ZFZhiHuDaily.


Contact me

License

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