Prechádzať zdrojové kódy

Merge branch 'master' into mv-dev-130

* master:
  预览页 选择音乐 icon变化
  LOG 添加区分人员和上报 bugly 方式
  1,快慢速模式时设置的设置值和跳跃卡的速度分开保存,2,sticker.clipCount分段数 从1 开始。3,修改clipCount临时变量名 防止重名。
  搜索默认提供热门数据
  1,视频切段错误问题导致3个视频+3个图片 显示不对问题,2,修改 LOG
  修复偶现的合成页播放完毕分享到微信返回有音无视频播放问题
  解决偶现预览页返回有loading遮罩显示问题
  fix:缓冲完毕后判断是否播放状态,修改icon
  1,添加快慢速精准位数,2,循环比 Int 整
  添加是否为 INT 值属性,并正确显示
  添加 float 类型精确位数 方法
  fix:偶现 预览页编辑返回
  fix:点击同一个item 标题重影问题
  fix:音乐播放icon状态错误问题
  修改选择框不停变大的bug
  fix:重播后显示loading图标

# Conflicts:
#	BFFramework/Classes/Utils/PQCommonMethodUtil.swift
huzhiqiang 3 rokov pred
rodič
commit
004858c621

+ 33 - 0
BFFramework/Classes/BFModules/BFCategorys/BFFloat+Ext.swift

@@ -0,0 +1,33 @@
+//
+//  BFFloat+Ext.swift
+//  BFFramework
+//
+//  Created by ak on 2021/10/11.
+//
+
+import Foundation
+
+extension Float {
+    /// 准确的小数尾截取 - 没有进位
+    /*
+     // 11.999003  -> 12.0
+     var pp = 11.999003
+     String(format: "%.1f", pp)  这个方法会进行四舍五入
+     */
+    func decimalString(_ base: Self = 1) -> String {
+       return "\(self.decimalNumber(base))"
+    }
+    func decimalNumber(_ base: Self = 1) -> Float {
+        let tempCount: Self = pow(10, base)
+        let temp = self*tempCount
+        
+        let target = Self(Int(temp))
+        let stepone = target/tempCount
+        if stepone.truncatingRemainder(dividingBy: 1) == 0 {
+            return Float(String(format: "%.0f", stepone)) ?? 0.0
+        }else{
+            return stepone
+        }
+    }
+}
+ 

+ 9 - 1
BFFramework/Classes/BFModules/BFCustomViews/views/BFUISlider.swift

