GithubHelp home page GithubHelp logo

twksky / zfplayer Goto Github PK

View Code? Open in Web Editor NEW

This project forked from renzifeng/zfplayer

1.0 2.0 0.0 52.86 MB

基于AVPlayer,支持横屏、竖屏(全屏播放还可锁定屏幕方向),上下滑动调节音量、屏幕亮度,左右滑动调节播放进度。 Based on AVPlayer, support for the horizontal screen, vertical screen (full screen playback can also lock the screen direction), the upper and lower slide to adjust the volume, the screen brightness, or so slide to adjust the playback progress

License: MIT License

Objective-C 99.52% Ruby 0.48%

zfplayer's Introduction

ZFPlayer

功能

  • 支持横、竖屏切换,在全屏播放模式下还可以锁定屏幕方向
  • 支持本地视频、网络视频播放
  • 支持在TableviewCell播放视频
  • 左侧1/2位置上下滑动调节屏幕亮度(模拟器调不了亮度,请在真机调试)
  • 右侧1/2位置上下滑动调节音量(模拟器调不了音量,请在真机调试)
  • 左右滑动调节播放进度
  • 断点下载功能

安装

CocoaPods

pod 'ZFPlayer'

Then, run the following command:

$ pod install

下载运行Demo报错的,请确认安装cocopods环境,pod install,然后打开“Player.xcworkspace”

使用 (支持IB和代码)

设置状态栏颜色

请在info.plist中增加"View controller-based status bar appearance"字段,并改为NO

IB用法

直接拖UIView到IB上,宽高比为约束为16:9(优先级改为750,比1000低就行),代码部分只需要实现

self.playerView.videoURL = self.videoURL;
// 返回按钮事件
__weak typeof(self) weakSelf = self;
self.playerView.goBackBlock = ^{
	[weakSelf.navigationController popViewControllerAnimated:YES];
};
代码实现(Masonry)用法
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);
	// 注意此处,宽高比16:9优先级比1000低就行,在因为iPhone 4S宽高比不是16:9
	make.height.equalTo(self.playerView.mas_width).multipliedBy(9.0f/16.0f).with.priority(750);
}];
self.playerView.videoURL = self.videoURL;
// 返回按钮事件
__weak typeof(self) weakSelf = self;
self.playerView.goBackBlock = ^{
	[weakSelf.navigationController popViewControllerAnimated:YES];
};
设置视频的填充模式(可选设置)
 // (可选设置)可以设置视频的填充模式,内部设置默认(ZFPlayerLayerGravityResizeAspect:等比例填充,直到一个维度到达区域边界)
 self.playerView.playerLayerGravity = ZFPlayerLayerGravityResizeAspect;
是否有断点下载功能(可选设置)
 // 默认是关闭断点下载功能,如需要此功能设置这里
 self.playerView.hasDownload = YES;
从xx秒开始播放视频(可选设置)
// 如果想从xx秒开始播放视频
self.playerView.seekTime = 15;

已知bug:

  1. 下载视频有一定的崩溃率,目前还没有找到原因,大家一块帮忙解决一下呀,谢谢!

图片效果演示

图片效果演示

声音调节演示

亮度调节演示

参考资料:


ps:本人最近swift做的项目,喜欢的朋友们看看吧:

知乎日报Swift

有技术问题也可以加我的iOS技术群,互相讨论,群号为:213376937


期待

  • 如果在使用过程中遇到BUG,或发现功能不够用,希望你能Issues我,或者微博联系我:@任子丰
  • 如果觉得好用请Star!

zfplayer's People

Contributors

renzifeng avatar bb9z avatar wukwei avatar

Stargazers

谭文凯 avatar

Watchers

James Cloos avatar 谭文凯 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.