Giter Site home page Giter Site logo

xieyingze / zfplayer Goto Github PK

View Code? Open in Web Editor NEW

This project forked from renzifeng/zfplayer

0.0 2.0 0.0 141.46 MB

Support customization of any player SDK and control layer(支持定制任何播放器SDK和控制层)

License: MIT License

Ruby 0.51% Objective-C 99.49%

zfplayer's Introduction

ZFPlayer

中文说明

Before this, you used ZFPlayer, are you worried about encapsulating avplayer instead of using or modifying the source code to support other players, the control layer is not easy to customize, and so on? In order to solve these problems, I have wrote this player template, for player SDK you can conform the ZFPlayerMediaPlayback protocol, for control view you can conform the ZFPlayerMediaControl protocol, can custom the player and control view.

在3.X之前,是不是在烦恼播放器SDK自定义、控制层自定义等问题。作者公司多个项目分别使用不同播放器SDK以及每个项目控制层都不一样,但是为了统一管理、统一调用,我特意写了这个播放器壳子。播放器SDK只要遵守ZFPlayerMediaPlayback协议,控制层只要遵守ZFPlayerMediaControl协议,完全可以实现自定义播放器和控制层。

ZFPlayer.png

Requirements

  • iOS 7+
  • Xcode 8+

Installation

ZFPlayer is available through CocoaPods. To install it,use player template simply add the following line to your Podfile: 只有Core文件夹下代码,使用AVPlayer、IJK、KSY都需要pod单独模块,或者使用自定义播放器管理类,如需定制功能请单独联系作者。

pod 'ZFPlayer', '~> 3.0'

Use default controlView simply add the following line to your Podfile:

pod 'ZFPlayer/ControlView', '~> 3.0'

Use AVPlayer simply add the following line to your Podfile:

pod 'ZFPlayer/AVPlayer', '~> 3.0'

如果使用AVPlayer边下边播可以参考使用KTVHTTPCache

Use ijkplayer simply add the following line to your Podfile:

pod 'ZFPlayer/ijkplayer', '~> 3.0'

IJKMediaFramework SDK support cocoapods

Use KSYMediaPlayer simply add the following line to your Podfile:

pod 'ZFPlayer/KSYMediaPlayer', '~> 3.0'

KSYMediaPlayer SDK support cocoapods

Usage introduce

ZFPlayerController

Main classes, two initialization methods, normal mode initialization and list style initialization (tableView, collection)

Normal style initialization

ZFPlayerController *player = [ZFPlayerController playerWithPlayerManager:playerManager containerView:containerView];
ZFPlayerController *player = [[ZFPlayerController alloc] initwithPlayerManager:playerManager containerView:containerView];

List style initialization

ZFPlayerController *player = [ZFPlayerController playerWithScrollView:tableView playerManager:playerManager containerViewTag:containerViewTag];
ZFPlayerController *player = [ZFPlayerController alloc] initWithScrollView:tableView playerManager:playerManager containerViewTag:containerViewTag];

ZFPlayerMediaPlayback

For the playerMnager,you must conform ZFPlayerMediaPlayback protocol,custom playermanager can supports any player SDK,such as AVPlayer,MPMoviePlayerController,ijkplayer,vlc,PLPlayerKit,KSYMediaPlayerand so on,you can reference the ZFAVPlayerManagerclass.

Class<ZFPlayerMediaPlayback> *playerManager = ...;

ZFPlayerMediaControl

This class is used to display the control layer, and you must conform the ZFPlayerMediaControl protocol, you can reference the ZFPlayerControlView class.

UIView<ZFPlayerMediaControl> *controlView = ...;
player.controlView = controlView;

Usage

Normal Style

/// Your custom playerManager must conform `ZFPlayerMediaPlayback` protocol.
Class<ZFPlayerMediaPlayback> *playerManager = ...;

/// playerController
ZFPlayerController *player = [ZFPlayerController playerWithPlayerManager:playerManager containerView:self.containerView];
player.controlView = controlView<ZFPlayerMediaControl>;
playerManager.assetURL = [NSURL URLWithString:...];

List style

/// Your custom playerManager must conform `ZFPlayerMediaPlayback` protocol.
Class<ZFPlayerMediaPlayback> *playerManager = ...;

/// playerController
ZFPlayerController *player = [ZFPlayerController playerWithScrollView:tableView playerManager:playerManager containerViewTag:tag<NSInteger>];
player.controlView = controlView<ZFPlayerMediaControl>;
self.player.assetURLs = array<NSURL *>;

Rotate the video the viewController must implement

- (BOOL)shouldAutorotate {
    return player.shouldAutorotate;
}

Picture demonstration

Picture effect

Reference

Author

打赏作者

如果ZFPlayer在开发中有帮助到你、如果你需要技术支持或者你需要定制功能,都可以拼命打赏我!

支付.jpg

License

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

Question

1、demo运行不了?

答:下载后本demo可以直接编译运行,不需要pod installpod install后会出错,因为依赖其他播放器SDK较大,所以默认没有添加进来。如果你想用,那请修改一podspec文件,具体怎么修改自己一查便知,然后再pod install。

2、为啥我podfile这样写pod 'ZFPlayer', '~> 3.0'和demo里不一样,缺少好多类

答:作者秉着插件化的**来开发此开源库,首先作者的**是提供一个播放器壳子,关于播放器的核心SDK、还有控制层是完全支持自定义的,所以默认只有Core文件夹下的代码,如果你想使用作者提供的AVPlayer、IJKPlayer等都可单独在podfile写,提供的默认控制层亦是如此,具体看上边readme吧。

3、之前是免费加群,为什么现在要付费加群?

答:之前是免费群每天找作者解决问题的太多了,作者还有自己的工作要干,为了过滤一些伸手党,所以变为付费入群。群内比较活跃,作者、群友都可帮忙解决,如果你有问题都可以加群交流。如果你QQ上没有钱,那你可以扫上边的码,付款大于10元备注写上QQ号,作者看到后会加你然后拉你入群。

zfplayer's People

Contributors

renzifeng avatar bb9z avatar victorchee avatar midea-smart avatar djliu328 avatar wukwei avatar

Watchers

James Cloos avatar jay 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.