Support customization of any player SDK and control layer

Overview

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.

Comments
  • iOS13-beta后切换横屏,状态栏没有切换

    iOS13-beta后切换横屏,状态栏没有切换

    iOS13后通过这个方法[UIApplication sharedApplication].statusBarOrientation = orientation设置状态栏失效. 系统提示: [Assert] -[UIApplication setStatusBarOrientation:] and -[UIApplication setStatusBarOrientation:animated:] API have been deprecated on iOS 8.0 and are no-ops on iOS 13.0

    opened by Lixyss 12
  • Xcode9,iOS11 bug

    Xcode9,iOS11 bug

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

    opened by ChildrenGreens 11
  • iOS12下开启控制器旋转就会奔溃

    iOS12下开启控制器旋转就会奔溃

    • (void)setFullScreen:(BOOL)fullScreen { _fullScreen = fullScreen; [[UIWindow zf_currentViewController] setNeedsStatusBarAppearanceUpdate]; [UIViewController attemptRotationToDeviceOrientation]; }

    error:Thread 1: Exception: "Supported orientations has no common orientation with the application, and [UINavigationController shouldAutorotate] is returning YES"

    opened by xiangchangming 10
  • 为什么不能全屏?

    为什么不能全屏?

    _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];
    
    opened by NSMichael 10
  • ijkplayer下的问题

    ijkplayer下的问题

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

    opened by Yuan920 9
  • 修复iOS16退出全屏后LandscapeWindow停留页面阻挡交互

    修复iOS16退出全屏后LandscapeWindow停留页面阻挡交互

    首先感谢大佬的辛苦付出,这个库用了很多年了,帮助非常多,白嫖这么多年从不提pr,这次希望能为维护这个库略尽绵薄之力。 如下是这次遇到问题的具体情况:

    设备

    iPhone 12 Pro Max,iOS 16.1.1

    问题

    播放器退出全屏后,界面无法交互,检查图层发现是LandscapeWindow未隐藏,定位代码确定是退出全屏时ZFLandscapeRotationManager_iOS16中所修改代码段中获取的fromOrientation、toOrientation都为UIInterfaceOrientationPortrait,导致进入错误的逻辑,LandscapeWindow未执行隐藏逻辑 代码截图

    解决

    • 以下两个判断条件理论是完全互斥关系,可任意调整位置
    • fromOrientation存在不准确的可能,toOrientation为强主观逻辑变量,优先判断toOrientation更准确
    • 在不影响逻辑优先度的情况下短路径放前面也更好一点

    基于以上3点原因建议调换判断条件的位置:

    if (fromOrientation == UIInterfaceOrientationPortrait || self.contentView.superview != self.landscapeViewController.view) { ... } else if (toOrientation == UIInterfaceOrientationPortrait) { ... }

    opened by Cyfuer 1
  • iOS 16, iPhone 12 pro max 调用全屏函数 app整个卡死

    iOS 16, iPhone 12 pro max 调用全屏函数 app整个卡死

    问题描述: 目前在非iOS 16系统上,iPhone设备正常 在iOS 16系统上,iPhone Xs Max正常; iPhone 12 pro max 全屏 app整个卡死,但还是有声音 未做任何其他处理,只调用了

    [self.player enterFullScreen:YES animated:YES];
    

    https://user-images.githubusercontent.com/13342825/199639538-3302abaf-c995-4415-8ae5-26c03a22f301.mov

    opened by yownyang 0
Owner
紫枫
iOS developer
紫枫
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.

Abe Wang 11 Nov 7, 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

null 1 Nov 26, 2022
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.

Eliyar Eziz 1.8k Jan 4, 2023
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

Millman Yang 724 Nov 24, 2022
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.

Yattee 1k Dec 27, 2022
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

Yattee 1.1k Jan 8, 2023
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

Sahin Boydas 3k Jan 2, 2023
▶️ 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

patrick piemonte 2k Jan 2, 2023
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

Sahin Boydas 3k Jan 2, 2023
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

Cédric Luthi 2.9k Jan 7, 2023
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

SRG SSR 144 Jul 22, 2022
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

Ryo Ishikawa 555 Dec 28, 2022
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

Jose Quintero 723 Dec 26, 2022
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

Jensen Zhang 6 Mar 13, 2022
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

WatchTubeTeam 11 May 30, 2022
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

noppefoxwolf 244 Jan 1, 2023
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

null 131 Oct 25, 2022
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

Abdullah Selek 148 Dec 18, 2022
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.

Wen Rong 399 Dec 23, 2022