|
@@ -85,6 +85,7 @@ class PQStuckPointCuttingView: UIView {
|
|
|
var isUserDrag:Bool = false
|
|
|
|
|
|
var suggestRhythmStartTime:CGFloat = 0.0
|
|
|
+ var suggestRhythmEndTime:CGFloat = 0.0
|
|
|
|
|
|
|
|
|
lazy var scrollView: UIScrollView = {
|
|
@@ -165,13 +166,20 @@ class PQStuckPointCuttingView: UIView {
|
|
|
|
|
|
|
|
|
|
|
|
- func updateEndTime(startTime: CGFloat, endTime: CGFloat) {
|
|
|
+ func updateEndTime(startTime: CGFloat, endTime: CGFloat,
|
|
|
+ suggestRhythmStartTime: CGFloat, suggestRhythmEndTime: CGFloat) {
|
|
|
+
|
|
|
+
|
|
|
+ self.suggestRhythmStartTime = suggestRhythmStartTime
|
|
|
+ self.suggestRhythmEndTime = suggestRhythmEndTime
|
|
|
+ startLineX = 0
|
|
|
+
|
|
|
stuckPointStartTime = startTime
|
|
|
stuckPointEndTime = endTime
|
|
|
|
|
|
tatalTimeLabel.text = "\(Float64(stuckPointEndTime - stuckPointStartTime).formatDurationToHMS())"
|
|
|
|
|
|
- BFLog(1, message: "推荐开始\(stuckPointStartTime) 结束\(stuckPointEndTime) 时长为:\(stuckPointEndTime - stuckPointStartTime) 音乐总时长为:\(videoDuration)")
|
|
|
+ BFLog(1, message: "播放开始:\(stuckPointStartTime) 结束:\(stuckPointEndTime) 时长为:\(stuckPointEndTime - stuckPointStartTime); 音乐总时长为:\(videoDuration);推荐卡点开始:\(suggestRhythmStartTime) 结束:\(suggestRhythmEndTime)")
|
|
|
backgroundColor = PQBFConfig.shared.styleBackGroundColor
|
|
|
addSubview(scrollView)
|
|
|
|
|
@@ -181,6 +189,8 @@ class PQStuckPointCuttingView: UIView {
|
|
|
videoCropView.addSubview(tatalTimeLabel)
|
|
|
addData()
|
|
|
videoCropView.frame = CGRect(x: (cScreenWidth - cropViewWidth) / 2, y: 0, width: cropViewWidth, height: 80)
|
|
|
+ leftMaskView.frame = CGRect(x:0, y: 0, width: (cScreenWidth - cropViewWidth) / 2 - 2, height: 80)
|
|
|
+ rightMaskView.frame = CGRect(x:videoCropView.frame.maxX + 2, y: 0, width: (cScreenWidth - cropViewWidth) / 2 - 2, height: 80)
|
|
|
|
|
|
tatalTimeLabel.snp.remakeConstraints { make in
|
|
|
make.width.equalTo(40)
|
|
@@ -196,11 +206,19 @@ class PQStuckPointCuttingView: UIView {
|
|
|
|
|
|
wavSelectCount = Int(ceil((cropViewWidth - frequencyWidth) / (frequencyWidth + frequencyMargin)) + 1)
|
|
|
|
|
|
- cropViewWidth = CGFloat(wavSelectCount - 1) * (frequencyWidth + frequencyMargin) + frequencyWidth
|
|
|
+ cropViewWidth = CGFloat(wavSelectCount) * (frequencyWidth + frequencyMargin) + frequencyWidth
|
|
|
+ margin = (cScreenWidth - cropViewWidth) / 2.0
|
|
|
+
|
|
|
|
|
|
|
|
|
- oneMarginTime = (stuckPointEndTime - stuckPointStartTime) / CGFloat(wavSelectCount - 1)
|
|
|
+ oneMarginTime = (stuckPointEndTime - stuckPointStartTime) / CGFloat(wavSelectCount)
|
|
|
|
|
|
+
|
|
|
+ var videoDurationTemp = suggestRhythmEndTime
|
|
|
+ while stuckPointEndTime > videoDurationTemp {
|
|
|
+ videoDurationTemp += (suggestRhythmEndTime - suggestRhythmStartTime)
|
|
|
+ }
|
|
|
+ videoDuration = videoDurationTemp
|
|
|
|
|
|
wavTotalCount = Int(ceil(videoDuration / oneMarginTime) + 1)
|
|
|
|
|
@@ -214,7 +232,7 @@ class PQStuckPointCuttingView: UIView {
|
|
|
}
|
|
|
scrollView.contentSize = CGSize(width: contentWidth, height: scrollView.frame.height)
|
|
|
|
|
|
- BFLog(1, message: "框内个数:\(wavSelectCount), 总线条数:\(wavTotalCount), 框宽:\(cropViewWidth)")
|
|
|
+ BFLog(1, message: "框内个数:\(wavSelectCount), 总线条数:\(wavTotalCount), 框宽:\(cropViewWidth), 最终音乐时长:\(videoDuration)")
|
|
|
scrollView.subviews.forEach { lable in
|
|
|
if lable is UILabel && lable.tag != 66 {
|
|
|
lable.removeFromSuperview()
|
|
@@ -239,7 +257,6 @@ class PQStuckPointCuttingView: UIView {
|
|
|
|
|
|
if(!isUserDrag){
|
|
|
scrollView.contentOffset = CGPoint(x: startLineX - margin, y: 0)
|
|
|
-
|
|
|
}
|
|
|
|
|
|
scrollView.addSubview(rateView)
|
|
@@ -278,11 +295,14 @@ class PQStuckPointCuttingView: UIView {
|
|
|
BFLog(message: "progress is error ")
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
+ BFLog(message: "progress is Start ************* ")
|
|
|
+
|
|
|
let startIndex = scrollView.contentOffset.x / (frequencyWidth + frequencyMargin)
|
|
|
let selectIndex = Int(floor(startIndex + progress * CGFloat(wavSelectCount)))
|
|
|
if(selectIndex < lineLayerArray.count){
|
|
|
let drawLayer:CAShapeLayer = lineLayerArray[selectIndex]
|
|
|
- BFLog(message: "progress is \(progress) i \(selectIndex) 命中的位置:\(CGFloat(selectIndex) * oneMarginTime)")
|
|
|
+ BFLog(1, message: "progress is \(progress) i \(selectIndex) 命中的位置:\(CGFloat(selectIndex) * oneMarginTime)")
|
|
|
if drawLayer.strokeColor != UIColor.hexColor(hexadecimal: PQBFConfig.shared.styleColor.rawValue).cgColor{
|
|
|
drawLayer.strokeColor = UIColor.hexColor(hexadecimal: PQBFConfig.shared.styleColor.rawValue).cgColor
|
|
|
drawLayer.setNeedsDisplay()
|
|
@@ -290,7 +310,7 @@ class PQStuckPointCuttingView: UIView {
|
|
|
}
|
|
|
|
|
|
|
|
|
- if(progress >= 0.99){
|
|
|
+ if(progress >= 1.01){
|
|
|
BFLog(message: "播放完成 重新更新 UI ")
|
|
|
resetDefaultsColor(clearData: false)
|
|
|
}
|
|
@@ -346,7 +366,7 @@ class PQStuckPointCuttingView: UIView {
|
|
|
lineLayer.fillColor = UIColor.black.cgColor
|
|
|
|
|
|
|
|
|
- BFLog(1, message: "suggestRhythmStartTime is \(suggestRhythmStartTime)")
|
|
|
+
|
|
|
if oneMarginTime * CGFloat(i) >= suggestRhythmStartTime && !isDrawLine {
|
|
|
isDrawLine = true
|
|
|
linePath.move(to: CGPoint(x: originX, y: -10))
|