Support customization of any player SDK and control layer

Last update: Jun 26, 2022

ZFPlayer

中文说明

ZFPlayer 4.x迁移指南

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.

ZFPlayer思维导图

🔨 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:

pod 'ZFPlayer', '~> 4.0'

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

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

Use AVPlayer simply add the following line to your Podfile:

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

Use ijkplayer simply add the following line to your Podfile:

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

IJKMediaFramework SDK support cocoapods

边下边播可以参考使用KTVHTTPCache

🐒 Usage

ZFPlayerController

Main classes,normal style initialization and list style initialization (tableView, collection,scrollView)

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];
ZFPlayerController *player = [ZFPlayerController playerWithScrollView:scrollView playerManager:playerManager containerView:containerView];
ZFPlayerController *player = [ZFPlayerController alloc] initWithScrollView:tableView playerManager:playerManager containerView:containerView];

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
    *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
    *controlView = ...;
player.controlView = controlView;
  

📷 Screenshots

Picture effect

👨🏻‍💻 Author

❤️ Contributors

林界:https://github.com/GeekLee609

🙋🏻‍♂️🙋🏻‍♀️寻求志同道合的小伙伴

  • 现寻求志同道合的小伙伴一起维护此框架,有兴趣的小伙伴可以发邮件给我,非常感谢!
  • 如果一切OK,我将开放框架维护权限(github、pod等)

💰 打赏作者

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

支付.jpg

👮🏻 License

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

GitHub

https://github.com/renzifeng/ZFPlayer
Comments
  • 1. Xcode9,iOS11 bug

    播放器显示:“加载失败,点击重试” 错误日志: CredStore - performQuery - Error copying matching creds. Error=-25300, query={ class = inet; "m_Limit" = "m_LimitAll"; "r_Attributes" = 1; sync = syna; } 初次进入,无法播放。

    Reviewed by ChildrenGreens at 2017-09-21 14:15
  • 2. 为什么不能全屏?

    _playerView = [[ZFPlayerView alloc] initWithFrame:CGRectMake(0, 0, kScreen_Width, kScreen_Width/2)];

    self.playerView.videoURL = [NSURL URLWithString:@"http://wvideo.spriteapp.cn/video/2016/0328/56f8ec01d9bfe_wpd.mp4"];
    
    //(可选设置)可以设置视频的填充模式,内部设置默认(ZFPlayerLayerGravityResizeAspect:等比例填充,直到一个维度到达区域边界)
    self.playerView.playerLayerGravity = ZFPlayerLayerGravityResizeAspect;
    // 是否自动播放,默认不自动播放
    //    [self.playerView autoPlayTheVideo];
    
    
    // 如果想从xx秒开始播放视频
    self.playerView.seekTime = 0;
    
    __weak typeof(self) weakSelf = self;
    self.playerView.goBackBlock = ^{
        [weakSelf.navigationController popViewControllerAnimated:YES];
    };
    [self.mScrollView addSubview:_playerView];
    
    Reviewed by NSMichael at 2016-08-04 13:49
  • 3. ijkplayer下的问题

    您好 使用ijkplayer控制台会报,是不是 ijk库的版本问题? <<<< AVOutputDeviceDiscoverySession (FigRouteDiscoverer) >>>> -[AVFigRouteDiscovererOutputDeviceDiscoverySessionImpl outputDeviceDiscoverySessionDidChangeDiscoveryMode:]: Setting device discovery mode to DiscoveryMode_None

    Reviewed by Yuan920 at 2019-11-08 04:58
  • 4. iOS 15 beta 4,横屏出现问题,没有正确渲染布局,且无法切回竖屏页面

    iOS 15 beta 4,横屏出现问题,没有正确渲染布局,且无法切回竖屏页面,有几率闪退,模拟器和真机均有此情况,不确定是否是beta版的bug,不知道作者会不会适配iOS 15 beta? Xcode版本:13 beta 4 真机版本:iPhone 6s plus,iOS 15 beta 4

    用作者的demo运行在模拟器和真机上也是一样的问题。 全屏后是下面这个现象,大概率1、2秒钟会变成正常横屏画面: Simulator Screen Shot - iPhone 12 Pro Max - 2021-08-10 at 15 53 20 退出全屏后就是下面这个现象,再也无法回到正常页面,页面也无法操作,而且过一会儿可能会闪退: Simulator Screen Shot - iPhone 12 Pro Max - 2021-08-10 at 15 53 30

    Reviewed by NarutoL at 2021-08-10 08:07
  • 5. ZFPlayerController 旋转屏幕不走完成回调

    错误源码出处如下: /// Enter the fullScreen while the ZFFullScreenMode is ZFFullScreenModeLandscape.

    • (void)rotateToOrientation:(UIInterfaceOrientation)orientation animated:(BOOL)animated completion:(void(^ __nullable)(void))completion { self.orientationObserver.fullScreenMode = ZFFullScreenModeLandscape; [self.orientationObserver rotateToOrientation:orientation animated:animated completion:nil]; }
    Reviewed by DoubleYao0112 at 2022-06-07 09:11
  • 6. addPlayerViewToSmallFloatView 开启小窗播放 播放样式错乱问题

    当调用 addPlayerViewToSmallFloatView 开启小窗播放 在部分系(比如:iOS15.4,iPhoneXR) 小窗布局错乱(首次开启小窗错乱,再次进入却正常) 原因分析: self.currentPlayerManager.view.autoresizingMask 以父视图为基础进行动态响应,而在 addPlayerViewToSmallFloatView 和 addPlayerViewToContainerView 等方法中将当前视频播放对象(self.currentPlayerManager.view)分别添加到 self.smallFloatView、self.containerView 等视图中没有移除之前的添加 解决方法: 添加(即调用:addSubview:self.currentPlayerManager.view)之前先移除 [self.currentPlayerManager.view removeFromSuperview]

    Reviewed by yimiSun at 2022-04-22 08:17
