Latest 3.1.6
Homepage https://github.com/renzifeng/ZFPlayer
License MIT
Platforms ios 7.0, requires ARC
Authors

ZFPlayer

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

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

打赏作者

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

ZFPlayer

License

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

Latest podspec

{
    "name": "ZFPlayer",
    "version": "3.1.6",
    "summary": "A good player made by renzifeng",
    "homepage": "https://github.com/renzifeng/ZFPlayer",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "renzifeng": "[email protected]"
    },
    "source": {
        "git": "https://github.com/renzifeng/ZFPlayer.git",
        "tag": "3.1.6"
    },
    "social_media_url": "http://weibo.com/zifeng1300",
    "platforms": {
        "ios": "7.0"
    },
    "requires_arc": true,
    "default_subspecs": "Core",
    "subspecs": [
        {
            "name": "Core",
            "source_files": "ZFPlayer/Classes/Core/**/*",
            "public_header_files": "ZFPlayer/Classes/Core/**/*.h",
            "frameworks": [
                "UIKit",
                "MediaPlayer",
                "AVFoundation"
            ]
        },
        {
            "name": "ControlView",
            "source_files": "ZFPlayer/Classes/ControlView/**/*.{h,m}",
            "public_header_files": "ZFPlayer/Classes/ControlView/**/*.h",
            "resources": "ZFPlayer/Classes/ControlView/ZFPlayer.bundle",
            "dependencies": {
                "ZFPlayer/Core": []
            }
        },
        {
            "name": "AVPlayer",
            "source_files": "ZFPlayer/Classes/AVPlayer/**/*.{h,m}",
            "public_header_files": "ZFPlayer/Classes/AVPlayer/**/*.h",
            "dependencies": {
                "ZFPlayer/Core": []
            }
        },
        {
            "name": "ijkplayer",
            "source_files": "ZFPlayer/Classes/ijkplayer/*.{h,m}",
            "public_header_files": "ZFPlayer/Classes/ijkplayer/*.h",
            "dependencies": {
                "ZFPlayer/Core": [],
                "IJKMediaFramework": []
            },
            "platforms": {
                "ios": "8.0"
            }
        },
        {
            "name": "KSYMediaPlayer",
            "source_files": "ZFPlayer/Classes/KSYMediaPlayer/*.{h,m}",
            "public_header_files": "ZFPlayer/Classes/KSYMediaPlayer/*.h",
            "dependencies": {
                "ZFPlayer/Core": [],
                "KSYMediaPlayer_iOS/KSYMediaPlayer_vod": []
            },
            "pod_target_xcconfig": {
                "ARCHS[sdk=iphonesimulator*]": "$(ARCHS_STANDARD_64_BIT)"
            }
        }
    ]
}

Pin It on Pinterest

Share This