@@ -36,6 +36,9 @@ class BFUISlider: UISlider {
     //slider的value文本颜色
     var valueTextColor:UIColor?
     
+    //返回的数值是否为整形
+    var valueIsInt:Bool = false
+    
     lazy var valueLabel:UILabel = {
         let valueLabel = UILabel.init()
         valueLabel.text = "0"
@@ -81,7 +84,12 @@ class BFUISlider: UISlider {
     }
     @objc func sliderValueChanged(sender: BFUISlider) {
         
-        valueText = String(format: "%.1fx", sender.value)
+        if(valueIsInt){
+            valueText = "\(Int(sender.value))x"
+        }else{
+            valueText = "\(sender.value.decimalString())x"
+        }
+      
  
     }
     @objc func sliderTouchUpInside(sender: BFUISlider) {

+ 2 - 0
BFFramework/Classes/Stuckpoint/Controller/PQEditMusicSearchController.swift

@@ -145,6 +145,8 @@ class PQEditMusicSearchController: PQBaseViewController {
 
             if musicInfo.count > 0 {
                 self?.searchController.hotList = musicInfo
+                self?.searchController.configMusicListData(isRefresh: true, musicListData: musicInfo)
+
             }
        
         }

+ 64 - 46
BFFramework/Classes/Stuckpoint/Controller/PQStuckPointEditerController.swift

@@ -60,8 +60,11 @@ class PQStuckPointEditerController: PQBaseViewController {
     var lastEditModelBtn: UIButton?
 
     // add by ak  最大、最小速度 有固定值和自定义,当快慢速下两个值都有效,当跳跃卡点只有maxSpeed有效
-    var maxSpeed: Float = 1
-    var minSpeed: Float = 1
+    // 快慢速模式的 速度设置,快/慢速
+    var modelSpeed_maxSpeed: Float = 1.0
+    var modelSpeed_minSpeed: Float = 1.0
+    //跳跃模式的速度
+    var modelPoint_speed:Float = 1.0
 
     // 快慢速最后一次选择的速度位置
     var lastSpeedSelectIndex: Int = 0
@@ -251,9 +254,12 @@ class PQStuckPointEditerController: PQBaseViewController {
         musicEditBGView.musicSearchBtn.addTarget(self, action: #selector(musicSearchBtnClick(sender:)), for: .touchUpInside)
 
         musicEditBGView.didSelectItemHandle = { [weak self] status in
-            self?.playerView.pause()
             if status == .isSelected{
-                self?.playerView.RenderViewOnclick()
+                if self?.playerView.status != .playing{
+                    self?.playerView.RenderViewOnclick()
+                }
+            }else{
+                self?.playerView.pause()
             }
         }
         musicEditBGView.btnClickHandle = { [weak self] _, bgmData in
@@ -300,7 +306,7 @@ class PQStuckPointEditerController: PQBaseViewController {
     //
     lazy var speedStuckBtnGif: UIImageView = {
         let speedStuckBtnGif = UIImageView()
-        speedStuckBtnGif.kf.setImage(with: URL(fileURLWithPath: Bundle().BF_mainbundle().path(forResource: "speedstuck_h", ofType: ".gif")!))
+        speedStuckBtnGif.kf.setImage(with: URL(fileURLWithPath: Bundle().BF_mainbundle().path(forResource: "speedstuck_h", ofType: "gif")!))
         speedStuckBtnGif.isHidden = true
         return speedStuckBtnGif
 
@@ -319,7 +325,7 @@ class PQStuckPointEditerController: PQBaseViewController {
 
     lazy var jumpPointBtnGif: UIImageView = {
         let jumpPointBtnGif = UIImageView()
-        jumpPointBtnGif.kf.setImage(with: URL(fileURLWithPath: Bundle().BF_mainbundle().path(forResource: "jumpPoint_n", ofType: ".gif")!))
+        jumpPointBtnGif.kf.setImage(with: URL(fileURLWithPath: Bundle().BF_mainbundle().path(forResource: "jumpPoint_n", ofType: "gif")!))
         jumpPointBtnGif.isHidden = true
         return jumpPointBtnGif
 
@@ -359,13 +365,15 @@ class PQStuckPointEditerController: PQBaseViewController {
                     // 更新最后一次选择的位置恢复时使用
                     if self?.speedSettingView.viewType == 1 {
                         self?.lastSpeedSelectIndex = selectIndex
+                        self?.modelSpeed_maxSpeed = maxSpeed
+                        self?.modelSpeed_minSpeed = minSpeed
                     } else if self?.speedSettingView.viewType == 2 {
                         self?.lastJumpSpeedSelectIndex = selectIndex
+                        self?.modelPoint_speed = maxSpeed
                     } else {
                         self?.lastCyclesSelectIndex = selectIndex
                     }
-                    self?.maxSpeed = maxSpeed
-                    self?.minSpeed = minSpeed
+    
                 } else {
                     BFLog(message: "设置速度无效")
                 }
@@ -384,16 +392,18 @@ class PQStuckPointEditerController: PQBaseViewController {
         customSpeedSetView.isHidden = true
         customSpeedSetView.selectSpeedCallBack = { [weak self, weak customSpeedSetView] maxSpeed, minSpeed, isJumpSpeedModel, isCancle in
             if !isCancle {
-                self?.maxSpeed = maxSpeed
-                self?.minSpeed = minSpeed
+     
                 BFLog(message: "自定义速度maxSpeed is\(maxSpeed) minSpeed \(minSpeed) \(isJumpSpeedModel)")
                 self?.musicEditBGView.pausePlayer()
 
                 // 自定定义的更新一下最后的选择位置
                 if self?.speedSettingView.viewType == 1 {
                     self?.lastSpeedSelectIndex = -1
+                    self?.modelSpeed_maxSpeed = maxSpeed
+                    self?.modelSpeed_minSpeed = minSpeed
                 } else if self?.speedSettingView.viewType == 2 {
                     self?.lastJumpSpeedSelectIndex = -1
+                    self?.modelPoint_speed = maxSpeed
                 } else {
                     self?.lastCyclesSelectIndex = Int(maxSpeed - 1)
                 }
@@ -646,8 +656,8 @@ class PQStuckPointEditerController: PQBaseViewController {
                 PQEventTrackViewModel.baseReportUpload(businessType: .bt_buttonClick, objectType: .ot_shanyinApp_musicVideoPreview_selectPatternBgm, pageSource: .sp_shanyinApp_main, extParams: nil, remindmsg: "")
             }
         }
-        speedStuckBtnGif.kf.setImage(with: URL(fileURLWithPath: Bundle().BF_mainbundle().path(forResource: speedStuckBtnGifName, ofType: ".gif")!))
-        jumpPointBtnGif.kf.setImage(with: URL(fileURLWithPath: Bundle().BF_mainbundle().path(forResource: jumpPointBtnGifName, ofType: ".gif")!))
+        speedStuckBtnGif.kf.setImage(with: URL(fileURLWithPath: Bundle().BF_mainbundle().path(forResource: speedStuckBtnGifName, ofType: "gif")!))
+        jumpPointBtnGif.kf.setImage(with: URL(fileURLWithPath: Bundle().BF_mainbundle().path(forResource: jumpPointBtnGifName, ofType: "gif")!))
 
         speedStuckBtnGif.isHidden = false
         jumpPointBtnGif.isHidden = false
@@ -673,6 +683,8 @@ class PQStuckPointEditerController: PQBaseViewController {
 
         musicEditBGView.pausePlayer()
         PQNotification.removeObserver(self)
+        
+        self.synchroMarskView.removeMarskView()
     }
 
     override func viewDidLoad() {
@@ -831,8 +843,8 @@ class PQStuckPointEditerController: PQBaseViewController {
         playerView.pause()
         let videoExporter = PQStuckPointPublicController()
         videoExporter.rhythmMode = currentCreateStickersModel
-        videoExporter.syncedUpVideoSpeedMin = minSpeed
-        videoExporter.syncedUpVideoSpeedMax = maxSpeed
+        videoExporter.syncedUpVideoSpeedMin = modelSpeed_maxSpeed
+        videoExporter.syncedUpVideoSpeedMax = modelSpeed_minSpeed
         videoExporter.isReCreate = isReCreate
         videoExporter.selectedTotalDuration = selectedTotalDuration
         videoExporter.selectedDataCount = selectedDataCount
@@ -1090,6 +1102,7 @@ class PQStuckPointEditerController: PQBaseViewController {
         PQSingletoMemoryUtil.shared.allExportSession.forEach { _, exportSession in
             exportSession.cancelExport()
         }
+        self.synchroMarskView.removeMarskView()
         BFLog(1, message: "卡点视频预览界面release")
     }
 }
@@ -1249,7 +1262,7 @@ extension PQStuckPointEditerController {
                                 let asset: AVURLAsset = AVURLAsset(url: URL(fileURLWithPath: documensDirectory + sticker.locationPath), options: nil)
                                 BFLog(message: "单个视频\(sticker.locationPath)时长::\(CMTimeGetSeconds(asset.duration)) ,clipNum is:\(sticker.clipCount)")
                                 var lastOutTime: Float64 = 0.0
-                                for _ in 0 ... sticker.clipCount {
+                                for _ in 1 ... sticker.clipCount {
                                     // deep copy sticker model 防止只有一个对象
                                     let deepCopyStickerDecoderTime: TimeInterval = Date().timeIntervalSince1970
                                     
@@ -1262,7 +1275,8 @@ extension PQStuckPointEditerController {
                                     // 当前分段的速度
                                     var tempSpeed: Float = 1.0
                                     if model == .createStickersModelSpeed {
-                                        tempSpeed = (stickers.count % 2) == 0 ? maxSpeed : minSpeed
+                                        
+                                        tempSpeed = (stickers.count % 2) == 0 ? modelSpeed_maxSpeed : modelSpeed_minSpeed
                                     }
 
                                     if stickers.count + 1 < finallyStuckPoints.count {
@@ -1311,10 +1325,14 @@ extension PQStuckPointEditerController {
 
                                         lastOutTime = deepCopySticker?.out ?? 0
                                     }
-                                    BFLog(message: "测试人员创建 sticker  crilp is in 视频 \(String(format: "%.6f", deepCopySticker?.model_in ?? 0))  out  \(String(format: "%.6f", deepCopySticker?.out ?? 0)) ,分段素材时长:\(String(format: "%.6f", (deepCopySticker?.out ?? 0) - (deepCopySticker?.model_in ?? 0))) ,分段显示时长:\(String(format: "%.6f", (deepCopySticker?.timelineOut ?? 0) - (deepCopySticker?.timelineIn ?? 0))), 视频素材原时长\(CMTimeGetSeconds(asset.duration)) timelineIN: \(String(format: "%.6f", deepCopySticker?.timelineIn ?? 0)) timelineOUT:\(String(format: "%.6f", deepCopySticker?.timelineOut ?? 0)) speedRate:\(deepCopySticker?.speedRate ?? 0.0)")
-
+                                    BFLog(message: "测试人员创建 sticker  crilp is in 视频 \(String(format: "%.6f", deepCopySticker?.model_in ?? 0))  out  \(String(format: "%.6f", deepCopySticker?.out ?? 0)) ,分段素材时长:\(String(format: "%.6f", (deepCopySticker?.out ?? 0) - (deepCopySticker?.model_in ?? 0))) ,分段显示时长:\(String(format: "%.6f", (deepCopySticker?.timelineOut ?? 0) - (deepCopySticker?.timelineIn ?? 0))), 视频素材原时长\(CMTimeGetSeconds(asset.duration)) clipNum \(sticker.clipCount) timelineIN: \(String(format: "%.6f", deepCopySticker?.timelineIn ?? 0)) timelineOUT:\(String(format: "%.6f", deepCopySticker?.timelineOut ?? 0)) speedRate:\(deepCopySticker?.speedRate ?? 0.0)")
+                                    
                                     if deepCopySticker != nil {
+                                        if(deepCopySticker?.timelineIn == 0){
+                                            BFLog(message: "timelineIn data is error!!!")
+                                        }
                                         stickers.append(deepCopySticker!)
+                                 
                                     }
                                 }
                             } else if sticker.type == StickerType.IMAGE.rawValue {
@@ -1327,7 +1345,7 @@ extension PQStuckPointEditerController {
                                 sticker.timelineIn = Float64(String(format: "%.6f",finallyStuckPoints[stickers.count])) ?? 0.0
                                 sticker.timelineOut = Float64(String(format: "%.6f",finallyStuckPoints[stickers.count + 1])) ?? 0.0
                                 stickers.append(sticker)
-                                BFLog(1, message: "测试人员创建 sticker  crilp is in 图片 \(String(format: "%.6f", sticker.model_in))  out  \(String(format: "%.6f", sticker.out)) ,分段素材时长:\(String(format: "%.6f", (sticker.out) - (sticker.model_in))) ,分段显示时长:\(String(format: "%.6f", (sticker.timelineOut) - (sticker.timelineIn))),   timelineIN: \(String(format: "%.6f", sticker.timelineIn)) timelineOUT:\(String(format: "%.6f", sticker.timelineOut)) speedRate:\(sticker.speedRate)")
+                                BFLog(message: "测试人员创建 sticker  crilp is in 图片 \(String(format: "%.6f", sticker.model_in))  out  \(String(format: "%.6f", sticker.out)) ,分段素材时长:\(String(format: "%.6f", (sticker.out) - (sticker.model_in))) ,分段显示时长:\(String(format: "%.6f", (sticker.timelineOut) - (sticker.timelineIn))),   timelineIN: \(String(format: "%.6f", sticker.timelineIn)) timelineOUT:\(String(format: "%.6f", sticker.timelineOut)) speedRate:\(sticker.speedRate)")
                             }
                         }
                     }
@@ -1399,10 +1417,10 @@ extension PQStuckPointEditerController {
         return stuckPoints
     }
 
-    func clipPoint(clipCount: Int, oldPoints: Array<Float>) {
-        BFLog(message: "拼接卡点数:\(clipCount)")
-        if(clipCount < 0 || oldPoints.count < 2){
-            BFLog(message: "clipCount is error!!!! \(clipCount)")
+    func clipPoint(clipNum: Int, oldPoints: Array<Float>) {
+        BFLog(message: "拼接卡点数:\(clipNum)")
+        if(clipNum < 0 || oldPoints.count < 2){
+            BFLog(message: "clipNum is error!!!! \(clipNum)")
             return
         }
         // 如果是第一次拼接先补第0位
@@ -1410,7 +1428,7 @@ extension PQStuckPointEditerController {
             finallyStuckPoints.append(stuckPointsTemp.first ?? 0.0)
         }
         
-        for i in finallyStuckPoints.count ... clipCount + finallyStuckPoints.count {
+        for i in finallyStuckPoints.count ... clipNum + finallyStuckPoints.count {
             if (i % (oldPoints.count - 1)) != 1 {
                let value =  String(format: "%.6f", finallyStuckPoints[i - 1] + oldPoints[((i-1) % (oldPoints.count - 1)) + 1] - oldPoints[((i - 2) % (oldPoints.count - 1)) + 1])
                 
@@ -1439,7 +1457,7 @@ extension PQStuckPointEditerController {
             var i: Int = 0
             // L/(n+1)  L -原视觉素材总时长  n-抛留倍数  lastJumpSpeedSelectIndex 是位置 对应的值要+1
             // 根据公式计划出的总时长
-            let jumpTime = Float(selectedTotalDuration) / Float(maxSpeed + 1)
+            let jumpTime = Float(selectedTotalDuration) / Float(modelPoint_speed + 1)
             // 只有图片素材时会为0
             if jumpTime > 0 {
                 while useAssestDuration < Float(jumpTime) {
@@ -1457,7 +1475,7 @@ extension PQStuckPointEditerController {
 
                 // 拼接要使用的卡点信息
 
-                clipPoint(clipCount: clipNum, oldPoints: stuckPointsTemp)
+                clipPoint(clipNum: clipNum, oldPoints: stuckPointsTemp)
             }
 
             break
@@ -1466,11 +1484,11 @@ extension PQStuckPointEditerController {
             var tempMaxSpeed: Float = 1
             var tempMinSpeed: Float = 1
             //速度有为0 会出现在切换模式时,目前是共用一个参数值,会清掉老值 TODO
-            if((maxSpeed == 0.0 && minSpeed == 0.0) && selectedDataCount != selectedImageDataCount && model == .createStickersModelSpeed){
-                BFLog(message: "速度参数有错误 要重新计算!!!")
-                dealWithDataSuccess()
-                return
-            }
+//            if((maxSpeed == 0.0 && minSpeed == 0.0) && selectedDataCount != selectedImageDataCount && model == .createStickersModelSpeed){
+//                BFLog(message: "速度参数有错误 要重新计算!!!")
+//                dealWithDataSuccess()
+//                return
+//            }
             if model == .createStickersModelSpeed {
                 // 改变速率,.只有快慢速且非只有图片素材时自动+1处理
                 if model == .createStickersModelSpeed && selectedDataCount != selectedImageDataCount {
@@ -1479,8 +1497,8 @@ extension PQStuckPointEditerController {
                     stuckPointsTemp = getUsedStuckPoint(seed: (stuckPointMusicData?.speed ?? 0))
                 }
 
-                tempMaxSpeed = maxSpeed
-                tempMinSpeed = minSpeed
+                tempMaxSpeed = modelSpeed_maxSpeed
+                tempMinSpeed = modelSpeed_minSpeed
             } else {
                 stuckPointsTemp = getUsedStuckPoint(seed: (stuckPointMusicData?.speed ?? 0))
                 
@@ -1511,12 +1529,12 @@ extension PQStuckPointEditerController {
                             }
                             var j = finallyStuckPoints.count
                             // 添加卡点的段数 用于判断当前卡点是快/慢速
-                            var pointCount:Int = 0
+                            var pointCount:Int = 1
                             // 已经取到的视频素材总长度,用于和原视频素材时长做对比,不够多加一个卡点
                             var useAssestDurationTemp: Float = 0.0
                             while useAssestDurationTemp < assetDuration {
                                 //当前段的应该使用的速度 A/B
-                                let useSpeed = (pointCount % 2 == 0 ) ? tempMaxSpeed : tempMinSpeed
+                                let useSpeed = (pointCount % 2 != 0 ) ? tempMaxSpeed : tempMinSpeed
                                 // 计算卡点
                                 //要添加的卡点数值
                                 var sub:Float = 0.0
@@ -1550,10 +1568,10 @@ extension PQStuckPointEditerController {
 
                             // 3,多补一个卡点 做 C级 速处理,要根据条件不满足 要删除最后一位,
                             if useAssestDurationTemp < assetDuration {
-                                // 下一个卡的的速度性质快、慢
+                                // 下一个卡的的速度性质快、慢,e.g. sticker.clipCount = 5时 tempSpeed 应该是慢速。下面计算正确。
                                 var tempSpeed: Float = 1.0
                                 if model == .createStickersModelSpeed {
-                                    tempSpeed = (sticker.clipCount) % 2 == 0 ? maxSpeed : minSpeed
+                                    tempSpeed = (sticker.clipCount) % 2 == 0 ? modelSpeed_maxSpeed : modelSpeed_minSpeed
                                 }
                                 // 最后一点素材时长
                                 let lastAssetDuration = Float(CMTimeGetSeconds(asset.duration)) - useAssestDurationTemp
@@ -1595,7 +1613,7 @@ extension PQStuckPointEditerController {
         }
         // 拼接图片所使用的时长.选择一组图片 按图片数量计算卡点的总时长
         if selectedImageDataCount > 0 {
-            clipPoint(clipCount: selectedImageDataCount - 1, oldPoints: stuckPointsTemp)
+            clipPoint(clipNum: selectedImageDataCount - 1, oldPoints: stuckPointsTemp)
         }
 
         // 全是图片时数组里放着的一定都是图片的使用的卡点
@@ -1612,7 +1630,7 @@ extension PQStuckPointEditerController {
             if lastCyclesSelectIndex != -1 {
                 // 纯图片时 已经默认添加一次循环 所以要用lastCyclesSelectIndex - 1
                 if(lastCyclesSelectIndex != 0){
-                    clipPoint(clipCount: selectedImageDataCount * lastCyclesSelectIndex - 1, oldPoints: stuckPointsTemp)
+                    clipPoint(clipNum: selectedImageDataCount * lastCyclesSelectIndex - 1, oldPoints: stuckPointsTemp)
                 }
            
             } else {
@@ -1620,7 +1638,7 @@ extension PQStuckPointEditerController {
                     lastCyclesSelectIndex = 0
                     while oneSelectImageDuration < 10 {
                         // 不够10S 时 一次加图片数量的卡点数
-                        clipPoint(clipCount: selectedImageDataCount - 1, oldPoints: stuckPointsTemp)
+                        clipPoint(clipNum: selectedImageDataCount - 1, oldPoints: stuckPointsTemp)
                         oneSelectImageDuration = Float((finallyStuckPoints.last ?? 0) - (finallyStuckPoints.first ?? 0))
 
                         lastCyclesSelectIndex = lastCyclesSelectIndex + 1
@@ -1836,12 +1854,12 @@ extension PQStuckPointEditerController {
             // 1 生成默认参数值
             /*
              - 当素材总时长∈[0-6)s 时,提示推荐仅配乐模式 or 快慢速模式
-             - 当素材总时长∈[6-80)s 时,卡点抛留倍数为1x,即留1抛1
-             - 当素材总时长∈[80,120)s 时,卡点抛留倍数为2x,即留1抛2
-             - 当素材总时长∈[120,160)s 时,卡点抛留倍数为3x,即留1抛3
-             - 当素材总时长∈[160,200)s 时,卡点抛留倍数为4x,即留1抛4
-             - 当素材总时长∈[200,240)s 时,卡点抛留倍数为5x,即留1抛5
-             - 当素材总时长∈[240,∞)s 时,卡点抛留倍数为5x,即留1抛5
+             - 当素材总时长∈[6-80)s 时,卡点抛留倍数为1x
+             - 当素材总时长∈[80,120)s 时,卡点抛留倍数为2x
+             - 当素材总时长∈[120,160)s 时,卡点抛留倍数为3x
+             - 当素材总时长∈[160,200)s 时,卡点抛留倍数为4x
+             - 当素材总时长∈[200,240)s 时,卡点抛留倍数为5x
+             - 当素材总时长∈[240,∞)s 时,卡点抛留倍数为5x
              */
             // 1.1) 生成跳跃卡点的默认值
             if selectedTotalDuration >= 6 && selectedTotalDuration < 80 {

+ 10 - 4
BFFramework/Classes/Stuckpoint/Controller/PQStuckPointMusicContentController.swift

@@ -248,17 +248,23 @@ extension PQStuckPointMusicContentController: UICollectionViewDelegate, UICollec
                     (itemList[indexPath.item] as? PQVoiceModel)?.isSelected = true
                     (itemList[indexPath.item] as? PQVoiceModel)?.isPlaying = true
                 }
-                var indexpaths = [indexPath]
+//                var indexpaths = [indexPath]
                 if lastIndexPath != nil {
-                    indexpaths.append(lastIndexPath!)
+//                    indexpaths.append(lastIndexPath!)
+                    let cell = collectionView.cellForItem(at: lastIndexPath!) as? PQStuckPointMusicContentCell
+                    cell?.bgmData = itemList[lastIndexPath!.item]
                 }
-                collectionView.reloadItems(at: indexpaths)
+                let cell = collectionView.cellForItem(at: indexPath) as? PQStuckPointMusicContentCell
+                cell?.bgmData = itemList[indexPath.item]
+//                collectionView.reloadItems(at: indexpaths)
                 lastIndexPath = indexPath
 //                collectionView.reloadData()
             } else if contentType != .catagery {
                 (itemList[indexPath.item] as? PQVoiceModel)?.isPlaying = !((itemList[indexPath.item] as? PQVoiceModel)?.isPlaying ?? false)
                 (itemList[indexPath.item] as? PQVoiceModel)?.isSelected = true
-                collectionView.reloadItems(at: [indexPath])
+                let cell = collectionView.cellForItem(at: indexPath) as? PQStuckPointMusicContentCell
+                cell?.bgmData = itemList[indexPath.item]
+//                collectionView.reloadItems(at: [indexPath])
             }
         }
         if contentType == .catagery {

+ 1 - 0
BFFramework/Classes/Stuckpoint/Controller/PQStuckPointMusicController.swift

@@ -395,6 +395,7 @@ class PQStuckPointMusicController: PQBaseViewController {
             if musicInfo.count > 0, isHotPage, isRefresh {
                 self?.hotList = musicInfo
                 self?.searchController.hotList = self?.hotList ?? []
+                self?.searchController.configMusicListData(isResetData: false, isRefresh: true, musicListData: musicInfo)
             }
         }
     }

+ 2 - 1
BFFramework/Classes/Stuckpoint/Controller/PQStuckPointPublicController.swift

@@ -35,7 +35,7 @@ class PQStuckPointPublicController: PQBaseViewController {
     // 最大的宽度
     private var maxWidth: CGFloat = cScreenWidth
     // 最大的高度
-    private var maxHeight: CGFloat = 385
+    private var maxHeight: CGFloat = cScreenHeigth > 568 ? 385 : 385*cScreenHeigth/818
     // 开始导出的时间
     private let startExportDate: Float64 = Date().timeIntervalSince1970
     // 导出结束的时间
@@ -1375,6 +1375,7 @@ extension PQStuckPointPublicController {
         }
 
         playBtn.isHidden = true
+        playerHeaderCoverImageView.isHidden = true
         avPlayer.play()
     }
 

+ 4 - 3
BFFramework/Classes/Stuckpoint/View/PQCustomSpeedSettingView.swift

@@ -131,6 +131,7 @@ class PQCustomSpeedSettingView: UIView {
             }else if(viewType == 3){
                 titleLab.text = "自定义循环"
                 jumpSpeedSlider.maximumValue = 20
+                jumpSpeedSlider.valueIsInt = true
             }
         }
     }
@@ -251,12 +252,12 @@ class PQCustomSpeedSettingView: UIView {
     // 确认
     @objc func confirmClick(sender _: UIButton) {
         isHidden = true
-        BFLog(message: "fastSlider: \(fastSlider.value) slowSlider: \(slowSlider.value) jumpSpeedSlider:\(jumpSpeedSlider.value)")
+        BFLog(message: "fastSlider: \(fastSlider.value.decimalNumber()) slowSlider: \(slowSlider.value.decimalNumber()) jumpSpeedSlider:\(jumpSpeedSlider.value.decimalNumber(0))")
         if selectSpeedCallBack != nil {
             if(viewType == 1){
-                selectSpeedCallBack!(fastSlider.value, slowSlider.value, viewType,false)
+                selectSpeedCallBack!(fastSlider.value.decimalNumber(), slowSlider.value.decimalNumber(), viewType,false)
             }else{
-                selectSpeedCallBack!(jumpSpeedSlider.value, 0, viewType,false)
+                selectSpeedCallBack!(jumpSpeedSlider.value.decimalNumber(0), 0, viewType,false)
             }
         
         }

+ 28 - 13
BFFramework/Classes/Stuckpoint/View/PQSelecteMusicView.swift

@@ -277,6 +277,14 @@ class PQSelecteMusicView: UIView {
             avPlayer.pause()
             playerItem?.removeObserver(self, forKeyPath: "status")
             playerItem?.removeObserver(self, forKeyPath: "error")
+            
+            if itemData!.musicId == currentPlayingInVideoData?.musicId {
+                itemData?.voiceStatue = .isSelected
+                currentPlayData = itemData
+                playerItem = nil
+                return
+            }
+            
             playerItem = AVPlayerItem(url: URL(string: itemData?.musicPath ?? "")!)
             if (itemData?.endTime ?? 0) > 0, (itemData?.endTime ?? 0) > (itemData?.startTime ?? 0) {
                 playerItem?.forwardPlaybackEndTime = CMTime(value: CMTimeValue((itemData?.endTime ?? 0) * playerTimescale), timescale: CMTimeScale(playerTimescale))
@@ -290,11 +298,12 @@ class PQSelecteMusicView: UIView {
 
             currentPlayData = itemData
         } else if itemData != nil, avPlayer.rate == 0.0 {
-            avPlayer.play()
-            itemData?.voiceStatue = .isPlaying
+            if itemData?.musicId != currentPlayingInVideoData?.musicId {
+                avPlayer.play()
+                itemData?.voiceStatue = .isPlaying
+            }
         } else {
             avPlayer.pause()
-     
             itemData?.voiceStatue = .isPause
       
         }
@@ -350,11 +359,15 @@ extension PQSelecteMusicView: UICollectionViewDelegate, UICollectionViewDataSour
 
             let itemData: Any = musicDatas[indexPath.item]
             let cell = collectionView.dequeueReusableCell(withReuseIdentifier: String(describing: PQSelectMusicCell.self), for: indexPath) as! PQSelectMusicCell
+            if (currentPlayingInVideoData?.musicId != nil && currentPlayingInVideoData?.musicId == (itemData as? PQVoiceModel)?.musicId){
+                (itemData as? PQVoiceModel)?.voiceStatue = .isSelected
+            }
             cell.bgmData = itemData as? PQVoiceModel
             cell.btnClickHandle = { [weak self] sender, bgmData in
                 
                 //暂停播放音乐
                 self?.pausePlayer()
+                self?.currentPlayingInVideoData?.voiceStatue = .isNormal
                 self?.currentPlayingInVideoData = bgmData as? PQVoiceModel
                 PQEventTrackViewModel.baseReportUpload(businessType: .bt_buttonClick, objectType: .ot_shanyinApp_musicVideoPreview_musicSelect, pageSource: .sp_shanyinApp_main, extParams: ["musicName":(bgmData as? PQVoiceModel)?.musicName ?? "" ,"musicId":(bgmData as? PQVoiceModel)?.musicId ?? ""], remindmsg: "")
                 
@@ -407,19 +420,21 @@ extension PQSelecteMusicView: UICollectionViewDelegate, UICollectionViewDataSour
             }
             let music = musicDatas[indexPath.item]
             music.voiceStatue = .isSelected
-            if music.musicId != currentPlayingInVideoData?.musicId{
-                playStuckPointMusic(itemData:music)
-            }
-            selectMusicCollection.reloadData()
+//            if music.musicId != currentPlayingInVideoData?.musicId{
+            playStuckPointMusic(itemData:music)
+//            }else{
+//                avPlayer.pause()
+//            }
             PQEventTrackViewModel.baseReportUpload(businessType: .bt_buttonClick, objectType: .ot_shanyinApp_musicVideoPreview_musicCategorySelect, pageSource: .sp_shanyinApp_main, extParams: ["categoryName":currentSelectTag?.tagName ?? "","categoryId":currentSelectTag?.tagId ?? ""], remindmsg: "")
 
-            if music.musicId != currentPlayingInVideoData?.musicId{
+//            if music.musicId != currentPlayingInVideoData?.musicId{
 //                BFLog(1, message: "预览:\(music.musicName) 当前:\(currentPlayingInVideoData?.musicName)")
-                if didSelectItemHandle != nil {
-                    didSelectItemHandle!(music.voiceStatue)
-                }
+//            }
+            if didSelectItemHandle != nil {
+                didSelectItemHandle!(music.voiceStatue)
             }
-            
+            selectMusicCollection.reloadData()
+
          
         }else{
             //停止分类列表的滑动。防止切换分类时 crash
@@ -443,7 +458,7 @@ extension PQSelecteMusicView: UICollectionViewDelegate, UICollectionViewDataSour
 
     func collectionView(_ collectionView: UICollectionView, willDisplay _: UICollectionViewCell, forItemAt indexPath: IndexPath) {
         
-        if (collectionView == selectMusicCollection ){
+        if (collectionView == selectMusicCollection && musicDatas.count > indexPath.item ){
             let music = musicDatas[indexPath.item]
             
             PQEventTrackViewModel.baseReportUpload(businessType: .bt_buttonView, objectType: .ot_shanyinApp_musicVideoPreview_musicView, pageSource: .sp_shanyinApp_main, extParams: ["musicName":music.musicName ?? "" ,"musicId":music.musicId ?? ""], remindmsg: "")

+ 1 - 1
BFFramework/Classes/Stuckpoint/View/PQStuckPointCuttingView.swift

@@ -205,7 +205,7 @@ class PQStuckPointCuttingView: UIView {
 
     func addData() {
         // 1,选择区内的线个数 ,划动区域后 个数会变???
-        wavSelectCount = Int(ceil((cropViewWidth - frequencyWidth) / (frequencyWidth + frequencyMargin)) + 1)
+        wavSelectCount = Int(ceil((adapterWidth(width: 250) - frequencyWidth) / (frequencyWidth + frequencyMargin)) + 1)
         
         cropViewWidth = CGFloat(wavSelectCount) * (frequencyWidth + frequencyMargin) + frequencyWidth
         margin = (cScreenWidth - cropViewWidth) / 2.0

+ 5 - 2
BFFramework/Classes/Stuckpoint/View/PQStuckPointMusicContentCell.swift

@@ -125,7 +125,8 @@ class PQStuckPointMusicContentCell: UICollectionViewCell {
                 imageMaskView.isHidden = false
                 playImageView.isHidden = false
                 if (bgmData as? PQVoiceModel)?.isPlaying ?? false {
-                    if playImageView.image == nil ||  playImageView.image == UIImage().BF_Image(named: "stuckPoint_music_pause"){
+//                    if playImageView.image == nil ||  playImageView.image == UIImage().BF_Image(named: "stuckPoint_music_pause"){
+                    if playImageView.image == nil {
                         playImageView.image = UIImage().BF_Image(named: "loading")
                         startLoadingAnimation()
                     }else {
@@ -248,6 +249,8 @@ class PQStuckPointMusicContentCell: UICollectionViewCell {
     
     func stopLoadingAnimation(){
         playImageView.layer.removeAllAnimations()
-        playImageView.kf.setImage(with: URL(fileURLWithPath: Bundle().BF_mainbundle().path(forResource: "stuckPoint_music_playing", ofType: ".gif")!))
+        if (bgmData as? PQVoiceModel)?.isPlaying ?? false {
+            playImageView.kf.setImage(with: URL(fileURLWithPath: Bundle().BF_mainbundle().path(forResource: "stuckPoint_music_playing", ofType: ".gif")!))
+        }
     }
 }

+ 2 - 2
BFFramework/Classes/Stuckpoint/ViewModel/PQPlayerViewModel.swift

@@ -670,7 +670,7 @@ extension PQPlayerViewModel {
                     
                     clipTotalDuration = clipTotalDuration + Float(CMTimeGetSeconds(trackTimeRange.duration))
                 }
-                BFLog(1, message: "原音频时长短:count = \(count),startTime = \(startTime),trackTimeRange = \(trackTimeRange)")
+//                BFLog(1, message: "原音频时长短:count = \(count),startTime = \(startTime),trackTimeRange = \(trackTimeRange)")
                 let parameters = mixAudioTrack(audioAsset: originAsset, startTime: startTime, trackTimeRange: trackTimeRange, volume: volume, composition: composition)
                 if parameters != nil {
                     tempParameters.append(parameters!)
@@ -684,7 +684,7 @@ extension PQPlayerViewModel {
             let startTime = CMTime(value: CMTimeValue(clipTotalDuration * Float(playerTimescaleInt)), timescale: playerTimescaleInt)
             
             let trackTimeRange = CMTimeRange(start: startTime, end: CMTime(value: CMTimeValue((CMTimeGetSeconds(startTime) + row) * Double(playerTimescaleInt)), timescale: playerTimescaleInt))
-            BFLog(1, message: "最后一小段音乐时长短:count = \(count),startTime = \(startTime),trackTimeRange = \(trackTimeRange)")
+            BFLog(1, message: "最后一小段音乐时长短:count = \(count),startTime = \(CMTimeShow(startTime)),trackTimeRange = \(CMTimeRangeShow(trackTimeRange))")
             let parameters = mixAudioTrack(audioAsset: originAsset, startTime: startTime, trackTimeRange: trackTimeRange, volume: volume, composition: composition)
             if parameters != nil {
                 tempParameters.append(parameters!)

+ 20 - 21
BFFramework/Classes/Utils/PQCommonMethodUtil.swift

@@ -132,32 +132,31 @@ public func kf_imageCacheImage(originUrl: String, completeHandle: @escaping (_ i
     }
 }
 
-/** 打印 */
+/** 打印
+   type = 1 : 胡志强
+   type = 2 :王成
+   type = 3 : 文伟伟
+ 
+ */
 public func BFLog<T>( _ type : Int = 0, _ file:String = #file, _ line:Int = #line, message: T) {
-    
-    
+   
     let file = (file as NSString).lastPathComponent;
-    let dateFmt = DateFormatter()
-    dateFmt.dateFormat = "HH:mm:ss:SSSS"
-    let msg = "\(dateFmt.string(from: Date())) \(file):(\(line))--\(message)"
-    
-#if DEBUG
-    if type == 0 {
-
+    let msg = "\(file) (L:\(line)) \(message)"
+    if type == 0{ 
         BuglyLog.level(.warn, logs: msg)
-    }else if type == 3 {
-        print("hhz-\(msg)");
     }
+#if DEBUG
+    let dateFmt = DateFormatter()
+    dateFmt.dateFormat = "HH:mm:ss:SSSS"
+     if type == 1 {
+        print("hhz-\(dateFmt.string(from: Date())) \(msg)");
+     }else if type == 2 {
+        print("ak-\(dateFmt.string(from: Date())) \(msg)");
+     }else if type == 3 {
+        print("ww-\(dateFmt.string(from: Date())) \(msg)");
+     }
+ 
 #endif
-//    if PQENVUtil.shared.envMode == .ENVModeTest {
-//     
-//    }else{
-//        if(PQBFConfig.shared.enableBFLog){
-//            print(message)
-//        }else{
-//            BuglyLog.level(.warn, logs: message as? String)
-//        }
-//    }
  
 }