Giter Site home page Giter Site logo

abvideorangeslider's Introduction

ABVideoRangeSlider

CI Status Version License Platform

Customizable Video Range Slider for trimming videos written in Swift 3.

Portrait

Custom Indicators

Progress Indicator

Custom Time Labels

Installation

ABVideoRangeSlider is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "ABVideoRangeSlider"

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Usage

  1. Insert an UIView in your Storyboard's ViewController
  2. Change the class of your view to 'ABVideoRangeSlider'
  3. Import ABVideoRangeSlider into your ViewController
  4. Control + Drag your UIView to create an IBOutlet in your ViewController
@IBOutlet var videoRangeSlider: ABVideoRangeSlider!
  1. Add ABVideoRangeSliderDelegate to your controller
  2. Setup:
// Set the video URL
var path = Bundle.main.path(forResource: "myVideo", ofType:"mp4")
videoRangeSlider.setVideoURL(videoURL: URL(fileURLWithPath: path!))

// Set the delegate
videoRangeSlider.delegate = self

// Set a minimun space (in seconds) between the Start indicator and End indicator
videoRangeSlider.minSpace = 60.0

// Set a maximun space (in seconds) between the Start indicator and End indicator - Default is 0 (no max limit)
videoRangeSlider.maxSpace = 120.0
// Set initial position of Start Indicator
videoRangeSlider.setStartPosition(seconds: 50.0)

// Set initial position of End Indicator
videoRangeSlider.setEndPosition(seconds: 150.0)

Progress indicator

You can show/hide this indicator using the following methods

    videoRangeSlider.hideProgressIndicator()
    videoRangeSlider.showProgressIndicator()

If you want to update the position:

    videoRangeSlider.updateProgressIndicator(seconds: elapsedTimeOfVideo)

You can also have the progress indicator be "sticky" follow the start crop indicator when adjusted:

    videoRangeSlider.isProgressIndicatorSticky = true

Custom Time Labels

You can customize the time label's backgrounds providing a custom UIView to videoRangeSlider.startTimeView.backgroundView.

Example

  let customView = UIView(frame: CGRect(x: 0,
                                        y: 0,
                                        width: 60,
                                        height: 40))
  customView.backgroundColor = .black
  customView.alpha = 0.5
  customView.layer.borderColor = UIColor.black.cgColor
  customView.layer.borderWidth = 1.0
  customView.layer.cornerRadius = 8.0
  videoRangeSlider.startTimeView.backgroundView = customView

Properties

  // Shows the formatted time
  timeLabel: UILabel

  // UILabel's margins - Default = 5.0
  marginTop: CGFloat     
  marginBottom: CGFloat   
  marginLeft: CGFloat      
  marginRight: CGFloat   

  // Background View
  backgroundView : UIView

Protocols

func didChangeValue(videoRangeSlider: ABVideoRangeSlider, startTime: Float64, endTime: Float64) {
    print(startTime)    // Prints the position of the Start indicator in seconds
    print(endTime)      // Prints the position of the End indicator in seconds
}
func indicatorDidChangePosition(videoRangeSlider: ABVideoRangeSlider, position: Float64) {
    print(position)      // Prints the position of the Progress indicator in seconds
}

Customization

        // Customize the Start indicator with a custom image
        let customStartIndicator =  UIImage(named: "CustomStartIndicator")
        videoRangeSlider.setStartIndicatorImage(image: customStartIndicator!)

        // Customize the End indicator with a custom image
        let customEndIndicator =  UIImage(named: "CustomEndIndicator")
        videoRangeSlider.setEndIndicatorImage(image: customEndIndicator!)

        // Customize bottom and top border with a custom image
        let customBorder =  UIImage(named: "CustomBorder")
        videoRangeSlider.setBorderImage(image: customBorder!)

        // Customize Progress indicator with a custom image
        let customProgressIndicator =  UIImage(named: "CustomProgressIndicator")
        videoRangeSlider.setProgressIndicatorImage(image: customProgressIndicator!)

Public method

If you need to update the thumbnails of the video, you can call this method manually. (By default it's called every time the view changes its bounds)

videoRangeSlider.updateThumbnails()

Author

Apps Boulevard

License

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

abvideorangeslider's People

Contributors

oscarjiv91 avatar tdelhaise avatar thetrevorharmon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

abvideorangeslider's Issues

Moving DraggableView Bug

When moving the draggableView to quickly and touching either the beginning or end of the slider itself, the entire slider continues to grow in width.

Video thumbnails are not updating in trimmer'view

I have added following code for trimmer in viewWillAppear:

videoRangeSlider.delegate = self
videoRangeSlider.setVideoURL(videoURL: url)
videoRangeSlider.minSpace = 0.0
videoRangeSlider.maxSpace = 20.0
videoRangeSlider.setStartPosition(seconds: 0.0)
videoRangeSlider.setEndPosition(seconds: 20.0)

When i comes to trimmer screen first time then this code updates the video thumbnail in trimmer's view. Then i move to the next screen for further advance video editing. After advance editing i do update my URL of video. Then if i navigate back to trimmer screen, video thumbnails are not updating. Sometimes thumbnails are updating and sometimes not.

Issue in implementing Delegate

Issue in implementing Delegate 'ABVideoRangeSliderDelegate'. Not found error is shown when trying to implement the delegate in objective c code.

Add ABVideoRangeSlider view programmatically

I have tried to add ABVideoRangeSlider view programmatically with the custom frame but not able to get a view as per you have show design in a demo

var rangeSlider = ABVideoRangeSlider()
self.rangeSlider.frame = CGRect(x: 16, y: 50, width: UIScreen.main.bounds.width - 16, height: 70.0)
self.view.addSubview(self.rangeSlider)

simulator screen shot - iphone x - 2018-06-01 at 17 10 33

Start and End labels overlaps

I am using this trimmer for my project and my requirement for minimum video seconds is 1 sec when a large video comes up then the start and end labels overlap with each other could you please suggest some solution for that.

UI API called on a background thread

I got an error message when function "thumbnailCount" is called:

Main Thread Checker: UI API called on a background thread: -[UIView frame][...]

Apparently, just calling this function inside the main thread seems to eliminate the error message.

I'm running on Swift 4, Xcode 9.2.

Crashing app

While i try to dismiss the viewcontrller where i used ABVideoRangeSlider my app crash and am getting this in log.

An instance 0x10445e320 of class ABVideoRangeSlider.ABVideoRangeSlider was deallocated while key value observers were still registered with it. Current observation info: <NSKeyValueObservationInfo 0x174039880> (
<NSKeyValueObservance 0x174251550: Observer: 0x10445e320, Key path: bounds, Options: <New: NO, Old: NO, Prior: NO> Context: 0x0, Property: 0x1742515b0>
)'

Get "module compiled with Swift 4.0 cannot be imported in Swift 3.1"

Hi guys, please can you help me with this error.

I have written my app on Xcode 9 (with iOS 11) but now I need to ship to TestFlight so I have to build the app with Xcode 8 (not beta version).

I have installed ABVideoRangeSlider with Cocoapod and I've already tried to clean pod, re-install, re-update. Everything!

When I try to compile I get this error for ABVideoRangeSlider

module compiled with Swift 4.0 cannot be imported in Swift 3.1

How can I solve this? Have you got any idea about why I can't compile in S3?

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.