|
@@ -80,6 +80,9 @@ class PQStuckPointCuttingView: UIView {
|
|
|
|
|
|
//推荐虚线的位置
|
|
|
var startLineX:CGFloat = 0.0
|
|
|
+
|
|
|
+ //如果是用户主动划动的 就不自动滚动到推荐位置了
|
|
|
+ var isUserDrag:Bool = false
|
|
|
/// 滚动视图
|
|
|
lazy var scrollView: UIScrollView = {
|
|
|
let scrollView = UIScrollView(frame: bounds)
|
|
@@ -215,15 +218,19 @@ class PQStuckPointCuttingView: UIView {
|
|
|
titleLab.tag = 100 + index
|
|
|
titleLab.backgroundColor = .clear
|
|
|
titleLab.textColor = UIColor.hexColor(hexadecimal: "#999999")
|
|
|
- titleLab.text = "\((Float64(index) * Float64(timeRange)).formatDurationToHMS())"
|
|
|
+
|
|
|
+ titleLab.text = "\(Float64(Int(index) * Int(timeRange)).formatDurationToHMS())"
|
|
|
scrollView.addSubview(titleLab)
|
|
|
}
|
|
|
if oneMarginTime > 0 {
|
|
|
// 1,处理音频频率
|
|
|
configVoiceFrequency()
|
|
|
// 2,滚动到推荐位置
|
|
|
- scrollView.contentOffset = CGPoint(x: startLineX - margin, y: 0)
|
|
|
-
|
|
|
+ if(!isUserDrag){
|
|
|
+ scrollView.contentOffset = CGPoint(x: startLineX - margin, y: 0)
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
scrollView.addSubview(rateView)
|
|
|
}
|
|
|
}
|
|
@@ -254,13 +261,20 @@ class PQStuckPointCuttingView: UIView {
|
|
|
/// 更新进度绘制不同色值
|
|
|
/// progress <#progress description#>
|
|
|
func updateProgress(progress: CGFloat) {
|
|
|
- for (i, layer) in lineLayerArray.enumerated() {
|
|
|
- if CGFloat(i) * oneMarginTime <= stuckPointStartTime + progress * CGFloat(stuckPointEndTime - stuckPointStartTime) && CGFloat(i) * oneMarginTime >= stuckPointStartTime {
|
|
|
- BFLog(message: "progress is \(progress) 命中的位置:\(CGFloat(i) * oneMarginTime)")
|
|
|
- layer.strokeColor = UIColor.hexColor(hexadecimal: PQBFConfig.shared.styleColor.rawValue).cgColor
|
|
|
- layer.setNeedsDisplay()
|
|
|
- }
|
|
|
- }
|
|
|
+
|
|
|
+// let seartIndex = stuckPointStartTime / oneMarginTime
|
|
|
+// for (i, layer) in lineLayerArray.enumerated() {
|
|
|
+//
|
|
|
+//// if CGFloat(i) * oneMarginTime <= stuckPointStartTime + progress * CGFloat(stuckPointEndTime - stuckPointStartTime) && CGFloat(i) * oneMarginTime >= stuckPointStartTime {
|
|
|
+// if(i > Int(seartIndex) && i < Int(seartIndex) + wavSelectCount){
|
|
|
+//
|
|
|
+// BFLog(message: "progress is \(progress) i \(i) 命中的位置:\(CGFloat(i) * oneMarginTime)")
|
|
|
+// layer.strokeColor = UIColor.hexColor(hexadecimal: PQBFConfig.shared.styleColor.rawValue).cgColor
|
|
|
+// layer.setNeedsDisplay()
|
|
|
+// usleep(UInt32(CGFloat(stuckPointEndTime - stuckPointStartTime) / CGFloat(wavSelectCount) * 1000))
|
|
|
+//
|
|
|
+// }
|
|
|
+// }
|
|
|
}
|
|
|
|
|
|
// 竖线恢复到原有色值
|
|
@@ -326,12 +340,15 @@ class PQStuckPointCuttingView: UIView {
|
|
|
let lastLine:UIView = scrollView.viewWithTag(100 + Int(videoDuration / timeRange) - 1) ?? UIView.init()
|
|
|
//移动后的开始时间
|
|
|
let startTime = videoDuration / lastLine.frame.maxX * scrollView.contentOffset.x
|
|
|
- BFLog(message: "拖拽结束 - 回调\(scrollView.contentOffset) \(scrollView.contentSize) 开始时间为:\(startTime) 结束时间为:\(startTime + CGFloat(stuckPointEndTime - stuckPointStartTime))")
|
|
|
+ //选中的时长
|
|
|
+ let selectDuration:CGFloat = CGFloat(stuckPointEndTime - stuckPointStartTime)
|
|
|
+ BFLog(message: "拖拽结束 - 回调\(scrollView.contentOffset) \(scrollView.contentSize) 开始时间为:\(startTime) 结束时间为:\(startTime + selectDuration)")
|
|
|
+ stuckPointStartTime = startTime
|
|
|
+ stuckPointEndTime = stuckPointStartTime + selectDuration
|
|
|
if(videoDidEndDragging != nil){
|
|
|
videoDidEndDragging!(1,startTime,startTime + CGFloat(stuckPointEndTime - stuckPointStartTime),0)
|
|
|
}
|
|
|
resetDefaultsColor()
|
|
|
-
|
|
|
PQEventTrackViewModel.baseReportUpload(businessType: .bt_buttonClick, objectType: .ot_shanyinApp_musicVideoPreview_musicPeriodSelect, pageSource: .sp_shanyinApp_main, extParams: nil, remindmsg: "")
|
|
|
|
|
|
|
|
@@ -346,6 +363,7 @@ extension PQStuckPointCuttingView: UIScrollViewDelegate {
|
|
|
func scrollViewDidScroll(_: UIScrollView) {}
|
|
|
|
|
|
func scrollViewWillBeginDragging(_ :UIScrollView){
|
|
|
+ isUserDrag = true
|
|
|
if(videoDidBeginDrag != nil){
|
|
|
videoDidBeginDrag!()
|
|
|
}
|