ABVideoRangeSlider 0.1.5

ABVideoRangeSlider 0.1.5

测试已测试
语言语言 SwiftSwift
许可证 MIT
发布最新发布2016年12月
SwiftSwift 版本3.0
SPM支持 SPM

Oscar J. Irun 维护。



ABVideoRangeSlider

Swift 3 编写的可用于裁剪视频的自定义视频范围滑块。

Portrait

Custom Indicators

Progress Indicator

Custom Time Labels

安装

ABVideoRangeSlider 通过 CocoaPods 提供。要安装它,只需将以下行添加到您的 Podfile 中。

pod "ABVideoRangeSlider"

示例

要运行示例项目,请克隆仓库,然后首先从 Example 目录中运行 pod install

使用

  1. 在 Storyboard 的 ViewController 中插入一个 UIView
  2. 将视图的类改为 ‘ABVideoRangeSlider’
  3. ABVideoRangeSlider 导入到您的 ViewController
  4. 通过 Control + DragUIView 拖动到创建 IBOutletViewController
@IBOutlet var videoRangeSlider: ABVideoRangeSlider!
  1. 为您的控制器添加 ABVideoRangeSliderDelegate
  2. 设置
// 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)

进度指示器

您可以使用以下方法显示/隐藏此指示器

    videoRangeSlider.hideProgressIndicator()
    videoRangeSlider.showProgressIndicator()

如果您想要更新位置

    videoRangeSlider.updateProgressIndicator(seconds: elapsedTimeOfVideo)

自定义时间标签

您可以通过提供自定义 UIViewvideoRangeSlider.startTimeView.backgroundView 来自定义时间标签的背景。

示例

  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

属性

  // Shows the formatted time
  timeLabel: UILabel

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

  // Background View
  backgroundView : UIView

协议

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
}

自定义

        // 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!)

公共方法

如果您需要更新视频的缩略图,可以手动调用此方法。默认情况下,每次视图更改其边界时都会调用它。

videoRangeSlider.updateThumbnails()

作者

Apps Boulevard

许可协议

ABVideoRangeSlider开源协议为MIT。更多信息请查看LICENSE文件。