|  | @@ -20,7 +20,8 @@ public class BFRecordScreenController: BFBaseViewController {
 | 
	
		
			
				|  |  |      public var closeActionHandle:(()->Void)?
 | 
	
		
			
				|  |  |      
 | 
	
		
			
				|  |  |      // MARK: - 录制参数
 | 
	
		
			
				|  |  | -    public var asset:PHAsset?
 | 
	
		
			
				|  |  | +    public var assets = [PHAsset]()
 | 
	
		
			
				|  |  | +    public var currAsset:PHAsset?
 | 
	
		
			
				|  |  |  //    var shouldPlayRecordIndex:Int = -1          // 当前应该播放的录音资源序号
 | 
	
		
			
				|  |  |      var currentPlayRecordIndex:Int = -1         // >= 0 :当前正在播放的录音资源序号; -3: 刚录音完,不需要播放录音; -1:初始化阶段
 | 
	
		
			
				|  |  |      var isRecording = false {                   // 是否正在录音
 | 
	
	
		
			
				|  | @@ -41,7 +42,9 @@ public class BFRecordScreenController: BFBaseViewController {
 | 
	
		
			
				|  |  |      var currentAssetProgress : CMTime = .zero   // 当前素材播放的进度
 | 
	
		
			
				|  |  |      // 视频素材
 | 
	
		
			
				|  |  |      public var avasset:AVURLAsset?
 | 
	
		
			
				|  |  | +    
 | 
	
		
			
				|  |  |      public var recordList:[PQVoiceModel] = [PQVoiceModel]()
 | 
	
		
			
				|  |  | +    
 | 
	
		
			
				|  |  |      var assetPlayer:AVPlayer?       // 原视频音频播放器
 | 
	
		
			
				|  |  |      var isCompletePlay = true
 | 
	
		
			
				|  |  |      var hadPrepareToPlayRecord = false    // 录音播放器准备
 | 
	
	
		
			
				|  | @@ -138,12 +141,12 @@ public class BFRecordScreenController: BFBaseViewController {
 | 
	
		
			
				|  |  |          return btn
 | 
	
		
			
				|  |  |      }()
 | 
	
		
			
				|  |  |      
 | 
	
		
			
				|  |  | -    lazy var progessSildeBackV : UIView = {
 | 
	
		
			
				|  |  | -        let vv = UIView()
 | 
	
		
			
				|  |  | -        vv.backgroundColor = .orange // .clear
 | 
	
		
			
				|  |  | -        
 | 
	
		
			
				|  |  | -        return vv
 | 
	
		
			
				|  |  | -    }()
 | 
	
		
			
				|  |  | +//    lazy var progessSildeBackV : UIView = {
 | 
	
		
			
				|  |  | +//        let vv = UIView()
 | 
	
		
			
				|  |  | +//        vv.backgroundColor = .orange // .clear
 | 
	
		
			
				|  |  | +//
 | 
	
		
			
				|  |  | +//        return vv
 | 
	
		
			
				|  |  | +//    }()
 | 
	
		
			
				|  |  |      
 | 
	
		
			
				|  |  |      lazy var withDrawBtn:UIButton = {
 | 
	
		
			
				|  |  |          let btn = UIButton(type: .custom)
 | 
	
	
		
			
				|  | @@ -253,7 +256,7 @@ public class BFRecordScreenController: BFBaseViewController {
 | 
	
		
			
				|  |  |          bottomeView.addSubview(withDrawBtn)
 | 
	
		
			
				|  |  |          bottomeView.addSubview(changeVoiceBtn)
 | 
	
		
			
				|  |  |          bottomeView.addSubview(progressThumV)
 | 
	
		
			
				|  |  | -        progressThumV.addSubview(progessSildeBackV)
 | 
	
		
			
				|  |  | +//        progressThumV.addSubview(progessSildeBackV)
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          if checkStatus() {
 | 
	
		
			
				|  |  |              try? AVAudioSession.sharedInstance().setCategory(.playAndRecord, options: .defaultToSpeaker)
 | 
	
	
		
			
				|  | @@ -292,12 +295,12 @@ public class BFRecordScreenController: BFBaseViewController {
 | 
	
		
			
				|  |  |              make.top.equalTo(withDrawBtn).offset(6)
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          
 | 
	
		
			
				|  |  | -        progessSildeBackV.snp.makeConstraints { make in
 | 
	
		
			
				|  |  | -            make.left.equalToSuperview()
 | 
	
		
			
				|  |  | -            make.right.equalToSuperview()
 | 
	
		
			
				|  |  | -            make.bottom.equalToSuperview()
 | 
	
		
			
				|  |  | -            make.height.equalTo(8)
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | +//        progessSildeBackV.snp.makeConstraints { make in
 | 
	
		
			
				|  |  | +//            make.left.equalToSuperview()
 | 
	
		
			
				|  |  | +//            make.right.equalToSuperview()
 | 
	
		
			
				|  |  | +//            make.bottom.equalToSuperview()
 | 
	
		
			
				|  |  | +//            make.height.equalTo(8)
 | 
	
		
			
				|  |  | +//        }
 | 
	
		
			
				|  |  |          
 | 
	
		
			
				|  |  |          withDrawBtn.imageEdgeInsets = UIEdgeInsets(top: -withDrawBtn.imageView!.height, left: 0, bottom: 0, right: -withDrawBtn.titleLabel!.width);
 | 
	
		
			
				|  |  |          withDrawBtn.titleEdgeInsets = UIEdgeInsets(top: withDrawBtn.titleLabel!.height + 2, left: -withDrawBtn.imageView!.width, bottom: 0, right: 0);
 | 
	
	
		
			
				|  | @@ -393,6 +396,8 @@ public class BFRecordScreenController: BFBaseViewController {
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |      @objc func withdrawAction(){
 | 
	
		
			
				|  |  |          pause()
 | 
	
		
			
				|  |  | +        recordList.removeLast()
 | 
	
		
			
				|  |  | +        drawOrUpdateRecordProgessLable()
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |      
 | 
	
		
			
				|  |  |      @objc func changeVoiceAction(){
 | 
	
	
		
			
				|  | @@ -568,52 +573,53 @@ public class BFRecordScreenController: BFBaseViewController {
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |      
 | 
	
		
			
				|  |  |      func fetchVideo(){
 | 
	
		
			
				|  |  | -        if let asset = self.asset {
 | 
	
		
			
				|  |  | -            let options = PHVideoRequestOptions()
 | 
	
		
			
				|  |  | -            options.isNetworkAccessAllowed = true
 | 
	
		
			
				|  |  | -            options.deliveryMode = .automatic
 | 
	
		
			
				|  |  | -            
 | 
	
		
			
				|  |  | -            PHImageManager.default().requestPlayerItem(forVideo:asset, options: options, resultHandler: { [weak self] playerItem, info in
 | 
	
		
			
				|  |  | +        if self.assets.count > 0 {
 | 
	
		
			
				|  |  | +            for (index, asset) in self.assets.enumerated() {
 | 
	
		
			
				|  |  | +                let options = PHVideoRequestOptions()
 | 
	
		
			
				|  |  | +                options.isNetworkAccessAllowed = true
 | 
	
		
			
				|  |  | +                options.deliveryMode = .automatic
 | 
	
		
			
				|  |  | +                
 | 
	
		
			
				|  |  | +                PHImageManager.default().requestPlayerItem(forVideo:asset, options: options, resultHandler: { [weak self] playerItem, info in
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -                guard let item = playerItem else {
 | 
	
		
			
				|  |  | -                    cShowHUB(superView: nil, msg: "视频获取失败")
 | 
	
		
			
				|  |  | -                    return
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -                self?.setAudioPlay(item: item)
 | 
	
		
			
				|  |  | -                self?.setVideoPlay(item: item)
 | 
	
		
			
				|  |  | +                    guard let item = playerItem else {
 | 
	
		
			
				|  |  | +                        cShowHUB(superView: nil, msg: "视频获取失败")
 | 
	
		
			
				|  |  | +                        return
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                    if index == 0 {
 | 
	
		
			
				|  |  | +                        self?.setAudioPlay(item: item)
 | 
	
		
			
				|  |  | +                        self?.setVideoPlay(item: item)
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                })
 | 
	
		
			
				|  |  |                  
 | 
	
		
			
				|  |  | -            })
 | 
	
		
			
				|  |  | -            
 | 
	
		
			
				|  |  | -            let option = PHImageRequestOptions()
 | 
	
		
			
				|  |  | -            option.isNetworkAccessAllowed = true //允许下载iCloud的图片
 | 
	
		
			
				|  |  | -            option.resizeMode = .fast
 | 
	
		
			
				|  |  | -            option.deliveryMode = .highQualityFormat
 | 
	
		
			
				|  |  | -            PHImageManager.default().requestImage(for: asset,
 | 
	
		
			
				|  |  | -                                           targetSize: self.view.bounds.size,
 | 
	
		
			
				|  |  | -                                          contentMode: .aspectFit,
 | 
	
		
			
				|  |  | -                                              options: option)
 | 
	
		
			
				|  |  | -            { (image, nil) in
 | 
	
		
			
				|  |  | -                 // 设置首帧/封面
 | 
	
		
			
				|  |  | -                if image != nil {
 | 
	
		
			
				|  |  | -                    let pic = GPUImagePicture(image: image)
 | 
	
		
			
				|  |  | -                    let filet = GPUImageFilter()
 | 
	
		
			
				|  |  | -                    pic?.addTarget(filet)
 | 
	
		
			
				|  |  | -                    filet.addTarget(self.playView)
 | 
	
		
			
				|  |  | -                    pic?.processImage()
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -            
 | 
	
		
			
				|  |  | -            PHCachingImageManager().requestAVAsset(forVideo: asset, options: options, resultHandler: {[weak self] (asset: AVAsset?, audioMix: AVAudioMix?, info) in
 | 
	
		
			
				|  |  | -                if let urlass = asset as? AVURLAsset {
 | 
	
		
			
				|  |  | -                    self?.avasset = urlass
 | 
	
		
			
				|  |  | -                    DispatchQueue.main.async {[weak self] in
 | 
	
		
			
				|  |  | -                        self?.progressThumV.videoAsset = urlass
 | 
	
		
			
				|  |  | -                        self?.progressThumV.isHidden = false
 | 
	
		
			
				|  |  | -//                        self?.progessSildeBackV.setNeedsLayout()
 | 
	
		
			
				|  |  | -//                        self?.progessSildeBackV.layoutIfNeeded()
 | 
	
		
			
				|  |  | +//                let option = PHImageRequestOptions()
 | 
	
		
			
				|  |  | +//                option.isNetworkAccessAllowed = true //允许下载iCloud的图片
 | 
	
		
			
				|  |  | +//                option.resizeMode = .fast
 | 
	
		
			
				|  |  | +//                option.deliveryMode = .highQualityFormat
 | 
	
		
			
				|  |  | +//                PHImageManager.default().requestImage(for: asset,
 | 
	
		
			
				|  |  | +//                                               targetSize: self.view.bounds.size,
 | 
	
		
			
				|  |  | +//                                              contentMode: .aspectFit,
 | 
	
		
			
				|  |  | +//                                                  options: option)
 | 
	
		
			
				|  |  | +//                { (image, nil) in
 | 
	
		
			
				|  |  | +//                     // 设置首帧/封面
 | 
	
		
			
				|  |  | +//                    if image != nil {
 | 
	
		
			
				|  |  | +//                        let pic = GPUImagePicture(image: image)
 | 
	
		
			
				|  |  | +//                        let filet = GPUImageFilter()
 | 
	
		
			
				|  |  | +//                        pic?.addTarget(filet)
 | 
	
		
			
				|  |  | +//                        filet.addTarget(self.playView)
 | 
	
		
			
				|  |  | +//                        pic?.processImage()
 | 
	
		
			
				|  |  | +//                    }
 | 
	
		
			
				|  |  | +//                }
 | 
	
		
			
				|  |  | +                
 | 
	
		
			
				|  |  | +                PHCachingImageManager().requestAVAsset(forVideo: asset, options: options, resultHandler: {[weak self] (asset: AVAsset?, audioMix: AVAudioMix?, info) in
 | 
	
		
			
				|  |  | +                    if let urlass = asset as? AVURLAsset {
 | 
	
		
			
				|  |  | +                        self?.avasset = urlass
 | 
	
		
			
				|  |  | +                        DispatchQueue.main.async {[weak self] in
 | 
	
		
			
				|  |  | +                            self?.progressThumV.videoAsset = urlass
 | 
	
		
			
				|  |  | +                            self?.progressThumV.isHidden = false
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  |                      }
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -            })
 | 
	
		
			
				|  |  | +                })
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      }
 | 
	
	
		
			
				|  | @@ -702,20 +708,20 @@ public class BFRecordScreenController: BFBaseViewController {
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |      
 | 
	
		
			
				|  |  |      func drawOrUpdateRecordProgessLable(){
 | 
	
		
			
				|  |  | -        DispatchQueue.main.async {[weak self] in
 | 
	
		
			
				|  |  | -            self?.progessSildeBackV.subviews.forEach { vv in
 | 
	
		
			
				|  |  | -                vv.removeFromSuperview()
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -            if let totalDur = self?.asset?.duration, totalDur > 0, let list = self?.recordList {
 | 
	
		
			
				|  |  | -                let width = self?.progessSildeBackV.width ?? 0
 | 
	
		
			
				|  |  | -                let height = self?.progessSildeBackV.height ?? 0
 | 
	
		
			
				|  |  | -                list.forEach { model in
 | 
	
		
			
				|  |  | -                    let lineV = UIView(frame: CGRect(x: model.startTime * width / totalDur , y: 0, width: (model.endTime - model.startTime) * width / totalDur, height: height))
 | 
	
		
			
				|  |  | -                    lineV.backgroundColor = ThemeStyleGreen()
 | 
	
		
			
				|  |  | -                    self?.progessSildeBackV.addSubview(lineV)
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | +//        DispatchQueue.main.async {[weak self] in
 | 
	
		
			
				|  |  | +//            self?.progessSildeBackV.subviews.forEach { vv in
 | 
	
		
			
				|  |  | +//                vv.removeFromSuperview()
 | 
	
		
			
				|  |  | +//            }
 | 
	
		
			
				|  |  | +//            if let totalDur = self?.currAsset?.duration, totalDur > 0, let list = self?.recordList {
 | 
	
		
			
				|  |  | +//                let width = self?.progessSildeBackV.width ?? 0
 | 
	
		
			
				|  |  | +//                let height = self?.progessSildeBackV.height ?? 0
 | 
	
		
			
				|  |  | +//                list.forEach { model in
 | 
	
		
			
				|  |  | +//                    let lineV = UIView(frame: CGRect(x: model.startTime * width / totalDur , y: 0, width: (model.endTime - model.startTime) * width / totalDur, height: height))
 | 
	
		
			
				|  |  | +//                    lineV.backgroundColor = ThemeStyleGreen()
 | 
	
		
			
				|  |  | +//                    self?.progessSildeBackV.addSubview(lineV)
 | 
	
		
			
				|  |  | +//                }
 | 
	
		
			
				|  |  | +//            }
 | 
	
		
			
				|  |  | +//        }
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 |