Browse Source

add codeformat(swiftformat)

wenweiwei 3 years ago
parent
commit
6619eb4bf2
38 changed files with 773 additions and 754 deletions
  1. 65 0
      .swiftformat
  2. 0 2
      BFStuckPointKit/Classes/BFConfig/BFStuckPointKitConfig.swift
  3. 5 5
      BFStuckPointKit/Classes/BFUtils/PQSingletoSourcesFileUtil.swift
  4. 28 28
      BFStuckPointKit/Classes/BFUtils/PQSingletoVideoPlayer.swift
  5. 2 2
      BFStuckPointKit/Classes/BFUtils/PQThirdPlatformUtil.swift
  6. 28 28
      BFStuckPointKit/Classes/Controller/PQEditMusicSearchController.swift
  7. 9 9
      BFStuckPointKit/Classes/Controller/PQStuckPointEditerController.swift
  8. 18 19
      BFStuckPointKit/Classes/Controller/PQStuckPointMaterialController.swift
  9. 10 10
      BFStuckPointKit/Classes/Controller/PQStuckPointMusicContentController.swift
  10. 41 43
      BFStuckPointKit/Classes/Controller/PQStuckPointMusicController.swift
  11. 6 6
      BFStuckPointKit/Classes/Controller/PQStuckPointMusicSearchController.swift
  12. 15 15
      BFStuckPointKit/Classes/Controller/PQStuckPointPublicController.swift
  13. 12 16
      BFStuckPointKit/Classes/Model/BFCoreDataModel.swift
  14. 5 6
      BFStuckPointKit/Classes/Model/BFDataPersistentManager.swift
  15. 26 30
      BFStuckPointKit/Classes/View/PQCustomSpeedSettingView.swift
  16. 19 22
      BFStuckPointKit/Classes/View/PQCustomSwitchView.swift
  17. 2 2
      BFStuckPointKit/Classes/View/PQCuttingPointView.swift
  18. 37 48
      BFStuckPointKit/Classes/View/PQEditPublicCoverImageView.swift
  19. 26 29
      BFStuckPointKit/Classes/View/PQEditPublicTitleView.swift
  20. 102 129
      BFStuckPointKit/Classes/View/PQSelecteMusicView.swift
  21. 2 2
      BFStuckPointKit/Classes/View/PQSelectedMaterialListView.swift
  22. 75 90
      BFStuckPointKit/Classes/View/PQSpeedSettingView.swift
  23. 73 90
      BFStuckPointKit/Classes/View/PQStuckPointCuttingView.swift
  24. 13 18
      BFStuckPointKit/Classes/View/PQStuckPointLoadingView.swift
  25. 3 3
      BFStuckPointKit/Classes/View/PQStuckPointMaterialHeadView.swift
  26. 14 15
      BFStuckPointKit/Classes/View/PQStuckPointMusicContentCell.swift
  27. 1 1
      BFStuckPointKit/Classes/View/PQStuckPointMusicTagsCell.swift
  28. 1 1
      BFStuckPointKit/Classes/View/PQStuckPointMusicTagsContentCell.swift
  29. 2 2
      BFStuckPointKit/Classes/View/PQStuckPointSearchEmptyCell.swift
  30. 3 3
      BFStuckPointKit/Classes/View/PQVideoCutingOprateView.swift
  31. 33 39
      BFStuckPointKit/Classes/ViewModel/PQBaseViewModel.swift
  32. 11 12
      BFStuckPointKit/Classes/ViewModel/PQStuckPointViewModel.swift
  33. 2 0
      Example/BFStuckPointKit.xcodeproj/project.pbxproj
  34. 6 11
      Example/BFStuckPointKit/AppDelegate.swift
  35. 0 3
      Example/BFStuckPointKit/ViewController.swift
  36. 6 8
      Example/Podfile.lock
  37. 5 7
      Example/Tests/Tests.swift
  38. 67 0
      rules.swiftformat

+ 65 - 0
.swiftformat

@@ -0,0 +1,65 @@
+--allman false
+--assetliterals visual-width
+--beforemarks 
+--binarygrouping none
+--categorymark "MARK: %c"
+--classthreshold 0
+--closingparen balanced
+--commas always
+--conflictmarkers reject
+--decimalgrouping none
+--elseposition same-line
+--enumthreshold 0
+--exponentcase lowercase
+--exponentgrouping disabled
+--extensionacl on-extension
+--extensionlength 0
+--extensionmark "MARK: - %t + %c"
+--fractiongrouping disabled
+--fragment false
+--funcattributes preserve
+--groupedextension "MARK: %c"
+--guardelse auto
+--header ignore
+--hexgrouping 4,8
+--hexliteralcase uppercase
+--ifdef indent
+--importgrouping alphabetized
+--indent 4
+--indentcase false
+--lifecycle 
+--linebreaks lf
+--markextensions always
+--marktypes always
+--maxwidth none
+--modifierorder 
+--nevertrailing 
+--nospaceoperators ...,..<
+--nowrapoperators 
+--octalgrouping none
+--operatorfunc spaced
+--organizetypes class,enum,struct
+--patternlet hoist
+--ranges spaced
+--redundanttype inferred
+--self remove
+--selfrequired 
+--semicolons inline
+--shortoptionals always
+--smarttabs enabled
+--stripunusedargs closure-only
+--structthreshold 0
+--tabwidth unspecified
+--trailingclosures 
+--trimwhitespace always
+--typeattributes preserve
+--typemark "MARK: - %t"
+--varattributes preserve
+--voidtype void
+--wraparguments preserve
+--wrapcollections preserve
+--wrapconditions preserve
+--wrapparameters preserve
+--wrapreturntype preserve
+--xcodeindentation disabled
+--yodaswap always

+ 0 - 2
BFStuckPointKit/Classes/BFConfig/BFStuckPointKitConfig.swift

@@ -24,7 +24,6 @@ public class BFStuckPointKitConfig: NSObject {
 }
 
 public func BFStuckPointImage(by name: String) -> UIImage? {
-    
     guard let url = currentBundle()?.url(forResource: "BFStuckPointKit_Resources", withExtension: "bundle") else {
         return nil
     }
@@ -34,4 +33,3 @@ public func BFStuckPointImage(by name: String) -> UIImage? {
 func currentBundle() -> Bundle? {
     return Bundle(for: BFStuckPointKitConfig.self)
 }
-

+ 5 - 5
BFStuckPointKit/Classes/BFUtils/PQSingletoSourcesFileUtil.swift

@@ -7,13 +7,13 @@
 //  Copyright © 2020 BytesFlow. All rights reserved.
 //
 
-import UIKit
 import BFCommonKit
+import UIKit
 
 public class PQSingletoSourcesFileUtil: NSObject {
-    static public let shared = PQSingletoSourcesFileUtil()
+    public static let shared = PQSingletoSourcesFileUtil()
 
-   public let cPlistPath = NSString(string: NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true).first!).appendingPathComponent("sourcesFile.plist")
+    public let cPlistPath = NSString(string: NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true).first!).appendingPathComponent("sourcesFile.plist")
 
     public func createFile() -> Bool {
         let fm = FileManager.default
@@ -65,11 +65,11 @@ public class PQSingletoSourcesFileUtil: NSObject {
         super.init()
     }
 
-    public override func copy() -> Any {
+    override public func copy() -> Any {
         return self
     }
 
-    public override func mutableCopy() -> Any {
+    override public func mutableCopy() -> Any {
         return self
     }
 }

+ 28 - 28
BFStuckPointKit/Classes/BFUtils/PQSingletoVideoPlayer.swift

@@ -7,10 +7,10 @@
 //  Copyright © 2020 BytesFlow. All rights reserved.
 //
 
-import BFCommonKit
-import UIKit
 import BFAnalyzeKit
+import BFCommonKit
 import BFUploadKit
+import UIKit
 
 public class PQSingletoVideoPlayer: NSObject {
     public static let shared = PQSingletoVideoPlayer()
@@ -106,10 +106,10 @@ public class PQSingletoVideoPlayer: NSObject {
                     extParams = ["topicId": isHomePageAllList ? "all" : "\(playVideoData?.topicData?["id"] ?? "")"]
                 } else if playVideoData?.pageSource == .sp_cmunit_follow {
                     extParams = ["followedUid": isHomePageAllList ? "all" : "\(playVideoData?.user?["uid"] ?? "")"]
-                } else if (playVideoData?.pageSource == .sp_cmunit_newTopicDetail || playVideoData?.pageSource == .sp_cmunit_hotTopicDetail) {
+                } else if playVideoData?.pageSource == .sp_cmunit_newTopicDetail || playVideoData?.pageSource == .sp_cmunit_hotTopicDetail {
                     extParams = ["topicId": "\(playVideoData?.topicData?["id"] ?? "")"]
                 }
-                BFEventTrackAdaptor.baseReportUpload(logType: .st_log_type_pLayaction,businessType: .bt_videoPlayDuration, objectType: nil, pageSource: playVideoData?.pageSource ?? .sp_cmunit_recommend, eventData: ["pageSource": (playVideoData?.pageSource ?? .sp_cmunit_recommend).rawValue, "playDuration": Int64(playDuration * 1000), "playId": playId, "uid": "\(playVideoData?.user?["uid"] ?? "")", "videoId": playVideoData?.id ?? 0], extParams: extParams,commonParams: commonParams())
+                BFEventTrackAdaptor.baseReportUpload(logType: .st_log_type_pLayaction, businessType: .bt_videoPlayDuration, objectType: nil, pageSource: playVideoData?.pageSource ?? .sp_cmunit_recommend, eventData: ["pageSource": (playVideoData?.pageSource ?? .sp_cmunit_recommend).rawValue, "playDuration": Int64(playDuration * 1000), "playId": playId, "uid": "\(playVideoData?.user?["uid"] ?? "")", "videoId": playVideoData?.id ?? 0], extParams: extParams, commonParams: commonParams())
                 lastPlaybackTime = player.currentPlaybackTime()
             }
             player.removeVideoWidget()
@@ -128,8 +128,8 @@ public class PQSingletoVideoPlayer: NSObject {
             }
             playId = getUniqueId(desc: "playId")
             // 开始播放
-            if let vc = bf_getCurrentViewController(), let playview = self.playControllerView{
-                if playview.isDescendant(of: vc.view){
+            if let vc = bf_getCurrentViewController(), let playview = playControllerView {
+                if playview.isDescendant(of: vc.view) {
                     startPlayr()
                 }
             }
@@ -155,10 +155,10 @@ public class PQSingletoVideoPlayer: NSObject {
                 extParams = ["topicId": isHomePageAllList ? "all" : "\(playVideoData?.topicData?["id"] ?? "")"]
             } else if playVideoData?.pageSource == .sp_cmunit_follow {
                 extParams = ["followedUid": isHomePageAllList ? "all" : "\(playVideoData?.user?["uid"] ?? "")"]
-            } else if (playVideoData?.pageSource == .sp_cmunit_newTopicDetail || playVideoData?.pageSource == .sp_cmunit_hotTopicDetail) {
+            } else if playVideoData?.pageSource == .sp_cmunit_newTopicDetail || playVideoData?.pageSource == .sp_cmunit_hotTopicDetail {
                 extParams = ["topicId": "\(playVideoData?.topicData?["id"] ?? "")"]
             }
-            BFEventTrackAdaptor.baseReportUpload(logType: .st_log_type_pLayaction,businessType: .bt_videoPlayDuration, objectType: nil, pageSource: playVideoData?.pageSource ?? .sp_cmunit_recommend, eventData: ["pageSource": (playVideoData?.pageSource ?? .sp_cmunit_recommend).rawValue, "playDuration": Int64(playDuration * 1000), "playId": playId, "uid": "\(playVideoData?.user?["uid"] ?? "")", "videoId": playVideoData?.id ?? 0], extParams: extParams,commonParams: commonParams())
+            BFEventTrackAdaptor.baseReportUpload(logType: .st_log_type_pLayaction, businessType: .bt_videoPlayDuration, objectType: nil, pageSource: playVideoData?.pageSource ?? .sp_cmunit_recommend, eventData: ["pageSource": (playVideoData?.pageSource ?? .sp_cmunit_recommend).rawValue, "playDuration": Int64(playDuration * 1000), "playId": playId, "uid": "\(playVideoData?.user?["uid"] ?? "")", "videoId": playVideoData?.id ?? 0], extParams: extParams, commonParams: commonParams())
             lastPlaybackTime = player.currentPlaybackTime()
         }
     }
@@ -177,10 +177,10 @@ public class PQSingletoVideoPlayer: NSObject {
                 extParams = ["topicId": isHomePageAllList ? "all" : "\(playVideoData?.topicData?["id"] ?? "")"]
             } else if playVideoData?.pageSource == .sp_cmunit_follow {
                 extParams = ["followedUid": isHomePageAllList ? "all" : "\(playVideoData?.user?["uid"] ?? "")"]
-            } else if (playVideoData?.pageSource == .sp_cmunit_newTopicDetail || playVideoData?.pageSource == .sp_cmunit_hotTopicDetail) {
+            } else if playVideoData?.pageSource == .sp_cmunit_newTopicDetail || playVideoData?.pageSource == .sp_cmunit_hotTopicDetail {
                 extParams = ["topicId": "\(playVideoData?.topicData?["id"] ?? "")"]
             }
-            BFEventTrackAdaptor.baseReportUpload(logType: .st_log_type_pLayaction,businessType: .bt_videoPlayDuration, objectType: nil, pageSource: playVideoData?.pageSource ?? .sp_cmunit_recommend, eventData: ["pageSource": (playVideoData?.pageSource ?? .sp_cmunit_recommend).rawValue, "playDuration": Int64(playDuration * 1000), "playId": playId, "uid": "\(playVideoData?.user?["uid"] ?? "")", "videoId": playVideoData?.id ?? 0], extParams: extParams,commonParams: commonParams())
+            BFEventTrackAdaptor.baseReportUpload(logType: .st_log_type_pLayaction, businessType: .bt_videoPlayDuration, objectType: nil, pageSource: playVideoData?.pageSource ?? .sp_cmunit_recommend, eventData: ["pageSource": (playVideoData?.pageSource ?? .sp_cmunit_recommend).rawValue, "playDuration": Int64(playDuration * 1000), "playId": playId, "uid": "\(playVideoData?.user?["uid"] ?? "")", "videoId": playVideoData?.id ?? 0], extParams: extParams, commonParams: commonParams())
             lastPlaybackTime = player.currentPlaybackTime()
         }
     }
@@ -202,10 +202,10 @@ public class PQSingletoVideoPlayer: NSObject {
                 extParams = ["topicId": isHomePageAllList ? "all" : "\(playVideoData?.topicData?["id"] ?? "")"]
             } else if playVideoData?.pageSource == .sp_cmunit_follow {
                 extParams = ["followedUid": isHomePageAllList ? "all" : "\(playVideoData?.user?["uid"] ?? "")"]
-            } else if (playVideoData?.pageSource == .sp_cmunit_newTopicDetail || playVideoData?.pageSource == .sp_cmunit_hotTopicDetail){
+            } else if playVideoData?.pageSource == .sp_cmunit_newTopicDetail || playVideoData?.pageSource == .sp_cmunit_hotTopicDetail {
                 extParams = ["topicId": "\(playVideoData?.topicData?["id"] ?? "")"]
             }
-            BFEventTrackAdaptor.baseReportUpload(logType: .st_log_type_pLayaction,businessType: .bt_videoPlayDuration, objectType: nil, pageSource: playVideoData?.pageSource ?? .sp_cmunit_recommend, eventData: ["pageSource": (playVideoData?.pageSource ?? .sp_cmunit_recommend).rawValue, "playDuration": Int64(playDuration * 1000), "playId": playId, "uid": "\(playVideoData?.user?["uid"] ?? "")", "videoId": playVideoData?.id ?? 0], extParams: extParams,commonParams: commonParams())
+            BFEventTrackAdaptor.baseReportUpload(logType: .st_log_type_pLayaction, businessType: .bt_videoPlayDuration, objectType: nil, pageSource: playVideoData?.pageSource ?? .sp_cmunit_recommend, eventData: ["pageSource": (playVideoData?.pageSource ?? .sp_cmunit_recommend).rawValue, "playDuration": Int64(playDuration * 1000), "playId": playId, "uid": "\(playVideoData?.user?["uid"] ?? "")", "videoId": playVideoData?.id ?? 0], extParams: extParams, commonParams: commonParams())
             lastPlaybackTime = player.currentPlaybackTime()
         }
     }
@@ -228,8 +228,8 @@ public class PQSingletoVideoPlayer: NSObject {
         NotificationCenter.default.addObserver(forName: UIApplication.willEnterForegroundNotification, object: nil, queue: nil) { _ in
 
             if self.autoResumePlayWhenEnterForeground, self.shouldResumePlayWhenEnterForeground {
-                if let vc = bf_getCurrentViewController(), let playview = self.playControllerView{
-                    if playview.isDescendant(of: vc.view){
+                if let vc = bf_getCurrentViewController(), let playview = self.playControllerView {
+                    if playview.isDescendant(of: vc.view) {
                         self.shouldResumePlayWhenEnterForeground = false
                         self.resumePlayer()
                     }
@@ -278,7 +278,7 @@ extension PQSingletoVideoPlayer: TXVodPlayListener {
                             extParams = ["followedUid": "all"]
                         }
                     }
-                    BFEventTrackAdaptor.videoRelationReportUpload(reportLogType: .reportLogType_Action, videoData: playVideoData, pageSource: nil, businessType: .bt_videoSemiRealPlay, objectType: nil, extParams: extParams, shareId: nil, videoIds: nil, playId: playId, headVideoId:(playVideoData as? PQVideoListModel)?.headVideoId,projectId:(playVideoData as? PQVideoListModel)?.reCreateVideoData?.projectId ?? "",parentProjectId:(playVideoData as? PQVideoListModel)?.reCreateVideoData?.parentProjectId ?? "",rootProjectId:(playVideoData as? PQVideoListModel)?.reCreateVideoData?.rootProjectId ?? "",canProduce:(playVideoData as? PQVideoListModel)?.reCreateVideoData?.canReproduce ?? 0,parentVideoId:(playVideoData as? PQVideoListModel)?.reCreateVideoData?.parentVideoId ?? "",commonParams:commonParams())
+                    BFEventTrackAdaptor.videoRelationReportUpload(reportLogType: .reportLogType_Action, videoData: playVideoData, pageSource: nil, businessType: .bt_videoSemiRealPlay, objectType: nil, extParams: extParams, shareId: nil, videoIds: nil, playId: playId, headVideoId: (playVideoData as? PQVideoListModel)?.headVideoId, projectId: (playVideoData as? PQVideoListModel)?.reCreateVideoData?.projectId ?? "", parentProjectId: (playVideoData as? PQVideoListModel)?.reCreateVideoData?.parentProjectId ?? "", rootProjectId: (playVideoData as? PQVideoListModel)?.reCreateVideoData?.rootProjectId ?? "", canProduce: (playVideoData as? PQVideoListModel)?.reCreateVideoData?.canReproduce ?? 0, parentVideoId: (playVideoData as? PQVideoListModel)?.reCreateVideoData?.parentVideoId ?? "", commonParams: commonParams())
                 }
             }
             if player.currentPlaybackTime() >= 20.0 || ((playProgress / duration) >= 0.3) {
@@ -294,7 +294,7 @@ extension PQSingletoVideoPlayer: TXVodPlayListener {
                             extParams = ["followedUid": "all"]
                         }
                     }
-                    BFEventTrackAdaptor.videoRelationReportUpload(reportLogType: .reportLogType_realPlay, videoData: playVideoData, pageSource: nil, businessType: .bt_videoRealPlay, objectType: nil, extParams: extParams, shareId: nil, videoIds: nil, playId: playId, headVideoId:(playVideoData as? PQVideoListModel)?.headVideoId,projectId:(playVideoData as? PQVideoListModel)?.reCreateVideoData?.projectId ?? "",parentProjectId:(playVideoData as? PQVideoListModel)?.reCreateVideoData?.parentProjectId ?? "",rootProjectId:(playVideoData as? PQVideoListModel)?.reCreateVideoData?.rootProjectId ?? "",canProduce:(playVideoData as? PQVideoListModel)?.reCreateVideoData?.canReproduce ?? 0,parentVideoId:(playVideoData as? PQVideoListModel)?.reCreateVideoData?.parentVideoId ?? "",commonParams:commonParams())
+                    BFEventTrackAdaptor.videoRelationReportUpload(reportLogType: .reportLogType_realPlay, videoData: playVideoData, pageSource: nil, businessType: .bt_videoRealPlay, objectType: nil, extParams: extParams, shareId: nil, videoIds: nil, playId: playId, headVideoId: (playVideoData as? PQVideoListModel)?.headVideoId, projectId: (playVideoData as? PQVideoListModel)?.reCreateVideoData?.projectId ?? "", parentProjectId: (playVideoData as? PQVideoListModel)?.reCreateVideoData?.parentProjectId ?? "", rootProjectId: (playVideoData as? PQVideoListModel)?.reCreateVideoData?.rootProjectId ?? "", canProduce: (playVideoData as? PQVideoListModel)?.reCreateVideoData?.canReproduce ?? 0, parentVideoId: (playVideoData as? PQVideoListModel)?.reCreateVideoData?.parentVideoId ?? "", commonParams: commonParams())
                 }
             }
             playVideoData?.playProgress = Float64(playProgress)
@@ -314,7 +314,7 @@ extension PQSingletoVideoPlayer: TXVodPlayListener {
                         extParams = ["followedUid": "all"]
                     }
                 }
-                BFEventTrackAdaptor.videoRelationReportUpload(reportLogType: .reportLogType_Action, videoData: playVideoData, pageSource: nil, businessType: .bt_videoPlaySuccess, objectType: nil, extParams: extParams, shareId: nil, videoIds: nil, playId: playId, headVideoId:(playVideoData as? PQVideoListModel)?.headVideoId,projectId:(playVideoData as? PQVideoListModel)?.reCreateVideoData?.projectId ?? "",parentProjectId:(playVideoData as? PQVideoListModel)?.reCreateVideoData?.parentProjectId ?? "",rootProjectId:(playVideoData as? PQVideoListModel)?.reCreateVideoData?.rootProjectId ?? "",canProduce:(playVideoData as? PQVideoListModel)?.reCreateVideoData?.canReproduce ?? 0,parentVideoId:(playVideoData as? PQVideoListModel)?.reCreateVideoData?.parentVideoId ?? "",commonParams:commonParams())
+                BFEventTrackAdaptor.videoRelationReportUpload(reportLogType: .reportLogType_Action, videoData: playVideoData, pageSource: nil, businessType: .bt_videoPlaySuccess, objectType: nil, extParams: extParams, shareId: nil, videoIds: nil, playId: playId, headVideoId: (playVideoData as? PQVideoListModel)?.headVideoId, projectId: (playVideoData as? PQVideoListModel)?.reCreateVideoData?.projectId ?? "", parentProjectId: (playVideoData as? PQVideoListModel)?.reCreateVideoData?.parentProjectId ?? "", rootProjectId: (playVideoData as? PQVideoListModel)?.reCreateVideoData?.rootProjectId ?? "", canProduce: (playVideoData as? PQVideoListModel)?.reCreateVideoData?.canReproduce ?? 0, parentVideoId: (playVideoData as? PQVideoListModel)?.reCreateVideoData?.parentVideoId ?? "", commonParams: commonParams())
             }
 
         case PLAY_EVT_PLAY_LOADING.rawValue: // 视频播放loading
@@ -337,7 +337,7 @@ extension PQSingletoVideoPlayer: TXVodPlayListener {
                         extParams = ["followedUid": "all"]
                     }
                 }
-                BFEventTrackAdaptor.videoRelationReportUpload(reportLogType: .reportLogType_play, videoData: playVideoData, pageSource: nil, businessType: nil, objectType: nil, extParams: extParams, shareId: nil, videoIds: nil, playId: playId, headVideoId:(playVideoData as? PQVideoListModel)?.headVideoId,projectId:(playVideoData as? PQVideoListModel)?.reCreateVideoData?.projectId ?? "",parentProjectId:(playVideoData as? PQVideoListModel)?.reCreateVideoData?.parentProjectId ?? "",rootProjectId:(playVideoData as? PQVideoListModel)?.reCreateVideoData?.rootProjectId ?? "",canProduce:(playVideoData as? PQVideoListModel)?.reCreateVideoData?.canReproduce ?? 0,parentVideoId:(playVideoData as? PQVideoListModel)?.reCreateVideoData?.parentVideoId ?? "",commonParams:commonParams())
+                BFEventTrackAdaptor.videoRelationReportUpload(reportLogType: .reportLogType_play, videoData: playVideoData, pageSource: nil, businessType: nil, objectType: nil, extParams: extParams, shareId: nil, videoIds: nil, playId: playId, headVideoId: (playVideoData as? PQVideoListModel)?.headVideoId, projectId: (playVideoData as? PQVideoListModel)?.reCreateVideoData?.projectId ?? "", parentProjectId: (playVideoData as? PQVideoListModel)?.reCreateVideoData?.parentProjectId ?? "", rootProjectId: (playVideoData as? PQVideoListModel)?.reCreateVideoData?.rootProjectId ?? "", canProduce: (playVideoData as? PQVideoListModel)?.reCreateVideoData?.canReproduce ?? 0, parentVideoId: (playVideoData as? PQVideoListModel)?.reCreateVideoData?.parentVideoId ?? "", commonParams: commonParams())
                 let duration = Int((Date().timeIntervalSince1970 * 1000) - loadingTime)
                 BFLog(message: "加载时长:\(duration)")
                 // 加载时间上报
@@ -347,7 +347,7 @@ extension PQSingletoVideoPlayer: TXVodPlayListener {
                         keyValue
                     }
                 }
-                BFEventTrackAdaptor.videoRelationReportUpload(reportLogType: .reportLogType_Frontend, videoData: playVideoData, pageSource: nil, businessType: .bt_videoPlaySuccessTime, objectType: nil, extParams: timeExtParams, shareId: nil, videoIds: nil, playId: playId, headVideoId:(playVideoData as? PQVideoListModel)?.headVideoId,projectId:(playVideoData as? PQVideoListModel)?.reCreateVideoData?.projectId ?? "",parentProjectId:(playVideoData as? PQVideoListModel)?.reCreateVideoData?.parentProjectId ?? "",rootProjectId:(playVideoData as? PQVideoListModel)?.reCreateVideoData?.rootProjectId ?? "",canProduce:(playVideoData as? PQVideoListModel)?.reCreateVideoData?.canReproduce ?? 0,parentVideoId:(playVideoData as? PQVideoListModel)?.reCreateVideoData?.parentVideoId ?? "",commonParams:commonParams())
+                BFEventTrackAdaptor.videoRelationReportUpload(reportLogType: .reportLogType_Frontend, videoData: playVideoData, pageSource: nil, businessType: .bt_videoPlaySuccessTime, objectType: nil, extParams: timeExtParams, shareId: nil, videoIds: nil, playId: playId, headVideoId: (playVideoData as? PQVideoListModel)?.headVideoId, projectId: (playVideoData as? PQVideoListModel)?.reCreateVideoData?.projectId ?? "", parentProjectId: (playVideoData as? PQVideoListModel)?.reCreateVideoData?.parentProjectId ?? "", rootProjectId: (playVideoData as? PQVideoListModel)?.reCreateVideoData?.rootProjectId ?? "", canProduce: (playVideoData as? PQVideoListModel)?.reCreateVideoData?.canReproduce ?? 0, parentVideoId: (playVideoData as? PQVideoListModel)?.reCreateVideoData?.parentVideoId ?? "", commonParams: commonParams())
             }
             BFLog(message: "首帧加载完成")
         case PLAY_EVT_PLAY_END.rawValue: // 播放结束
