فهرست منبع

音频波形纹重新调整

huzhiqiang 3 سال پیش
والد
کامیت
d818cbf4bf

+ 29 - 9
BFFramework/Classes/Stuckpoint/View/PQStuckPointCuttingView.swift

@@ -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 {
     /// 更新卡点值
     /// - Parameter endTime: endTime description
     /// - Returns: <#description#>
-    func updateEndTime(startTime: CGFloat, endTime: CGFloat) {
+    func updateEndTime(startTime: CGFloat, endTime: CGFloat,
+                       suggestRhythmStartTime: CGFloat, suggestRhythmEndTime: CGFloat) {
+        
+//        videoDuration = duration
+        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 {
         // 1,选择区内的线个数 ,划动区域后 个数会变???
         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
+
      
         // 2竖线一个间隔代表多少 S 是动态的
-        oneMarginTime = (stuckPointEndTime - stuckPointStartTime) / CGFloat(wavSelectCount - 1)
+        oneMarginTime = (stuckPointEndTime - stuckPointStartTime) / CGFloat(wavSelectCount)
         
+        // 如果视频结束时间点大于歌曲有效结束点,则拼接推荐的时间段直到满足视频播放
+        var videoDurationTemp = suggestRhythmEndTime
+        while stuckPointEndTime > videoDurationTemp {
+            videoDurationTemp  += (suggestRhythmEndTime - suggestRhythmStartTime)
+        }
+        videoDuration = videoDurationTemp
         // 3,一共绘制的竖线个数
         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 {
             // 2,滚动到推荐位置
             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)")
+//            BFLog(1, message: "suggestRhythmStartTime is \(suggestRhythmStartTime)")
             if oneMarginTime * CGFloat(i) >= suggestRhythmStartTime && !isDrawLine {
                 isDrawLine = true
                 linePath.move(to: CGPoint(x: originX, y: -10))

+ 1 - 1
BFFramework/Classes/Utils/PQThirdPlatformUtil.swift

@@ -24,7 +24,7 @@ public class PQSingletoBuglyUtil: NSObject {
         buglyConfig.reportLogLevel = .warn
         #if DEBUG
             buglyConfig.version = versionName + ".6666"
-            buglyConfig.debugMode = true
+            buglyConfig.debugMode = false
         #else
             if PQENVUtil.shared.envMode == .ENVModeOnline {
                 buglyConfig.version = versionName + "." + versionCode