Skip to content

z624821876/JPVideoPlayer

 
 

Repository files navigation

license pod pod pod pod

This library provides an video player with cache support in UITableView.

Watch out

You may download my demo to know how to play video in UITableViewController, this framework just provides a player cache video data at playing.

Features

  • Cache video data at playing
  • Handle play or stop video in main thread
  • Excellent performance!
  • Always play the video of the UITableViewCell in screen center when scrolling
  • A guarantee that the same URL won't be downloaded several times
  • A guarantee that main thread will never be blocked
  • Location video play support
  • HTTPS support
  • Swift support
  • Carthage support
  • Landscape support

Requirements

  • iOS 8.0 or later
  • Xcode 7.3 or later

Getting Started

Communication

  • If you found a bug, open an issue.
  • If you have a feature request, open an issue.
  • If you want to contribute, submit a pull request.

Installation

How To Use

Play video, and play audio.

Objective-C:

#import <UIView+WebVideoCache.h>

...
NSURL *url = [NSURL URLWithString:@"http://lavaweb-10015286.video.myqcloud.com/%E5%B0%BD%E6%83%85LAVA.mp4"];
[aview jp_playVideoWithURL:url];
Swift:

import JPVideoPlayer

...
let url = URL(string: videoPath)
aview.jp_playVideoWithURL(with: url)

Play video muted, display status view.

Objective-C:

#import <UIView+WebVideoCache.h>

...
NSURL *url = [NSURL URLWithString:@"http://lavaweb-10015286.video.myqcloud.com/%E5%B0%BD%E6%83%85LAVA.mp4"];
[aview jp_playVideoHiddenStatusViewWithURL:url];

Play video muted, hidden status view.

Objective-C:

#import <UIView+WebVideoCache.h>

...
NSURL *url = [NSURL URLWithString:@"http://lavaweb-10015286.video.myqcloud.com/%E5%B0%BD%E6%83%85LAVA.mp4"];
[aview jp_playVideoMutedHiddenStatusViewWithURL:url];

Play video muted, display status view.

Objective-C:

#import <UIView+WebVideoCache.h>

...
NSURL *url = [NSURL URLWithString:@"http://lavaweb-10015286.video.myqcloud.com/%E5%B0%BD%E6%83%85LAVA.mp4"];
[aview jp_playVideoMutedDisplayStatusViewWithURL:url];

Custom progress view.


#import <UIView+WebVideoCache.h>

...
[aview jp_perfersDownloadProgressViewColor: [UIColor grayColor]];
[aview jp_perfersPlayingProgressViewColor: [UIColor blueColor]];

Player control.


#import <UIView+WebVideoCache.h>

...
[aview jp_stopPlay];
[aview jp_pause];
[aview jp_resume];
[aview jp_setPlayerMute:YES];

Landscape Or Portrait Control


#import <UIView+WebVideoCache.h>

...
[aview jp_landscapeAnimated:YES completion:nil];
[aview jp_portraitAnimated:YES completion:nil];

Cache manage.


#import <JPVideoPlayerCache.h>

...
[[JPVideoPlayerCache sharedCache] calculateSizeWithCompletionBlock:^(NSUInteger fileCount, NSUInteger totalSize) {
     // do something.
}];

[[JPVideoPlayerCache sharedCache] clearDiskOnCompletion:^{
    // do something
}];

Installation

There are three ways to use JPVideoPlayer in your project:

  • using CocoaPods
  • using Carthage
  • by cloning the project into your repository

Installation with CocoaPods

CocoaPods is a dependency manager for Objective-C, which automates and simplifies the process of using 3rd-party libraries in your projects. See the Get Started section for more details.

Podfile

platform :ios, '8.0'
target "YourProjectName" do
pod 'JPVideoPlayer', '~> 2.3.4'
end

Installation with Carthage

Carthage is a simple, decentralized dependency manager for Cocoa.

github "newyjp/JPVideoPlayer"

Licenses

All source code is licensed under the MIT License.

Architecture

如果你在天朝

注意:

如果你需要在UITableViewController中滑动播放视频, 请下载我的完整demo, 这个框架只提供一个边下边缓存视频数据的播放器.