@@ -367,7 +367,7 @@ extension PQSingletoVideoPlayer: TXVodPlayListener {
                         extParams = ["followedUid": "all"]
                     }
                 }
-                BFEventTrackAdaptor.videoRelationReportUpload(reportLogType: .reportLogType_Action, videoData: playVideoData, pageSource: nil, businessType: .bt_videoPlayEnd, objectType: nil, extParams: extParams, shareId: nil, videoIds: nil, playId: playId, headVideoId:(playVideoData as? PQVideoListModel)?.headVideoId,projectId:(playVideoData as? PQVideoListModel)?.reCreateVideoData?.projectId ?? "",parentProjectId:(playVideoData as? PQVideoListModel)?.reCreateVideoData?.parentProjectId ?? "",rootProjectId:(playVideoData as? PQVideoListModel)?.reCreateVideoData?.rootProjectId ?? "",canProduce:(playVideoData as? PQVideoListModel)?.reCreateVideoData?.canReproduce ?? 0,parentVideoId:(playVideoData as? PQVideoListModel)?.reCreateVideoData?.parentVideoId ?? "",commonParams:commonParams())
+                BFEventTrackAdaptor.videoRelationReportUpload(reportLogType: .reportLogType_Action, videoData: playVideoData, pageSource: nil, businessType: .bt_videoPlayEnd, objectType: nil, extParams: extParams, shareId: nil, videoIds: nil, playId: playId, headVideoId: (playVideoData as? PQVideoListModel)?.headVideoId, projectId: (playVideoData as? PQVideoListModel)?.reCreateVideoData?.projectId ?? "", parentProjectId: (playVideoData as? PQVideoListModel)?.reCreateVideoData?.parentProjectId ?? "", rootProjectId: (playVideoData as? PQVideoListModel)?.reCreateVideoData?.rootProjectId ?? "", canProduce: (playVideoData as? PQVideoListModel)?.reCreateVideoData?.canReproduce ?? 0, parentVideoId: (playVideoData as? PQVideoListModel)?.reCreateVideoData?.parentVideoId ?? "", commonParams: commonParams())
             }
             let playDuration = player.currentPlaybackTime() - lastPlaybackTime
             debugPrint("当前播放时长:\(player.currentPlaybackTime()),lastPlaybackTime:\(lastPlaybackTime),playDuration:\(playDuration)")
@@ -377,10 +377,10 @@ extension PQSingletoVideoPlayer: TXVodPlayListener {
                     extParams = ["topicId": isHomePageAllList ? "all" : "\(playVideoData?.topicData?["id"] ?? "")"]
                 } else if playVideoData?.pageSource == .sp_cmunit_follow {
                     extParams = ["followedUid": isHomePageAllList ? "all" : "\(playVideoData?.user?["uid"] ?? "")"]
-                } else if (playVideoData?.pageSource == .sp_cmunit_newTopicDetail || playVideoData?.pageSource == .sp_cmunit_hotTopicDetail) {
+                } else if playVideoData?.pageSource == .sp_cmunit_newTopicDetail || playVideoData?.pageSource == .sp_cmunit_hotTopicDetail {
                     extParams = ["topicId": "\(playVideoData?.topicData?["id"] ?? "")"]
                 }
-                BFEventTrackAdaptor.baseReportUpload(logType: .st_log_type_pLayaction,businessType: .bt_videoPlayDuration, objectType: nil, pageSource: playVideoData?.pageSource ?? .sp_cmunit_recommend, eventData: ["pageSource": (playVideoData?.pageSource ?? .sp_cmunit_recommend).rawValue, "playDuration": Int64(playDuration * 1000), "playId": playId, "uid": "\(playVideoData?.user?["uid"] ?? "")", "videoId": playVideoData?.id ?? 0], extParams: extParams,commonParams: commonParams())
+                BFEventTrackAdaptor.baseReportUpload(logType: .st_log_type_pLayaction, businessType: .bt_videoPlayDuration, objectType: nil, pageSource: playVideoData?.pageSource ?? .sp_cmunit_recommend, eventData: ["pageSource": (playVideoData?.pageSource ?? .sp_cmunit_recommend).rawValue, "playDuration": Int64(playDuration * 1000), "playId": playId, "uid": "\(playVideoData?.user?["uid"] ?? "")", "videoId": playVideoData?.id ?? 0], extParams: extParams, commonParams: commonParams())
                 lastPlaybackTime = player.currentPlaybackTime()
             }
         case PLAY_ERR_NET_DISCONNECT.rawValue, -2301: // 重连失败
@@ -398,7 +398,7 @@ extension PQSingletoVideoPlayer: TXVodPlayListener {
                         extParams["followedUid"] = "all"
                     }
                 }
-                BFEventTrackAdaptor.videoRelationReportUpload(reportLogType: .reportLogType_Action, videoData: playVideoData, pageSource: nil, businessType: .bt_videoPlayError, objectType: nil, extParams: extParams, shareId: nil, videoIds: nil, playId: playId, headVideoId:(playVideoData as? PQVideoListModel)?.headVideoId,projectId:(playVideoData as? PQVideoListModel)?.reCreateVideoData?.projectId ?? "",parentProjectId:(playVideoData as? PQVideoListModel)?.reCreateVideoData?.parentProjectId ?? "",rootProjectId:(playVideoData as? PQVideoListModel)?.reCreateVideoData?.rootProjectId ?? "",canProduce:(playVideoData as? PQVideoListModel)?.reCreateVideoData?.canReproduce ?? 0,parentVideoId:(playVideoData as? PQVideoListModel)?.reCreateVideoData?.parentVideoId ?? "",commonParams:commonParams())
+                BFEventTrackAdaptor.videoRelationReportUpload(reportLogType: .reportLogType_Action, videoData: playVideoData, pageSource: nil, businessType: .bt_videoPlayError, objectType: nil, extParams: extParams, shareId: nil, videoIds: nil, playId: playId, headVideoId: (playVideoData as? PQVideoListModel)?.headVideoId, projectId: (playVideoData as? PQVideoListModel)?.reCreateVideoData?.projectId ?? "", parentProjectId: (playVideoData as? PQVideoListModel)?.reCreateVideoData?.parentProjectId ?? "", rootProjectId: (playVideoData as? PQVideoListModel)?.reCreateVideoData?.rootProjectId ?? "", canProduce: (playVideoData as? PQVideoListModel)?.reCreateVideoData?.canReproduce ?? 0, parentVideoId: (playVideoData as? PQVideoListModel)?.reCreateVideoData?.parentVideoId ?? "", commonParams: commonParams())
             }
         case PLAY_ERR_FILE_NOT_FOUND.rawValue: // 播放文件不存在
             if playStatusBloc != nil {
@@ -415,7 +415,7 @@ extension PQSingletoVideoPlayer: TXVodPlayListener {
                         extParams["followedUid"] = "all"
                     }
                 }
-                BFEventTrackAdaptor.videoRelationReportUpload(reportLogType: .reportLogType_Action, videoData: playVideoData, pageSource: nil, businessType: .bt_videoPlayError, objectType: nil, extParams: extParams, shareId: nil, videoIds: nil, playId: playId, headVideoId:(playVideoData as? PQVideoListModel)?.headVideoId,projectId:(playVideoData as? PQVideoListModel)?.reCreateVideoData?.projectId ?? "",parentProjectId:(playVideoData as? PQVideoListModel)?.reCreateVideoData?.parentProjectId ?? "",rootProjectId:(playVideoData as? PQVideoListModel)?.reCreateVideoData?.rootProjectId ?? "",canProduce:(playVideoData as? PQVideoListModel)?.reCreateVideoData?.canReproduce ?? 0,parentVideoId:(playVideoData as? PQVideoListModel)?.reCreateVideoData?.parentVideoId ?? "",commonParams:commonParams())
+                BFEventTrackAdaptor.videoRelationReportUpload(reportLogType: .reportLogType_Action, videoData: playVideoData, pageSource: nil, businessType: .bt_videoPlayError, objectType: nil, extParams: extParams, shareId: nil, videoIds: nil, playId: playId, headVideoId: (playVideoData as? PQVideoListModel)?.headVideoId, projectId: (playVideoData as? PQVideoListModel)?.reCreateVideoData?.projectId ?? "", parentProjectId: (playVideoData as? PQVideoListModel)?.reCreateVideoData?.parentProjectId ?? "", rootProjectId: (playVideoData as? PQVideoListModel)?.reCreateVideoData?.rootProjectId ?? "", canProduce: (playVideoData as? PQVideoListModel)?.reCreateVideoData?.canReproduce ?? 0, parentVideoId: (playVideoData as? PQVideoListModel)?.reCreateVideoData?.parentVideoId ?? "", commonParams: commonParams())
             }
         case PLAY_ERR_HEVC_DECODE_FAIL.rawValue, PLAY_ERR_HLS_KEY.rawValue, PLAY_ERR_GET_PLAYINFO_FAIL.rawValue, PLAY_WARNING_VIDEO_DECODE_FAIL.rawValue, PLAY_WARNING_AUDIO_DECODE_FAIL.rawValue: // H265解码失败,HLS解码key获取失败,获取点播文件信息失败,当前视频解码失败,当前音频解码失败
             if playStatusBloc != nil {
@@ -432,7 +432,7 @@ extension PQSingletoVideoPlayer: TXVodPlayListener {
                         extParams["followedUid"] = "all"
                     }
                 }
-                BFEventTrackAdaptor.videoRelationReportUpload(reportLogType: .reportLogType_Action, videoData: playVideoData, pageSource: nil, businessType: .bt_videoPlayError, objectType: nil, extParams: extParams, shareId: nil, videoIds: nil, playId: playId, headVideoId:(playVideoData as? PQVideoListModel)?.headVideoId,projectId:(playVideoData as? PQVideoListModel)?.reCreateVideoData?.projectId ?? "",parentProjectId:(playVideoData as? PQVideoListModel)?.reCreateVideoData?.parentProjectId ?? "",rootProjectId:(playVideoData as? PQVideoListModel)?.reCreateVideoData?.rootProjectId ?? "",canProduce:(playVideoData as? PQVideoListModel)?.reCreateVideoData?.canReproduce ?? 0,parentVideoId:(playVideoData as? PQVideoListModel)?.reCreateVideoData?.parentVideoId ?? "",commonParams:commonParams())
+                BFEventTrackAdaptor.videoRelationReportUpload(reportLogType: .reportLogType_Action, videoData: playVideoData, pageSource: nil, businessType: .bt_videoPlayError, objectType: nil, extParams: extParams, shareId: nil, videoIds: nil, playId: playId, headVideoId: (playVideoData as? PQVideoListModel)?.headVideoId, projectId: (playVideoData as? PQVideoListModel)?.reCreateVideoData?.projectId ?? "", parentProjectId: (playVideoData as? PQVideoListModel)?.reCreateVideoData?.parentProjectId ?? "", rootProjectId: (playVideoData as? PQVideoListModel)?.reCreateVideoData?.rootProjectId ?? "", canProduce: (playVideoData as? PQVideoListModel)?.reCreateVideoData?.canReproduce ?? 0, parentVideoId: (playVideoData as? PQVideoListModel)?.reCreateVideoData?.parentVideoId ?? "", commonParams: commonParams())
             }
         case PLAY_WARNING_RECONNECT.rawValue: // 断线重连已启动重新连接
             if playStatusBloc != nil {
@@ -446,7 +446,7 @@ extension PQSingletoVideoPlayer: TXVodPlayListener {
                     extParams["followedUid"] = "all"
                 }
             }
-            BFEventTrackAdaptor.videoRelationReportUpload(reportLogType: .reportLogType_Action, videoData: playVideoData, pageSource: nil, businessType: .bt_videoPlayException, objectType: nil, extParams: extParams, shareId: nil, videoIds: nil, playId: playId, headVideoId:(playVideoData as? PQVideoListModel)?.headVideoId,projectId:(playVideoData as? PQVideoListModel)?.reCreateVideoData?.projectId ?? "",parentProjectId:(playVideoData as? PQVideoListModel)?.reCreateVideoData?.parentProjectId ?? "",rootProjectId:(playVideoData as? PQVideoListModel)?.reCreateVideoData?.rootProjectId ?? "",canProduce:(playVideoData as? PQVideoListModel)?.reCreateVideoData?.canReproduce ?? 0,parentVideoId:(playVideoData as? PQVideoListModel)?.reCreateVideoData?.parentVideoId ?? "",commonParams:commonParams())
+            BFEventTrackAdaptor.videoRelationReportUpload(reportLogType: .reportLogType_Action, videoData: playVideoData, pageSource: nil, businessType: .bt_videoPlayException, objectType: nil, extParams: extParams, shareId: nil, videoIds: nil, playId: playId, headVideoId: (playVideoData as? PQVideoListModel)?.headVideoId, projectId: (playVideoData as? PQVideoListModel)?.reCreateVideoData?.projectId ?? "", parentProjectId: (playVideoData as? PQVideoListModel)?.reCreateVideoData?.parentProjectId ?? "", rootProjectId: (playVideoData as? PQVideoListModel)?.reCreateVideoData?.rootProjectId ?? "", canProduce: (playVideoData as? PQVideoListModel)?.reCreateVideoData?.canReproduce ?? 0, parentVideoId: (playVideoData as? PQVideoListModel)?.reCreateVideoData?.parentVideoId ?? "", commonParams: commonParams())
         case PLAY_WARNING_RECV_DATA_LAG.rawValue, PLAY_WARNING_VIDEO_PLAY_LAG.rawValue: // 网络来包不稳:可能是下行带宽不足 | 当前视频播放出现卡顿(用户直观感受)
             // 播放失败
             var extParams1: [String: Any] = ["pageSource": playVideoData!.pageSource.rawValue, "networkType": networkStatus(), "url": playVideoData?.videoPath ?? "", "videoId": playVideoData?.uniqueId ?? "0", "what": event, "position": player.currentPlaybackTime()]
@@ -460,8 +460,8 @@ extension PQSingletoVideoPlayer: TXVodPlayListener {
                     extParams2["topicId"] = "all"
                 }
             }
-            BFEventTrackAdaptor.videoRelationReportUpload(reportLogType: .reportLogType_Frontend, videoData: playVideoData, pageSource: nil, businessType: .bt_videoPlaySlow, objectType: nil, extParams: extParams1, shareId: nil, videoIds: nil, playId: playId, headVideoId:(playVideoData as? PQVideoListModel)?.headVideoId,projectId:(playVideoData as? PQVideoListModel)?.reCreateVideoData?.projectId ?? "",parentProjectId:(playVideoData as? PQVideoListModel)?.reCreateVideoData?.parentProjectId ?? "",rootProjectId:(playVideoData as? PQVideoListModel)?.reCreateVideoData?.rootProjectId ?? "",canProduce:(playVideoData as? PQVideoListModel)?.reCreateVideoData?.canReproduce ?? 0,parentVideoId:(playVideoData as? PQVideoListModel)?.reCreateVideoData?.parentVideoId ?? "",commonParams:commonParams())
-            BFEventTrackAdaptor.videoRelationReportUpload(reportLogType: .reportLogType_Action, videoData: playVideoData, pageSource: nil, businessType: .bt_videoPlayException, objectType: nil, extParams: extParams2, shareId: nil, videoIds: nil, playId: playId, headVideoId:(playVideoData as? PQVideoListModel)?.headVideoId,projectId:(playVideoData as? PQVideoListModel)?.reCreateVideoData?.projectId ?? "",parentProjectId:(playVideoData as? PQVideoListModel)?.reCreateVideoData?.parentProjectId ?? "",rootProjectId:(playVideoData as? PQVideoListModel)?.reCreateVideoData?.rootProjectId ?? "",canProduce:(playVideoData as? PQVideoListModel)?.reCreateVideoData?.canReproduce ?? 0,parentVideoId:(playVideoData as? PQVideoListModel)?.reCreateVideoData?.parentVideoId ?? "",commonParams:commonParams())
+            BFEventTrackAdaptor.videoRelationReportUpload(reportLogType: .reportLogType_Frontend, videoData: playVideoData, pageSource: nil, businessType: .bt_videoPlaySlow, objectType: nil, extParams: extParams1, shareId: nil, videoIds: nil, playId: playId, headVideoId: (playVideoData as? PQVideoListModel)?.headVideoId, projectId: (playVideoData as? PQVideoListModel)?.reCreateVideoData?.projectId ?? "", parentProjectId: (playVideoData as? PQVideoListModel)?.reCreateVideoData?.parentProjectId ?? "", rootProjectId: (playVideoData as? PQVideoListModel)?.reCreateVideoData?.rootProjectId ?? "", canProduce: (playVideoData as? PQVideoListModel)?.reCreateVideoData?.canReproduce ?? 0, parentVideoId: (playVideoData as? PQVideoListModel)?.reCreateVideoData?.parentVideoId ?? "", commonParams: commonParams())
+            BFEventTrackAdaptor.videoRelationReportUpload(reportLogType: .reportLogType_Action, videoData: playVideoData, pageSource: nil, businessType: .bt_videoPlayException, objectType: nil, extParams: extParams2, shareId: nil, videoIds: nil, playId: playId, headVideoId: (playVideoData as? PQVideoListModel)?.headVideoId, projectId: (playVideoData as? PQVideoListModel)?.reCreateVideoData?.projectId ?? "", parentProjectId: (playVideoData as? PQVideoListModel)?.reCreateVideoData?.parentProjectId ?? "", rootProjectId: (playVideoData as? PQVideoListModel)?.reCreateVideoData?.rootProjectId ?? "", canProduce: (playVideoData as? PQVideoListModel)?.reCreateVideoData?.canReproduce ?? 0, parentVideoId: (playVideoData as? PQVideoListModel)?.reCreateVideoData?.parentVideoId ?? "", commonParams: commonParams())
         default:
             break
         }

+ 2 - 2
BFStuckPointKit/Classes/BFUtils/PQThirdPlatformUtil.swift

@@ -6,11 +6,11 @@
 //  Copyright © 2020 BytesFlow. All rights reserved.
 //
 
+import BFCommonKit
 import Kingfisher
 import UIKit
 import UserNotifications
 import WechatOpenSDK
-import BFCommonKit
 
 // MARK: - Bugly初始化工具类
 
