GithubHelp home page GithubHelp logo

liuruxian / bmplayer Goto Github PK

View Code? Open in Web Editor NEW

This project forked from brikerman/bmplayer

0.0 1.0 0.0 9.58 MB

video player based on AVPlayer, support the horizontal, vertical screen. support adjust volume, brigtness and seek by slide. Swift 2. 基于AVPlayer,支持横屏、竖屏,上下滑动调节音量、屏幕亮度,左右滑动调节播放进度。

License: MIT License

Ruby 0.77% Swift 90.47% Objective-C 5.41% Shell 3.36%

bmplayer's Introduction

BMPlayer

Swift 2.2 Swift 3.0 Build Status Version License Platform Weibo

A simple video player for iOS, based on AVPlayer, pure swift.

中文说明

Features

  • Support for horizontal and vertical play mode
  • Support play with online URL and local file
  • Adjust brightness by slide vertical at left side of screen
  • Adjust volume by slide vertical at right side of screen
  • Slide horizontal to fast forward and rewind
  • Support multi-definition video
  • Mirror mode, slow play mode

Requirements

  • iOS 8 +
  • Xcode 7.3
  • Swift 2.2

Installation

CocoaPods

use_frameworks!

pod 'BMPlayer', '~> 0.2.0'

Swift 3: swift3 branch

Demo

run pod install at Example folder before run the demo.

Usage (Support IB and code)

Set status bar color

Please add the View controller-based status bar appearance field in info.plist and change it to NO

IB usage

Direct drag IB to UIView, the aspect ratio for the 16:9 constraint (priority to 750, lower than the 1000 line), the code section only needs to achieve. See more detail on the demo.

import BMPlayer

player.playWithURL(NSURL(string: url)!)

player.backBlock = { [unowned self] in
    self.navigationController?.popViewControllerAnimated(true)
}

Code implementation by SnapKit

import BMPlayer

player = BMPlayer()
view.addSubview(player)
player.snp_makeConstraints { (make) in
    make.top.equalTo(self.view).offset(20)
    make.left.right.equalTo(self.view)
    // Note here, the aspect ratio 16:9 priority is lower than 1000 on the line, because the 4S iPhone aspect ratio is not 16:9
    make.height.equalTo(player.snp_width).multipliedBy(9.0/16.0).priority(750)
}
// Back button event
player.backBlock = { [unowned self] in
    self.navigationController?.popViewControllerAnimated(true)
}

Set video url

player.playWithURL(NSURL(string: "http://baobab.wdjcdn.com/14571455324031.mp4")!, title: "风格互换:原来你我相爱")

multi-definition video with cover

let resource0 = BMPlayerItemDefinitionItem(url: NSURL(string: "http://baobab.wdjcdn.com/14570071502774.mp4")!, definitionName: "HD")
let resource1 = BMPlayerItemDefinitionItem(url: NSURL(string: "http://baobab.wdjcdn.com/1457007294968_5824_854x480.mp4")!, definitionName: "SD")

let item = BMPlayerItem(title: "周末号外丨川普版权力的游戏",
                        resource: [resource0, resource1],
                        cover: "http://img.wdjimg.com/image/video/acdba01e52efe8082d7c33556cf61549_0_0.jpeg")

Customize player

Needs to change before the player alloc.

// should print log, default false
BMPlayerConf.allowLog = false
// should auto play, default true
BMPlayerConf.shouldAutoPlay = true
// main tint color, default whiteColor
BMPlayerConf.tintColor = UIColor.whiteColor()
// options to show header view (which include the back button, title and definition change button) , default .Always,options: .Always, .HorizantalOnly and .None
BMPlayerConf.topBarShowInCase = .Always
// show mirror mode, slow play mode button, default false
BMPlayerConf.slowAndMirror = true
// loader type, see detail:https://github.com/ninjaprox/NVActivityIndicatorView
BMPlayerConf.loaderType  = NVActivityIndicatorType.BallRotateChase

Advanced

Demonstration

gif

Reference:

This project heavily reference the Objective-C version of this project ZFPlayer, thanks for the generous help of ZFPlayer's author.

Contact me:

Contributors

License

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

bmplayer's People

Contributors

brikerman avatar cedared avatar

Watchers

 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.