特性

  • 视频播放边下边播, 同时边缓存到本地
  • 主线程处理切换视频
  • 不阻塞线程,不卡顿,滑动如丝顺滑
  • 当滚屏时采取总是播放处在屏幕中心的那个 cell 的视频的策略
  • 保证同一个URL的视频不会重复下载
  • 保证不会阻塞线程
  • 支持播放本地视频
  • HTTPS 支持
  • Swift 支持
  • Carthage 支持
  • 横屏支持

组件要求

  • iOS 8.0 +
  • Xcode 7.3 +

如何使用

联系

  • 如果你发现了bug, 请帮我提交issue
  • 如果你有好的建议, 请帮我提交issue
  • 如果你想贡献代码, 请提交请求

如何使用

播放音视频.

Objective-C:

#import <UIView+WebVideoCache.h>

...
NSURL *url = [NSURL URLWithString:@"http://lavaweb-10015286.video.myqcloud.com/%E5%B0%BD%E6%83%85LAVA.mp4"];
[aview jp_playVideoWithURL:url];
Swift:

import JPVideoPlayer

...
let url = URL(string: videoPath)
aview.jp_playVideoWithURL(with: url)

播放音视频, 隐藏进度指示(可以成为代理添加指示器, 或者直接自定义指示器).

Objective-C:

#import <UIView+WebVideoCache.h>

...
NSURL *url = [NSURL URLWithString:@"http://lavaweb-10015286.video.myqcloud.com/%E5%B0%BD%E6%83%85LAVA.mp4"];
[aview jp_playVideoHiddenStatusViewWithURL:url];

静音播放视频, 隐藏进度指示(可以成为代理添加指示器, 或者直接自定义指示器).

Objective-C:

#import <UIView+WebVideoCache.h>

...
NSURL *url = [NSURL URLWithString:@"http://lavaweb-10015286.video.myqcloud.com/%E5%B0%BD%E6%83%85LAVA.mp4"];
[aview jp_playVideoMutedHiddenStatusViewWithURL:url];

静音播放视频, 并且显示进度指示.

Objective-C:

#import <UIView+WebVideoCache.h>

...
NSURL *url = [NSURL URLWithString:@"http://lavaweb-10015286.video.myqcloud.com/%E5%B0%BD%E6%83%85LAVA.mp4"];
[aview jp_playVideoMutedDisplayStatusViewWithURL:url];

自定义进度指示颜色(下载和播放进度).


#import <UIView+WebVideoCache.h>

...
[aview jp_perfersDownloadProgressViewColor: [UIColor grayColor]];
[aview jp_perfersPlayingProgressViewColor: [UIColor blueColor]];

播放器控制.


#import <UIView+WebVideoCache.h>

...
[aview jp_stopPlay];
[aview jp_pause];
[aview jp_resume];
[aview jp_setPlayerMute:YES];

视频横竖屏切换


#import <UIView+WebVideoCache.h>

...
[aview jp_landscapeAnimated:YES completion:nil];
[aview jp_portraitAnimated:YES completion:nil];

缓存查询管理.


#import <JPVideoPlayerCache.h>

...
[[JPVideoPlayerCache sharedCache] calculateSizeWithCompletionBlock:^(NSUInteger fileCount, NSUInteger totalSize) {
     // do something.
}];

[[JPVideoPlayerCache sharedCache] clearDiskOnCompletion:^{
    // do something
}];

如何安装

两种选择把框架集成到你的项目:

  • 使用 CocoaPods
  • 使用 Carthage
  • 下载我的demo, 把'JPVideoPlayer'文件夹拽到你的项目中

使用 CocoaPods 安装

Podfile

platform :ios, '8.0'
target "你的项目名称" do
pod 'JPVideoPlayer', '~> 2.3.4'
end

使用 Carthage 安装

cartfile

github "newyjp/JPVideoPlayer"

证书

MIT License

架构

About

Automatic play video in UITableView like Weibo home page in main thread and never block it.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Objective-C 92.2%
  • Swift 4.6%
  • Shell 3.0%
  • Ruby 0.2%