@@ -135,7 +135,7 @@ public class PQSingletoWXApiUtil: NSObject {
         message.title = (title?.count ?? 0) > 0 ? title! : "分享一个视频给你"
         message.description = description ?? ""
         BFLog(1, message: "test - \(String(describing: imageUrl))")
-        
+
         ImageDownloader.default.downloadImage(with: URL(string: imageUrl ?? "")!, options: nil) { result in
             switch result {
             case let .success(imageResult):

+ 28 - 28
BFStuckPointKit/Classes/Controller/PQEditMusicSearchController.swift

@@ -5,11 +5,11 @@
 //  Created by ak on 2021/8/7.
 //  功能:显示编辑界中搜索音乐界面
 
-import Foundation
-import BFUIKit
-import BFMediaKit
-import BFCommonKit
 import BFAnalyzeKit
+import BFCommonKit
+import BFMediaKit
+import BFUIKit
+import Foundation
 
 class PQEditMusicSearchController: BFBaseViewController {
     // 当前播放的音乐
@@ -46,6 +46,7 @@ class PQEditMusicSearchController: BFBaseViewController {
 //        }
         return avPlayer
     }()
+
     // 输入框清空按钮
     lazy var clearBtn: UIButton = {
         let clearBtn = UIButton(type: .custom)
@@ -56,6 +57,7 @@ class PQEditMusicSearchController: BFBaseViewController {
         clearBtn.isHidden = true
         return clearBtn
     }()
+
     // 搜索框
     lazy var searchTF: UITextField = {
         let searchTF = UITextField(frame: CGRect(x: leftMargin, y: cDevice_iPhoneStatusBarHei, width: cScreenWidth - leftMargin * 2, height: searchTFH))
@@ -87,25 +89,24 @@ class PQEditMusicSearchController: BFBaseViewController {
     lazy var searchController: PQStuckPointMusicSearchController = {
         let searchController = PQStuckPointMusicSearchController()
         searchController.cellHight = cDefaultMargin * 8
- 
+
         searchController.updateViewFrame(newFrame: CGRect(x: 0, y: cDevice_iPhoneNavBarAndStatusBarHei + cDefaultMargin * 2, width: view.frame.width, height: view.frame.height - (cDevice_iPhoneNavBarAndStatusBarHei + cDefaultMargin * 2)))
         searchController.didSelectedHandle = { [weak self] isTagsClick, _, _, itemData in
             if !isTagsClick {
                 self?.view.endEditing(true)
                 if !(itemData is BFEmptyModel) {
-                    BFEventTrackAdaptor.baseReportUpload(businessType: .bt_buttonClick, objectType: .ot_shanyinApp_musicVideoPreview_musicSearchAudition, pageSource: .sp_shanyinApp_main, extParams: ["musicName":(itemData as? PQVoiceModel)?.musicName ?? "" ,"musicId":(itemData as? PQVoiceModel)?.musicId ?? ""],commonParams: commonParams())
+                    BFEventTrackAdaptor.baseReportUpload(businessType: .bt_buttonClick, objectType: .ot_shanyinApp_musicVideoPreview_musicSearchAudition, pageSource: .sp_shanyinApp_main, extParams: ["musicName": (itemData as? PQVoiceModel)?.musicName ?? "", "musicId": (itemData as? PQVoiceModel)?.musicId ?? ""], commonParams: commonParams())
                     self?.playStuckPointMusic(itemData: itemData as? PQVoiceModel)
                 }
             }
         }
         searchController.btnClickHandle = { [weak self] btn, bgmData in
-            BFEventTrackAdaptor.baseReportUpload(businessType: .bt_buttonClick, objectType: .ot_shanyinApp_musicVideoPreview_musicSearchSelect, pageSource: .sp_shanyinApp_main, extParams: ["musicName":(bgmData as? PQVoiceModel)?.musicName ?? "" ,"musicId":(bgmData as? PQVoiceModel)?.musicId ?? ""],commonParams: commonParams())
+            BFEventTrackAdaptor.baseReportUpload(businessType: .bt_buttonClick, objectType: .ot_shanyinApp_musicVideoPreview_musicSearchSelect, pageSource: .sp_shanyinApp_main, extParams: ["musicName": (bgmData as? PQVoiceModel)?.musicName ?? "", "musicId": (bgmData as? PQVoiceModel)?.musicId ?? ""], commonParams: commonParams())
             // 使用音乐
             self?.backBtnClick()
-            if(self?.btnClickHandle != nil){
-                self?.btnClickHandle!(btn,bgmData)
+            if self?.btnClickHandle != nil {
+                self?.btnClickHandle!(btn, bgmData)
             }
- 
         }
         searchController.scroDidScroHandle = { [weak self] in
             self?.view.endEditing(true)
@@ -113,10 +114,12 @@ class PQEditMusicSearchController: BFBaseViewController {
         searchController.contentType = .serach
         return searchController
     }()
+
     override func backBtnClick() {
         super.backBtnClick()
         avPlayer.pause()
     }
+
     deinit {
         PQNotification.removeObserver(self)
         avPlayer.currentItem?.removeObserver(self, forKeyPath: "status")
@@ -125,33 +128,32 @@ class PQEditMusicSearchController: BFBaseViewController {
         avPlayer.replaceCurrentItem(with: nil)
         playerItem = nil
     }
+
     override func viewWillAppear(_ animated: Bool) {
         super.viewDidAppear(animated)
-        BFEventTrackAdaptor.baseReportUpload(businessType: .bt_windowView, objectType: .ot_shanyinApp_musicVideoPreview_musicSearch, pageSource: .sp_shanyinApp_main,commonParams: commonParams())
+        BFEventTrackAdaptor.baseReportUpload(businessType: .bt_windowView, objectType: .ot_shanyinApp_musicVideoPreview_musicSearch, pageSource: .sp_shanyinApp_main, commonParams: commonParams())
     }
+
     override func viewDidLoad() {
         super.viewDidLoad()
         view.addSubview(searchTF)
         searchTF.becomeFirstResponder()
-        
+
         addChild(searchController)
         view.addSubview(searchController.view)
-        
+
         leftButton(image: UIImage(named: "upload_delete"), tintColor: BFConfig.shared.styleTitleColor)
-        
-        //请求一下热门数据在没有搜索数据时显示
+
+        // 请求一下热门数据在没有搜索数据时显示
         PQStuckPointViewModel.stuckPointMusicPageList(tagId: 425, parentTagId: 0, pageNum: 1, videoCount: 0, imageCount: 0, totalDuration: 0) { [weak self] musicInfo, _ in
 
             if musicInfo.count > 0 {
                 self?.searchController.hotList = musicInfo
                 self?.searchController.configMusicListData(isRefresh: true, musicListData: musicInfo)
-
             }
-       
         }
     }
-    
-    
+
     /// 按钮点击事件
     /// - Parameter sender: <#sender description#>
     /// - Returns: <#description#>
@@ -165,8 +167,8 @@ class PQEditMusicSearchController: BFBaseViewController {
             break
         }
     }
-    
-    var avPlayerTimeObserver:Any?
+
+    var avPlayerTimeObserver: Any?
     /// 播放音乐
     /// - Parameter itemData: <#itemData description#>
     func playStuckPointMusic(itemData: PQVoiceModel?, isClearCurrentMusic: Bool = false) {
@@ -181,7 +183,7 @@ class PQEditMusicSearchController: BFBaseViewController {
             if avPlayerTimeObserver != nil {
                 avPlayer.removeTimeObserver(avPlayerTimeObserver as Any)
             }
-            
+
             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))
@@ -191,8 +193,8 @@ class PQEditMusicSearchController: BFBaseViewController {
             playerItem?.addObserver(self, forKeyPath: "error", options: .new, context: nil)
             avPlayer.seek(to: CMTime(value: CMTimeValue((itemData?.startTime ?? 0) * playerTimescale), timescale: CMTimeScale(playerTimescale)))
             avPlayer.play()
-            
-            avPlayerTimeObserver = avPlayer.addPeriodicTimeObserver(forInterval: CMTime(value: 1, timescale: 10), queue: DispatchQueue.global()) {[weak self] time in
+
+            avPlayerTimeObserver = avPlayer.addPeriodicTimeObserver(forInterval: CMTime(value: 1, timescale: 10), queue: DispatchQueue.global()) { [weak self] time in
                 if fabs(CMTimeGetSeconds(time) - (itemData?.startTime ?? 0)) > 0.1 {
                     self?.avPlayer.removeTimeObserver(self?.avPlayerTimeObserver as Any)
                     self?.avPlayerTimeObserver = nil
@@ -205,7 +207,6 @@ class PQEditMusicSearchController: BFBaseViewController {
             avPlayer.play()
         } else {
             avPlayer.pause()
- 
         }
         if isClearCurrentMusic {
             avPlayer.pause()
@@ -266,7 +267,6 @@ extension PQEditMusicSearchController: UITextFieldDelegate {
 
         searchController.hotList = hotList
         playStuckPointMusic(itemData: nil)
-    
     }
 
     /// 键盘将要隐藏
@@ -292,7 +292,7 @@ extension PQEditMusicSearchController: UITextFieldDelegate {
 
     func textFieldShouldReturn(_ textField: UITextField) -> Bool {
         loadSearchData()
-        BFEventTrackAdaptor.baseReportUpload(businessType: .bt_buttonClick, objectType: .ot_shanyinApp_musicVideoPreview_musicSearch, pageSource: .sp_shanyinApp_main,commonParams: commonParams())
+        BFEventTrackAdaptor.baseReportUpload(businessType: .bt_buttonClick, objectType: .ot_shanyinApp_musicVideoPreview_musicSearch, pageSource: .sp_shanyinApp_main, commonParams: commonParams())
         view.endEditing(true)
         if textField.text == nil || (textField.text?.count ?? 0) <= 0 {
             cShowHUB(superView: nil, msg: "请先输入搜索内容")
@@ -300,6 +300,7 @@ extension PQEditMusicSearchController: UITextFieldDelegate {
         return true
     }
 }
+
 extension PQEditMusicSearchController {
     override func observeValue(forKeyPath keyPath: String?, of object: Any?, change _: [NSKeyValueChangeKey: Any]?, context _: UnsafeMutableRawPointer?) {
         if object is AVPlayerItem, keyPath == "status" {
@@ -319,4 +320,3 @@ extension PQEditMusicSearchController {
         }
     }
 }
-

+ 9 - 9
BFStuckPointKit/Classes/Controller/PQStuckPointEditerController.swift

@@ -6,16 +6,16 @@
 //  Copyright © 2021 BytesFlow. All rights reserved.
 //  功能:卡点音乐编辑界面
 
-import Foundation
-import Photos
-import UIKit
-import ObjectMapper
-import RealmSwift
 import BFAnalyzeKit
 import BFCommonKit
-import BFUIKit
 import BFMediaKit
+import BFUIKit
 import BFUploadKit
+import Foundation
+import ObjectMapper
+import Photos
+import RealmSwift
+import UIKit
 
 class PQStuckPointEditerController: BFBaseViewController {
     // 是否导出视频成功
@@ -1233,7 +1233,7 @@ extension PQStuckPointEditerController {
                 let clipNum = Int(max(round(Double(kongduan) * CMTimeGetSeconds(asset.duration) / videoTotalDuration), 1))
                 sticker.duration = CMTimeGetSeconds(asset.duration)
                 BFLog(message: "单个视频\(sticker.locationPath)时长::\(CMTimeGetSeconds(asset.duration)) ,clipNum is:\(clipNum)")
-                for clipindex in 0 ..< clipNum {
+                for clipindex in 0..<clipNum {
                     // deep copy sticker model 防止只有一个对象
                     let deepCopySticker: PQEditVisionTrackMaterialsModel? = sticker.copy() as? PQEditVisionTrackMaterialsModel
 
@@ -1387,7 +1387,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 1 ... sticker.clipCount {
+                                for _ in 1...sticker.clipCount {
                                     // deep copy sticker model 防止只有一个对象
                                     let deepCopyStickerDecoderTime: TimeInterval = Date().timeIntervalSince1970
 
@@ -1546,7 +1546,7 @@ extension PQStuckPointEditerController {
             finallyStuckPoints.append(stuckPointsTemp.first ?? 0.0)
         }
 
-        for i in finallyStuckPoints.count ... clipNum + 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])
 

+ 18 - 19
BFStuckPointKit/Classes/Controller/PQStuckPointMaterialController.swift

@@ -6,17 +6,17 @@
 //  Copyright © 2021 BytesFlow. All rights reserved.
 //
 
-import UIKit
-import Photos
-import BFUIKit
+import BFAnalyzeKit
+import BFCommonKit
 import BFMaterialKit
 import BFMediaKit
-import BFCommonKit
-import BFAnalyzeKit
+import BFUIKit
+import Photos
+import UIKit
 
 public class PQStuckPointMaterialController: BFBaseViewController {
-    public var isToPublicHandle:((_ isReCreate:Bool,_ selectedTotalDuration: Float64,_ selectedDataCount:Int,_ selectedImageDataCount: Int,_ mStickers: [PQEditVisionTrackMaterialsModel]?,_ stuckPointMusicData: PQVoiceModel?,_ editProjectModel: PQEditProjectModel?,_ rhythmMode:createStickersModel,_ speedMin:Float,_ speedMax:Float,_ audioTime:Float,_ clipAudioRange:CMTimeRange,_ playeTimeRange:CMTimeRange) -> Void)?
-               
+    public var isToPublicHandle: ((_ isReCreate: Bool, _ selectedTotalDuration: Float64, _ selectedDataCount: Int, _ selectedImageDataCount: Int, _ mStickers: [PQEditVisionTrackMaterialsModel]?, _ stuckPointMusicData: PQVoiceModel?, _ editProjectModel: PQEditProjectModel?, _ rhythmMode: createStickersModel, _ speedMin: Float, _ speedMax: Float, _ audioTime: Float, _ clipAudioRange: CMTimeRange, _ playeTimeRange: CMTimeRange) -> Void)?
+
     // 按钮高
     let choseBtnH: CGFloat = cDefaultMargin * 3
     // 按钮宽
@@ -39,8 +39,8 @@ public class PQStuckPointMaterialController: BFBaseViewController {
         changeCollecBtn.titleLabel?.lineBreakMode = .byTruncatingTail
         changeCollecBtn.tintColor = BFConfig.shared.styleTitleColor
         changeCollecBtn.setTitle("我的相册", for: .normal)
-        changeCollecBtn.setImage(UIImage.moduleImage(named: "icon_selected_down", moduleName: "BFStuckPointKit",isAssets: false)?.withRenderingMode(.alwaysTemplate), for: .normal)
-        changeCollecBtn.setImage(UIImage.moduleImage(named: "icon_selected_up", moduleName: "BFStuckPointKit",isAssets: false)?.withRenderingMode(.alwaysTemplate), for: .selected)
+        changeCollecBtn.setImage(UIImage.moduleImage(named: "icon_selected_down", moduleName: "BFStuckPointKit", isAssets: false)?.withRenderingMode(.alwaysTemplate), for: .normal)
+        changeCollecBtn.setImage(UIImage.moduleImage(named: "icon_selected_up", moduleName: "BFStuckPointKit", isAssets: false)?.withRenderingMode(.alwaysTemplate), for: .selected)
         changeCollecBtn.setTitleColor(BFConfig.shared.styleTitleColor, for: .normal)
         changeCollecBtn.titleLabel?.font = UIFont.systemFont(ofSize: 18, weight: .medium)
         changeCollecBtn.tag = 1
@@ -182,10 +182,10 @@ public class PQStuckPointMaterialController: BFBaseViewController {
         view.insertSubview(photoMaterialVc.view, belowSubview: bottomRemindView)
         photoMaterialVc.updateFrame(newFrame: CGRect(x: 0, y: (navHeadImageView?.frame.maxY ?? cDevice_iPhoneNavBarAndStatusBarHei) + margin / 2, width: view.frame.width, height: view.frame.height - ((navHeadImageView?.frame.maxY ?? cDevice_iPhoneNavBarAndStatusBarHei) + margin + bottomRemindView.frame.height)))
         photoMaterialVc.selectedMaterialHandle = { [weak self] currentMaterialData, selectedPhotoData, selectedTotalDuration, imageCount in
-            
+
             self?.selectedDataCount = selectedPhotoData.count
             self?.selectedImageDataCount = imageCount
-            
+
             self?.dealWithSelectedMaterial(materialData: currentMaterialData, totalDuration: selectedTotalDuration)
             /// 处理已经选择的数据
             self?.dealWithSelectedMaterials(isDissmiss: selectedPhotoData.count <= 0, isChose: true, materialData: currentMaterialData)
@@ -216,7 +216,7 @@ public class PQStuckPointMaterialController: BFBaseViewController {
 
     override public func viewDidLoad() {
         super.viewDidLoad()
-        leftButton(image: UIImage.init(named: "upload_delete"), tintColor: BFConfig.shared.styleTitleColor)
+        leftButton(image: UIImage(named: "upload_delete"), tintColor: BFConfig.shared.styleTitleColor)
         navHeadImageView?.addSubview(changeCollecBtn)
         navHeadImageView?.frame.size.height = cDevice_iPhoneNavBarAndStatusBarHei + margin * 2 + choseBtnH
         navHeadImageView?.addSubview(choseLocalAllBtn)
@@ -266,19 +266,19 @@ public class PQStuckPointMaterialController: BFBaseViewController {
         case 13:
             if confirmBtn.isSelected {
 //                reCreateMusicData?.endTime = (reCreateMusicData?.startTime ?? 0) + (reCreateMusicData?.stuckPointCuttingTime(videoCount: selectedDataCount - selectedImageDataCount, imageCount: selectedImageDataCount, totalDuration: photoMaterialVc.selectedTotalDuration) ?? 0)
-                
-                if(reCreateMusicData != nil){
+
+                if reCreateMusicData != nil {
                     let editerVC: PQStuckPointEditerController = PQStuckPointEditerController()
                     editerVC.stuckPointMusicData = reCreateMusicData
                     editerVC.selectedDataCount = selectedDataCount
                     editerVC.selectedImageDataCount = selectedImageDataCount
-                    //mdf by ak 进入编辑界面的时候去掉图片的时长
+                    // mdf by ak 进入编辑界面的时候去掉图片的时长
                     editerVC.selectedTotalDuration = photoMaterialVc.selectedTotalDuration - (Double(selectedImageDataCount) * 1.5)
                     editerVC.selectedPhotoData = photoMaterialVc.selectedPhotoData
                     editerVC.reCreateVideoData = reCreateVideoData
                     editerVC.isReCreate = true
                     navigationController?.pushViewController(editerVC, animated: true)
-                }else{
+                } else {
                     let stuckPointMusicVc = PQStuckPointMusicController()
                     stuckPointMusicVc.selectedMusicData = reCreateMusicData
                     stuckPointMusicVc.selectedDataCount = selectedDataCount
@@ -289,14 +289,14 @@ public class PQStuckPointMaterialController: BFBaseViewController {
                     navigationController?.pushViewController(stuckPointMusicVc, animated: true)
                 }
                 // 卡点视频素材确认按钮
-                BFEventTrackAdaptor.baseReportUpload(businessType: .bt_buttonClick, objectType: .ot_click_confirmMaterial, pageSource: .sp_stuck_selectMaterial,extParams: ["materialNumber": selectedDataCount], commonParams: commonParams())
+                BFEventTrackAdaptor.baseReportUpload(businessType: .bt_buttonClick, objectType: .ot_click_confirmMaterial, pageSource: .sp_stuck_selectMaterial, extParams: ["materialNumber": selectedDataCount], commonParams: commonParams())
             }
         default:
             break
         }
     }
 
-    public override func backBtnClick() {
+    override public func backBtnClick() {
         super.backBtnClick()
         if isPresent {
             postNotification(name: cFinishedPublishedNotiKey)
@@ -354,7 +354,6 @@ public class PQStuckPointMaterialController: BFBaseViewController {
             bottomRemindLab.attributedText = att
         }
         confirmBtn.setTitle(selectedDataCount > 0 ? "确定(\(selectedDataCount))" : "确定", for: .normal)
-
     }
 
     /// 处理已经选择的数据

+ 10 - 10
BFStuckPointKit/Classes/Controller/PQStuckPointMusicContentController.swift

@@ -6,11 +6,11 @@
 //  Copyright © 2021 BytesFlow. All rights reserved.
 //
 
+import BFAnalyzeKit
 import BFCommonKit
+import BFMediaKit
 import BFUIKit
 import UIKit
-import BFMediaKit
-import BFAnalyzeKit
 
 class PQStuckPointMusicContentController: BFBaseViewController {
     var itemList: [Any] = Array<Any>.init() // 所有分类数据
@@ -203,7 +203,7 @@ extension PQStuckPointMusicContentController: UICollectionViewDelegate, UICollec
                 }
                 if tagsData != nil {
                     // 点击上报:选择音乐分类下的 TAG
-                    BFEventTrackAdaptor.baseReportUpload(businessType: .bt_buttonClick, objectType: .ot_click_chooseMusicCategoryTag, pageSource: .sp_stuck_selectSynceedUpMusic,extParams:["categoryName": tagsData?.tagName ?? "", "categoryId": tagsData?.tagId ?? ""], commonParams: commonParams())
+                    BFEventTrackAdaptor.baseReportUpload(businessType: .bt_buttonClick, objectType: .ot_click_chooseMusicCategoryTag, pageSource: .sp_stuck_selectSynceedUpMusic, extParams: ["categoryName": tagsData?.tagName ?? "", "categoryId": tagsData?.tagId ?? ""], commonParams: commonParams())
                 }
             }
             return cell
@@ -228,10 +228,10 @@ extension PQStuckPointMusicContentController: UICollectionViewDelegate, UICollec
                 if bgmData is PQVoiceModel {
                     if self?.contentType == .page {
                         // 卡点视频音乐选择音乐素材
-                        BFEventTrackAdaptor.baseReportUpload(businessType: .bt_buttonClick, objectType: .ot_click_chooseMusic, pageSource: .sp_stuck_selectSynceedUpMusic,extParams:["musicName": (bgmData as? PQVoiceModel)?.musicName ?? "", "musicId": (bgmData as? PQVoiceModel)?.musicId ?? ""], commonParams: commonParams())
+                        BFEventTrackAdaptor.baseReportUpload(businessType: .bt_buttonClick, objectType: .ot_click_chooseMusic, pageSource: .sp_stuck_selectSynceedUpMusic, extParams: ["musicName": (bgmData as? PQVoiceModel)?.musicName ?? "", "musicId": (bgmData as? PQVoiceModel)?.musicId ?? ""], commonParams: commonParams())
                     } else if self?.contentType == .serach {
                         // 点击上报:选择音乐素材
-                        BFEventTrackAdaptor.baseReportUpload(businessType: .bt_buttonClick, objectType: .ot_click_chooseSearchMusic, pageSource: .sp_stuck_searchSyncedUpMusic,extParams:["musicName": (bgmData as? PQVoiceModel)?.musicName ?? "", "musicId": (bgmData as? PQVoiceModel)?.musicId ?? "", "isHotMusic": self?.itemList.first is BFEmptyModel], commonParams: commonParams())
+                        BFEventTrackAdaptor.baseReportUpload(businessType: .bt_buttonClick, objectType: .ot_click_chooseSearchMusic, pageSource: .sp_stuck_searchSyncedUpMusic, extParams: ["musicName": (bgmData as? PQVoiceModel)?.musicName ?? "", "musicId": (bgmData as? PQVoiceModel)?.musicId ?? "", "isHotMusic": self?.itemList.first is BFEmptyModel], commonParams: commonParams())
                     }
                 }
             }
@@ -291,14 +291,14 @@ extension PQStuckPointMusicContentController: UICollectionViewDelegate, UICollec
         if itemList[indexPath.item] is PQVoiceModel {
             if contentType == .page {
                 // 卡点视频音乐素材试听
-                BFEventTrackAdaptor.baseReportUpload(businessType: .bt_buttonClick, objectType: .ot_click_auditionMusic, pageSource: .sp_stuck_selectSynceedUpMusic,extParams:["musicName": (itemList[indexPath.item] as? PQVoiceModel)?.musicName ?? "", "musicId": (itemList[indexPath.item] as? PQVoiceModel)?.musicId ?? ""], commonParams: commonParams())
+                BFEventTrackAdaptor.baseReportUpload(businessType: .bt_buttonClick, objectType: .ot_click_auditionMusic, pageSource: .sp_stuck_selectSynceedUpMusic, extParams: ["musicName": (itemList[indexPath.item] as? PQVoiceModel)?.musicName ?? "", "musicId": (itemList[indexPath.item] as? PQVoiceModel)?.musicId ?? ""], commonParams: commonParams())
             } else if contentType == .serach {
                 // 点击上报:试听音乐素材
-                BFEventTrackAdaptor.baseReportUpload(businessType: .bt_buttonClick, objectType: .ot_click_auditionSearchMusic, pageSource: .sp_stuck_searchSyncedUpMusic,extParams:["musicName": (itemList[indexPath.item] as? PQVoiceModel)?.musicName ?? "", "musicId": (itemList[indexPath.item] as? PQVoiceModel)?.musicId ?? "", "isHotMusic": itemList.first is BFEmptyModel], commonParams: commonParams())
+                BFEventTrackAdaptor.baseReportUpload(businessType: .bt_buttonClick, objectType: .ot_click_auditionSearchMusic, pageSource: .sp_stuck_searchSyncedUpMusic, extParams: ["musicName": (itemList[indexPath.item] as? PQVoiceModel)?.musicName ?? "", "musicId": (itemList[indexPath.item] as? PQVoiceModel)?.musicId ?? "", "isHotMusic": itemList.first is BFEmptyModel], commonParams: commonParams())
             }
         } else if contentType == .catagery && (itemList[indexPath.item] is PQStuckPointMusicTagsModel) {
             // 点击上报:选择音乐分类
-            BFEventTrackAdaptor.baseReportUpload(businessType: .bt_buttonClick, objectType: .ot_click_chooseMusicCategory, pageSource: .sp_stuck_selectSynceedUpMusic,extParams:["categoryName": (itemList[indexPath.item] as? PQStuckPointMusicTagsModel)?.tagName ?? "", "categoryId": (itemList[indexPath.item] as? PQStuckPointMusicTagsModel)?.tagId ?? ""], commonParams: commonParams())
+            BFEventTrackAdaptor.baseReportUpload(businessType: .bt_buttonClick, objectType: .ot_click_chooseMusicCategory, pageSource: .sp_stuck_selectSynceedUpMusic, extParams: ["categoryName": (itemList[indexPath.item] as? PQStuckPointMusicTagsModel)?.tagName ?? "", "categoryId": (itemList[indexPath.item] as? PQStuckPointMusicTagsModel)?.tagId ?? ""], commonParams: commonParams())
         }
     }
 
@@ -313,10 +313,10 @@ extension PQStuckPointMusicContentController: UICollectionViewDelegate, UICollec
         if itemData is PQVoiceModel {
             if contentType == .page {
                 // 卡点视频音乐音乐素材曝光
-                BFEventTrackAdaptor.baseReportUpload(businessType: .bt_buttonView, objectType: .ot_view_syncedUpMusic, pageSource: .sp_stuck_selectSynceedUpMusic,extParams:["musicName": (itemData as? PQVoiceModel)?.musicName ?? "", "musicId": (itemData as? PQVoiceModel)?.musicId ?? ""], commonParams: commonParams())
+                BFEventTrackAdaptor.baseReportUpload(businessType: .bt_buttonView, objectType: .ot_view_syncedUpMusic, pageSource: .sp_stuck_selectSynceedUpMusic, extParams: ["musicName": (itemData as? PQVoiceModel)?.musicName ?? "", "musicId": (itemData as? PQVoiceModel)?.musicId ?? ""], commonParams: commonParams())
             } else if contentType == .serach {
                 // 曝光上报:搜索结果音乐素材曝光
-                BFEventTrackAdaptor.baseReportUpload(businessType: .bt_buttonView, objectType: .ot_view_searchMusic, pageSource: .sp_stuck_searchSyncedUpMusic,extParams:["musicName": (itemData as? PQVoiceModel)?.musicName ?? "", "musicId": (itemData as? PQVoiceModel)?.musicId ?? "", "isHotMusic": itemList.first is BFEmptyModel], commonParams: commonParams())
+                BFEventTrackAdaptor.baseReportUpload(businessType: .bt_buttonView, objectType: .ot_view_searchMusic, pageSource: .sp_stuck_searchSyncedUpMusic, extParams: ["musicName": (itemData as? PQVoiceModel)?.musicName ?? "", "musicId": (itemData as? PQVoiceModel)?.musicId ?? "", "isHotMusic": itemList.first is BFEmptyModel], commonParams: commonParams())
             }
         }
     }

+ 41 - 43
BFStuckPointKit/Classes/Controller/PQStuckPointMusicController.swift

@@ -7,12 +7,12 @@
 //
 
 import AVFoundation
-import UIKit
-import Photos
-import BFUIKit
-import BFMediaKit
-import BFCommonKit
 import BFAnalyzeKit
+import BFCommonKit
+import BFMediaKit
+import BFUIKit
+import Photos
+import UIKit
 
 class PQStuckPointMusicController: BFBaseViewController {
     // 选中的总时长
@@ -21,36 +21,36 @@ class PQStuckPointMusicController: BFBaseViewController {
     var selectedDataCount: Int = 0
     // 选择的图片总数
     var selectedImageDataCount: Int = 0
-    weak var stuckPointEditVC : PQStuckPointEditerController?
-    var firstFrameImage:UIImage?
+    weak var stuckPointEditVC: PQStuckPointEditerController?
+    var firstFrameImage: UIImage?
     // 选中的素材数据
-    var selectedPhotoData: [PHAsset]?{
+    var selectedPhotoData: [PHAsset]? {
         didSet {
-            if selectedPhotoData != nil && selectedPhotoData!.count > 0 {
+            if selectedPhotoData != nil, selectedPhotoData!.count > 0 {
                 let photo = selectedPhotoData!.first!
                 let option = PHImageRequestOptions()
-                option.isNetworkAccessAllowed = true //允许下载iCloud的图片
+                option.isNetworkAccessAllowed = true // 允许下载iCloud的图片
                 option.resizeMode = .none
                 option.deliveryMode = .highQualityFormat
                 let startTime = Date()
                 PHImageManager.default().requestImage(for: photo,
                                                       targetSize: CGSize(width: 1920, height: 1920),
                                                       contentMode: .aspectFit,
-                                                      options: option)
-                { (image, nil) in
-                     //image就是图片
+                                                      options: option) { image, _ in
+                    // image就是图片
                     if image != nil {
                         self.firstFrameImage = image
                         if self.stuckPointEditVC != nil {
                             self.stuckPointEditVC?.firstFrameImage = image
                         }
-                        
+
 //                        BFLog(1, message: "aaa: \(Date().timeIntervalSince(startTime)), \(String(describing: image?.size))")
                     }
                 }
             }
         }
     }
+
     // 选中的音乐数据
     var selectedMusicData: PQVoiceModel?
     /// 缓存数据
@@ -104,7 +104,7 @@ class PQStuckPointMusicController: BFBaseViewController {
     // 输入框清空按钮
     lazy var clearBtn: UIButton = {
         let clearBtn = UIButton(type: .custom)
-        clearBtn.setImage(UIImage.moduleImage(named: "icon_search_delete", moduleName: "BFStuckPointKit",isAssets: false), for: .normal)
+        clearBtn.setImage(UIImage.moduleImage(named: "icon_search_delete", moduleName: "BFStuckPointKit", isAssets: false), for: .normal)
         clearBtn.frame = CGRect(x: 0, y: 0, width: 28, height: 32)
         clearBtn.tag = 1
         clearBtn.addTarget(self, action: #selector(btnClick(sender:)), for: .touchUpInside)
@@ -123,7 +123,7 @@ class PQStuckPointMusicController: BFBaseViewController {
 
         searchTF.leftViewMode = .always
         let leftView = UIView(frame: CGRect(x: 0, y: 0, width: 35, height: 32))
-        let imageView = UIImageView(image:UIImage.moduleImage(named: "icon_search_s", moduleName: "BFStuckPointKit",isAssets: false))
+        let imageView = UIImageView(image: UIImage.moduleImage(named: "icon_search_s", moduleName: "BFStuckPointKit", isAssets: false))
         imageView.frame = CGRect(x: 15, y: 8, width: 16, height: 16)
         leftView.addSubview(imageView)
         searchTF.leftView = leftView
@@ -262,7 +262,7 @@ class PQStuckPointMusicController: BFBaseViewController {
         leftButton(image: nil, tintColor: BFConfig.shared.styleTitleColor)
         setTitle(title: "选择音乐主题", color: BFConfig.shared.styleTitleColor)
         view.addSubview(searchTF)
-      
+
         /// 请求标签数据
         loadRequestTagsList()
         PQNotification.addObserver(self, selector: #selector(enterBackground), name: UIApplication.didEnterBackgroundNotification, object: nil)
@@ -271,7 +271,7 @@ class PQStuckPointMusicController: BFBaseViewController {
             editerVC.stuckPointMusicData = selectedMusicData
             editerVC.selectedDataCount = selectedDataCount
             editerVC.selectedImageDataCount = selectedImageDataCount
-            //mdf by ak 进入编辑界面的时候去掉图片的时长
+            // mdf by ak 进入编辑界面的时候去掉图片的时长
             editerVC.selectedTotalDuration = selectedTotalDuration - (Double(selectedImageDataCount) * 1.5)
             editerVC.selectedPhotoData = selectedPhotoData
             editerVC.reCreateVideoData = reCreateVideoData
@@ -283,21 +283,20 @@ class PQStuckPointMusicController: BFBaseViewController {
             }
         }
         // 卡点视频音乐选择曝光上报
-        BFEventTrackAdaptor.baseReportUpload(businessType: .bt_windowView, objectType: .ot_view_selectSyncedUpMusic, pageSource: .sp_stuck_selectSynceedUpMusic,commonParams: commonParams())
+        BFEventTrackAdaptor.baseReportUpload(businessType: .bt_windowView, objectType: .ot_view_selectSyncedUpMusic, pageSource: .sp_stuck_selectSynceedUpMusic, commonParams: commonParams())
     }
 
-    override func viewWillAppear(_ animated: Bool) {
+    override func viewWillAppear(_: Bool) {
         // mdf by ak 修复其它界面的键盘会影响这个界面问题
         addKeyboardObserver()
     }
+
     override func viewWillDisappear(_ animated: Bool) {
         super.viewWillDisappear(animated)
         playStuckPointMusic(itemData: nil)
-        
+
         PQNotification.removeObserver(self, name: UIResponder.keyboardWillShowNotification, object: nil)
         PQNotification.removeObserver(self, name: UIResponder.keyboardWillHideNotification, object: nil)
- 
- 
     }
 
     /// 按钮点击事件
@@ -412,7 +411,7 @@ class PQStuckPointMusicController: BFBaseViewController {
         pageNum = 1
     }
 
-    var avPlayerTimeObserver:Any?
+    var avPlayerTimeObserver: Any?
     /// 播放音乐
     /// - Parameter itemData: <#itemData description#>
     func playStuckPointMusic(itemData: PQVoiceModel?, isClearCurrentMusic: Bool = false) {
@@ -427,7 +426,7 @@ class PQStuckPointMusicController: BFBaseViewController {
             if avPlayerTimeObserver != nil {
                 avPlayer.removeTimeObserver(avPlayerTimeObserver as Any)
             }
-            
+
             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))
@@ -437,15 +436,15 @@ class PQStuckPointMusicController: BFBaseViewController {
             playerItem?.addObserver(self, forKeyPath: "error", options: .new, context: nil)
             avPlayer.seek(to: CMTime(value: CMTimeValue((itemData?.startTime ?? 0) * playerTimescale), timescale: CMTimeScale(playerTimescale)))
             avPlayer.play()
-            
-            avPlayerTimeObserver = avPlayer.addPeriodicTimeObserver(forInterval: CMTime(value: 1, timescale: 10), queue: DispatchQueue.global()) {[weak self] time in
+
+            avPlayerTimeObserver = avPlayer.addPeriodicTimeObserver(forInterval: CMTime(value: 1, timescale: 10), queue: DispatchQueue.global()) { [weak self] time in
                 if fabs(CMTimeGetSeconds(time) - (itemData?.startTime ?? 0)) > 0.1 {
                     self?.avPlayer.removeTimeObserver(self?.avPlayerTimeObserver as Any)
                     self?.avPlayerTimeObserver = nil
                     // 停止cell loading动画
                     PQNotification.post(name: NSNotification.Name(rawValue: "MusicContentCellIconLoadingAnimationStop"), object: nil)
                 }
-             //    进度监控
+                //    进度监控
 //                BFLog(1, message: "\(Int(CMTimeGetSeconds((self?.playerItem?.asset.duration)!))),curr:\(CMTimeGetSeconds(time))")
             }
 //            let player = TXVodPlayer()
@@ -494,11 +493,11 @@ class PQStuckPointMusicController: BFBaseViewController {
         if searchController.view.isHidden {
             navigationController?.popViewController(animated: true)
             // 点击上报:选择音乐分类
-            BFEventTrackAdaptor.baseReportUpload(businessType: .bt_buttonClick, objectType: .ot_click_back, pageSource: .sp_stuck_selectSynceedUpMusic,commonParams: commonParams())
+            BFEventTrackAdaptor.baseReportUpload(businessType: .bt_buttonClick, objectType: .ot_click_back, pageSource: .sp_stuck_selectSynceedUpMusic, commonParams: commonParams())
         } else {
             hiddenSearchController()
             // 点击上报:返回按钮
-            BFEventTrackAdaptor.baseReportUpload(businessType: .bt_buttonClick, objectType: .ot_click_back, pageSource: .sp_stuck_searchSyncedUpMusic,commonParams: commonParams())
+            BFEventTrackAdaptor.baseReportUpload(businessType: .bt_buttonClick, objectType: .ot_click_back, pageSource: .sp_stuck_searchSyncedUpMusic, commonParams: commonParams())
         }
     }
 
@@ -573,7 +572,7 @@ extension PQStuckPointMusicController: UITextFieldDelegate {
         searchController.hotList = hotList
         playStuckPointMusic(itemData: nil)
         // 曝光上报:音乐素材搜索页
-        BFEventTrackAdaptor.baseReportUpload(businessType: .bt_windowView, objectType: .ot_view_searchSyncedUpMusic, pageSource: .sp_stuck_searchSyncedUpMusic,commonParams: commonParams())
+        BFEventTrackAdaptor.baseReportUpload(businessType: .bt_windowView, objectType: .ot_view_searchSyncedUpMusic, pageSource: .sp_stuck_searchSyncedUpMusic, commonParams: commonParams())
     }
 
     /// 键盘将要隐藏
@@ -612,7 +611,8 @@ extension PQStuckPointMusicController: UITextFieldDelegate {
 }
 
 // MARK: - 缓存相关
-//缓存歌曲列表 KEY
+
+// 缓存歌曲列表 KEY
 let kSaveMusicListDatas = "kSaveMusicListDatas"
 /// 缓存相关
 extension PQStuckPointMusicController {
@@ -620,21 +620,20 @@ extension PQStuckPointMusicController {
     /// - Parameter itemData: <#itemData description#>
     /// - Returns: <#description#>
     func getMusicCacheData(itemData: PQStuckPointMusicTagsModel?) -> (([PQStuckPointMusicTagsModel], ([UICollectionViewLayoutAttributes], CGFloat))?, [PQVoiceModel]?, PQStuckPointMusicTagsModel?)? {
-        let saveMusicListStr =  getUserDefaults(key: kSaveMusicListDatas)
-    
-        if(((saveMusicListStr as? String)?.count ?? 0 ) > 0){
+        let saveMusicListStr = getUserDefaults(key: kSaveMusicListDatas)
+
+        if ((saveMusicListStr as? String)?.count ?? 0) > 0 {
             let cacheMusicDataTemp = jsonStringToDictionary(saveMusicListStr as! String)
-            
+
             if itemData != nil, cacheMusicData.keys.contains("\(itemData?.tagId ?? 0)") {
-                let tempData = cacheMusicDataTemp?["\(itemData?.tagId ?? 0)"] as? Dictionary<String, Any>
-                
-                return (tempData?["tagInfo"] as? ([PQStuckPointMusicTagsModel],([UICollectionViewLayoutAttributes], CGFloat)),tempData?["pageList"] as? [PQVoiceModel],tempData?["currentTag"] as? PQStuckPointMusicTagsModel)
+                let tempData = cacheMusicDataTemp?["\(itemData?.tagId ?? 0)"] as? [String: Any]
+
+                return (tempData?["tagInfo"] as? ([PQStuckPointMusicTagsModel], ([UICollectionViewLayoutAttributes], CGFloat)), tempData?["pageList"] as? [PQVoiceModel], tempData?["currentTag"] as? PQStuckPointMusicTagsModel)
 
             } else {
                 return nil
             }
-        }else{ return nil}
-     
+        } else { return nil }
     }
 
     /// 更新缓存
@@ -680,9 +679,8 @@ extension PQStuckPointMusicController {
                 }
                 cacheMusicData["\(tagId)"] = tempDic
             }
-            
+
             saveUserDefaults(key: kSaveMusicListDatas, value: dictionaryToJsonString(cacheMusicData) as Any)
-        
         }
     }
 }

+ 6 - 6
BFStuckPointKit/Classes/Controller/PQStuckPointMusicSearchController.swift

@@ -6,11 +6,11 @@
 //  Copyright © 2021 BytesFlow. All rights reserved.
 //
 
-import UIKit
+import BFAnalyzeKit
 import BFCommonKit
-import BFUIKit
 import BFMediaKit
-import BFAnalyzeKit
+import BFUIKit
+import UIKit
 
 class PQStuckPointMusicSearchController: PQStuckPointMusicContentController {
     // 选中的总时长
@@ -70,12 +70,12 @@ class PQStuckPointMusicSearchController: PQStuckPointMusicContentController {
             if bgmList.count <= 0 {
                 self?.pageNum = (self?.pageNum ?? 0) - 1
             }
- 
+
             if bgmList.count <= 0, (self?.itemList.count ?? 0) <= 0, (self?.hotList.count ?? 0) > 0 {
-                if !(self?.hotList.first is BFEmptyModel){
+                if !(self?.hotList.first is BFEmptyModel) {
                     self?.hotList.insert(BFEmptyModel(), at: 0)
                 }
-              
+
                 self?.configMusicListData(isRefresh: true, musicListData: self?.hotList ?? [])
             } else {
                 self?.configMusicListData(isRefresh: isRefresh, musicListData: bgmList)

+ 15 - 15
BFStuckPointKit/Classes/Controller/PQStuckPointPublicController.swift

@@ -6,17 +6,17 @@
 //  Copyright © 2021 BytesFlow. All rights reserved.
 //
 
-import Photos
-import UIKit
 import Alamofire
-import WechatOpenSDK
-import Kingfisher
-import ObjectMapper
+import BFAnalyzeKit
 import BFCommonKit
-import BFUIKit
 import BFMediaKit
-import BFAnalyzeKit
+import BFUIKit
 import BFUploadKit
+import Kingfisher
+import ObjectMapper
+import Photos
+import UIKit
+import WechatOpenSDK
 
 // mdf by ak 按 UI图 下方操作区的高度是固定的, 其它区高度和设备自适应
 public let bottomOprationBgViewHeight: CGFloat = 322.0
@@ -756,7 +756,7 @@ extension PQStuckPointPublicController {
         // 第一段的区间
         var timeRange: CMTimeRange = CMTimeRange.zero
         if count > 0 {
-            for index in 0 ..< count {
+            for index in 0..<count {
                 // 第0段从0开始到推荐的结束,播放器的开始时间不是从0开始的
                 duration = CMTime(value: CMTimeValue(CMTimeGetSeconds(clipAudioRange.end) * Double(playerTimescaleInt)), timescale: playerTimescaleInt)
                 BFLog(message: "每一个文件的 duration \(CMTimeGetSeconds(duration))")
@@ -1315,7 +1315,7 @@ extension PQStuckPointPublicController {
 //                                cShowHUB(superView: nil, msg: "视频发布成功")
                 // 发布成功后续操作
                 self?.publicEnd()
-                BFEventTrackAdaptor.publishReportUpload(projectId: videoData.projectId, businessType: .bt_publish_success, ossInfo: videoData.stsToken ?? [:], params: ["title": videoData.title ?? "", "videoPath": videoData.uplpadBucketKey ?? "", "descr": videoData.summary ?? ""],commonParams: commonParams())
+                BFEventTrackAdaptor.publishReportUpload(projectId: videoData.projectId, businessType: .bt_publish_success, ossInfo: videoData.stsToken ?? [:], params: ["title": videoData.title ?? "", "videoPath": videoData.uplpadBucketKey ?? "", "descr": videoData.summary ?? ""], commonParams: commonParams())
             }
 //                        } else {
 //                            // 图片上传失败
@@ -1395,11 +1395,10 @@ extension PQStuckPointPublicController {
         return eventTrackData
     }
 
-    
     /// 初始化
     /// - Parameter projectModel: <#projectModel description#>
-   public func createEventTrackData(projectModel: PQEditProjectModel?, reCreateData: PQReCreateModel?) -> PQVideoMakeEventTrackModel {
-       let eventTrackData = PQVideoMakeEventTrackModel.init()
+    public func createEventTrackData(projectModel: PQEditProjectModel?, reCreateData: PQReCreateModel?) -> PQVideoMakeEventTrackModel {
+        let eventTrackData = PQVideoMakeEventTrackModel()
         if projectModel != nil {
             eventTrackData.draftId = projectModel?.draftboxId
             eventTrackData.projectId = projectModel?.projectId
@@ -1493,8 +1492,9 @@ extension PQStuckPointPublicController {
             eventTrackData.rootProjectId = reCreateData?.rootProjectId ?? reCreateData?.projectId
             eventTrackData.fatherDraftId = reCreateData?.draftboxId
         }
-       return eventTrackData
+        return eventTrackData
     }
+
     /// 播放视频
     /// - Returns: description
     @objc func playVideo() {
@@ -1732,7 +1732,7 @@ extension PQStuckPointPublicController {
             self?.navigationController?.pushViewController(imageSelected, animated: true)
         }
 
-        BFEventTrackAdaptor.baseReportUpload(businessType: .bt_buttonClick, objectType: .ot_shanyinApp_clickButton_changeCover, pageSource: .sp_stuck_publishSyncedUp, eventData: ["videoId": videoData?.uniqueId ?? "", "rootPageSource": isReCreate ? "shanyinApp-main-syncedUpMusicRecreate" : "shanyinApp-main-syncedUpMusic"],commonParams: commonParams())
+        BFEventTrackAdaptor.baseReportUpload(businessType: .bt_buttonClick, objectType: .ot_shanyinApp_clickButton_changeCover, pageSource: .sp_stuck_publishSyncedUp, eventData: ["videoId": videoData?.uniqueId ?? "", "rootPageSource": isReCreate ? "shanyinApp-main-syncedUpMusicRecreate" : "shanyinApp-main-syncedUpMusic"], commonParams: commonParams())
     }
 
     // 更新标题或封面
@@ -1798,7 +1798,7 @@ extension PQStuckPointPublicController {
             if (titles?.count ?? 0) > 0 {
                 var temp: [String] = titles!
                 if (titles?.count ?? 0) <= 13 {
-                    for _ in 0 ... (13 - (titles?.count ?? 0)) {
+                    for _ in 0...(13 - (titles?.count ?? 0)) {
                         temp.append("")
                     }
                 }

+ 12 - 16
BFStuckPointKit/Classes/Model/BFCoreDataModel.swift

@@ -5,44 +5,40 @@
 //  Created by 胡志强 on 2021/11/12.
 //
 
-import Foundation
 import CoreData
+import Foundation
 
 let persistentContext = BFDataPersistentManager.shared.persistentContainer.viewContext
 open class BFCoreDataModel: NSObject, NSFetchRequestResult {
-    
-    
-    public class func createModel(modelName:String) -> AnyObject {
+    public class func createModel(modelName: String) -> AnyObject {
         return NSEntityDescription.insertNewObject(forEntityName: modelName, into: persistentContext)
     }
-    
-    public func save(){
+
+    public func save() {
         do {
             try persistentContext.save()
         } catch {
             fatalError("不能保存:\(error)")
         }
     }
-    
-    public class func getList(fetchRequest:NSFetchRequest<NSFetchRequestResult>) -> [NSFetchRequestResult]?{
+
+    public class func getList(fetchRequest: NSFetchRequest<NSFetchRequestResult>) -> [NSFetchRequestResult]? {
         do {
             let fetchedObjects = try persistentContext.fetch(fetchRequest)
             return fetchedObjects as? [NSFetchRequestResult]
-        }
-        catch {
+        } catch {
             fatalError("不能保存:\(error)")
         }
     }
-    
-    
-    public func deleteMode(fetchRequest:NSFetchRequest<NSFetchRequestResult>){
-        do{
+
+    public func deleteMode(fetchRequest: NSFetchRequest<NSFetchRequestResult>) {
+        do {
             let fetchedObjects = try persistentContext.fetch(fetchRequest)
-            for info in fetchedObjects{
+            for info in fetchedObjects {
                 persistentContext.delete(info as! NSManagedObject)
             }
             try! persistentContext.save()
-        }catch {
+        } catch {
             fatalError("不能保存:\(error)")
         }
     }

+ 5 - 6
BFStuckPointKit/Classes/Model/BFDataPersistentManager.swift

@@ -5,24 +5,23 @@
 //  Created by 胡志强 on 2021/11/12.
 //
 
-import Foundation
 import CoreData
+import Foundation
 
 class BFDataPersistentManager: NSObject {
-    
     static let shared = BFDataPersistentManager()
-    
+
     lazy var persistentContainer: NSPersistentContainer = {
         let container = NSPersistentContainer(name: "CoreDataDemo")
-        container.loadPersistentStores(completionHandler: { (storeDescription, error) in
+        container.loadPersistentStores(completionHandler: { _, error in
             if let error = error as NSError? {
                 fatalError("Unresolved error \(error), \(error.userInfo)")
             }
         })
         return container
     }()
-    
-    func saveContext () {
+
+    func saveContext() {
         let context = persistentContainer.viewContext
         if context.hasChanges {
             do {

+ 26 - 30
BFStuckPointKit/Classes/View/PQCustomSpeedSettingView.swift

@@ -5,9 +5,9 @@
 //  Created by ak on 2021/8/3.
 //  功能:自定义速度界面
 
-import Foundation
 import BFCommonKit
 import BFUIKit
+import Foundation
 
 class PQCustomSpeedSettingView: UIView {
     // 左上角返回
@@ -86,7 +86,7 @@ class PQCustomSpeedSettingView: UIView {
 
     lazy var slowSlider: BFUISlider = {
         let slowSlider = BFUISlider()
-        let thbImage =  UIImage.moduleImage(named: BFConfig.shared.silderPinUsedImageName, moduleName: "BFStuckPointKit", isAssets: false)
+        let thbImage = UIImage.moduleImage(named: BFConfig.shared.silderPinUsedImageName, moduleName: "BFStuckPointKit", isAssets: false)
         slowSlider.setMinimumTrackImage(thbImage, for: .normal)
         slowSlider.setMaximumTrackImage(thbImage, for: .normal)
         slowSlider.setThumbImage(thbImage, for: .highlighted)
@@ -105,7 +105,7 @@ class PQCustomSpeedSettingView: UIView {
 
     lazy var jumpSpeedSlider: BFUISlider = {
         let jumpSpeedSlider = BFUISlider()
-        let thbImage =  UIImage.moduleImage(named: BFConfig.shared.silderPinUsedImageName, moduleName: "BFStuckPointKit", isAssets: false)
+        let thbImage = UIImage.moduleImage(named: BFConfig.shared.silderPinUsedImageName, moduleName: "BFStuckPointKit", isAssets: false)
         jumpSpeedSlider.setMinimumTrackImage(thbImage, for: .normal)
         jumpSpeedSlider.setMaximumTrackImage(thbImage, for: .normal)
         jumpSpeedSlider.setThumbImage(thbImage, for: .highlighted)
@@ -121,16 +121,16 @@ class PQCustomSpeedSettingView: UIView {
 
         return jumpSpeedSlider
     }()
- 
+
     // view 初化的类型 1, 快慢速度卡点  2,跳跃卡点 ,3,循环设置
     var viewType: Int = 0 {
-        didSet{
+        didSet {
             showHiddenView()
-            if(viewType == 1){
+            if viewType == 1 {
                 titleLab.text = "自定义快慢速"
-            }else if(viewType == 2){
+            } else if viewType == 2 {
                 titleLab.text = "自定义跳跃快慢速"
-            }else if(viewType == 3){
+            } else if viewType == 3 {
                 titleLab.text = "自定义循环"
                 jumpSpeedSlider.maximumValue = 20
                 jumpSpeedSlider.valueIsInt = true
@@ -139,12 +139,12 @@ class PQCustomSpeedSettingView: UIView {
     }
 
     // 点击完成回调
-    public var selectSpeedCallBack: ((_ fastSpeed: Float, _ slowSpeed: Float, _ viewType: Int , _ isCancle :Bool) -> Void)?
+    public var selectSpeedCallBack: ((_ fastSpeed: Float, _ slowSpeed: Float, _ viewType: Int, _ isCancle: Bool) -> Void)?
 
     override init(frame: CGRect) {
         super.init(frame: frame)
         backgroundColor = BFConfig.shared.otherTintColor
-       
+
         layer.shadowColor = UIColor(red: 0, green: 0, blue: 0, alpha: 0.15).cgColor
         layer.shadowOpacity = 1
         layer.shadowOffset = CGSize(width: 0, height: -6)
@@ -164,26 +164,24 @@ class PQCustomSpeedSettingView: UIView {
 
         autolayout()
         showHiddenView()
-        self.addGestureRecognizer(UIPanGestureRecognizer(target: self, action: #selector(panGes(_:))))
+        addGestureRecognizer(UIPanGestureRecognizer(target: self, action: #selector(panGes(_:))))
     }
 
     required init?(coder _: NSCoder) {
         fatalError("init(coder:) has not been implemented")
     }
-    
+
     deinit {
         BFLog(1, message: "custom speed setting view release")
     }
 
-    @objc func panGes(_ ges:UIPanGestureRecognizer){
-        
-    }
-    
+    @objc func panGes(_: UIPanGestureRecognizer) {}
+
     func showHiddenView() {
         customSpeedFastView.isHidden = !(viewType == 1)
-        customSpeedSlowView.isHidden =  !(viewType == 1)
-        fastSlider.isHidden =  !(viewType == 1)
-        slowSlider.isHidden =  !(viewType == 1)
+        customSpeedSlowView.isHidden = !(viewType == 1)
+        fastSlider.isHidden = !(viewType == 1)
+        slowSlider.isHidden = !(viewType == 1)
         jumpSpeedSlider.isHidden = (viewType == 1)
     }
 
@@ -247,8 +245,7 @@ class PQCustomSpeedSettingView: UIView {
     // 返回
     @objc func backClick(sender _: UIButton) {
         isHidden = true
-        selectSpeedCallBack!(jumpSpeedSlider.value, 0, viewType,true)
-
+        selectSpeedCallBack!(jumpSpeedSlider.value, 0, viewType, true)
     }
 
     // 确认
@@ -256,16 +253,15 @@ class PQCustomSpeedSettingView: UIView {
         isHidden = true
         BFLog(message: "fastSlider: \(fastSlider.value.decimalNumber()) slowSlider: \(slowSlider.value.decimalNumber()) jumpSpeedSlider:\(jumpSpeedSlider.value.decimalNumber(0))")
         if selectSpeedCallBack != nil {
-            if(viewType == 1){
-                selectSpeedCallBack!(fastSlider.value.decimalNumber(), slowSlider.value.decimalNumber(), viewType,false)
-            }else if(viewType == 2){
-                //跳跃模式时 支持小数值
-                selectSpeedCallBack!(jumpSpeedSlider.value, 0, viewType,false)
-            }else{
-                //循环比时都是整数
-                selectSpeedCallBack!(jumpSpeedSlider.value.decimalNumber(0), 0, viewType,false)
+            if viewType == 1 {
+                selectSpeedCallBack!(fastSlider.value.decimalNumber(), slowSlider.value.decimalNumber(), viewType, false)
+            } else if viewType == 2 {
+                // 跳跃模式时 支持小数值
+                selectSpeedCallBack!(jumpSpeedSlider.value, 0, viewType, false)
+            } else {
+                // 循环比时都是整数
+                selectSpeedCallBack!(jumpSpeedSlider.value.decimalNumber(0), 0, viewType, false)
             }
-        
         }
     }
 }

+ 19 - 22
BFStuckPointKit/Classes/View/PQCustomSwitchView.swift

@@ -6,17 +6,17 @@
 //  Copyright © 2021 BytesFlow. All rights reserved.
 //
 
-import UIKit
 import BFCommonKit
+import UIKit
 
 class PQCustomSwitchView: UIView {
     /// 当前选中的item
     var currentItemBtn: UIButton?
     /// 按钮点击的回调
     var switchChangeHandle: ((_ sender: UIButton) -> Void)?
- 
-    var saveBtns:Array<UIButton> = Array.init()
-    
+
+    var saveBtns: [UIButton] = Array()
+
     override private init(frame: CGRect) {
         super.init(frame: frame)
     }
@@ -39,65 +39,62 @@ class PQCustomSwitchView: UIView {
         let itemWidth: CGFloat = frame.width / CGFloat(titles.count)
         for (index, itemTitle) in titles.enumerated() {
             let itemBtn = UIButton(type: .custom)
-            //8 是每一个btn 的间隔
+            // 8 是每一个btn 的间隔
             itemBtn.frame = CGRect(x: CGFloat(index) * itemWidth + CGFloat(index) * 8, y: 0, width: itemWidth, height: frame.height)
             itemBtn.tag = (3 - index)
             itemBtn.setTitle(itemTitle, for: .normal)
             itemBtn.setTitleColor(UIColor.hexColor(hexadecimal: "#959595"), for: .normal)
             itemBtn.setTitleColor(UIColor.hexColor(hexadecimal: BFConfig.shared.styleColor.rawValue), for: .selected)
             itemBtn.addTarget(self, action: #selector(btnClick(sender:)), for: .touchUpInside)
-  
-            if itemBtn.tag == defaultIndex  {
+
+            if itemBtn.tag == defaultIndex {
                 itemBtn.isSelected = true
-              
+
                 currentItemBtn = itemBtn
                 let styleColor = UIColor.hexColor(hexadecimal: BFConfig.shared.styleColor.rawValue)
                 itemBtn.backgroundColor = UIColor(red: styleColor.rgbaf[0], green: styleColor.rgbaf[1], blue: styleColor.rgbaf[2], alpha: 0.15)
-                
+
                 itemBtn.titleLabel?.font = UIFont.boldSystemFont(ofSize: 13)
-            }else{
+            } else {
                 itemBtn.backgroundColor = BFConfig.shared.pointEditNamalBackgroundColor
                 itemBtn.titleLabel?.font = UIFont.systemFont(ofSize: 13)
             }
-           
-            itemBtn.addCorner(corner:5)
+
+            itemBtn.addCorner(corner: 5)
             addSubview(itemBtn)
-            
+
             saveBtns.append(itemBtn)
         }
     }
-    
-    func selectOneBtn(Index:Int) {
-         
+
+    func selectOneBtn(Index: Int) {
         let selectIndex = saveBtns.firstIndex(where: { (svaeBtn) -> Bool in
 
-            (svaeBtn.tag == Index)
+            svaeBtn.tag == Index
         })
         BFLog(message: "选择节奏 \(selectIndex ?? -1)")
         updateSelectBtn(sender: saveBtns[selectIndex ?? 0])
     }
-    
+
     func updateSelectBtn(sender: UIButton) {
         currentItemBtn?.isSelected = false
         currentItemBtn?.titleLabel?.font = UIFont.systemFont(ofSize: 13)
         currentItemBtn?.backgroundColor = BFConfig.shared.pointEditNamalBackgroundColor
-        
+
         sender.titleLabel?.font = UIFont.boldSystemFont(ofSize: 13)
         sender.isSelected = true
         let styleColor = UIColor.hexColor(hexadecimal: BFConfig.shared.styleColor.rawValue)
         sender.backgroundColor = UIColor(red: styleColor.rgbaf[0], green: styleColor.rgbaf[1], blue: styleColor.rgbaf[2], alpha: 0.15)
         currentItemBtn = sender
     }
- 
+
     /// 按钮点击事件
     /// - Parameter sender: <#sender description#>
     /// - Returns: <#description#>
     @objc func btnClick(sender: UIButton) {
-
         updateSelectBtn(sender: sender)
         if switchChangeHandle != nil {
             switchChangeHandle!(sender)
         }
- 
     }
 }

+ 2 - 2
BFStuckPointKit/Classes/View/PQCuttingPointView.swift

@@ -6,8 +6,8 @@
 //  Copyright © 2021 BytesFlow. All rights reserved.
 //
 
-import UIKit
 import BFCommonKit
+import UIKit
 
 class PQCuttingPointView: UIView {
     lazy var pointView: UIView = {
@@ -18,7 +18,7 @@ class PQCuttingPointView: UIView {
     }()
 
     lazy var dragingImageView: UIImageView = {
-        let dragingImageView = UIImageView(image:UIImage.moduleImage(named: "stuckPoint_dragingImage", moduleName: "BFStuckPointKit",isAssets: false)?.withRenderingMode(.alwaysTemplate))
+        let dragingImageView = UIImageView(image: UIImage.moduleImage(named: "stuckPoint_dragingImage", moduleName: "BFStuckPointKit", isAssets: false)?.withRenderingMode(.alwaysTemplate))
         dragingImageView.tintColor = UIColor.hexColor(hexadecimal: BFConfig.shared.styleColor.rawValue)
         return dragingImageView
     }()

+ 37 - 48
BFStuckPointKit/Classes/View/PQEditPublicCoverImageView.swift

@@ -5,22 +5,21 @@
 //  Created by ak on 2021/7/22.
 //  功能:选择封面
 
-import Foundation
 import BFCommonKit
 import BFUIKit
+import Foundation
 
 class PQEditPublicCoverImageView: UIView {
-    
-    //确认选择回调
-    public var selectImageCallBack: ((_ image:  UIImage?) -> Void)?
-    
-    //从相册选择 BTN 点击回调 用于弹出照片选择界面
-    public var selectPhotoBtnCallBack:(() -> Void)?
-    //选择的封面图片
-    var selectImage:UIImage?
-    //最后选择的封面 btn 用于还原角标
-    var lastSelectcoverImageBtn:UIButton?
-    
+    // 确认选择回调
+    public var selectImageCallBack: ((_ image: UIImage?) -> Void)?
+
+    // 从相册选择 BTN 点击回调 用于弹出照片选择界面
+    public var selectPhotoBtnCallBack: (() -> Void)?
+    // 选择的封面图片
+    var selectImage: UIImage?
+    // 最后选择的封面 btn 用于还原角标
+    var lastSelectcoverImageBtn: UIButton?
+
     lazy var backView: UIView = {
         let backView = UIView()
         backView.addCorner(corner: 1.5)
@@ -37,7 +36,7 @@ class PQEditPublicCoverImageView: UIView {
     // 确定按钮
     lazy var compliteBtn: UIButton = {
         let compliteBtn = UIButton(type: .custom)
-        compliteBtn.backgroundColor =  UIColor.hexColor(hexadecimal: BFConfig.shared.styleColor.rawValue)
+        compliteBtn.backgroundColor = UIColor.hexColor(hexadecimal: BFConfig.shared.styleColor.rawValue)
         compliteBtn.setTitle("确定", for: .normal)
         compliteBtn.titleLabel?.font = UIFont.systemFont(ofSize: 18, weight: .medium)
         compliteBtn.setTitleColor(UIColor.hexColor(hexadecimal: "#FFFFFF"), for: .normal)
@@ -51,8 +50,8 @@ class PQEditPublicCoverImageView: UIView {
     // 从相册选择
     lazy var selectPhotoBtn: UIButton = {
         let selectPhotoBtn = UIButton(type: .custom)
-       
-        selectPhotoBtn.setImage(UIImage.moduleImage(named:  BFConfig.shared.editCoverimageSelectImage, moduleName: "BFStuckPointKit",isAssets: false), for: .normal)
+
+        selectPhotoBtn.setImage(UIImage.moduleImage(named: BFConfig.shared.editCoverimageSelectImage, moduleName: "BFStuckPointKit", isAssets: false), for: .normal)
         selectPhotoBtn.adjustsImageWhenHighlighted = false
         selectPhotoBtn.addCorner(corner: 11)
         selectPhotoBtn.tag = 1
@@ -62,7 +61,7 @@ class PQEditPublicCoverImageView: UIView {
 
     override init(frame: CGRect) {
         super.init(frame: frame)
- 
+
         closeView.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(viewHidden)))
         backgroundColor = .clear
 
@@ -70,14 +69,14 @@ class PQEditPublicCoverImageView: UIView {
         addSubview(backView)
         addSubview(compliteBtn)
         addSubview(selectPhotoBtn)
- 
+
         // 9个封面
-        for i in 0 ... 8 {
+        for i in 0...8 {
             let coverImageBtn = UIButton(type: .custom)
             var frame: CGRect = .zero
             frame.size.width = 108.0 * cAdaptatWidth
             frame.size.height = 108.0 * cAdaptatWidth
-            
+
             // 按钮横向间隔10,左边距16
             let spedScorp = 10.0 * cAdaptatWidth
             let spedHeght = 16.0 * cAdaptatWidth
@@ -90,22 +89,20 @@ class PQEditPublicCoverImageView: UIView {
             coverImageBtn.adjustsImageWhenHighlighted = false
             coverImageBtn.imageView?.contentMode = .scaleAspectFit
             coverImageBtn.addTarget(self, action: #selector(coverImageBtnClick(sender:)), for: .touchUpInside)
-            //选中后的角标
-            let iconView = UIImageView.init(frame: CGRect(x: frame.size.width  - 22.0 - 6, y: 6, width: 22, height: 22))
-            iconView.image = UIImage.moduleImage(named:  BFConfig.shared.editCoverimageSelectedImage, moduleName: "BFStuckPointKit",isAssets: false)
-           
-          
+            // 选中后的角标
+            let iconView = UIImageView(frame: CGRect(x: frame.size.width - 22.0 - 6, y: 6, width: 22, height: 22))
+            iconView.image = UIImage.moduleImage(named: BFConfig.shared.editCoverimageSelectedImage, moduleName: "BFStuckPointKit", isAssets: false)
+
             iconView.tag = 1000
-            if(i == 0){
+            if i == 0 {
                 iconView.isHidden = false
                 lastSelectcoverImageBtn = coverImageBtn
-            }else{
+            } else {
                 iconView.isHidden = true
             }
-    
+
             coverImageBtn.addSubview(iconView)
             backView.addSubview(coverImageBtn)
-
         }
 
         backView.snp.makeConstraints { make in
@@ -124,7 +121,7 @@ class PQEditPublicCoverImageView: UIView {
 
         selectPhotoBtn.snp.makeConstraints { make in
             make.left.equalToSuperview().offset(16 * cAdaptatWidth)
-            make.width.equalTo(164 * cAdaptatWidth )
+            make.width.equalTo(164 * cAdaptatWidth)
             make.height.equalTo(54 * cAdaptatWidth)
             make.bottom.equalToSuperview().offset(-19 - cAKSafeAreaHeight)
         }
@@ -143,28 +140,23 @@ class PQEditPublicCoverImageView: UIView {
 
     @objc func viewHidden() {
         isHidden = true
-        if(selectImageCallBack != nil){
+        if selectImageCallBack != nil {
             selectImageCallBack!(nil)
         }
     }
-    
-    func show(videoURL: URL ,duration:Float64) {
-       isHidden = false
-        
+
+    func show(videoURL: URL, duration: Float64) {
+        isHidden = false
+
         PQVideoSnapshotUtil.videoSnapshot(videoURL: videoURL, duration: TimeInterval(duration), count: 9) { [weak self] images in
             DispatchQueue.main.async {
-                for i in 0...(images?.count ?? 0) - 1{
-                    
+                for i in 0...(images?.count ?? 0) - 1 {
                     let btn = self?.backView.viewWithTag((i + 1) * 100) as? UIButton
                     btn?.setImage(images?[i], for: .normal)
-               
                 }
             }
-
         }
     }
-    
-    
 
     /// 按钮点击事件
     /// - Parameter sender: <#sender description#>
@@ -173,18 +165,16 @@ class PQEditPublicCoverImageView: UIView {
         switch sender?.tag {
         case 1:
             BFLog(message: "选择图库")
-            if(selectPhotoBtnCallBack != nil){
+            if selectPhotoBtnCallBack != nil {
                 selectPhotoBtnCallBack!()
             }
-            
-            break
+
         case 2:
             BFLog(message: "确认选择")
-            if(selectImageCallBack != nil){
+            if selectImageCallBack != nil {
                 selectImageCallBack!(selectImage)
             }
             isHidden = true
-            break
         default:
             break
         }
@@ -192,13 +182,12 @@ class PQEditPublicCoverImageView: UIView {
 
     // 封面选择
     @objc func coverImageBtnClick(sender: UIButton?) {
-        //角标的显示
+        // 角标的显示
         lastSelectcoverImageBtn?.viewWithTag(1000)?.isHidden = true
         sender?.viewWithTag(1000)?.isHidden = false
         lastSelectcoverImageBtn = sender
-        
+
         BFLog(message: "封面选择了\(String(describing: sender?.tag))")
         selectImage = sender?.currentImage
- 
     }
 }

+ 26 - 29
BFStuckPointKit/Classes/View/PQEditPublicTitleView.swift

@@ -5,16 +5,15 @@
 //  Created by ak on 2021/7/22.
 //  功能:编辑标题
 
-import Foundation
-import BFUIKit
 import BFCommonKit
+import BFUIKit
+import Foundation
 
 class PQEditPublicTitleView: UIView {
-    
-    //点击确认回调
+    // 点击确认回调
     public var confirmBtnClock: ((_ selectTitle: String?) -> Void)?
-    
-    //VIEW 隐藏回调事件
+
+    // VIEW 隐藏回调事件
     public var viewIsHiddenCallBack: (() -> Void)?
 
     lazy var backView: UIView = {
@@ -77,7 +76,7 @@ class PQEditPublicTitleView: UIView {
         flowLayout.minimumLineSpacing = 0
         flowLayout.minimumInteritemSpacing = 0
         flowLayout.scrollDirection = .vertical
- 
+
         let collectionView = UICollectionView(frame: .zero, collectionViewLayout: flowLayout)
 
         collectionView.showsVerticalScrollIndicator = false
@@ -95,11 +94,10 @@ class PQEditPublicTitleView: UIView {
     }()
 
     // 标题数据
-    var titles: Array<String> = Array() {
+    var titles: [String] = Array() {
         didSet {
             titleCollectionView.reloadData()
         }
-        
     }
 
     override init(frame: CGRect) {
@@ -162,7 +160,7 @@ class PQEditPublicTitleView: UIView {
 //            make.width.equalTo(cScreenWidth)
 //            make.height.equalTo(542 - cAKSafeAreaHeight)
         }
- 
+
 //        titleCollectionView.reloadData()
     }
 
@@ -173,7 +171,7 @@ class PQEditPublicTitleView: UIView {
     /// 按钮点击事件
     @objc func btnClick(sender _: UIButton?) {
         BFLog(message: "点击了确定 \(String(describing: inputTV.text))")
-   
+
         if confirmBtnClock != nil {
             confirmBtnClock!(inputTV.text)
             inputTV.text = ""
@@ -182,14 +180,14 @@ class PQEditPublicTitleView: UIView {
     }
 
     @objc func viewClick() {
-        self.isHidden = true
+        isHidden = true
         inputTV.resignFirstResponder()
-        if viewIsHiddenCallBack != nil{
+        if viewIsHiddenCallBack != nil {
             viewIsHiddenCallBack!()
         }
     }
-    
-    //显示界面
+
+    // 显示界面
     func show() {
         isHidden = false
         inputTV.becomeFirstResponder()
@@ -212,16 +210,16 @@ extension PQEditPublicTitleView: UICollectionViewDelegate, UICollectionViewDataS
         inputTV.text = titles[indexPath.item]
     }
 
-    func collectionView(_ collectionView: UICollectionView, layout _: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
+    func collectionView(_: UICollectionView, layout _: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
         let title = titles[indexPath.row]
- 
-        let textSize =  sizeWithText(text: title, font: UIFont.systemFont(ofSize: 17, weight: .regular), size: CGSize.init(width: 295, height: CGFloat.greatestFiniteMagnitude))
 
-        //28  是 cell label 上下边距总和
+        let textSize = sizeWithText(text: title, font: UIFont.systemFont(ofSize: 17, weight: .regular), size: CGSize(width: 295, height: CGFloat.greatestFiniteMagnitude))
+
+        // 28  是 cell label 上下边距总和
         return CGSize(width: cScreenWidth, height: textSize.height + 28)
     }
 
-     func scrollViewWillBeginDecelerating(_: UIScrollView) {
+    func scrollViewWillBeginDecelerating(_: UIScrollView) {
         inputTV.resignFirstResponder()
     }
 }
@@ -242,7 +240,7 @@ class PQEditPublicTitleViewContentCell: UICollectionViewCell {
     lazy var iconView: UIImageView = {
         let iconView = UIImageView()
         iconView.backgroundColor = .clear
-        iconView.image = UIImage.moduleImage(named: "editTitleTips", moduleName: "BFStuckPointKit",isAssets: false)
+        iconView.image = UIImage.moduleImage(named: "editTitleTips", moduleName: "BFStuckPointKit", isAssets: false)
         return iconView
     }()
 
@@ -267,11 +265,11 @@ class PQEditPublicTitleViewContentCell: UICollectionViewCell {
     var titleStr: String? {
         didSet {
             titleLab.text = titleStr
-            
-            if(titleLab.text?.count ?? 0 == 0){
+
+            if titleLab.text?.count ?? 0 == 0 {
                 lineView.backgroundColor = .white
                 iconView.isHidden = true
-            }else{
+            } else {
                 lineView.backgroundColor = UIColor.hexColor(hexadecimal: "#EFEFEF")
                 iconView.isHidden = false
             }
@@ -280,18 +278,17 @@ class PQEditPublicTitleViewContentCell: UICollectionViewCell {
     }
 
     func addLayout() {
-        
-        let textSize =  sizeWithText(text: titleStr ?? "", font: UIFont.systemFont(ofSize: 17, weight: .regular), size: CGSize.init(width: 295, height: CGFloat.greatestFiniteMagnitude))
-  
+        let textSize = sizeWithText(text: titleStr ?? "", font: UIFont.systemFont(ofSize: 17, weight: .regular), size: CGSize(width: 295, height: CGFloat.greatestFiniteMagnitude))
+
         titleLab.snp.remakeConstraints { make in
             make.height.equalTo(textSize.height * cAdaptatWidth)
             make.right.equalToSuperview().offset(-64)
             make.left.equalToSuperview().offset(16)
             make.top.equalToSuperview().offset(12)
         }
-  
+
         lineView.snp.makeConstraints { make in
-           
+
             make.right.equalToSuperview().offset(-16)
             make.left.equalToSuperview().offset(16)
             make.bottom.equalToSuperview().offset(-1)

+ 102 - 129
BFStuckPointKit/Classes/View/PQSelecteMusicView.swift

@@ -5,11 +5,11 @@
 //  Created by ak on 2021/8/4.
 //  功能:显示编辑界面里的音乐选择界面
 
-import Foundation
-import BFUIKit
+import BFAnalyzeKit
 import BFCommonKit
 import BFMediaKit
-import BFAnalyzeKit
+import BFUIKit
+import Foundation
 
 class PQSelecteMusicView: UIView {
     // 所有分类数据
@@ -19,40 +19,39 @@ class PQSelecteMusicView: UIView {
     var musicDatas: [PQVoiceModel] = Array<PQVoiceModel>.init()
     // 当前页码
     var pageNum: Int = 0
-    
+
     // 当前视频使用的音乐数据
-    var currentPlayingInVideoData : PQVoiceModel?
+    var currentPlayingInVideoData: PQVoiceModel?
     // 当前试听播放的音乐数据
     var currentPlayData: PQVoiceModel?
     // 当前播放的音频
     var playerItem: AVPlayerItem?
     var playerItemHavObserver: Bool = false
-    
+
     // 按钮点击的回调
     var btnClickHandle: ((_ sender: UIButton, _ bgmData: Any?) -> Void)?
-    
+
     // 点击播放一个歌,回调
-    var didSelectItemHandle:((_ statue:voiceStatue) -> Void)?
+    var didSelectItemHandle: ((_ statue: voiceStatue) -> Void)?
     // 当前选择的分类
-    var currentSelectTag:PQStuckPointMusicTagsModel?
-    
-    //搜索出来的歌曲要插入到热门的前面 有可能是多个
+    var currentSelectTag: PQStuckPointMusicTagsModel?
+
+    // 搜索出来的歌曲要插入到热门的前面 有可能是多个
     var searchMusiceDatas: [PQVoiceModel] = Array<PQVoiceModel>.init()
-    
-    //第一次进入时自动插入的数据
-    var firstInsertVoiceModel:PQVoiceModel?
- 
+
+    // 第一次进入时自动插入的数据
+    var firstInsertVoiceModel: PQVoiceModel?
+
     lazy var avPlayer: AVPlayer = {
         let avPlayer = AVPlayer()
         PQNotification.addObserver(forName: .AVPlayerItemDidPlayToEndTime, object: avPlayer.currentItem, queue: .main) { [weak self] notify in
             BFLog(message: "AVPlayerItemDidPlayToEndTime = \(notify)")
             avPlayer.seek(to: CMTime(value: CMTimeValue((self?.currentPlayData?.startTime ?? 0) * 1000), timescale: CMTimeScale(playerTimescale)))
-            
-            if(self?.currentPlayData?.voiceStatue == .isPlaying){
+
+            if self?.currentPlayData?.voiceStatue == .isPlaying {
                 self?.currentPlayData?.voiceStatue = .isPause
                 self?.selectMusicCollection.reloadData()
             }
-           
         }
 //        PQNotification.addObserver(forName: .AVPlayerItemNewErrorLogEntry, object: avPlayer.currentItem, queue: .main) { notify in
 //            BFLog(message: "AVPlayerItemNewErrorLogEntry = \(notify)")
@@ -68,7 +67,7 @@ class PQSelecteMusicView: UIView {
 //        }
         return avPlayer
     }()
-    
+
     // 音乐分类的
     lazy var categoryCollection: UICollectionView = {
         let flowLayout = UICollectionViewFlowLayout()
@@ -119,7 +118,7 @@ class PQSelecteMusicView: UIView {
 
         return musicSearchBtn
     }()
-    
+
     deinit {
         PQNotification.removeObserver(self)
         PQNotification.removeObserver(self.avPlayer.currentItem as Any)
@@ -138,54 +137,51 @@ class PQSelecteMusicView: UIView {
         addSubview(selectMusicCollection)
         addSubview(musicSearchBtn)
     }
-    func showData(){
-        
+
+    func showData() {
         autolayout()
 
         isHidden = false
-        //不是每一次点击都显示数据
-        if(musicDatas.count == 0){
+        // 不是每一次点击都显示数据
+        if musicDatas.count == 0 {
             loadRequestTagsList()
         }
-     
     }
 
     required init?(coder _: NSCoder) {
         fatalError("init(coder:) has not been implemented")
     }
 
-    //插入数据
-    func insertSearchMusic(model:PQVoiceModel) {
-      
+    // 插入数据
+    func insertSearchMusic(model: PQVoiceModel) {
         for oldModel in musicDatas {
             oldModel.voiceStatue = .isNormal
         }
-   
+
         let musicIndex = musicDatas.firstIndex(where: { (music) -> Bool in
-            (music.musicId == model.musicId)
+            music.musicId == model.musicId
         })
-        
-        if(musicIndex == nil){
+
+        if musicIndex == nil {
             model.voiceStatue = .isSelected
             searchMusiceDatas.insert(model, at: 0)
-            //有搜索的数据
-            if(currentSelectTag?.tagId == 425){
+            // 有搜索的数据
+            if currentSelectTag?.tagId == 425 {
                 musicDatas.insert(model, at: 0)
             }
-        }else{
-            
+        } else {
             let selectMusicData = musicDatas[musicIndex!]
             selectMusicData.voiceStatue = .isSelected
             musicDatas.remove(at: musicIndex!)
             musicDatas.insert(selectMusicData, at: 0)
         }
-        self.currentPlayingInVideoData = model
+        currentPlayingInVideoData = model
         selectMusicCollection.reloadData()
-       
-        //划动到选择的音乐位置
+
+        // 划动到选择的音乐位置
         selectMusicCollection.scrollToItem(at: IndexPath(row: 0, section: 0), at: .centeredHorizontally, animated: true)
- 
     }
+
     func autolayout() {
         categoryCollection.snp.removeConstraints()
         selectMusicCollection.snp.removeConstraints()
@@ -235,44 +231,39 @@ class PQSelecteMusicView: UIView {
             pageNum = 1
             musicDatas = []
         }
-        PQStuckPointViewModel.stuckPointMusicPageList(tagId: tagId, pageNum: pageNum, videoCount: 0, imageCount: 0, totalDuration: 0,oldDataMusic: musicDatas) { [weak self] musicInfo, _ in
+        PQStuckPointViewModel.stuckPointMusicPageList(tagId: tagId, pageNum: pageNum, videoCount: 0, imageCount: 0, totalDuration: 0, oldDataMusic: musicDatas) { [weak self] musicInfo, _ in
             BFLog(message: "请求音乐列表 pageNum\(String(describing: self?.pageNum)) tagId \(tagId) 返回条数\(musicInfo.count)")
             if musicInfo.count > 0 {
                 self?.pageNum = (self?.pageNum ?? 0) + 1
-                
+
                 self?.musicDatas = self!.musicDatas + musicInfo
-                
-                //有搜索的数据
-                if((self?.searchMusiceDatas.count ?? 0) > 0 && self!.musicDatas.first?.cacheTagID == 425 && self?.pageNum == 2){
-                    self?.musicDatas.insert(contentsOf: self?.searchMusiceDatas ?? Array.init(), at: 0)
-                   
+
+                // 有搜索的数据
+                if (self?.searchMusiceDatas.count ?? 0) > 0, self!.musicDatas.first?.cacheTagID == 425, self?.pageNum == 2 {
+                    self?.musicDatas.insert(contentsOf: self?.searchMusiceDatas ?? Array(), at: 0)
                 }
-                
-                if(self?.musicDatas.count ?? 0 > 0){
+
+                if self?.musicDatas.count ?? 0 > 0 {
                     self?.selectMusicCollection.reloadData()
-                }else{
+                } else {
                     BFLog(message: "分类歌曲数据为空!!!!")
                 }
-         
-                if( self?.pageNum == 2){
-                    //歌曲列表返回到头部
+
+                if self?.pageNum == 2 {
+                    // 歌曲列表返回到头部
                     self?.selectMusicCollection.setContentOffset(.zero, animated: false)
-                    
-                    //第一次进入插入的歌曲,插入后置空 如果 不存在只插入一次 防止重
-                    if(self?.firstInsertVoiceModel != nil){
+
+                    // 第一次进入插入的歌曲,插入后置空 如果 不存在只插入一次 防止重
+                    if self?.firstInsertVoiceModel != nil {
                         self?.insertSearchMusic(model: (self?.firstInsertVoiceModel)!)
                         self?.currentPlayingInVideoData = self?.firstInsertVoiceModel
                         self?.firstInsertVoiceModel = nil
                     }
-                    
-                    
                 }
-           
             }
-
         }
     }
-    
+
     /// 播放音乐
     /// - Parameter itemData: <#itemData description#>
     func playStuckPointMusic(itemData: PQVoiceModel?, isClearCurrentMusic: Bool = false) {
@@ -294,7 +285,7 @@ class PQSelecteMusicView: UIView {
                 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))
@@ -316,24 +307,21 @@ class PQSelecteMusicView: UIView {
         } else {
             avPlayer.pause()
             itemData?.voiceStatue = .isPause
-      
         }
         if isClearCurrentMusic {
             avPlayer.pause()
             currentPlayData = nil
         }
     }
-    
-    //暂停播放音乐 并刷新 UI
+
+    // 暂停播放音乐 并刷新 UI
     func pausePlayer() {
         avPlayer.pause()
-        if(currentPlayData?.voiceStatue == .isPlaying){
+        if currentPlayData?.voiceStatue == .isPlaying {
             currentPlayData?.voiceStatue = .isPause
             selectMusicCollection.reloadData()
         }
-
     }
-   
 }
 
 extension PQSelecteMusicView {
@@ -367,49 +355,46 @@ extension PQSelecteMusicView: UICollectionViewDelegate, UICollectionViewDataSour
 
     func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
         if collectionView == selectMusicCollection {
-
             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){
+            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
-                BFEventTrackAdaptor.baseReportUpload(businessType: .bt_buttonClick, objectType: .ot_shanyinApp_musicVideoPreview_musicSelect, pageSource: .sp_shanyinApp_main, extParams: ["musicName":(bgmData as? PQVoiceModel)?.musicName ?? "" ,"musicId":(bgmData as? PQVoiceModel)?.musicId ?? ""],commonParams: commonParams())
+                BFEventTrackAdaptor.baseReportUpload(businessType: .bt_buttonClick, objectType: .ot_shanyinApp_musicVideoPreview_musicSelect, pageSource: .sp_shanyinApp_main, extParams: ["musicName": (bgmData as? PQVoiceModel)?.musicName ?? "", "musicId": (bgmData as? PQVoiceModel)?.musicId ?? ""], commonParams: commonParams())
                 if self?.btnClickHandle != nil {
                     self?.btnClickHandle!(sender, bgmData)
-                    
                 }
-                //恢复原来状态
-                if(self?.musicDatas.count != 0){
+                // 恢复原来状态
+                if self?.musicDatas.count != 0 {
                     for oldModel in self!.musicDatas {
                         oldModel.voiceStatue = .isNormal
                     }
                 }
-             
+
                 let musicIndex = self?.musicDatas.firstIndex(where: { (music) -> Bool in
-                    (music.musicId == (bgmData as? PQVoiceModel)?.musicId)
+                    music.musicId == (bgmData as? PQVoiceModel)?.musicId
                 })
-                
+
                 self?.musicDatas[musicIndex ?? 0].voiceStatue = .isSelected
 
                 self?.selectMusicCollection.reloadData()
             }
-            
-            //自动请求下一页数据
-            if(indexPath.row == musicDatas.count - 5){
+
+            // 自动请求下一页数据
+            if indexPath.row == musicDatas.count - 5 {
                 // 请求这个分类的歌单
-                requestPageListData(isRefresh: false, tagId:   currentSelectTag?.tagId ?? 0)
+                requestPageListData(isRefresh: false, tagId: currentSelectTag?.tagId ?? 0)
             }
             return cell
         }
-        
-        
+
         let itemData: Any = catageryDatas[indexPath.item]
         let cell = collectionView.dequeueReusableCell(withReuseIdentifier: String(describing: PQSelectMusicTagsCell.self), for: indexPath) as! PQSelectMusicTagsCell
         cell.tagData = itemData as? PQStuckPointMusicTagsModel
@@ -428,23 +413,22 @@ extension PQSelecteMusicView: UICollectionViewDelegate, UICollectionViewDataSour
     }
 
     func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
-        
-        //歌曲列表
-        if (collectionView == selectMusicCollection ){
+        // 歌曲列表
+        if collectionView == selectMusicCollection {
             musicDatas.forEach { item in
                 item.voiceStatue = .isNormal
             }
             let music = musicDatas[indexPath.item]
             music.voiceStatue = .isSelected
-            playStuckPointMusic(itemData:music)
-            BFEventTrackAdaptor.baseReportUpload(businessType: .bt_buttonClick, objectType: .ot_shanyinApp_musicVideoPreview_musicCategorySelect, pageSource: .sp_shanyinApp_main, extParams: ["categoryName":currentSelectTag?.tagName ?? "","categoryId":currentSelectTag?.tagId ?? ""],commonParams: commonParams())
+            playStuckPointMusic(itemData: music)
+            BFEventTrackAdaptor.baseReportUpload(businessType: .bt_buttonClick, objectType: .ot_shanyinApp_musicVideoPreview_musicCategorySelect, pageSource: .sp_shanyinApp_main, extParams: ["categoryName": currentSelectTag?.tagName ?? "", "categoryId": currentSelectTag?.tagId ?? ""], commonParams: commonParams())
             if didSelectItemHandle != nil {
                 didSelectItemHandle!(music.voiceStatue)
             }
             selectMusicCollection.reloadData()
-        }else{
-            //停止分类列表的滑动。防止切换分类时 crash
-            selectMusicCollection.setContentOffset(selectMusicCollection.contentOffset , animated: false)
+        } else {
+            // 停止分类列表的滑动。防止切换分类时 crash
+            selectMusicCollection.setContentOffset(selectMusicCollection.contentOffset, animated: false)
             if !isNetConnected() {
                 cShowHUB(superView: nil, msg: "请有网时再试")
                 return
@@ -457,16 +441,14 @@ extension PQSelecteMusicView: UICollectionViewDelegate, UICollectionViewDataSour
             categoryCollection.reloadData()
             currentSelectTag = catageryDatas[indexPath.item]
             // 请求这个分类的歌单
-            requestPageListData(isRefresh: true, tagId:   currentSelectTag?.tagId ?? 0)
+            requestPageListData(isRefresh: true, tagId: currentSelectTag?.tagId ?? 0)
         }
-   
     }
 
     func collectionView(_ collectionView: UICollectionView, willDisplay _: UICollectionViewCell, forItemAt indexPath: IndexPath) {
-        
-        if (collectionView == selectMusicCollection && musicDatas.count > indexPath.item ){
+        if collectionView == selectMusicCollection, musicDatas.count > indexPath.item {
             let music = musicDatas[indexPath.item]
-            BFEventTrackAdaptor.baseReportUpload(businessType: .bt_buttonView, objectType: .ot_shanyinApp_musicVideoPreview_musicView, pageSource: .sp_shanyinApp_main, extParams: ["musicName":music.musicName ?? "" ,"musicId":music.musicId ?? ""],commonParams: commonParams())
+            BFEventTrackAdaptor.baseReportUpload(businessType: .bt_buttonView, objectType: .ot_shanyinApp_musicVideoPreview_musicView, pageSource: .sp_shanyinApp_main, extParams: ["musicName": music.musicName ?? "", "musicId": music.musicId ?? ""], commonParams: commonParams())
         }
     }
 }
@@ -533,14 +515,14 @@ class PQSelectMusicCell: UICollectionViewCell {
 
     lazy var imageMaskView: UIView = {
         let imageMaskView = UIView()
-        imageMaskView.backgroundColor = UIColor.hexColor(hexadecimal: BFConfig.shared.styleColor.rawValue,alpha: 0.76)
+        imageMaskView.backgroundColor = UIColor.hexColor(hexadecimal: BFConfig.shared.styleColor.rawValue, alpha: 0.76)
         imageMaskView.addCorner(corner: 4)
         return imageMaskView
     }()
 
     lazy var playImageView: UIImageView = {
         let playImageView = UIImageView()
-        playImageView.image = UIImage.moduleImage(named: "stuckPoint_music_pause", moduleName: "BFStuckPointKit",isAssets: false)
+        playImageView.image = UIImage.moduleImage(named: "stuckPoint_music_pause", moduleName: "BFStuckPointKit", isAssets: false)
         playImageView.contentMode = .scaleAspectFit
         return playImageView
     }()
@@ -596,8 +578,6 @@ class PQSelectMusicCell: UICollectionViewCell {
         contentView.addSubview(musicNameLab)
         contentView.addSubview(remindView)
         contentView.addSubview(confirmBtn)
-        
-        
     }
 
     required init?(coder _: NSCoder) {
@@ -613,37 +593,36 @@ class PQSelectMusicCell: UICollectionViewCell {
 
     func addData() {
         audioImageView.setNetImage(url: "\(bgmData?.avatarUrl ?? "")", placeholder: BFStuckPointImage(by: "videomk_music_default")!)
-        
-        if((bgmData?.musicName ?? "").count <= 4){
+
+        if (bgmData?.musicName ?? "").count <= 4 {
             musicNameLab.text = (bgmData?.musicName ?? "").appending("\n ")
-        }else{
+        } else {
             musicNameLab.text = (bgmData?.musicName ?? "")
         }
-     
-        
-        if  bgmData?.voiceStatue == .isSelected{
+
+        if bgmData?.voiceStatue == .isSelected {
             playImageView.isHidden = false
             imageMaskView.isHidden = false
             playImageView.image = UIImage().BF_Image(named: "stuckPoint_music_selected")
-    
-        } else if  bgmData?.voiceStatue == .isPlaying{
+
+        } else if bgmData?.voiceStatue == .isPlaying {
             playImageView.isHidden = false
             imageMaskView.isHidden = false
             playImageView.image = nil
             playImageView.kf.setImage(with: URL(fileURLWithPath: currentBundle()!.path(forResource: "stuckPoint_music_playing", ofType: ".gif")!))
-      
-        } else if  bgmData?.voiceStatue == .isPause{
+
+        } else if bgmData?.voiceStatue == .isPause {
             playImageView.isHidden = false
             imageMaskView.isHidden = false
-            playImageView.image = UIImage.moduleImage(named: "stuckPoint_music_pause", moduleName: "BFStuckPointKit",isAssets: false)
-      
-        }else {
+            playImageView.image = UIImage.moduleImage(named: "stuckPoint_music_pause", moduleName: "BFStuckPointKit", isAssets: false)
+
+        } else {
             playImageView.isHidden = true
             playImageView.image = nil
-            
+
             imageMaskView.isHidden = true
         }
-        
+
 //        if  bgmData?.voiceStatue == .isSelected{
 //            playImageView.isHidden = false
 //            imageMaskView.isHidden = false
@@ -661,22 +640,19 @@ class PQSelectMusicCell: UICollectionViewCell {
 //
 //            imageMaskView.isHidden = true
 //        }
-        
+
         confirmBtn.isHidden = !(bgmData?.voiceStatue == .isPause || bgmData?.voiceStatue == .isPlaying)
 
-        if(bgmData?.voiceStatue == .isSelected || bgmData?.voiceStatue == .isPause || bgmData?.voiceStatue == .isPlaying){
+        if bgmData?.voiceStatue == .isSelected || bgmData?.voiceStatue == .isPause || bgmData?.voiceStatue == .isPlaying {
             musicNameLab.textColor = UIColor.hexColor(hexadecimal: BFConfig.shared.styleColor.rawValue)
             musicNameLab.font = UIFont.boldSystemFont(ofSize: 12)
-        }else{
-            musicNameLab.textColor =  UIColor.hexColor(hexadecimal: "#959595")
+        } else {
+            musicNameLab.textColor = UIColor.hexColor(hexadecimal: "#959595")
             musicNameLab.font = UIFont.systemFont(ofSize: 12)
         }
-        
-
     }
 
     func addLayout() {
-      
         audioImageView.snp.remakeConstraints { make in
             make.left.top.equalToSuperview()
             make.width.height.equalTo(60)
@@ -694,23 +670,20 @@ class PQSelectMusicCell: UICollectionViewCell {
             make.height.equalTo(30)
             make.top.equalTo(audioImageView.snp.bottom).offset(6)
         }
- 
+
         confirmBtn.snp.remakeConstraints { make in
             make.width.equalTo(54)
             make.height.equalTo(29)
             make.top.equalTo(musicNameLab.snp.bottom).offset(6)
             make.centerX.equalTo(audioImageView.snp.centerX)
-          
         }
         audioImageView.addCorner(corner: 60 / 2)
         imageMaskView.addCorner(corner: 60 / 2)
     }
 
-    @objc func confirmClick(sender: UIButton) {
+    @objc func confirmClick(sender _: UIButton) {
         if btnClickHandle != nil {
             btnClickHandle!(confirmBtn, bgmData)
         }
     }
 }
-
-

+ 2 - 2
BFStuckPointKit/Classes/View/PQSelectedMaterialListView.swift

@@ -6,11 +6,11 @@
 //  Copyright © 2021 BytesFlow. All rights reserved.
 //
 
-import UIKit
 import BFCommonKit
 import BFMaterialKit
 import BFMediaKit
 import BFUIKit
+import UIKit
 
 class PQSelectedMaterialListView: UIView {
     var photoData: [PQEditVisionTrackMaterialsModel] = Array<PQEditVisionTrackMaterialsModel>.init() // 相册数据
@@ -44,7 +44,7 @@ class PQSelectedMaterialListView: UIView {
     required init?(coder _: NSCoder) {
         fatalError("init(coder:) has not been implemented")
     }
-    
+
     deinit {
         BFLog(1, message: "meterialview release")
     }

+ 75 - 90
BFStuckPointKit/Classes/View/PQSpeedSettingView.swift

@@ -5,9 +5,9 @@
 //  Created by ak on 2021/8/2.
 //  功能:设置快慢速 跳越卡点 的倍速 VIEW
 
-import Foundation
-import BFCommonKit
 import BFAnalyzeKit
+import BFCommonKit
+import Foundation
 
 class PQSpeedSettingView: UIView {
     // 速度列表
@@ -35,16 +35,15 @@ class PQSpeedSettingView: UIView {
     }()
 
     // 保存数据
-    var datas: Array<PQSpeedTitleModel> = Array()
+    var datas: [PQSpeedTitleModel] = Array()
     var lastSelectModel: PQSpeedTitleModel?
     // view 初化的类型 1, 快慢速度卡点  2,跳跃卡点 ,3,循环设置
     var viewType: Int = 0 {
         didSet {
-            
-            if(viewType == oldValue){
+            if viewType == oldValue {
                 return
             }
-            
+
             titleCollectionView.snp.remakeConstraints { make in
                 make.right.equalToSuperview()
                 make.width.equalToSuperview()
@@ -61,9 +60,9 @@ class PQSpeedSettingView: UIView {
                      "5.0x\n1.0x",
                      "6.0x\n1.2x",
                      "自定义\n快慢速"]
-                
-                let tempMaxSpeed = [1.0,   1.8,   2.4,   3, 5, 6, 0.0]
-                let tempMinSpeed = [0.2,   0.3,  0.4,0.5,1.0,1.2, 0.0]
+
+                let tempMaxSpeed = [1.0, 1.8, 2.4, 3, 5, 6, 0.0]
+                let tempMinSpeed = [0.2, 0.3, 0.4, 0.5, 1.0, 1.2, 0.0]
                 for (index, str) in tempTitle.enumerated() {
                     let model = PQSpeedTitleModel()
                     model.title = str
@@ -73,7 +72,7 @@ class PQSpeedSettingView: UIView {
                 }
 
             } else {
-                let str:String = (viewType == 2) ? "跳跃" : "循环"
+                let str: String = (viewType == 2) ? "跳跃" : "循环"
                 let tempTitle =
                     ["\(str)1x",
                      "2x",
@@ -89,24 +88,23 @@ class PQSpeedSettingView: UIView {
                     datas.append(model)
                 }
             }
-            //如果有老数据先插入 补位
-            if viewType == 3 && insertModle != nil{
+            // 如果有老数据先插入 补位
+            if viewType == 3, insertModle != nil {
                 datas.insert(insertModle!, at: 5)
             }
-            if(lastSelectModel != nil){
+            if lastSelectModel != nil {
                 selectCustom()
-            }else{
+            } else {
                 titleCollectionView.reloadData()
             }
-
         }
     }
-    
-    //上一次插入的倍速数据
-    var insertModle:PQSpeedTitleModel?
+
+    // 上一次插入的倍速数据
+    var insertModle: PQSpeedTitleModel?
 
     // 点击回调 maxSpeed,minSpeed 同时为0 说明点击的是自定义速度
-    public var selectSpeedCallBack: ((_ maxSpeed: Float, _ minSpeed: Float,_ selectIndex:Int,_ isSettingPlayer:Bool) -> Void)?
+    public var selectSpeedCallBack: ((_ maxSpeed: Float, _ minSpeed: Float, _ selectIndex: Int, _ isSettingPlayer: Bool) -> Void)?
 
     override init(frame: CGRect) {
         super.init(frame: frame)
@@ -116,47 +114,47 @@ class PQSpeedSettingView: UIView {
     required init?(coder _: NSCoder) {
         fatalError("init(coder:) has not been implemented")
     }
-    
-    
+
     deinit {
         BFLog(1, message: "speed setting view release")
     }
-    //设置默认选择的
+
+    // 设置默认选择的
     /// - Parameters:
     ///   - index: index: 第几位 从0 开始
     ///   - isSettingPlayer: 是否重启播放器
     ///   - setEnable: 设置不可用状态
     ///   - enableInsert: 是否插入一组新数据,只有第一次 < 10s 设置为 true ,自定义及其它情况都不设置 true
 
-    func setSelectItem(index:Int,isSettingPlayer:Bool = true,setDisable:Bool = false,isCancle:Bool = false,enableInsert:Bool = false) {
-       BFLog(message: "setSelectItem is \(index)")
-        if(index < 0 ){
+    func setSelectItem(index: Int, isSettingPlayer: Bool = true, setDisable: Bool = false, isCancle _: Bool = false, enableInsert: Bool = false) {
+        BFLog(message: "setSelectItem is \(index)")
+        if index < 0 {
             BFLog(message: "选择位置数据出错\(index)")
             return
         }
-        //设置不可用状态
-        if(setDisable){
-            for (i,model) in datas.enumerated() {
-                model.isDisable = i == index ? false: true
+        // 设置不可用状态
+        if setDisable {
+            for (i, model) in datas.enumerated() {
+                model.isDisable = i == index ? false : true
             }
         }
         lastSelectModel?.isSelected = false
-       
-        if viewType == 3{
-            if(index > 4 && datas.count < 7 && enableInsert){
-                if(index >= datas.count - 1){
+
+        if viewType == 3 {
+            if index > 4, datas.count < 7, enableInsert {
+                if index >= datas.count - 1 {
                     let model = PQSpeedTitleModel()
                     model.title = "\(index + 1)x"
                     model.maxSpeed = Float(index + 1)
                     insertModle = model
                     datas.insert(insertModle!, at: 5)
                     lastSelectModel = datas[5]
-                }else{
+                } else {
                     lastSelectModel = datas[index]
                 }
-         
-            }else{
-                if(index > datas.count){
+
+            } else {
+                if index > datas.count {
                     lastSelectModel?.isSelected = true
                     titleCollectionView.reloadData()
 
@@ -164,36 +162,30 @@ class PQSpeedSettingView: UIView {
                 }
                 lastSelectModel = datas[index]
             }
-        }else{
+        } else {
             lastSelectModel = datas[index]
         }
         lastSelectModel?.isSelected = true
         titleCollectionView.reloadData()
- 
-        
-        //发出回调,调用方走统一处理逻辑
+
+        // 发出回调,调用方走统一处理逻辑
         if selectSpeedCallBack != nil {
             BFLog(message: "选择的速度为 max: \(lastSelectModel?.maxSpeed ?? 0.0) min: \(lastSelectModel?.minSpeed ?? 0.0) title  \(lastSelectModel?.title ?? "")")
-      
-                
+
             let lastSelectIndex = datas.firstIndex(where: { (model) -> Bool in
-                (model.maxSpeed == lastSelectModel?.maxSpeed)
+                model.maxSpeed == lastSelectModel?.maxSpeed
             }) ?? 0
 
-            selectSpeedCallBack!(lastSelectModel?.maxSpeed ?? 0.0, lastSelectModel?.minSpeed ?? 0.0,lastSelectIndex,isSettingPlayer)
-       
- 
+            selectSpeedCallBack!(lastSelectModel?.maxSpeed ?? 0.0, lastSelectModel?.minSpeed ?? 0.0, lastSelectIndex, isSettingPlayer)
         }
     }
-    
-    //选中自定义
+
+    // 选中自定义
     func selectCustom() {
-        
         lastSelectModel?.isSelected = false
         lastSelectModel = datas.last
         lastSelectModel?.isSelected = true
         titleCollectionView.reloadData()
-         
     }
 }
 
@@ -211,45 +203,41 @@ extension PQSpeedSettingView: UICollectionViewDelegate, UICollectionViewDataSour
 
     func collectionView(_: UICollectionView, didSelectItemAt indexPath: IndexPath) {
         BFLog(message: "选择了 \(String(describing: datas[indexPath.row]))")
-        if(datas[indexPath.row].isDisable){
+        if datas[indexPath.row].isDisable {
             BFLog(message: "不可用速度")
             cShowHUB(superView: nil, msg: "素材时长需要大于6秒\n   才可选择其他档位")
             return
         }
-        
-        if(datas[indexPath.row].title == "自定义" || datas[indexPath.row].title == "自定义\n快慢速"){
-            selectSpeedCallBack!(-1,-1,indexPath.row, false)
-        }else{
-        
+
+        if datas[indexPath.row].title == "自定义" || datas[indexPath.row].title == "自定义\n快慢速" {
+            selectSpeedCallBack!(-1, -1, indexPath.row, false)
+        } else {
             setSelectItem(index: indexPath.row)
         }
-        //下面只是统计  //1, 快慢速度卡点  2,跳跃卡点 ,3,循环设置
-        if(viewType == 1){
-            
-            if(datas[indexPath.row].title == "自定义" || datas[indexPath.row].title == "自定义\n快慢速"){
-                BFEventTrackAdaptor.baseReportUpload(businessType: .bt_buttonClick, objectType: .ot_shanyinApp_musicVideoPreview_customizeSpeed, pageSource: .sp_stuck_previewSyncedUp,commonParams: commonParams())
-            }else{
-                BFEventTrackAdaptor.baseReportUpload(businessType: .bt_buttonClick, objectType: .ot_shanyinApp_musicVideoPreview_selectSpeed, pageSource: .sp_stuck_previewSyncedUp,commonParams: commonParams())
+        // 下面只是统计  //1, 快慢速度卡点  2,跳跃卡点 ,3,循环设置
+        if viewType == 1 {
+            if datas[indexPath.row].title == "自定义" || datas[indexPath.row].title == "自定义\n快慢速" {
+                BFEventTrackAdaptor.baseReportUpload(businessType: .bt_buttonClick, objectType: .ot_shanyinApp_musicVideoPreview_customizeSpeed, pageSource: .sp_stuck_previewSyncedUp, commonParams: commonParams())
+            } else {
+                BFEventTrackAdaptor.baseReportUpload(businessType: .bt_buttonClick, objectType: .ot_shanyinApp_musicVideoPreview_selectSpeed, pageSource: .sp_stuck_previewSyncedUp, commonParams: commonParams())
             }
-        }else if(viewType == 2){
-           
-            if(datas[indexPath.row].title == "自定义" || datas[indexPath.row].title == "自定义\n快慢速"){
-                BFEventTrackAdaptor.baseReportUpload(businessType: .bt_buttonClick, objectType: .ot_shanyinApp_musicVideoPreview_customizeRatio, pageSource: .sp_stuck_previewSyncedUp,commonParams: commonParams())
-            }else{
-                BFEventTrackAdaptor.baseReportUpload(businessType: .bt_buttonClick, objectType: .ot_shanyinApp_musicVideoPreview_selectRatio, pageSource: .sp_stuck_previewSyncedUp,commonParams: commonParams())
+        } else if viewType == 2 {
+            if datas[indexPath.row].title == "自定义" || datas[indexPath.row].title == "自定义\n快慢速" {
+                BFEventTrackAdaptor.baseReportUpload(businessType: .bt_buttonClick, objectType: .ot_shanyinApp_musicVideoPreview_customizeRatio, pageSource: .sp_stuck_previewSyncedUp, commonParams: commonParams())
+            } else {
+                BFEventTrackAdaptor.baseReportUpload(businessType: .bt_buttonClick, objectType: .ot_shanyinApp_musicVideoPreview_selectRatio, pageSource: .sp_stuck_previewSyncedUp, commonParams: commonParams())
             }
-     
-        }else if(viewType == 3){
-            if(datas[indexPath.row].title == "自定义" || datas[indexPath.row].title == "自定义\n快慢速"){
-                BFEventTrackAdaptor.baseReportUpload(businessType: .bt_buttonClick, objectType: .ot_shanyinApp_musicVideoPreview_customizeRepeatTimes, pageSource: .sp_stuck_previewSyncedUp,commonParams: commonParams())
-            }else{
-                BFEventTrackAdaptor.baseReportUpload(businessType: .bt_buttonClick, objectType: .ot_shanyinApp_musicVideoPreview_selectRepeatTimes, pageSource: .sp_stuck_previewSyncedUp,commonParams: commonParams())
+
+        } else if viewType == 3 {
+            if datas[indexPath.row].title == "自定义" || datas[indexPath.row].title == "自定义\n快慢速" {
+                BFEventTrackAdaptor.baseReportUpload(businessType: .bt_buttonClick, objectType: .ot_shanyinApp_musicVideoPreview_customizeRepeatTimes, pageSource: .sp_stuck_previewSyncedUp, commonParams: commonParams())
+            } else {
+                BFEventTrackAdaptor.baseReportUpload(businessType: .bt_buttonClick, objectType: .ot_shanyinApp_musicVideoPreview_selectRepeatTimes, pageSource: .sp_stuck_previewSyncedUp, commonParams: commonParams())
             }
         }
- 
     }
 
-    func collectionView(_ collectionView: UICollectionView, layout _: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
+    func collectionView(_: UICollectionView, layout _: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
         // 20  是 cell label 上下边距总和
         if viewType == 1 {
             if indexPath.row == datas.count - 1 {
@@ -274,9 +262,9 @@ class PQSpeedTitleModel: NSObject {
     // 最大、最小速度
     var maxSpeed: Float = 0.0
     var minSpeed: Float = 0.0
-    //是否可用
-    var isDisable:Bool = false
-    public override init() {
+    // 是否可用
+    var isDisable: Bool = false
+    override public init() {
         super.init()
     }
 }
@@ -322,27 +310,24 @@ class PQSpeedTitleCell: UICollectionViewCell {
             }
 
             if titleModel?.isSelected ?? false {
-            
                 let styleColor = UIColor.hexColor(hexadecimal: BFConfig.shared.styleColor.rawValue)
                 titleLab.backgroundColor = UIColor(red: styleColor.rgbaf[0], green: styleColor.rgbaf[1], blue: styleColor.rgbaf[2], alpha: 0.15)
                 titleLab.textColor = UIColor.hexColor(hexadecimal: BFConfig.shared.styleColor.rawValue)
-                
+
                 titleLab.font = UIFont.boldSystemFont(ofSize: 13)
 
             } else {
-                if(titleModel?.isDisable ?? false){
-                    
+                if titleModel?.isDisable ?? false {
                     let backColor = BFConfig.shared.pointEditNamalBackgroundColor
                     let textColor = UIColor.hexColor(hexadecimal: "#959595")
-                    titleLab.backgroundColor = UIColor.init(red: backColor.rgbaf[0], green: backColor.rgbaf[1], blue: backColor.rgbaf[2], alpha: 0.3)
-                    titleLab.textColor =  UIColor.init(red: textColor.rgbaf[0], green: textColor.rgbaf[1], blue: textColor.rgbaf[2], alpha: 0.3)
-                    
-                }else{
+                    titleLab.backgroundColor = UIColor(red: backColor.rgbaf[0], green: backColor.rgbaf[1], blue: backColor.rgbaf[2], alpha: 0.3)
+                    titleLab.textColor = UIColor(red: textColor.rgbaf[0], green: textColor.rgbaf[1], blue: textColor.rgbaf[2], alpha: 0.3)
+
+                } else {
                     titleLab.backgroundColor = BFConfig.shared.pointEditNamalBackgroundColor
                     titleLab.textColor = UIColor.hexColor(hexadecimal: "#959595")
                 }
                 titleLab.font = UIFont.systemFont(ofSize: 13, weight: .regular)
-              
             }
         }
     }

+ 73 - 90
BFStuckPointKit/Classes/View/PQStuckPointCuttingView.swift

@@ -6,15 +6,15 @@
 //  Copyright © 2021 BytesFlow. All rights reserved.
 //
 
-import UIKit
-import BFCommonKit
 import BFAnalyzeKit
+import BFCommonKit
 import BFUIKit
+import UIKit
 
 class PQStuckPointCuttingView: UIView {
     // 视频时长
     var videoDuration: CGFloat = 0
-    var lastVideoDuration:CGFloat = 0
+    var lastVideoDuration: CGFloat = 0
     // 卡点开始时间 默认 0
     var stuckPointStartTime: CGFloat = 0
     // 卡点结束时间
@@ -48,9 +48,9 @@ class PQStuckPointCuttingView: UIView {
     /// 时间线高
     private var timeHeight: CGFloat = cDefaultMargin * 4
     /// 频率线宽
-    private var frequencyWidth: CGFloat =  adapterWidth(width: 1.5)
+    private var frequencyWidth: CGFloat = adapterWidth(width: 1.5)
     /// 频率间隔
-    private var frequencyMargin: CGFloat =  adapterWidth(width: 3)
+    private var frequencyMargin: CGFloat = adapterWidth(width: 3)
     /// 竖线和contentview 父视图的左右间隔
     private var margin: CGFloat = (cScreenWidth - adapterWidth(width: 250)) / 2
 
@@ -64,7 +64,7 @@ class PQStuckPointCuttingView: UIView {
 
     // 保存已经绘制的竖线用于变色使用
     var lineLayerArray: Array = Array<CAShapeLayer>.init()
-    var lastDrawedLineIndex : Int = 0
+    var lastDrawedLineIndex: Int = 0
 
     // 裁剪区的相素大小
     var cropViewWidth: CGFloat = adapterWidth(width: 250)
@@ -81,16 +81,16 @@ class PQStuckPointCuttingView: UIView {
     var wavSelectCount: Int = 0
     // 整首歌的线的个数
     var wavTotalCount: Int = 0
-    
-    //推荐虚线的位置
-    var startLineX:CGFloat = 0.0
-    
-    //如果是用户主动划动的 就不自动滚动到推荐位置了
-    var isUserDrag:Bool = false
+
+    // 推荐虚线的位置
+    var startLineX: CGFloat = 0.0
+
+    // 如果是用户主动划动的 就不自动滚动到推荐位置了
+    var isUserDrag: Bool = false
     // 推荐卡点起始时间
-    var suggestRhythmStartTime:CGFloat = 0.0
-    var suggestRhythmEndTime:CGFloat = 0.0
-    
+    var suggestRhythmStartTime: CGFloat = 0.0
+    var suggestRhythmEndTime: CGFloat = 0.0
+
     /// 滚动视图
     lazy var scrollView: UIScrollView = {
         let scrollView = UIScrollView(frame: bounds)
@@ -134,25 +134,24 @@ class PQStuckPointCuttingView: UIView {
 
         return videoCropView
     }()
-    //两边的mask 2 是裁剪区的边框
+
+    // 两边的mask 2 是裁剪区的边框
     lazy var leftMaskView: UIView = {
-        let leftMaskView: UIView = UIView(frame: CGRect(x:0, y: 0, width: (cScreenWidth - cropViewWidth) / 2 - 2, height: 80))
+        let leftMaskView: UIView = UIView(frame: CGRect(x: 0, y: 0, width: (cScreenWidth - cropViewWidth) / 2 - 2, height: 80))
         leftMaskView.backgroundColor = BFConfig.shared.styleBackGroundColor
         leftMaskView.alpha = 0.7
         return leftMaskView
     }()
-    
-    //右边的mask 2 是裁剪区的边框
+
+    // 右边的mask 2 是裁剪区的边框
     lazy var rightMaskView: UIView = {
-        let rightMaskView: UIView = UIView(frame: CGRect(x:videoCropView.frame.maxX + 2, y: 0, width: (cScreenWidth - cropViewWidth) / 2, height: 80))
+        let rightMaskView: UIView = UIView(frame: CGRect(x: videoCropView.frame.maxX + 2, y: 0, width: (cScreenWidth - cropViewWidth) / 2, height: 80))
         rightMaskView.backgroundColor = BFConfig.shared.styleBackGroundColor
         rightMaskView.alpha = 0.7
         return rightMaskView
     }()
-    
-    
 
-    private override init(frame: CGRect) {
+    override private init(frame: CGRect) {
         super.init(frame: frame)
     }
 
@@ -164,25 +163,24 @@ class PQStuckPointCuttingView: UIView {
         super.init(frame: frame)
         videoDuration = duration
         self.suggestRhythmStartTime = suggestRhythmStartTime
-    
     }
 
     /// 更新卡点值
     /// - Parameter endTime: endTime description
     /// - Returns: <#description#>
     func updateEndTime(startTime: CGFloat, endTime: CGFloat,
-                       suggestRhythmStartTime: CGFloat, suggestRhythmEndTime: 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);推荐卡点开始:\(suggestRhythmStartTime) 结束:\(suggestRhythmEndTime)")
         backgroundColor = BFConfig.shared.styleBackGroundColor
         addSubview(scrollView)
@@ -193,8 +191,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)
+        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)
@@ -202,25 +200,22 @@ class PQStuckPointCuttingView: UIView {
             make.top.equalTo(videoCropView.snp.top).offset(6)
             make.right.equalTo(videoCropView.snp.right).offset(-6)
         }
-        
-      
     }
 
     func addData() {
         // 1,选择区内的线个数 ,划动区域后 个数会变???
         wavSelectCount = Int(ceil((adapterWidth(width: 250) - frequencyWidth) / (frequencyWidth + frequencyMargin)) + 1)
-        
+
         cropViewWidth = CGFloat(wavSelectCount) * (frequencyWidth + frequencyMargin) + frequencyWidth
         margin = (cScreenWidth - cropViewWidth) / 2.0
 
-     
         // 2竖线一个间隔代表多少 S 是动态的
         oneMarginTime = (stuckPointEndTime - stuckPointStartTime) / CGFloat(wavSelectCount)
-        
+
         // 如果视频结束时间点大于歌曲有效结束点,则拼接推荐的时间段直到满足视频播放
         var videoDurationTemp = suggestRhythmEndTime
         while stuckPointEndTime > videoDurationTemp {
-            videoDurationTemp  += (suggestRhythmEndTime - suggestRhythmStartTime)
+            videoDurationTemp += (suggestRhythmEndTime - suggestRhythmStartTime)
         }
         videoDuration = videoDurationTemp
         // 3,一共绘制的竖线个数
@@ -229,29 +224,29 @@ class PQStuckPointCuttingView: UIView {
         timeRange = oneMarginTime * 10
         // 显示时间 label 的个数 , -1 不够整倍数就不显示时间了
         let timeLabelCount = Int(wavTotalCount / 10)
-        
+
         contentWidth = CGFloat(wavTotalCount - 1) * (frequencyWidth + frequencyMargin) + frequencyWidth + (cScreenWidth - cropViewWidth)
         if contentWidth < scrollView.frame.width {
             contentWidth = scrollView.frame.width
         }
         scrollView.contentSize = CGSize(width: contentWidth, height: scrollView.frame.height)
-        
+
         BFLog(1, message: "框内个数:\(wavSelectCount), 总线条数:\(wavTotalCount), 框宽:\(cropViewWidth), 最终音乐时长:\(videoDuration)")
         scrollView.subviews.forEach { lable in
-            if lable is UILabel && lable.tag != 66 {
+            if lable is UILabel, lable.tag != 66 {
                 lable.removeFromSuperview()
             }
         }
-        for index in 0 ... timeLabelCount {
+        for index in 0...timeLabelCount {
 //            scrollView.viewWithTag(100 + index)?.removeFromSuperview()
-            let titleLab = UILabel(frame: CGRect(x: CGFloat(index) *  (frequencyWidth + frequencyMargin) * 10 + margin - timeLineWidth / 2, y: rateView.frame.maxY, width: timeLineWidth, height: 30))
+            let titleLab = UILabel(frame: CGRect(x: CGFloat(index) * (frequencyWidth + frequencyMargin) * 10 + margin - timeLineWidth / 2, y: rateView.frame.maxY, width: timeLineWidth, height: 30))
             titleLab.font = UIFont.systemFont(ofSize: 11)
             titleLab.textAlignment = .center
             titleLab.numberOfLines = 1
             titleLab.tag = 100 + index
             titleLab.backgroundColor = .clear
             titleLab.textColor = UIColor.hexColor(hexadecimal: "#999999")
-          
+
             titleLab.text = "\(Float64(Int(CGFloat(index) * timeRange)).formatDurationToHMS())"
             scrollView.addSubview(titleLab)
         }
@@ -259,10 +254,10 @@ class PQStuckPointCuttingView: UIView {
             // 1,处理音频频率
             configVoiceFrequency()
             // 2,滚动到推荐位置
-            if(!isUserDrag){
+            if !isUserDrag {
                 scrollView.contentOffset = CGPoint(x: startLineX - margin, y: 0)
             }
-        
+
             scrollView.addSubview(rateView)
         }
     }
@@ -276,7 +271,7 @@ class PQStuckPointCuttingView: UIView {
         var remainder = Int(wavTotalCount % cFrequency.count)
         var totalWave: [CGFloat] = Array<CGFloat>.init()
 //         1,先画整倍数个竖线
-        for _ in 0 ..< waveTotalCount {
+        for _ in 0..<waveTotalCount {
             totalWave = totalWave + cFrequency
         }
         if remainder > cFrequency.count - 1 {
@@ -284,7 +279,7 @@ class PQStuckPointCuttingView: UIView {
         }
         // 1,再画余数个竖线
         if remainder > 0 {
-            totalWave = totalWave + cFrequency[0 ... (remainder - 1)]
+            totalWave = totalWave + cFrequency[0...(remainder - 1)]
         }
 
         createWave(waveArr: totalWave)
@@ -293,54 +288,49 @@ class PQStuckPointCuttingView: UIView {
     /// 更新进度绘制不同色值
     /// progress <#progress description#>
     func updateProgress(progress: CGFloat) {
-        
-        if(progress <= 0 || lineLayerArray.count == 0 || progress.isNaN){
+        if progress <= 0 || lineLayerArray.count == 0 || progress.isNaN {
             BFLog(message: "progress is error \(progress) lineLayerArray \(lineLayerArray)")
             return
         }
-        
+
         let startIndex = scrollView.contentOffset.x / (frequencyWidth + frequencyMargin)
         lastDrawedLineIndex = max(lastDrawedLineIndex, Int(ceil(startIndex)))
         let selectIndex = Int(ceil(startIndex + progress * CGFloat(wavSelectCount)))
-        while(selectIndex < lineLayerArray.count && selectIndex > lastDrawedLineIndex){
-            let drawLayer:CAShapeLayer = lineLayerArray[lastDrawedLineIndex]
-            if drawLayer.strokeColor != UIColor.hexColor(hexadecimal: BFConfig.shared.styleColor.rawValue).cgColor{
+        while selectIndex < lineLayerArray.count, selectIndex > lastDrawedLineIndex {
+            let drawLayer: CAShapeLayer = lineLayerArray[lastDrawedLineIndex]
+            if drawLayer.strokeColor != UIColor.hexColor(hexadecimal: BFConfig.shared.styleColor.rawValue).cgColor {
 //                BFLog(1, message: "progress is \(progress) i \(lastDrawedLineIndex) 命中的位置:\(CGFloat(lastDrawedLineIndex) * oneMarginTime)")
                 drawLayer.strokeColor = UIColor.hexColor(hexadecimal: BFConfig.shared.styleColor.rawValue).cgColor
                 drawLayer.setNeedsDisplay()
                 drawLayer.layoutIfNeeded()
             }
             lastDrawedLineIndex += 1
-
         }
 
-        
-        if(progress >= 0.999){
+        if progress >= 0.999 {
             BFLog(message: "播放完成 重新更新 UI ")
             resetDefaultsColor(clearData: false)
         }
-
     }
 
     // 竖线恢复到原有色值
-    func resetDefaultsColor(clearData:Bool = true) {
+    func resetDefaultsColor(clearData: Bool = true) {
         lastDrawedLineIndex = 0
         for layer in lineLayerArray {
             layer.strokeColor = UIColor.hexColor(hexadecimal: "#999999").cgColor
             layer.setNeedsDisplay()
         }
-        if(clearData == true){
+        if clearData == true {
             lineLayerArray.removeAll()
-            if(rateView.layer.sublayers != nil){
-                for (_,layer) in rateView.layer.sublayers!.enumerated() {
+            if rateView.layer.sublayers != nil {
+                for (_, layer) in rateView.layer.sublayers!.enumerated() {
                     layer.removeFromSuperlayer()
                 }
             }
-      
+
             isUserDrag = false
             isDrawLine = false
         }
-   
     }
 
     /// 生成波纹
@@ -373,7 +363,7 @@ class PQStuckPointCuttingView: UIView {
 
             // 推荐的开始起点是虚线 减0.0001因为精度问题
 //            BFLog(1, message: "suggestRhythmStartTime is \(suggestRhythmStartTime)")
-            if oneMarginTime * CGFloat(i) >= (suggestRhythmStartTime-0.0001) && !isDrawLine {
+            if oneMarginTime * CGFloat(i) >= (suggestRhythmStartTime - 0.0001), !isDrawLine {
                 isDrawLine = true
                 linePath.move(to: CGPoint(x: originX, y: -10))
                 // 终点
@@ -382,7 +372,7 @@ class PQStuckPointCuttingView: UIView {
                 lineLayer.lineDashPhase = 0
                 lineLayer.lineDashPattern = [3, 3]
             }
-            if startLineX == 0 && oneMarginTime * CGFloat(i) >= stuckPointStartTime{
+            if startLineX == 0, oneMarginTime * CGFloat(i) >= stuckPointStartTime {
                 startLineX = originX
             }
 
@@ -394,24 +384,24 @@ class PQStuckPointCuttingView: UIView {
     deinit {
         BFLog(message: "卡点裁剪-裁剪视图销毁")
     }
-    
-    //划动结速后处理
+
+    // 划动结速后处理
     func moveEnd() {
-        //最后一个竖线VIEW
-        let lastLine:UIView = scrollView.viewWithTag(100 +  Int(videoDuration / timeRange) - 1) ?? UIView.init()
-        //移动后的开始时间
-        let startTime =  videoDuration / lastLine.frame.maxX * scrollView.contentOffset.x
+        // 最后一个竖线VIEW
+        let lastLine: UIView = scrollView.viewWithTag(100 + Int(videoDuration / timeRange) - 1) ?? UIView()
+        // 移动后的开始时间
+        let startTime = videoDuration / lastLine.frame.maxX * scrollView.contentOffset.x
 //        let startTime =  videoDuration * (margin + scrollView.contentOffset.x) / scrollView.contentSize.width
-        //选中的时长
-        let selectDuration:CGFloat = 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)
+        if videoDidEndDragging != nil {
+            videoDidEndDragging!(1, startTime, startTime + CGFloat(stuckPointEndTime - stuckPointStartTime), 0)
         }
         resetDefaultsColor(clearData: false)
-        BFEventTrackAdaptor.baseReportUpload(businessType: .bt_buttonClick, objectType: .ot_shanyinApp_musicVideoPreview_musicPeriodSelect, pageSource: .sp_shanyinApp_main,commonParams: commonParams())
+        BFEventTrackAdaptor.baseReportUpload(businessType: .bt_buttonClick, objectType: .ot_shanyinApp_musicVideoPreview_musicPeriodSelect, pageSource: .sp_shanyinApp_main, commonParams: commonParams())
     }
 }
 
@@ -420,38 +410,31 @@ class PQStuckPointCuttingView: UIView {
 /// scrollView滑动代理
 extension PQStuckPointCuttingView: UIScrollViewDelegate {
     func scrollViewDidScroll(_: UIScrollView) {}
- 
-    func scrollViewWillBeginDragging(_ :UIScrollView){
+
+    func scrollViewWillBeginDragging(_: UIScrollView) {
         isUserDrag = true
-        if(videoDidBeginDrag != nil){
+        if videoDidBeginDrag != nil {
             videoDidBeginDrag!()
         }
-        
     }
-    
+
     func scrollViewDidEndDecelerating(_: UIScrollView) {
         if !scrollView.isDragging, !scrollView.isDecelerating {
-
             DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.2) { [weak self] in
                 self?.moveEnd()
             }
         }
-       
     }
-    func scrollViewDidEndDragging(_:UIScrollView,willDecelerate decelerate:Bool){
+
+    func scrollViewDidEndDragging(_: UIScrollView, willDecelerate decelerate: Bool) {
         if !decelerate, !scrollView.isDragging, !scrollView.isDecelerating {
-            
             DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.2) { [weak self] in
                 self?.moveEnd()
             }
- 
         }
-       
     }
-    
+
     func scrollViewDidEndScrollingAnimation(_: UIScrollView) {
         BFLog(message: "scrollViewDidEndScrollingAnimation")
-        
-        
     }
 }

+ 13 - 18
BFStuckPointKit/Classes/View/PQStuckPointLoadingView.swift

@@ -6,14 +6,14 @@
 //  Copyright © 2021 BytesFlow. All rights reserved.
 //
 
-import Kingfisher
-import UIKit
 import BFCommonKit
 import BFUIKit
+import Kingfisher
+import UIKit
 
 class PQStuckPointLoadingView: UIView {
     var cancelHandle: ((_ sender: UIButton) -> Void)?
-    
+
     /// 同步进度显示
     lazy var loadingView: AnimatedImageView = {
         let videoLoadingView = AnimatedImageView()
@@ -21,7 +21,7 @@ class PQStuckPointLoadingView: UIView {
         videoLoadingView.stopAnimating()
         return videoLoadingView
     }()
- 
+
     lazy var navBarLeftBtn: UIButton = {
         let navBarLeftBtn = UIButton(type: .custom)
         navBarLeftBtn.frame = CGRect(x: 0, y: cDevice_iPhoneStatusBarHei, width: cDefaultMargin * 4, height: cDefaultMargin * 4)
@@ -35,13 +35,13 @@ class PQStuckPointLoadingView: UIView {
 
     override init(frame: CGRect) {
         super.init(frame: frame)
-        backgroundColor = UIColor.init(red: 1, green: 1, blue: 1, alpha: 0.5)
+        backgroundColor = UIColor(red: 1, green: 1, blue: 1, alpha: 0.5)
         addSubViews()
         addLayout()
-        
+
         loadingView.startAnimating()
     }
-    
+
     required init?(coder _: NSCoder) {
         fatalError("init(coder:) has not been implemented")
     }
@@ -51,10 +51,8 @@ class PQStuckPointLoadingView: UIView {
     }
 
     func addSubViews() {
-    
         addSubview(loadingView)
         addSubview(navBarLeftBtn)
-        
     }
 
     func addLayout() {
@@ -64,28 +62,25 @@ class PQStuckPointLoadingView: UIView {
             make.centerY.equalTo(cScreenHeigth / 2.0)
             make.width.height.equalTo(cDefaultMargin * 10)
         }
-        
     }
-    
-    
+
     func show() {
-        if self.superview != nil {
+        if superview != nil {
             return
         }
         UIApplication.shared.keyWindow?.addSubview(self)
         loadingView.startAnimating()
-
     }
 
     /// 移除视图
     /// - Returns: <#description#>
     func removeMarskView() {
         loadingView.stopAnimating()
-     
-        if self.superview != nil {
-            removeFromSuperview()            
+
+        if superview != nil {
+            removeFromSuperview()
         }
-      
+
         BFLog(message: "removeMarskViewremoveMarskViewremoveMarskViewremoveMarskView")
     }
 

+ 3 - 3
BFStuckPointKit/Classes/View/PQStuckPointMaterialHeadView.swift

@@ -6,14 +6,14 @@
 //  Copyright © 2021 BytesFlow. All rights reserved.
 //
 
-import SnapKit
-import UIKit
 import BFCommonKit
 import BFUIKit
+import SnapKit
+import UIKit
 
 class PQStuckPointMaterialHeadView: UIView {
     lazy var iconImageView: UIImageView = {
-        let iconImageView = UIImageView(image:UIImage.moduleImage(named: "videomk_netMaterial_selected", moduleName: "BFStuckPointKit",isAssets: false))
+        let iconImageView = UIImageView(image: UIImage.moduleImage(named: "videomk_netMaterial_selected", moduleName: "BFStuckPointKit", isAssets: false))
         return iconImageView
     }()
 

+ 14 - 15
BFStuckPointKit/Classes/View/PQStuckPointMusicContentCell.swift

@@ -6,10 +6,10 @@
 //  Copyright © 2021 BytesFlow. All rights reserved.
 //
 
-import UIKit
 import BFCommonKit
 import BFMediaKit
 import BFUIKit
+import UIKit
 
 class PQStuckPointMusicContentCell: UICollectionViewCell {
     // 按钮点击的回调
@@ -17,7 +17,7 @@ class PQStuckPointMusicContentCell: UICollectionViewCell {
     var contentType: stuckPointMusicContentType = .catagery
 
     lazy var audioImageView: UIImageView = {
-         let audioImageView = UIImageView(image:BFStuckPointImage(by: "videomk_music_default")!)
+        let audioImageView = UIImageView(image: BFStuckPointImage(by: "videomk_music_default")!)
         audioImageView.addCorner(corner: 4)
         audioImageView.contentMode = .scaleAspectFill
         return audioImageView
@@ -32,7 +32,7 @@ class PQStuckPointMusicContentCell: UICollectionViewCell {
 
     lazy var playImageView: UIImageView = {
         let playImageView = UIImageView()
-        playImageView.image = UIImage.moduleImage(named: "stuckPoint_music_pause", moduleName: "BFStuckPointKit",isAssets: false)
+        playImageView.image = UIImage.moduleImage(named: "stuckPoint_music_pause", moduleName: "BFStuckPointKit", isAssets: false)
         return playImageView
     }()
 
@@ -99,8 +99,8 @@ class PQStuckPointMusicContentCell: UICollectionViewCell {
         contentView.addSubview(remindView)
         contentView.addSubview(confirmContentView)
         confirmContentView.addSubview(confirmBtn)
-        PQNotification.addObserver(forName: Notification.Name(rawValue: "MusicContentCellIconLoadingAnimationStop"), object: nil, queue: .main) { [weak self] notice in
-            if !(self?.imageMaskView.isHidden ?? true){
+        PQNotification.addObserver(forName: Notification.Name(rawValue: "MusicContentCellIconLoadingAnimationStop"), object: nil, queue: .main) { [weak self] _ in
+            if !(self?.imageMaskView.isHidden ?? true) {
                 self?.stopLoadingAnimation()
             }
         }
@@ -109,6 +109,7 @@ class PQStuckPointMusicContentCell: UICollectionViewCell {
     required init?(coder _: NSCoder) {
         fatalError("init(coder:) has not been implemented")
     }
+
     deinit {
         PQNotification.removeObserver(self)
     }
@@ -131,17 +132,15 @@ class PQStuckPointMusicContentCell: UICollectionViewCell {
                 imageMaskView.isHidden = false
                 playImageView.isHidden = false
                 if (bgmData as? PQVoiceModel)?.isPlaying ?? false {
-
                     if playImageView.image == nil {
                         playImageView.image = UIImage.moduleImage(named: "loading", moduleName: "BFStuckPointKit", isAssets: false)
                         startLoadingAnimation()
-                    }else {
-                        playImageView.kf.setImage(with: URL(fileURLWithPath: (currentBundlePath()!.path(forResource: "stuckPoint_music_playing", ofType: ".gif")!)))
-
+                    } else {
+                        playImageView.kf.setImage(with: URL(fileURLWithPath: currentBundlePath()!.path(forResource: "stuckPoint_music_playing", ofType: ".gif")!))
                     }
                     musicNameLab.move()
                 } else {
-                    playImageView.image = UIImage.moduleImage(named: "stuckPoint_music_pause", moduleName: "BFStuckPointKit",isAssets: false)
+                    playImageView.image = UIImage.moduleImage(named: "stuckPoint_music_pause", moduleName: "BFStuckPointKit", isAssets: false)
                     musicNameLab.stop()
                 }
             } else {
@@ -151,7 +150,7 @@ class PQStuckPointMusicContentCell: UICollectionViewCell {
             }
         } else {
             if (bgmData as? PQStuckPointMusicTagsModel)?.tagEmoji != nil {
-                audioImageView.setNetImage(url: "\((bgmData as? PQStuckPointMusicTagsModel)?.tagEmoji ?? "")", placeholder:BFStuckPointImage(by: "videomk_music_default")!)
+                audioImageView.setNetImage(url: "\((bgmData as? PQStuckPointMusicTagsModel)?.tagEmoji ?? "")", placeholder: BFStuckPointImage(by: "videomk_music_default")!)
             } else {
                 audioImageView.image = BFStuckPointImage(by: "videomk_music_default")
             }
@@ -244,16 +243,16 @@ class PQStuckPointMusicContentCell: UICollectionViewCell {
             btnClickHandle!(confirmBtn, bgmData)
         }
     }
-    
-    func startLoadingAnimation(){
+
+    func startLoadingAnimation() {
         let rotateAnimation = CABasicAnimation(keyPath: "transform.rotation")
         rotateAnimation.toValue = Double.pi * 2
         rotateAnimation.duration = 1
         rotateAnimation.repeatCount = .infinity
         playImageView.layer.add(rotateAnimation, forKey: nil)
     }
-    
-    func stopLoadingAnimation(){
+
+    func stopLoadingAnimation() {
         playImageView.layer.removeAllAnimations()
         if (bgmData as? PQVoiceModel)?.isPlaying ?? false {
             playImageView.kf.setImage(with: URL(fileURLWithPath: currentBundlePath()!.path(forResource: "stuckPoint_music_playing", ofType: ".gif")!))

+ 1 - 1
BFStuckPointKit/Classes/View/PQStuckPointMusicTagsCell.swift

@@ -6,8 +6,8 @@
 //  Copyright © 2021 BytesFlow. All rights reserved.
 //
 
-import UIKit
 import BFMediaKit
+import UIKit
 
 class PQStuckPointMusicTagsCell: UICollectionViewCell {
     /// 点击标签

+ 1 - 1
BFStuckPointKit/Classes/View/PQStuckPointMusicTagsContentCell.swift

@@ -6,9 +6,9 @@
 //  Copyright © 2021 BytesFlow. All rights reserved.
 //
 
-import UIKit
 import BFCommonKit
 import BFMediaKit
+import UIKit
 
 class PQStuckPointMusicTagsContentCell: UICollectionViewCell {
     lazy var titleLab: UILabel = {

+ 2 - 2
BFStuckPointKit/Classes/View/PQStuckPointSearchEmptyCell.swift

@@ -6,13 +6,13 @@
 //  Copyright © 2021 BytesFlow. All rights reserved.
 //
 
-import UIKit
 import BFCommonKit
 import BFUIKit
+import UIKit
 
 class PQStuckPointSearchEmptyCell: UICollectionViewCell {
     lazy var emptyImageView: UIImageView = {
-        let emptyImageView = UIImageView(image:UIImage.moduleImage(named: "pic_search_empty", moduleName: "BFUIKit",isAssets: false))
+        let emptyImageView = UIImageView(image: UIImage.moduleImage(named: "pic_search_empty", moduleName: "BFUIKit", isAssets: false))
         emptyImageView.backgroundColor = UIColor.clear
         emptyImageView.contentMode = .scaleAspectFit
         return emptyImageView

+ 3 - 3
BFStuckPointKit/Classes/View/PQVideoCutingOprateView.swift

@@ -6,8 +6,8 @@
 //  Copyright © 2021 BytesFlow. All rights reserved.
 //
 
-import UIKit
 import BFCommonKit
+import UIKit
 
 class PQVideoCutingOprateView: UIView {
     // 距离左边间隔
@@ -68,7 +68,7 @@ class PQVideoCutingOprateView: UIView {
     }()
 
     lazy var leftOprateView: UIImageView = {
-        let leftOprateView = UIImageView(image:UIImage.moduleImage(named: "videomk_crop_left", moduleName: "BFStuckPointKit",isAssets: false)?.withRenderingMode(.alwaysTemplate))
+        let leftOprateView = UIImageView(image: UIImage.moduleImage(named: "videomk_crop_left", moduleName: "BFStuckPointKit", isAssets: false)?.withRenderingMode(.alwaysTemplate))
         leftOprateView.tintColor = BFConfig.shared.cutViewTintColor
         leftOprateView.contentMode = .scaleAspectFill
         leftOprateView.isUserInteractionEnabled = true
@@ -81,7 +81,7 @@ class PQVideoCutingOprateView: UIView {
     }()
 
     lazy var rightOprateView: UIImageView = {
-        let rightOprateView = UIImageView(image:UIImage.moduleImage(named: "videomk_crop_right", moduleName: "BFStuckPointKit",isAssets: false)?.withRenderingMode(.alwaysTemplate))
+        let rightOprateView = UIImageView(image: UIImage.moduleImage(named: "videomk_crop_right", moduleName: "BFStuckPointKit", isAssets: false)?.withRenderingMode(.alwaysTemplate))
         rightOprateView.tintColor = BFConfig.shared.cutViewTintColor
         rightOprateView.contentMode = .scaleAspectFill
         rightOprateView.isUserInteractionEnabled = true

+ 33 - 39
BFStuckPointKit/Classes/ViewModel/PQBaseViewModel.swift

@@ -7,18 +7,17 @@
 //
 
 import Alamofire
-import UIKit
-import ObjectMapper
-import RealmSwift
 import BFCommonKit
+import BFMediaKit
 import BFNetRequestKit
 import BFUploadKit
-import BFMediaKit
+import ObjectMapper
+import RealmSwift
+import UIKit
 
 public class PQBaseViewModel: NSObject {
-    
-   public typealias completeHander = (_ userInfo: [String: Any]?, _ msg: String?) -> Void
-    
+    public typealias completeHander = (_ userInfo: [String: Any]?, _ msg: String?) -> Void
+
     /// 搜索背景音乐
     /// - Parameters:
     ///   - keyWord: 搜索key
@@ -29,7 +28,7 @@ public class PQBaseViewModel: NSObject {
     ///   - totalDuration: 卡点音乐数据搜索-素材总时长
     ///   - completeHander: completeHander description
     /// - Returns: <#description#>
-    public class func searchBGMListData(_ keyWord: String?, _ pageNum: Int = 1, _ pageSize: Int = 30,videoCount: Int = 0, imageCount: Int = 0, totalDuration: Float64 = 0, completeHander: @escaping (_ bgmList: [PQVoiceModel], _ msg: String?) -> Void) {
+    public class func searchBGMListData(_ keyWord: String?, _ pageNum: Int = 1, _ pageSize: Int = 30, videoCount: Int = 0, imageCount: Int = 0, totalDuration: Float64 = 0, completeHander: @escaping (_ bgmList: [PQVoiceModel], _ msg: String?) -> Void) {
         BFNetRequestAdaptor.postRequestData(url: PQENVUtil.shared.materialSearchApi + searchBGMMaterialUrl, parames: ["keyWord": keyWord ?? "", "pageNo": pageNum, "pageSize": pageSize], commonParams: commonParams(), encoding: JSONEncoding.default, isJsonEncodingNormal: true) { response, _, error, _ in
             DispatchQueue.global().async {
                 var bgmList = Array<PQVoiceModel>.init()
@@ -45,7 +44,7 @@ public class PQBaseViewModel: NSObject {
                         let tempModel = PQVoiceModel(jsonDict: item)
                         tempModel.volume = 30
                         tempModel.voiceType = VOICETYPT.BGM.rawValue
-                        if tempModel.rhythmSdata.count > 0 && (videoCount > 0 || imageCount > 0 ||  totalDuration > 0)  {
+                        if tempModel.rhythmSdata.count > 0, videoCount > 0 || imageCount > 0 || totalDuration > 0 {
 //                            tempModel.endTime = tempModel.startTime + tempModel.stuckPointCuttingTime(videoCount: videoCount, imageCount: imageCount, totalDuration: totalDuration)
                         }
                         bgmList.append(tempModel)
@@ -57,6 +56,7 @@ public class PQBaseViewModel: NSObject {
             }
         }
     }
+
     /// 请求系统配置
     /// - Parameter completeHander: <#completeHander description#>
     /// - Returns: <#description#>
@@ -86,21 +86,19 @@ public class PQBaseViewModel: NSObject {
             completeHander(true)
         }
     }
-  
- 
 
     /// 删除某个视频
     /// - Parameters:
     ///   - videoId: <#videoId description#>
     ///   - completeHander: <#completeHander description#>
     /// - Returns: <#description#>
-    public class func deleteVideo(videoId: Int, completeHander: @escaping (_ isSuccess: Bool,_ videoId: Int, _ msg: String?) -> Void) {
+    public class func deleteVideo(videoId: Int, completeHander: @escaping (_ isSuccess: Bool, _ videoId: Int, _ msg: String?) -> Void) {
         BFNetRequestAdaptor.postRequestData(url: PQENVUtil.shared.longvideoapi + deleteVideoUrl, parames: ["videoId": videoId], commonParams: commonParams()) { response, _, error, _ in
             if response != nil {
                 postNotification(name: cDeleteVideoSuccessKey, userInfo: ["videoId": "\(videoId)"])
-                completeHander(true,videoId, nil)
+                completeHander(true, videoId, nil)
             } else {
-                completeHander(false,videoId,error?.msg)
+                completeHander(false, videoId, error?.msg)
             }
         }
     }
@@ -277,7 +275,7 @@ public class PQBaseViewModel: NSObject {
     /// 获取用户管理列表
     /// - Parameter completeHander: <#completeHander description#>
     /// - Returns: <#description#>
-    class public func bannedUserList(completeHander: @escaping (_ listData: [PQUserInfoModel]?) -> Void) {
+    public class func bannedUserList(completeHander: @escaping (_ listData: [PQUserInfoModel]?) -> Void) {
         BFNetRequestAdaptor.postRequestData(url: PQENVUtil.shared.longvideoapi + bannedUserListUrl, parames: nil, commonParams: commonParams()) { response, _, _, _ in
             var listData = Array<PQUserInfoModel>.init()
             if response is NSNull || response == nil {
@@ -367,8 +365,7 @@ public class PQBaseViewModel: NSObject {
             completeHander((response as? Int) == 1, nil)
         }
     }
-    
-    
+
     /// add by ak 取 STS token
     /// - Parameter completeHander: completeHander description
     public class func getStsToken(completeHander: @escaping completeHander) {
@@ -380,7 +377,7 @@ public class PQBaseViewModel: NSObject {
             completeHander(response as? [String: Any], nil)
         }
     }
-    
+
     /// 获取OSS
     /// - Parameter completeHander: <#completeHander description#>
     /// - Returns: <#description#>
@@ -389,30 +386,27 @@ public class PQBaseViewModel: NSObject {
             completeHander(response as? [String: Any], nil)
         }
     }
-    
+
     /// 请求APP 常规配置参数
     /// - Parameter completeHander: <#completeHander description#>
     /// - Returns: <#description#>
-    public class func getBaseConfig(completeHander: @escaping (_ titles: Array<String>?) -> Void) {
-      
+    public class func getBaseConfig(completeHander: @escaping (_ titles: [String]?) -> Void) {
         BFNetRequestAdaptor.postRequestData(url: PQENVUtil.shared.longvideoapi + getBaseConfigURL, parames: nil, commonParams: commonParams()) { response, _, _, _ in
             if response != nil, !(response is NSNull) {
- 
                 let responseDic = response as! [String: Any]
                 BFLog(message: "推荐的标题为\(String(describing: responseDic["rhythmVideoTitles"]))")
-                completeHander(responseDic["rhythmVideoTitles"] as? Array<String>)
+                completeHander(responseDic["rhythmVideoTitles"] as? [String])
             } else {
                 completeHander(nil)
             }
         }
     }
-
 }
 
 // MARK: - 草稿箱相关
 
 /// 草稿箱相关
-extension PQBaseViewModel {
+public extension PQBaseViewModel {
     /// 保存草稿-进入创作工具调用
     /// - Parameters:
     ///   - draftboxId: 草稿ID
@@ -424,15 +418,15 @@ extension PQBaseViewModel {
     ///   - originProjectId:卡点视频制作再创作传-源项目ID从那个项目做同款
     ///   - completeHander: <#completeHander description#>
     /// - Returns: <#description#>
-    public class func saveDraftbox(draftboxId: String?, title: String?, coverUrl: String?, sdata: String, videoFromScene: videoFromScene,copyType:Int? = nil,originProjectId:String? = nil, completeHander: @escaping (_ draftboxInfo: [String: Any]?, _ msg: String?) -> Void) {
+    class func saveDraftbox(draftboxId: String?, title: String?, coverUrl: String?, sdata: String, videoFromScene: videoFromScene, copyType: Int? = nil, originProjectId: String? = nil, completeHander: @escaping (_ draftboxInfo: [String: Any]?, _ msg: String?) -> Void) {
         var parames: [String: Any] = ["sdata": sdata, "fromScene": videoFromScene.rawValue]
         if draftboxId != nil {
             parames["draftboxId"] = draftboxId
         }
-        if copyType != nil && videoFromScene == .stuckPoint{
+        if copyType != nil, videoFromScene == .stuckPoint {
             parames["copyType"] = 3
         }
-        if originProjectId != nil && videoFromScene == .stuckPoint{
+        if originProjectId != nil, videoFromScene == .stuckPoint {
             parames["originProjectId"] = originProjectId
         }
         if title != nil {
@@ -471,8 +465,8 @@ extension PQBaseViewModel {
     ///   - videoFromScene:上传场景 1:普通上传 2:创作工具,3:普通上传转创作工具,4:后台转换加工,5:卡点视频制作
     ///   - completeHander: <#completeHander description#>
     /// - Returns: <#description#>
-    public class func saveProject(draftboxId: String?, sdata: String, videoFromScene: videoFromScene, rhythmMode:createStickersModel? = nil, completeHander: @escaping (_ projectId: String?, _ msg: String?) -> Void) {
-        var parames: [String: Any] = ["sdata": sdata,"fromScene": videoFromScene.rawValue]
+    class func saveProject(draftboxId: String?, sdata: String, videoFromScene: videoFromScene, rhythmMode: createStickersModel? = nil, completeHander: @escaping (_ projectId: String?, _ msg: String?) -> Void) {
+        var parames: [String: Any] = ["sdata": sdata, "fromScene": videoFromScene.rawValue]
         if draftboxId != nil {
             parames["draftboxId"] = draftboxId
         }
@@ -493,7 +487,7 @@ extension PQBaseViewModel {
     /// - Parameter projectId: 项目 ID
     /// - Parameter produceStatus: 合成状态 必传-合成状态(5:合成成功,99:合成失败)
     /// - Parameter completeHander: 回调
-    public class func updateProject(projectId: String?, produceStatus: String, completeHander: @escaping (_ projectId: String?, _ msg: String?) -> Void) {
+    class func updateProject(projectId: String?, produceStatus: String, completeHander: @escaping (_ projectId: String?, _ msg: String?) -> Void) {
         var parames: [String: String] = ["produceStatus": produceStatus]
 
         if projectId != nil {
@@ -516,7 +510,7 @@ extension PQBaseViewModel {
     ///   - videoFromScene:上传场景 1:普通上传 2:创作工具,3:普通上传转创作工具,4:后台转换加工,5:卡点视频制作
     ///   - completeHander: <#completeHander description#>
     /// - Returns: <#description#>
-    public class func reportSendVideo(_ projectId: String, _ videoId: String, videoFromScene: videoFromScene, completeHander: @escaping (_ isSeccess: Bool, _ msg: String?) -> Void) {
+    class func reportSendVideo(_ projectId: String, _ videoId: String, videoFromScene: videoFromScene, completeHander: @escaping (_ isSeccess: Bool, _ msg: String?) -> Void) {
         BFNetRequestAdaptor.postRequestData(url: PQENVUtil.shared.clipapiapi + reportSendVideoUrl, parames: ["projectId": projectId, "videoId": videoId, "fromScene": videoFromScene.rawValue], commonParams: commonParams()) { _, _, error, _ in
 
             BFLog(message: "发布视频后上报:projectId = \(projectId),videoId = \(videoId)")
@@ -534,7 +528,7 @@ extension PQBaseViewModel {
     ///   - pageSize: 每页大小
     ///   - isSelected: 是否已选
     ///   - completeHander: <#completeHander description#>
-    public class func listUserDraftbox(lastTimestamp: Int, pageSize: Int = 10, isSelected: Bool = false, completeHander: @escaping (_ projectList: [PQEditProjectModel]?, _ msg: String?) -> Void) {
+    class func listUserDraftbox(lastTimestamp: Int, pageSize: Int = 10, isSelected: Bool = false, completeHander: @escaping (_ projectList: [PQEditProjectModel]?, _ msg: String?) -> Void) {
         let params: [String: Any] = ["pageSize": pageSize, "lastTimestamp": lastTimestamp]
         BFNetRequestAdaptor.postRequestData(url: PQENVUtil.shared.clipapiapi + listUserDraftboxUrl, parames: params, commonParams: commonParams()) { response, _, error, _ in
             if error?.code == -1009 || error?.code == -1001 {
@@ -567,7 +561,7 @@ extension PQBaseViewModel {
     /// 获取草稿箱数量
     /// - Parameter completeHander: <#completeHander description#>
     /// - Returns: <#description#>
-    public class func draftboxUserCount(completeHander: @escaping (_ draftboxCount: Int, _ msg: String?) -> Void) {
+    class func draftboxUserCount(completeHander: @escaping (_ draftboxCount: Int, _ msg: String?) -> Void) {
         BFNetRequestAdaptor.postRequestData(url: PQENVUtil.shared.clipapiapi + draftboxUserCountUrl, parames: nil, commonParams: commonParams()) { response, _, error, _ in
             if response is NSNull || response == nil {
                 completeHander(0, error?.msg)
@@ -582,7 +576,7 @@ extension PQBaseViewModel {
     ///   - isBatch: 是否批量删除(多个用英文逗号分隔)
     ///   - draftboxIds: 草稿id
     ///   - completeHander: <#completeHander description#>
-    public class func deleteDraftbox(isBatch: Bool = false, draftboxIds: String?, completeHander: @escaping (_ isSuccess: Bool, _ msg: String?) -> Void) {
+    class func deleteDraftbox(isBatch: Bool = false, draftboxIds: String?, completeHander: @escaping (_ isSuccess: Bool, _ msg: String?) -> Void) {
         var url: String = PQENVUtil.shared.clipapiapi
         var params: [String: Any] = Dictionary<String, Any>.init()
         if isBatch {
@@ -603,7 +597,7 @@ extension PQBaseViewModel {
     ///   - title: 草稿箱标题
     ///   - copyType: 复制类型(1:复制自己的项目,2:创建副本(复制别人的项目) 3:再创作)
     ///   - completeHander: <#completeHander description#>
-    public class func copyDraftbox(draftboxId: String?, title: String, copyType: Int, completeHander: @escaping (_ newDraftboxId: String?, _ msg: String?) -> Void) {
+    class func copyDraftbox(draftboxId: String?, title: String, copyType: Int, completeHander: @escaping (_ newDraftboxId: String?, _ msg: String?) -> Void) {
         BFNetRequestAdaptor.postRequestData(url: PQENVUtil.shared.clipapiapi + copyDraftboxUrl, parames: ["draftboxId": draftboxId ?? "", "title": title, "copyType": copyType], commonParams: commonParams()) { response, _, error, _ in
             if response is NSNull || response == nil {
                 completeHander(nil, error?.msg)
@@ -618,7 +612,7 @@ extension PQBaseViewModel {
     ///   - draftboxId: 草稿id
     ///   - title: 标题
     ///   - completeHander: <#completeHander description#>
-    public class func updateDraftBoxTitle(draftboxId: String?, title: String, completeHander: @escaping (_ newDraftData: PQEditProjectModel?, _ msg: String?) -> Void) {
+    class func updateDraftBoxTitle(draftboxId: String?, title: String, completeHander: @escaping (_ newDraftData: PQEditProjectModel?, _ msg: String?) -> Void) {
         BFNetRequestAdaptor.postRequestData(url: PQENVUtil.shared.clipapiapi + updateDraftboxTitleUrl, parames: ["draftboxId": draftboxId ?? "", "title": title], commonParams: commonParams()) { response, _, error, _ in
             if response is NSNull || response == nil {
                 completeHander(nil, error?.msg)
@@ -632,7 +626,7 @@ extension PQBaseViewModel {
     /// - Parameters:
     ///   - : <# description#>
     ///   - completeHander: <#completeHander description#>
-    public class func draftboxGetSdata(draftboxId: String?, completeHander: @escaping (_ projectModel: PQEditSdataModel?, _ msg: String?) -> Void) {
+    class func draftboxGetSdata(draftboxId: String?, completeHander: @escaping (_ projectModel: PQEditSdataModel?, _ msg: String?) -> Void) {
         let params: [String: Any] = ["draftboxId": draftboxId ?? ""]
         BFNetRequestAdaptor.postRequestData(url: PQENVUtil.shared.clipapiapi + draftboxGetSdataUrl, parames: params, commonParams: commonParams()) { response, _, error, _ in
 
@@ -651,7 +645,7 @@ extension PQBaseViewModel {
     /// 素材上报扩展字段
     /// - Parameter materialData: <#materialData description#>
     /// - Returns: <#description#>
-    public class func uploadReportExParams(isDownload: Bool, materialData: PQEditVisionTrackMaterialsModel?) -> [String: Any] {
+    class func uploadReportExParams(isDownload: Bool, materialData: PQEditVisionTrackMaterialsModel?) -> [String: Any] {
         var params: [String: Any] = ["draftboxId": PQSingletoMemoryUtil.shared.draftboxId ?? "", "materialType": materialData?.type ?? ""]
         if !isDownload {
             params["materialSource"] = (materialData?.localSearchId != nil && (materialData?.localSearchId ?? "").count > 0) ? "netMaterial" : "localMaterial"

+ 11 - 12
BFStuckPointKit/Classes/ViewModel/PQStuckPointViewModel.swift

@@ -6,12 +6,12 @@
 //  Copyright © 2021 BytesFlow. All rights reserved.
 //
 
-import UIKit
+import BFAnalyzeKit
 import BFCommonKit
-import BFNetRequestKit
 import BFMediaKit
-import BFAnalyzeKit
+import BFNetRequestKit
 import BFUIKit
+import UIKit
 
 public class PQStuckPointViewModel: NSObject {
     /// 获取卡点音乐分类列表
@@ -81,7 +81,7 @@ public class PQStuckPointViewModel: NSObject {
     ///   - totalDuration: 选择素材总时长
     ///   - complateHandle: <#complateHandle description#>
     /// - Returns: <#description#>
-    class func stuckPointMusicPageList(tagId: Int64, parentTagId: Int64 = 0, pageNum: Int = 1, pageSize: Int = 20,videoCount: Int = 0, imageCount: Int = 0, totalDuration: Float64 = 0, oldDataMusic:[PQVoiceModel]? = nil, complateHandle: @escaping (_ musicPageList: [PQVoiceModel], _ msg: String?) -> Void) {
+    class func stuckPointMusicPageList(tagId: Int64, parentTagId: Int64 = 0, pageNum: Int = 1, pageSize: Int = 20, videoCount: Int = 0, imageCount: Int = 0, totalDuration: Float64 = 0, oldDataMusic: [PQVoiceModel]? = nil, complateHandle: @escaping (_ musicPageList: [PQVoiceModel], _ msg: String?) -> Void) {
         BFNetRequestAdaptor.postRequestData(url: PQENVUtil.shared.longvideoapi + stuckPointMusicPageUrl, parames: ["tagId": tagId, "parentTagId": parentTagId, "pageNum": pageNum, "pageSize": pageSize], commonParams: commonParams()) { response, _, error, _ in
             var musicPageList = Array<PQVoiceModel>.init()
             if response is NSNull || response == nil {
@@ -90,24 +90,23 @@ public class PQStuckPointViewModel: NSObject {
             }
             let tempArr = response as? [[String: Any]]
             if tempArr != nil, (tempArr?.count ?? 0) > 0 {
-                for (_,dict) in tempArr!.enumerated() {
+                for (_, dict) in tempArr!.enumerated() {
                     let tempMusic = PQVoiceModel(jsonDict: dict)
                     tempMusic.cacheTagID = tagId
-                    if tempMusic.rhythmSdata.count > 0 && (videoCount > 0 || imageCount > 0 ||  totalDuration > 0)  {
+                    if tempMusic.rhythmSdata.count > 0 && (videoCount > 0 || imageCount > 0 || totalDuration > 0) {
 //                        tempMusic.endTime = tempMusic.startTime + tempMusic.stuckPointCuttingTime(videoCount: videoCount, imageCount: imageCount, totalDuration: totalDuration)
                         BFLog(message: "music:\(tempMusic.musicName ?? ""),\(tempMusic.startTime),\(tempMusic.endTime)")
                     }
                     if tempMusic.endTime <= tempMusic.startTime {
                         tempMusic.endTime = tempMusic.startTime + 40
                     }
-                    
+
                     let haveIndex = oldDataMusic?.firstIndex(where: { (music) -> Bool in
-                        (music.musicId == tempMusic.musicId)
+                        music.musicId == tempMusic.musicId
                     })
-                    if(haveIndex == nil){
+                    if haveIndex == nil {
                         musicPageList.append(tempMusic)
                     }
-    
                 }
             }
             complateHandle(musicPageList, nil)
@@ -138,7 +137,7 @@ public class PQStuckPointViewModel: NSObject {
     /// 请求再创作项目信息
     /// - Parameter projectId: 项目id
     /// - Returns: <#description#>
-    class public func stuckPointProjectMusicInfo(projectId: String, complateHandle: @escaping (_ musicDetaiData: PQVoiceModel?, _ msg: String?) -> Void) {
+    public class func stuckPointProjectMusicInfo(projectId: String, complateHandle: @escaping (_ musicDetaiData: PQVoiceModel?, _ msg: String?) -> Void) {
         BFNetRequestAdaptor.postRequestData(url: PQENVUtil.shared.longvideoapi + stuckPointProjectMusicInfoUrl, parames: ["projectId": projectId], commonParams: commonParams()) { response, _, error, _ in
             if response is NSNull || response == nil {
                 complateHandle(nil, error?.msg)
@@ -153,7 +152,7 @@ public class PQStuckPointViewModel: NSObject {
                 if tempDict?.keys.contains("rhythmMusicOut") ?? false {
                     musicData.rhythmMusicOut = (Float64("\(tempDict?["rhythmMusicOut"] ?? "0")") ?? 0) / 1_000_000
                 }
-                if (tempDict?.keys.contains("rhythmMusicSpeed") ?? false) && "\(tempDict?["rhythmMusicSpeed"] ?? "")" != "<null>"  {
+                if tempDict?.keys.contains("rhythmMusicSpeed") ?? false, "\(tempDict?["rhythmMusicSpeed"] ?? "")" != "<null>" {
                     musicData.speed = Int("\(tempDict?["rhythmMusicSpeed"] ?? "2")") ?? 2
                 }
                 musicData.originProjectId = projectId

+ 2 - 0
Example/BFStuckPointKit.xcodeproj/project.pbxproj

@@ -287,6 +287,7 @@
 				"${BUILT_PRODUCTS_DIR}/LMJHorizontalScrollText/LMJHorizontalScrollText.framework",
 				"${BUILT_PRODUCTS_DIR}/MGSwipeTableCell/MGSwipeTableCell.framework",
 				"${BUILT_PRODUCTS_DIR}/MJRefresh/MJRefresh.framework",
+				"${PODS_ROOT}/NuiSDK/nuisdk.framework",
 				"${BUILT_PRODUCTS_DIR}/ObjectMapper/ObjectMapper.framework",
 				"${BUILT_PRODUCTS_DIR}/Realm/Realm.framework",
 				"${BUILT_PRODUCTS_DIR}/RealmSwift/RealmSwift.framework",
@@ -311,6 +312,7 @@
 				"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/LMJHorizontalScrollText.framework",
 				"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MGSwipeTableCell.framework",
 				"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MJRefresh.framework",
+				"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/nuisdk.framework",
 				"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/ObjectMapper.framework",
 				"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Realm.framework",
 				"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RealmSwift.framework",

+ 6 - 11
Example/BFStuckPointKit/AppDelegate.swift

@@ -10,37 +10,32 @@ import UIKit
 
 @UIApplicationMain
 class AppDelegate: UIResponder, UIApplicationDelegate {
-
     var window: UIWindow?
 
-
-    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
+    func application(_: UIApplication, didFinishLaunchingWithOptions _: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
         // Override point for customization after application launch.
         return true
     }
 
-    func applicationWillResignActive(_ application: UIApplication) {
+    func applicationWillResignActive(_: UIApplication) {
         // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
         // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
     }
 
-    func applicationDidEnterBackground(_ application: UIApplication) {
+    func applicationDidEnterBackground(_: UIApplication) {
         // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
         // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
     }
 
-    func applicationWillEnterForeground(_ application: UIApplication) {
+    func applicationWillEnterForeground(_: UIApplication) {
         // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
     }
 
-    func applicationDidBecomeActive(_ application: UIApplication) {
+    func applicationDidBecomeActive(_: UIApplication) {
         // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
     }
 
-    func applicationWillTerminate(_ application: UIApplication) {
+    func applicationWillTerminate(_: UIApplication) {
         // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
     }
-
-
 }
-

+ 0 - 3
Example/BFStuckPointKit/ViewController.swift

@@ -9,7 +9,6 @@
 import UIKit
 
 class ViewController: UIViewController {
-
     override func viewDidLoad() {
         super.viewDidLoad()
         // Do any additional setup after loading the view, typically from a nib.
@@ -19,6 +18,4 @@ class ViewController: UIViewController {
         super.didReceiveMemoryWarning()
         // Dispose of any resources that can be recreated.
     }
-
 }
-

+ 6 - 8
Example/Podfile.lock

@@ -15,7 +15,6 @@ PODS:
     - BFCommonKit/BFProtocols (= 1.5.2)
     - BFCommonKit/BFUtility (= 1.5.2)
     - BFCommonKit/BFVendors (= 1.5.2)
-    - BFCommonKit/BFVendorsUtils (= 1.5.2)
   - BFCommonKit/BFCategorys (1.5.2):
     - KingfisherWebP (= 1.3.0)
   - BFCommonKit/BFConfig (1.5.2):
@@ -37,15 +36,11 @@ PODS:
     - KingfisherWebP (= 1.3.0)
     - Toast-Swift (= 5.0.1)
   - BFCommonKit/BFVendors (1.5.2)
-  - BFCommonKit/BFVendorsUtils (1.5.2):
-    - BFCommonKit/BFEnums
-    - BFCommonKit/BFProtocols
-    - BFCommonKit/BFUtility
-    - RealmSwift (= 10.7.6)
   - BFMaterialKit (0.2.0):
     - BFUIKit
   - BFMediaKit (0.1.0):
     - BFCommonKit
+    - NuiSDK (= 2.5.14)
     - ObjectMapper (= 4.2.0)
     - RealmSwift (= 10.7.6)
   - BFNetRequestKit (1.0.1):
@@ -127,6 +122,7 @@ PODS:
   - LMJHorizontalScrollText (2.0.2)
   - MGSwipeTableCell (1.6.11)
   - MJRefresh (3.7.2)
+  - NuiSDK (2.5.14)
   - ObjectMapper (4.2.0)
   - Realm (10.7.6):
     - Realm/Headers (= 10.7.6)
@@ -154,6 +150,7 @@ SPEC REPOS:
     - AliyunOSSiOS
     - Bugly
     - LMJHorizontalScrollText
+    - NuiSDK
     - ObjectMapper
     - TXLiteAVSDK_Player
     - WechatOpenSDK-Swift
@@ -194,9 +191,9 @@ SPEC CHECKSUMS:
   Alamofire: f3b09a368f1582ab751b3fff5460276e0d2cf5c9
   AliyunOSSiOS: b8f1dfc229cd9abf68c8ee0cb245c2d66e00dd96
   BFAnalyzeKit: 457ecf2fcb09cb83417e2adea50f98c60a50ddec
-  BFCommonKit: a16175825b1aec5fcce898ec7beea0927bd06840
+  BFCommonKit: 86a8c8818c9430b01ee654ba60eb5cb8b863c0e6
   BFMaterialKit: 0a15786e2a55587f1b2b4b74c0bff5321ebf3630
-  BFMediaKit: 84a6f93a937e09a1b5b8ef56759a24d7c293b09e
+  BFMediaKit: 9e2d138ae02e7d7f15425561de527a5bd470040b
   BFNetRequestKit: 1d074023eafe7c272fab4ed3a608e685902235d0
   BFStuckPointKit: 833444e54fdd30812b452b650a905eafcfe90aa0
   BFUIKit: f209190fb92c8f9050554ac5950a2e4852e8a481
@@ -210,6 +207,7 @@ SPEC CHECKSUMS:
   LMJHorizontalScrollText: ebc9b908db297f603c5b98c9b4e5f4582f5a14b8
   MGSwipeTableCell: b804e4e450dee439c42250be90bd50458bf67fce
   MJRefresh: 30997d30b347c8e9508a4db11e3a690da0c9b85a
+  NuiSDK: 96e2a2acc66b6404bc794f2c4702ce0278edcd7c
   ObjectMapper: 1eb41f610210777375fa806bf161dc39fb832b81
   Realm: ed860452717c8db8f4bf832b6807f7f2ce708839
   RealmSwift: e31c4ddbcc42ac879313d656b86f9ca539f6f4f4

+ 5 - 7
Example/Tests/Tests.swift

@@ -1,28 +1,26 @@
-import XCTest
 import BFStuckPointKit
+import XCTest
 
 class Tests: XCTestCase {
-    
     override func setUp() {
         super.setUp()
         // Put setup code here. This method is called before the invocation of each test method in the class.
     }
-    
+
     override func tearDown() {
         // Put teardown code here. This method is called after the invocation of each test method in the class.
         super.tearDown()
     }
-    
+
     func testExample() {
         // This is an example of a functional test case.
         XCTAssert(true, "Pass")
     }
-    
+
     func testPerformanceExample() {
         // This is an example of a performance test case.
-        self.measure() {
+        measure {
             // Put the code you want to measure the time of here.
         }
     }
-    
 }

+ 67 - 0
rules.swiftformat

@@ -0,0 +1,67 @@
+--allman false
+--assetliterals visual-width
+--beforemarks 
+--binarygrouping 4,8
+--categorymark "MARK: %c"
+--classthreshold 0
+--closingparen balanced
+--commas always
+--conflictmarkers reject
+--decimalgrouping 3,6
+--elseposition same-line
+--enumthreshold 0
+--exponentcase lowercase
+--exponentgrouping disabled
+--extensionacl on-extension
+--extensionlength 0
+--extensionmark "MARK: - %t + %c"
+--fractiongrouping disabled
+--fragment false
+--funcattributes preserve
+--groupedextension "MARK: %c"
+--guardelse auto
+--header ignore
+--hexgrouping 4,8
+--hexliteralcase uppercase
+--ifdef indent
+--importgrouping alphabetized
+--indent 4
+--indentcase false
+--lifecycle 
+--linebreaks lf
+--markextensions always
+--marktypes always
+--maxwidth none
+--modifierorder 
+--nevertrailing 
+--nospaceoperators 
+--nowrapoperators 
+--octalgrouping 4,8
+--operatorfunc spaced
+--organizetypes class,enum,struct
+--patternlet hoist
+--ranges spaced
+--redundanttype inferred
+--self remove
+--selfrequired 
+--semicolons inline
+--shortoptionals always
+--smarttabs enabled
+--stripunusedargs always
+--structthreshold 0
+--swiftversion 4.0
+--tabwidth unspecified
+--trailingclosures 
+--trimwhitespace always
+--typeattributes preserve
+--typemark "MARK: - %t"
+--varattributes preserve
+--voidtype void
+--wraparguments preserve
+--wrapcollections preserve
+--wrapconditions preserve
+--wrapparameters preserve
+--wrapreturntype preserve
+--xcodeindentation disabled
+--yodaswap always
+--disable initCoderUnavailable,redundantType