Giter Site home page Giter Site logo

lzbmac / jpvideoplayer Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dito010/jpvideoplayer

0.0 2.0 0.0 28.72 MB

Automatic play video & cache video data in UITableView like Weibo and Douyin.

Home Page: http://www.jianshu.com/users/e2f2d779c022/latest_articles

License: MIT License

Ruby 0.35% Objective-C 99.65%

jpvideoplayer's Introduction

license pod pod pod

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

Features

  • Cache video data at playing.
  • Seek time support(new).
  • Breakpoint continuingly support(new).
  • Landscape auto-layout support(new).
  • Custom player controlView support(new).
  • Excellent performance!
  • 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
  • Swift support

Requirements

  • iOS 8.0 or later
  • Xcode 7.3 or later

Getting Started

How To Use

01.Play video.

1.1.Mute play video and display progressView on UITableViewCell or any view.

NSURL *url = [NSURL URLWithString:@"http://p11s9kqxf.bkt.clouddn.com/bianche.mp4"];
[aview jp_playVideoMuteWithURL:url
            bufferingIndicator:nil
                  progressView:nil
           	 configuration:nil];

1.2.Resume mute play from UITableViewController to a detail UIViewControllerwhen user selected a UITableViewCell.

NSURL *url = [NSURL URLWithString:@"http://p11s9kqxf.bkt.clouddn.com/bianche.mp4"];
[aview jp_resumeMutePlayWithURL:url
             bufferingIndicator:nil
                   progressView:nil
        	  configuration:nil];

1.3.Play video and display controlView & progressView.

NSURL *url = [NSURL URLWithString:@"http://p11s9kqxf.bkt.clouddn.com/bianche.mp4"];
[aview jp_playVideoWithURL:url
        bufferingIndicator:nil
               controlView:nil
              progressView:nil
   	     configuration:nil];

1.4.Resume play with displaying controlView & progressView.

NSURL *url = [NSURL URLWithString:@"http://p11s9kqxf.bkt.clouddn.com/bianche.mp4"];
[aview jp_resumePlayWithURL:url
         bufferingIndicator:nil
                controlView:nil
               progressView:nil
    	      configuration:nil];

1.5.Play video without controlView & progressView.

NSURL *url = [NSURL URLWithString:@"http://p11s9kqxf.bkt.clouddn.com/bianche.mp4"];
[aview jp_playVideoWithURL:url
		   options:kNilOptions
   	     configuration:nil];

1.6. Resume play without controlView & progressView.

NSURL *url = [NSURL URLWithString:@"http://p11s9kqxf.bkt.clouddn.com/bianche.mp4"];
[aview jp_resumePlayWithURL:url
		    options:kNilOptions
    	      configuration:nil];

2.Landscape Or Portrait Control

2.1. Go to landscape.

[aview jp_gotoLandscape];

[aview jp_gotoLandscapeAnimated:YES completion:nil];

2.2. Go to portrait.

[aview jp_gotoPortrait];

[aview jp_gotoPortraitAnimated:YES completion:nil];

3. Play video in UITableView like Weibo.

Play video in UITableView support equal height and un-eqaul height cell now, you can use a category method on UITableView directly. You also should set the jp_tableViewVisibleFrame accurately to insure playing video on the cell that closest to the center of the screen.

[tableView jp_playVideoInVisibleCellsIfNeed];

[tableView jp_handleCellUnreachableTypeInVisibleCellsAfterReloadData];

[tableView jp_handleCellUnreachableTypeForCell:cell
                                   atIndexPath:indexPath];

[tableView jp_scrollViewDidScroll];

[tableView jp_scrollViewDidEndDraggingWillDecelerate:decelerate];

[tableView jp_scrollViewDidEndDecelerating];

4. Custom controlView & progressView & bufferingIndicator.

This library offered a basic JPVideoPlayerProgressViewJPVideoPlayerBufferingIndicatorJPVideoPlayerControlView, so you can pass nil in play video method. You can inherit those basic class to custom your own UI, and you also can not inherit it, directly use your own UI, but you must implete the method in JPVideoPlayerControlProgressProtocolJPVideoPlayerBufferingProtocolJPVideoPlayerProtocol.

5. Cache manage.

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

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

Installation

There are two ways to use JPVideoPlayer in your project:

  • using CocoaPods
  • 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'
end

Communication

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

Licenses

All source code is licensed under the MIT License.

Architecture

赞助

你这一赞助,我写的就更来劲了!

微信赞助扫码

支付宝赞助扫码

jpvideoplayer's People

Contributors

dito010 avatar chris-pan avatar memetghini avatar audrl1010 avatar smhjsw avatar riveryan avatar

Watchers

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