iOS video player for trailer. You can customize layout for the control panel. Support PiP and DRM.

iOS video player for trailer. You can customize layout for the control panel. Support PiP and DRM.

Jan 31, 2022
Musical Player - A Simple Musical Player For iOS

Musical_Player The app is a musical player. It was written as an task for a mobi

Jan 6, 2022
BMPlayer - A video player for iOS, based on AVPlayer, support the horizontal, vertical screen
BMPlayer - A video player for iOS, based on AVPlayer, support the horizontal, vertical screen

A video player for iOS, based on AVPlayer, support the horizontal, vertical screen. support adjust volume, brightness and seek by slide, support subtitles.

Jun 22, 2022
MMPlayerView - Custom AVPlayerLayer on view and transition player with good effect like youtube and facebook
MMPlayerView - Custom AVPlayerLayer on view and transition player with good effect like youtube and facebook

MMPlayerView Demo-Swift List / Shrink / Transition / Landscape MMPlayerLayer ex. use when change player view frequently like tableView / collectionVie

May 30, 2022
Yattee: video player for Invidious and Piped built for iOS 15, tvOS 15 and macOS Monterey
Yattee: video player for Invidious and Piped built for iOS 15, tvOS 15 and macOS Monterey

Video player with support for Invidious and Piped instances built for iOS 15, tvOS 15 and macOS Monterey.

Jun 27, 2022
Yattee: video player for Invidious and Piped built for iOS, tvOS and macOS
Yattee: video player for Invidious and Piped built for iOS, tvOS and macOS

Video player for Invidious and Piped instances built for iOS, tvOS and macOS. Features Native user interface built with SwiftUI Multiple instances and

Jun 17, 2022
MobilePlayer - A powerful and completely customizable media player for iOS
MobilePlayer - A powerful and completely customizable media player for iOS

MobilePlayer A powerful and completely customizable media player for iOS. Table of Contents Features Installation Usage Customization Skinning Showing

Jun 23, 2022
▶️ video player in Swift, simple way to play and stream media on iOS/tvOS

Player Player is a simple iOS video player library written in Swift. Looking for an obj-c video player? Check out PBJVideoPlayer (obj-c). Looking for

Jun 22, 2022
YouTube video player for iOS, tvOS and macOS
YouTube video player for iOS, tvOS and macOS

About XCDYouTubeKit is a YouTube video player for iOS, tvOS and macOS. Are you enjoying XCDYouTubeKit? You can say thank you with a tweet. I am also a

Jun 16, 2022
An advanced media player library, simple and reliable
An advanced media player library, simple and reliable

About The SRG Media Player library provides a simple way to add universal audio / video playback support to any application. It provides: A controller

Jun 19, 2022
YoutubeKit is a video player that fully supports Youtube IFrame API and YoutubeDataAPI for easily create a Youtube app
YoutubeKit is a video player that fully supports Youtube IFrame API and YoutubeDataAPI for easily create a Youtube app

YoutubeKit YoutubeKit is a video player that fully supports Youtube IFrame API and YoutubeDataAPI to easily create Youtube applications. Important Ref

Jun 16, 2022
Versatile Video Player implementation for iOS, macOS, and tvOS
Versatile Video Player implementation for iOS, macOS, and tvOS

News ?? - Since 2.1.3 VersaPlayer now supports iOS, macOS, and tvOS Example Installation Usage Basic Usage Adding Controls Advanced Usage Encrypted Co

Jun 16, 2022
A powerful and completely customizable media player for iOS
A powerful and completely customizable media player for iOS

MobilePlayer A powerful and completely customizable media player for iOS. Table of Contents Features Installation Usage Customization Skinning Showing

Jun 16, 2022
Audio player demo based on Swift and SwiftUI, which can play local or network audio.
Audio player demo based on Swift and SwiftUI, which can play local or network audio.

SwiftAudioDemo Audio player demo based on Swift and SwiftUI, which can play local or network audio. In this demo, I have made a radio player to play n

Mar 13, 2022
WatchTube: a standalone WatchOS youtube player utilizing Download API for search data and video streaming
WatchTube: a standalone WatchOS youtube player utilizing Download API for search data and video streaming

WatchTube is a standalone WatchOS youtube player utilizing Download API for sear

May 30, 2022
Overlay alpha channel video animation player view using Metal.
Overlay alpha channel video animation player view using Metal.

Overlay alpha channel video animation player view using Metal. Example To run the example project, clone the repo, and run pod install from the Exampl

May 27, 2022
Player View is a delegated view using AVPlayer of Swift

PlayerView [![CI Status](http://img.shields.io/travis/David Alejandro/PlayerView.svg?style=flat)](https://travis-ci.org/David Alejandro/PlayerView) An

May 31, 2022
Swifty360Player - iOS 360-degree video player streaming from an AVPlayer.
Swifty360Player - iOS 360-degree video player streaming from an AVPlayer.

Swifty360Player iOS 360-degree video player streaming from an AVPlayer. Demo Requirements Swifty360Player Version Minimum iOS Target Swift Version 0.2

Jun 10, 2022
VGPlayer - 📺 A simple iOS video player by Vein.
 VGPlayer - 📺  A simple iOS video player by Vein.

Swift developed based on AVPlayer iOS player,support horizontal gestures Fast forward, pause, vertical gestures Support brightness and volume adjustment, support full screen, adaptive screen rotation direction.

Apr 8, 2022