ABVideoRangeSlider
Customizable Video Range Slider for trimming videos written in Swift 3.
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
- Insert an
UIView
in your Storyboard'sViewController
- Change the class of your view to 'ABVideoRangeSlider'
- Import
ABVideoRangeSlider
into yourViewController
Control + Drag
yourUIView
to create anIBOutlet
in yourViewController
@IBOutlet var videoRangeSlider: ABVideoRangeSlider!
- Add
ABVideoRangeSliderDelegate
to your controller - 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
Delegate
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
}
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!)
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
- Twitter: @AppsBoulevard
- Facebook: facebook.com/AppsBoulevard
- Email: [email protected]
License
ABVideoRangeSlider is available under the MIT license. See the LICENSE file for more info.