Browse Source

Merge branch 'master' of https://git.yishihui.com/iOS/BFFramework
合并代码

jsonwang 3 năm trước cách đây
mục cha
commit
e624c9f4a7

+ 1 - 1
BFFramework/Classes/Base/ViewModel/PQBaseViewModel.swift

@@ -395,7 +395,7 @@ public class PQBaseViewModel: NSObject {
             if response != nil, !(response is NSNull) {
  
                 let responseDic = response as! [String: Any]
-                BFLog(message: "推荐的标题为\(responseDic["rhythmVideoTitles"])")
+                BFLog(message: "推荐的标题为\(String(describing: responseDic["rhythmVideoTitles"]))")
                 completeHander(responseDic["rhythmVideoTitles"] as? Array<String>)
             } else {
                 completeHander(nil)

+ 1 - 1
BFFramework/Classes/PModels/editDarftModels/PQEditBaseModel.swift

@@ -23,7 +23,7 @@ public let timeTransform = TransformOf<Float64, Float64>(fromJSON: { (value: Flo
 
 // 自定义音量转换协议,服务器单位0.0-1.0,我们使用 0-100
 public let volumeGainTransform = TransformOf<Float64, Float64>(fromJSON: { (value: Float64?) -> Float64? in
-    BFLog(message: "value is \(value)")
+    BFLog(message: "value is \(String(describing: value))")
     return (value ?? 0.0) * 100.0
 }, toJSON: { (value: Float64?) -> Float64? in
     if let value = value {

+ 1 - 1
BFFramework/Classes/PQGPUImage/akfilters/PQGPUImageFilterGroup.swift

@@ -47,7 +47,7 @@ open class PQGPUImageFilterGroup: PQBaseFilter{
     override public func newFramebufferAvailable(_ framebuffer: Framebuffer, fromSourceIndex: UInt) {
         super.newFramebufferAvailable(framebuffer, fromSourceIndex: fromSourceIndex)
 
-        let currTime = CMTimeGetSeconds(CMTime(value: framebuffer.timingStyle.timestamp!.value, timescale: framebuffer.timingStyle.timestamp!.timescale))
+//        let currTime = CMTimeGetSeconds(CMTime(value: framebuffer.timingStyle.timestamp!.value, timescale: framebuffer.timingStyle.timestamp!.timescale))
         
 //        var showFilter = findShowStikcer(currTime: currTime)
 //        if(showFilter){

+ 3 - 3
BFFramework/Classes/PQGPUImage/akfilters/PQGPUImageTools.swift

@@ -55,7 +55,7 @@ open class PQGPUImageTools: NSObject {
         let heightOfImage = GLint(image.height)
 
         let smoothlyScaleOutput: Bool = true
-        let orientation: ImageOrientation = .portrait
+//        let orientation: ImageOrientation = .portrait
         var textureID: GLuint = 0
         autoreleasepool {
             // If passed an empty image reference, CGContextDrawImage will fail in future versions of the SDK.
@@ -319,8 +319,8 @@ open class PQGPUImageTools: NSObject {
                     oldTextureCoordinates[2], oldTextureCoordinates[3], // 2
                     oldTextureCoordinates[4], oldTextureCoordinates[5], // 3
                     oldTextureCoordinates[0], oldTextureCoordinates[1]] // 1
-        default:
-            return oldTextureCoordinates
+//        default:
+//            return oldTextureCoordinates
         }
     }
 

+ 1 - 1
BFFramework/Classes/PQGPUImage/akfilters/PQMovieFilter.swift

@@ -113,7 +113,7 @@ class PQMovieFilter: PQBaseFilter {
     var framebufferIndex:Int = 0
 
     deinit {
-        FilterLog(message: "movie filter deinit")
+//        BFLog(1, message: "movie filter deinit")
         clearData()
     }
 

+ 1 - 1
BFFramework/Classes/PQGPUImage/akfilters/PQMovieInput.swift

@@ -517,7 +517,7 @@ public class PQMovieInput: ImageSource {
         autoreleasepool {
             guard let sampleBuffer = audioTrackOutput.copyNextSampleBuffer(),CMSampleBufferIsValid(sampleBuffer) else {
                 if(assetReader.status == .completed){
-                    FilterLog(message: "提前结束的了!!!!\(assetReader.error)")
+                    FilterLog(message: "提前结束的了!!!!\(String(describing: assetReader.error))")
                 }
                 if let movieOutput = synchronizedMovieOutput {
                     FilterLog(message: "this is runing assetWriterAudioInput  markAsFinished \(String(describing: assetReader.error)) \(assetReader)")

+ 24 - 8
BFFramework/Classes/Stuckpoint/Controller/PQStuckPointEditerController.swift

@@ -243,8 +243,11 @@ class PQStuckPointEditerController: PQBaseViewController {
         musicEditBGView.isHidden = true
         musicEditBGView.musicSearchBtn.addTarget(self, action: #selector(musicSearchBtnClick(sender:)), for: .touchUpInside)
 
-        musicEditBGView.didSelectItemHandle = { [weak self] _ in
+        musicEditBGView.didSelectItemHandle = { [weak self] status in
             self?.playerView.pause()
+            if status == .isSelected{
+                self?.playerView.RenderViewOnclick()
+            }
         }
         musicEditBGView.btnClickHandle = { [weak self] _, bgmData in
             // 使用音乐
@@ -973,7 +976,14 @@ class PQStuckPointEditerController: PQBaseViewController {
 
         // 更新裁剪时间条的的ui数据
         stuckPointCuttingView.videoDuration = max(CGFloat(finallyUserAudioTime), CGFloat(finallyStuckPoints.last!))
-        stuckPointCuttingView.updateEndTime(startTime: CGFloat(CMTimeGetSeconds(playeTimeRange.start)), endTime: CGFloat(CMTimeGetSeconds(playeTimeRange.end)))
+        let counn = (stuckPointMusicData?.rhythmSdata[0].pointTimes.count)! - 2
+        let suggestRhythmStartTime = CGFloat(stuckPointMusicData?.suggestRhythmStartTime ?? 0)
+        let suggestRhythmEndTime = max(suggestRhythmStartTime, CGFloat(stuckPointMusicData?.rhythmSdata[0].pointTimes[max(counn, 0)] ?? 0)/CGFloat(BASE_FILTER_TIMESCALE))
+        stuckPointCuttingView.updateEndTime(
+            startTime: CGFloat(CMTimeGetSeconds(playeTimeRange.start)),
+            endTime: CGFloat(CMTimeGetSeconds(playeTimeRange.end)),
+            suggestRhythmStartTime: suggestRhythmStartTime,
+            suggestRhythmEndTime: suggestRhythmEndTime)
 
         // 2,创建滤镜
         DispatchQueue.global().async {
@@ -1014,13 +1024,18 @@ class PQStuckPointEditerController: PQBaseViewController {
                 let end3: TimeInterval = Date().timeIntervalSince1970
 
                 self.playerView.play(pauseFirstFrame: false, playeTimeRange: CMTimeRange(start: self.playeTimeRange.start, end: self.playeTimeRange.end))
-
+                self.stuckPointCuttingView.updateProgress(progress: 0)
+                
                 let end4: TimeInterval = Date().timeIntervalSince1970
                 BFLog(message: " playerView.play tiskskskskme  \(end4 - end3)")
 
                 // 6,进度回调
-                self.playerView.progress = { [weak self] currentTime, tatolTime, _ in
-                    
+                self.playerView.progress = { [weak self] currentTime, tatolTime, percent in
+                    if percent == 1 {
+                        self?.stuckPointCuttingView.resetDefaultsColor(clearData: false)
+
+                        return
+                    }
                     if(CMTimeGetSeconds(self?.playeTimeRange.duration ?? .zero) <= 0.0){
                         BFLog(message: "时长错误!!!!")
                         return
@@ -1129,7 +1144,7 @@ extension PQStuckPointEditerController {
             if section.sectionType == "normal" {
                 // 第一种情况:全是图片,三种模式都进行图片回环播放
                 if section.sectionTimeline!.visionTrack!.getEnableVisionTrackMaterials(type: "video").count == 0, section.sectionTimeline!.visionTrack!.getEnableVisionTrackMaterials(type: "image").count > 0 {
-                    for (index, point) in finallyStuckPoints.enumerated() {
+                    for (index, _) in finallyStuckPoints.enumerated() {
                         let sticker: PQEditVisionTrackMaterialsModel = section.sectionTimeline!.visionTrack!.getEnableVisionTrackMaterials()[index % section.sectionTimeline!.visionTrack!.getEnableVisionTrackMaterials().count]
                         BFLog(message: "stickerlocationPath sticker : \(sticker.locationPath)")
 //
@@ -1875,8 +1890,9 @@ extension PQStuckPointEditerController {
                 editModelClick(sender: speedStuckBtn, reportLog: false)
 
             } else {
-                // 默认进入卡点模式
-                editModelClick(sender: jumpPointBtn, reportLog: false)
+//                // 默认进入卡点模式
+//                editModelClick(sender: jumpPointBtn, reportLog: false)
+                editModelClick(sender: lastEditModelBtn ?? jumpPointBtn, reportLog: false)
             }
         }
     }

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

@@ -1446,14 +1446,13 @@ extension PQStuckPointPublicController {
             let endpoint: String = "\(response?["endPoint"] ?? "")"
             let bucketName: String = "\(response?["bucketName"] ?? "")"
             let objectKey: String = "\(response?["objectKey"] ?? "")"
-            PQAliOssUtil.shared
+            _ = PQAliOssUtil.shared
                 .startClient(
                     accessKeyId: accessKeyId,
                     secretKeyId: secretKeyId,
                     securityToken: securityToken,
                     endpoint: endpoint
                 )
-
                 .uploadObjectAsync(bucketName: bucketName, objectKey: objectKey, data: data!, fileExtensions: "png", imageUploadBlock: { _, code, ossObjectKey, _ in
                     if code == 1 && ossObjectKey == objectKey && ossObjectKey.count > 0 {
                         // add by ak 这里会在服务器生成分享使用的图片到1-2S 时间

+ 1 - 1
BFFramework/Classes/Stuckpoint/Model/PQVoiceModel.swift

@@ -13,7 +13,7 @@ public enum voiceStatue: Int {
     case isPlaying = 1 // 播放中
     case isNormal = 2 // 正常状态
     case isSelected = 3 // 选中状态,有红框 字红色 ,别的都没有
-    case isPause = 4 // 播放中
+    case isPause = 4 // 播放状态暂停
 }
 
 open class PQVoiceModel: NSObject, NSCopying {

+ 19 - 10
BFFramework/Classes/Stuckpoint/View/PQSelecteMusicView.swift

@@ -16,16 +16,18 @@ class PQSelecteMusicView: UIView {
     // 当前页码
     var pageNum: Int = 0
     
-    // 当前播放的音乐
+    // 当前视频使用的音乐数据
+    var currentPlayingInVideoData : PQVoiceModel?
+    // 当前试听播放的音乐数据
     var currentPlayData: PQVoiceModel?
-    // 当前播放的视频
+    // 当前播放的
     var playerItem: AVPlayerItem?
     
     // 按钮点击的回调
     var btnClickHandle: ((_ sender: UIButton, _ bgmData: Any?) -> Void)?
     
     // 点击播放一个歌,回调
-    var didSelectItemHandle:((_ isPlaying:Bool) -> Void)?
+    var didSelectItemHandle:((_ statue:voiceStatue) -> Void)?
     // 当前选择的分类
     var currentSelectTag:PQStuckPointMusicTagsModel?
     
@@ -169,7 +171,7 @@ class PQSelecteMusicView: UIView {
             musicDatas.remove(at: musicIndex!)
             musicDatas.insert(selectMusicData, at: 0)
         }
-
+        self.currentPlayingInVideoData = model
         selectMusicCollection.reloadData()
        
         //划动到选择的音乐位置
@@ -246,6 +248,7 @@ class PQSelecteMusicView: UIView {
                     //第一次进入插入的歌曲,插入后置空 如果 不存在只插入一次 防止重
                     if(self?.firstInsertVoiceModel != nil){
                         self?.insertSearchMusic(model: (self?.firstInsertVoiceModel)!)
+                        self?.currentPlayingInVideoData = self?.firstInsertVoiceModel
                         self?.firstInsertVoiceModel = nil
                     }
                     
@@ -346,7 +349,7 @@ extension PQSelecteMusicView: UICollectionViewDelegate, UICollectionViewDataSour
                 
                 //暂停播放音乐
                 self?.pausePlayer()
-                
+                self?.currentPlayingInVideoData = bgmData as? PQVoiceModel
                 PQEventTrackViewModel.baseReportUpload(businessType: .bt_buttonClick, objectType: .ot_shanyinApp_musicVideoPreview_musicSelect, pageSource: .sp_shanyinApp_main, extParams: ["musicName":(bgmData as? PQVoiceModel)?.musicName ?? "" ,"musicId":(bgmData as? PQVoiceModel)?.musicId ?? ""], remindmsg: "")
                 
                 if self?.btnClickHandle != nil {
@@ -370,6 +373,8 @@ extension PQSelecteMusicView: UICollectionViewDelegate, UICollectionViewDataSour
             }
             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
@@ -392,19 +397,23 @@ extension PQSelecteMusicView: UICollectionViewDelegate, UICollectionViewDataSour
         //歌曲列表
         if (collectionView == selectMusicCollection ){
             musicDatas.forEach { item in
-
                 item.voiceStatue = .isNormal
             }
             let music = musicDatas[indexPath.item]
             music.voiceStatue = .isSelected
-            playStuckPointMusic(itemData:music)
+            if music.musicId != currentPlayingInVideoData?.musicId{
+                playStuckPointMusic(itemData:music)
+            }
             selectMusicCollection.reloadData()
-            
             PQEventTrackViewModel.baseReportUpload(businessType: .bt_buttonClick, objectType: .ot_shanyinApp_musicVideoPreview_musicCategorySelect, pageSource: .sp_shanyinApp_main, extParams: ["categoryName":currentSelectTag?.tagName ?? "","categoryId":currentSelectTag?.tagId ?? ""], remindmsg: "")
 
-            if didSelectItemHandle != nil {
-                didSelectItemHandle!(music.voiceStatue == .isPlaying)
+            if music.musicId != currentPlayingInVideoData?.musicId{
+//                BFLog(1, message: "预览:\(music.musicName) 当前:\(currentPlayingInVideoData?.musicName)")
+                if didSelectItemHandle != nil {
+                    didSelectItemHandle!(music.voiceStatue)
+                }
             }
+            
          
         }else{
     

+ 4 - 0
BFFramework/Classes/Stuckpoint/View/PQSelectedMaterialListView.swift

@@ -40,6 +40,10 @@ class PQSelectedMaterialListView: UIView {
     required init?(coder _: NSCoder) {
         fatalError("init(coder:) has not been implemented")
     }
+    
+    deinit {
+        BFLog(1, message: "meterialview release")
+    }
 
     /// 添加新素材
     /// - Parameter itemData: <#itemData description#>

+ 39 - 16
BFFramework/Classes/Stuckpoint/View/PQStuckPointCuttingView.swift

@@ -61,6 +61,7 @@ class PQStuckPointCuttingView: UIView {
 
     // 保存已经绘制的竖线用于变色使用
     var lineLayerArray: Array = Array<CAShapeLayer>.init()
+    var lastDrawedLineIndex : Int = 0
 
     // 裁剪区的相素大小
     var cropViewWidth: CGFloat = adapterWidth(width: 250)
@@ -85,6 +86,7 @@ class PQStuckPointCuttingView: UIView {
     var isUserDrag:Bool = false
     // 推荐卡点起始时间
     var suggestRhythmStartTime:CGFloat = 0.0
+    var suggestRhythmEndTime:CGFloat = 0.0
     
     /// 滚动视图
     lazy var scrollView: UIScrollView = {
@@ -165,13 +167,20 @@ class PQStuckPointCuttingView: UIView {
     /// 更新卡点值
     /// - Parameter endTime: endTime description
     /// - Returns: <#description#>
-    func updateEndTime(startTime: CGFloat, endTime: CGFloat) {
+    func updateEndTime(startTime: CGFloat, endTime: CGFloat,
+                       suggestRhythmStartTime: CGFloat, suggestRhythmEndTime: CGFloat) {
+        
+//        videoDuration = duration
+        self.suggestRhythmStartTime = suggestRhythmStartTime
+        self.suggestRhythmEndTime = suggestRhythmEndTime
+        startLineX = 0
+        
         stuckPointStartTime = startTime
         stuckPointEndTime = endTime
         
         tatalTimeLabel.text = "\(Float64(stuckPointEndTime - stuckPointStartTime).formatDurationToHMS())"
   
-        BFLog(1, message: "推荐开始\(stuckPointStartTime) 结束\(stuckPointEndTime) 时长为:\(stuckPointEndTime - stuckPointStartTime)  音乐总时长为:\(videoDuration)")
+        BFLog(1, message: "播放开始:\(stuckPointStartTime) 结束:\(stuckPointEndTime) 时长为:\(stuckPointEndTime - stuckPointStartTime); 音乐总时长为:\(videoDuration);推荐卡点开始:\(suggestRhythmStartTime) 结束:\(suggestRhythmEndTime)")
         backgroundColor = PQBFConfig.shared.styleBackGroundColor
         addSubview(scrollView)
 
@@ -181,6 +190,8 @@ class PQStuckPointCuttingView: UIView {
         videoCropView.addSubview(tatalTimeLabel)
         addData()
         videoCropView.frame = CGRect(x: (cScreenWidth - cropViewWidth) / 2, y: 0, width: cropViewWidth, height: 80)
+        leftMaskView.frame = CGRect(x:0, y: 0, width: (cScreenWidth - cropViewWidth) / 2 - 2, height: 80)
+        rightMaskView.frame = CGRect(x:videoCropView.frame.maxX + 2, y: 0, width: (cScreenWidth - cropViewWidth) / 2 - 2, height: 80)
 
         tatalTimeLabel.snp.remakeConstraints { make in
             make.width.equalTo(40)
@@ -196,11 +207,19 @@ class PQStuckPointCuttingView: UIView {
         // 1,选择区内的线个数 ,划动区域后 个数会变???
         wavSelectCount = Int(ceil((cropViewWidth - frequencyWidth) / (frequencyWidth + frequencyMargin)) + 1)
         
-        cropViewWidth = CGFloat(wavSelectCount - 1) * (frequencyWidth + frequencyMargin) + frequencyWidth
+        cropViewWidth = CGFloat(wavSelectCount) * (frequencyWidth + frequencyMargin) + frequencyWidth
+        margin = (cScreenWidth - cropViewWidth) / 2.0
+
      
         // 2竖线一个间隔代表多少 S 是动态的
-        oneMarginTime = (stuckPointEndTime - stuckPointStartTime) / CGFloat(wavSelectCount - 1)
+        oneMarginTime = (stuckPointEndTime - stuckPointStartTime) / CGFloat(wavSelectCount)
         
+        // 如果视频结束时间点大于歌曲有效结束点,则拼接推荐的时间段直到满足视频播放
+        var videoDurationTemp = suggestRhythmEndTime
+        while stuckPointEndTime > videoDurationTemp {
+            videoDurationTemp  += (suggestRhythmEndTime - suggestRhythmStartTime)
+        }
+        videoDuration = videoDurationTemp
         // 3,一共绘制的竖线个数
         wavTotalCount = Int(ceil(videoDuration / oneMarginTime) + 1)
 
@@ -214,7 +233,7 @@ class PQStuckPointCuttingView: UIView {
         }
         scrollView.contentSize = CGSize(width: contentWidth, height: scrollView.frame.height)
         
-        BFLog(1, message: "框内个数:\(wavSelectCount), 总线条数:\(wavTotalCount), 框宽:\(cropViewWidth)")
+        BFLog(1, message: "框内个数:\(wavSelectCount), 总线条数:\(wavTotalCount), 框宽:\(cropViewWidth), 最终音乐时长:\(videoDuration)")
         scrollView.subviews.forEach { lable in
             if lable is UILabel && lable.tag != 66 {
                 lable.removeFromSuperview()
@@ -239,7 +258,6 @@ class PQStuckPointCuttingView: UIView {
             // 2,滚动到推荐位置
             if(!isUserDrag){
                 scrollView.contentOffset = CGPoint(x: startLineX - margin, y: 0)
-                
             }
         
             scrollView.addSubview(rateView)
@@ -273,24 +291,28 @@ class PQStuckPointCuttingView: UIView {
     /// progress <#progress description#>
     func updateProgress(progress: CGFloat) {
         
-
         if(progress <= 0 || lineLayerArray.count == 0 || progress.isNaN){
             BFLog(message: "progress is error ")
             return
         }
+        
         let startIndex = scrollView.contentOffset.x / (frequencyWidth + frequencyMargin)
-        let selectIndex = Int(floor(startIndex + progress * CGFloat(wavSelectCount)))
-        if(selectIndex < lineLayerArray.count){
-            let drawLayer:CAShapeLayer = lineLayerArray[selectIndex]
-            BFLog(message: "progress is \(progress) i \(selectIndex) 命中的位置:\(CGFloat(selectIndex) * oneMarginTime)")
+        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: PQBFConfig.shared.styleColor.rawValue).cgColor{
+                BFLog(1, message: "progress is \(progress) i \(lastDrawedLineIndex) 命中的位置:\(CGFloat(lastDrawedLineIndex) * oneMarginTime)")
                 drawLayer.strokeColor = UIColor.hexColor(hexadecimal: PQBFConfig.shared.styleColor.rawValue).cgColor
                 drawLayer.setNeedsDisplay()
+                drawLayer.layoutIfNeeded()
             }
+            lastDrawedLineIndex += 1
+
         }
 
         
-        if(progress >= 0.99){
+        if(progress >= 0.999){
             BFLog(message: "播放完成 重新更新 UI ")
             resetDefaultsColor(clearData: false)
         }
@@ -299,6 +321,7 @@ class PQStuckPointCuttingView: UIView {
 
     // 竖线恢复到原有色值
     func resetDefaultsColor(clearData:Bool = true) {
+        lastDrawedLineIndex = 0
         for layer in lineLayerArray {
             layer.strokeColor = UIColor.hexColor(hexadecimal: "#999999").cgColor
             layer.setNeedsDisplay()
@@ -318,7 +341,7 @@ class PQStuckPointCuttingView: UIView {
     }
 
     /// 生成波纹
-    /// - Parameter waveArr: <#waveArr description#>
+    /// - Parameter waveArr: <#waveArr description#> // warning 有崩溃 _buffer    _ArrayBuffer<CoreGraphics.CGFloat>    wavearr为CoreGraph.CGFloat数组
     /// - Returns: <#description#>
     func createWave(waveArr: [CGFloat]) {
         for (i, power) in waveArr.enumerated() {
@@ -345,9 +368,9 @@ class PQStuckPointCuttingView: UIView {
             lineLayer.path = linePath.cgPath
             lineLayer.fillColor = UIColor.black.cgColor
 
-            // 推荐的开始起点是虚线
-            BFLog(1, message: "suggestRhythmStartTime is \(suggestRhythmStartTime)")
-            if oneMarginTime * CGFloat(i) >= suggestRhythmStartTime && !isDrawLine {
+            // 推荐的开始起点是虚线 减0.0001因为精度问题
+//            BFLog(1, message: "suggestRhythmStartTime is \(suggestRhythmStartTime)")
+            if oneMarginTime * CGFloat(i) >= (suggestRhythmStartTime-0.0001) && !isDrawLine {
                 isDrawLine = true
                 linePath.move(to: CGPoint(x: originX, y: -10))
                 // 终点

+ 7 - 9
BFFramework/Classes/Stuckpoint/ViewModel/PQGPUImagePlayerView.swift

@@ -361,7 +361,6 @@ public class PQGPUImagePlayerView: UIView {
         var composition: AVMutableComposition?
 
         let asset = AVURLAsset(url: url, options: nil)
-//        FilterLog(message: "播放器初始化的音频时长\(asset.duration.seconds)  url is \(url),最终使用时长\(originMusicDuration),裁剪范围\(CMTimeGetSeconds(clipAudioRange.start)) 到 \(CMTimeGetSeconds(clipAudioRange.end))")
         BFLog(1, message:  "播放器初始化的音频时长\(asset.duration.seconds)  url is \(url),最终使用时长\(originMusicDuration),裁剪范围\(CMTimeGetSeconds(clipAudioRange.start)) 到 \(CMTimeGetSeconds(clipAudioRange.end))")
 
         self.asset = asset
@@ -455,6 +454,7 @@ public class PQGPUImagePlayerView: UIView {
                 strongSelf.status = .stop
                 strongSelf.finishedClosure?()
                 strongSelf.showPlayBtn(isHidden: false)
+                strongSelf.progress!(0,0,1)
             }
         }
         speaker = SpeakerOutput()
@@ -549,7 +549,7 @@ public class PQGPUImagePlayerView: UIView {
     /// 按时间从缓存中取出要显示的filter
     /// - Parameter currTime: 当前播放时间
     func changeFilter(currTime: Float64) {
-        let  starts:CFTimeInterval = CFAbsoluteTimeGetCurrent()
+//        let  starts:CFTimeInterval = CFAbsoluteTimeGetCurrent()
         BFLog(message: " 要查找的 currTime is \(currTime)")
         //1,删除已经显示过的 filter
         self.cacheFilters.removeAll(where: {(filter) -> Bool in
@@ -564,17 +564,15 @@ public class PQGPUImagePlayerView: UIView {
 
         })
   
-        if(showIndex == nil){
-          
+        guard let showIndex = showIndex else {
             FilterLog(message: "缓存没有查找到?出现数据错误!!!!")
-            for (index,bsFilter )in cacheFilters.enumerated() {
-                BFLog(1, message: "22222缓存操作   没要查找到要查找的显示是为:\(currTime) 缓存数据timeline in :\(bsFilter.stickerInfo?.timelineIn ?? 0.0)) timelineOut:\(bsFilter.stickerInfo?.timelineOut ?? 0.0) 缓存数 \(cacheFilters.count) index: \(index)")
-            }
-            
+//            for (index,bsFilter )in cacheFilters.enumerated() {
+//                BFLog(1, message: "22222缓存操作   没要查找到要查找的显示是为:\(currTime) 缓存数据timeline in :\(bsFilter.stickerInfo?.timelineIn ?? 0.0)) timelineOut:\(bsFilter.stickerInfo?.timelineOut ?? 0.0) 缓存数 \(cacheFilters.count) index: \(index)")
+//            }
             return
         }
     
-        let showFilter: PQBaseFilter = cacheFilters[showIndex ?? 0]
+        let showFilter: PQBaseFilter = cacheFilters[showIndex]
         
         FilterLog(message: "缓存操作   查找到命中的显示是为:\(currTime) 缓存数据timeline in :\(showFilter.stickerInfo?.timelineIn ?? 0.0)) timelineOut:\(showFilter.stickerInfo?.timelineOut ?? 0.0) in:\(showFilter.stickerInfo?.model_in ?? 0.0) out:\(showFilter.stickerInfo?.out ?? 0.0) 缓存数 \(cacheFilters.count) index: \(String(describing: showIndex))")
         

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

@@ -646,14 +646,14 @@ extension PQPlayerViewModel {
         let originaDuration = CMTimeGetSeconds(clipAudioRange.duration)
         BFLog(message: "处理主音频 原始时长startTime = \(originaDuration) 要显示时长totalDuration = \(totalDuration)")
         //整倍数
-        var  count = Int(totalDuration) / Int(originaDuration)
+        let  count = Int(totalDuration) / Int(originaDuration)
 //        count = count + 1
         //有余数多 clip 一整段
         let row = totalDuration - Double(count) * originaDuration
         //已经拼接的总时长
         var clipTotalDuration:Float = 0.0
         if count > 0 {
-            for index in 0 ... count {
+            for index in 0 ..< count {
                 BFLog(message: "this is running running")
                 //第一段是用户选择的开始时间 到倒数第二个卡点, 其它段都是从推荐卡点到倒数第二个卡点
                 var startTime = CMTime.zero
@@ -661,7 +661,7 @@ extension PQPlayerViewModel {
        
                 if(index == 0){
                     startTime = mStartTime
-                    trackTimeRange =  CMTimeRange(start: startTime, end: CMTime(value: CMTimeValue((CMTimeGetSeconds(clipAudioRange.end) - CMTimeGetSeconds(startTime)) * Double(playerTimescaleInt)), timescale: playerTimescaleInt))
+                    trackTimeRange =  CMTimeRange(start: startTime, end: CMTime(value: CMTimeValue(CMTimeGetSeconds(clipAudioRange.end)), timescale: playerTimescaleInt))
                     clipTotalDuration = clipTotalDuration + Float(CMTimeGetSeconds(trackTimeRange.duration))
                 }else{
                     // (CMTimeGetSeconds(clipAudioRange.end) - CMTimeGetSeconds(mStartTime))为用户选择的第一段时长
@@ -670,7 +670,7 @@ extension PQPlayerViewModel {
                     
                     clipTotalDuration = clipTotalDuration + Float(CMTimeGetSeconds(trackTimeRange.duration))
                 }
-                BFLog(message: "原音频时长短:count = \(count),startTime = \(startTime),trackTimeRange = \(trackTimeRange)")
+                BFLog(1, message: "原音频时长短:count = \(count),startTime = \(startTime),trackTimeRange = \(trackTimeRange)")
                 let parameters = mixAudioTrack(audioAsset: originAsset, startTime: startTime, trackTimeRange: trackTimeRange, volume: volume, composition: composition)
                 if parameters != nil {
                     tempParameters.append(parameters!)
@@ -684,7 +684,7 @@ extension PQPlayerViewModel {
             let startTime = CMTime(value: CMTimeValue(clipTotalDuration * Float(playerTimescaleInt)), timescale: playerTimescaleInt)
             
             let trackTimeRange = CMTimeRange(start: startTime, end: CMTime(value: CMTimeValue((CMTimeGetSeconds(startTime) + row) * Double(playerTimescaleInt)), timescale: playerTimescaleInt))
-            BFLog(message: "最后一小段音乐时长短:count = \(count),startTime = \(startTime),trackTimeRange = \(trackTimeRange)")
+            BFLog(1, message: "最后一小段音乐时长短:count = \(count),startTime = \(startTime),trackTimeRange = \(trackTimeRange)")
             let parameters = mixAudioTrack(audioAsset: originAsset, startTime: startTime, trackTimeRange: trackTimeRange, volume: volume, composition: composition)
             if parameters != nil {
                 tempParameters.append(parameters!)

+ 10 - 10
BFFramework/Classes/Utils/PQCommonMethodUtil.swift

@@ -136,15 +136,8 @@ public func kf_imageCacheImage(originUrl: String, completeHandle: @escaping (_ i
 public func BFLog<T>( _ type : Int = 9, _ file:String = #file, _ line:Int = #line, message: T) {
 #if DEBUG
     if type == 0 {
-        let logger = NXLogger.shared
-        
-        logger.level = .info
-        logger.ouput = .deviceConsoleAndFile
-        
-        logger.d(message as? String ?? "")
-        
-        BuglyLog.level(.warn, logs: message as? String)
-    }else if type == 1 {
+        print(message)
+    }else if type == 3 {
         let file = (file as NSString).lastPathComponent;
         let dateFmt = DateFormatter()
         dateFmt.dateFormat = "HH:mm:ss:SSSS"
@@ -621,7 +614,14 @@ public func sendLocalNotification(title: String, body: String) {
 /// 打开应用设置
 public func openAppSetting() {
     if UIApplication.shared.canOpenURL(URL(string: UIApplication.openSettingsURLString)!) {
-        UIApplication.shared.openURL(URL(string: UIApplication.openSettingsURLString)!)
+        guard let settingsUrl = URL(string: UIApplication.openSettingsURLString) else {
+            return
+        }
+        if UIApplication.shared.canOpenURL(settingsUrl) {
+            UIApplication.shared.open(settingsUrl, completionHandler: { (success) in
+                BFLog(message: "Settings opened: \(success)") // Prints true
+            })
+        }
     }
 }