瀏覽代碼

Merge branch 'feature/dev_Chris' into develop

Chris 5 年之前
父節點
當前提交
e83ba65377

+ 2 - 0
RainbowPlanet/RainbowPlanet/Macro/ColorMacro.swift

@@ -145,3 +145,5 @@ let kDDDDDDColor = UIColor(hexString: "DDDDDD")
 let kFEFEFEColor = UIColor(hexString: "#FEFEFE")
 
 let k7AD489Color = UIColor(hexString: "7AD489")
+
+let kFF5E5EColor = UIColor(hexString: "FF5E5E")

+ 20 - 1
RainbowPlanet/RainbowPlanet/Modules/PublishModule/PublishTakeVideo/PublishVideoRecorderController.swift

@@ -170,13 +170,15 @@ class PublishVideoRecorderController: BaseViewController {
         recorder?.frontCaptureSessionPreset = AVCaptureSession.Preset.hd1280x720.rawValue
         
         // 设置视频最大时长 默认8
-        recorder?.clipManager.maxDuration = 3;
+        recorder?.clipManager.maxDuration = self.maxDuration
         
         return recorder!
     }()
     
     lazy var videoCameraView: PublishVideoView = {
         let videoCameraView = PublishVideoView()
+        videoCameraView.maxDuration = self.maxDuration
+        videoCameraView.minDuration = self.minDuration
         videoCameraView.btnClickClosure = {
             [weak self] (btnType) in
             switch btnType {
@@ -302,6 +304,15 @@ extension PublishVideoRecorderController: AliyunIRecorderDelegate {
         }
     }
     
+    // 录制实时时长
+    func recorderVideoDuration(_ duration: CGFloat) {
+        DispatchQueue.main.async {
+            print("----duration == \(duration)")
+            self.videoCameraView.recordingPercent(percent: duration)
+            self.recordingDuration = Double(duration)
+        }
+    }
+    
     // 暂停录制回调
     func recorderDidStopRecording() {
         print("---------->暂停录制回调")
@@ -326,6 +337,14 @@ extension PublishVideoRecorderController: AliyunIRecorderDelegate {
     func recorderDidStopWithMaxDuration() {
         recorder.finishRecording()
         print("----超时")
+        
+//        self.magicCameraView.backButton.enabled = YES;
+//        [MBProgressHUD showHUDAddedTo:self.view animated:YES];
+//        self.magicCameraView.flashButton.userInteractionEnabled = (_recorder.cameraPosition != 0);
+//        self.magicCameraView.progressView.videoCount++;
+//        self.magicCameraView.progressView.showBlink = NO;
+//        [self.recorder finishRecording];
+//        [self.magicCameraView destroy];
     }
     
 }

+ 103 - 3
RainbowPlanet/RainbowPlanet/Modules/PublishModule/PublishTakeVideo/PublishVideoView.swift

@@ -25,12 +25,27 @@ class PublishVideoView: BaseView {
     typealias BtnClickClosure = (_ btnType: BtnActionType) -> Void
     var btnClickClosure : BtnClickClosure?
     
-    typealias VideoClosure = (_ isRecording: Int) -> Void
+    typealias VideoClosure = (_ isRecord: Int) -> Void
     var videoClosure : VideoClosure?
     
+    var maxDuration: CGFloat? {
+        didSet {
+            progressView.maxDuration = maxDuration!
+        }
+    }
+    var minDuration: CGFloat? {
+        didSet {
+            progressView.minDuration = minDuration!
+        }
+    }
+    
+    // 是否正在录制
+    var recording: Bool = false
+    
     override func setupViews() {
         self.backgroundColor = kffffffColor
         
+        addSubview(progressView)
         addSubview(backButton)
         addSubview(recordButton)
         addSubview(segmentedView)
@@ -40,6 +55,10 @@ class PublishVideoView: BaseView {
         controlBackView.addSubview(musicButton)
         controlBackView.addSubview(filterButton)
         
+        addSubview(timeBackView)
+        timeBackView.addSubview(timeDotView)
+        timeBackView.addSubview(timeLabel)
+        
         addSubview(selBackView)
         selBackView.addSubview(confirmButton)
         selBackView.addSubview(delButton)
@@ -50,6 +69,13 @@ class PublishVideoView: BaseView {
     
     override func setupLayouts() {
         
+        progressView.snp.makeConstraints { (make) in
+            make.top.equalTo(40)
+            make.left.equalTo(14)
+            make.right.equalTo(-14)
+            make.height.equalTo(5)
+        }
+        
         backButton.snp.makeConstraints { (make) in
             make.top.equalTo(55)
             make.left.equalTo(5)
@@ -99,6 +125,26 @@ class PublishVideoView: BaseView {
         }
         filterButton.layoutButton(edgeInsetsStyle: ButtonEdgeInsetsStyle.top, imageTitleSpace: 4)
         
+        /***** 拍摄时长 *****/
+        timeBackView.snp.makeConstraints { (make) in
+            make.bottom.equalTo(recordButton.snp_top).offset(-20)
+            make.centerX.equalToSuperview()
+            make.height.equalTo(20)
+        }
+        
+        timeDotView.snp.makeConstraints { (make) in
+            make.left.equalToSuperview()
+            make.centerY.equalToSuperview()
+            make.size.equalTo(8)
+        }
+        
+        timeLabel.snp.makeConstraints { (make) in
+            make.left.equalTo(timeDotView.snp_right).offset(4)
+            make.top.bottom.equalToSuperview()
+            make.width.equalTo(40)
+            make.right.equalToSuperview()
+        }
+        
         /***** 回删、确定 *****/
         selBackView.snp.makeConstraints { (make) in
             make.bottom.equalTo(-83)
@@ -126,6 +172,26 @@ class PublishVideoView: BaseView {
         }
     }
     
+    // 刷新进度条进度
+    func recordingPercent(percent: CGFloat) {
+        print("----updates - \(percent)")
+        progressView.updateProgress(percent)
+        
+//        if recording {
+            let d: Int = Int(percent)
+            let m: Int = Int(d / 60)
+            let s: Int = Int(d % 60)
+            
+            timeLabel.text = String(format: "%02d:%02d", m, s)
+//        }
+        
+        if percent == 0 {
+            progressView.reset()
+            timeLabel.text = ""
+        }
+        
+    }
+    
     // MARK: - 创建视图控件
     //1.初始化JXSegmentedViewx
     lazy var segmentedView: JXSegmentedView = {
@@ -224,6 +290,29 @@ class PublishVideoView: BaseView {
         return filterButton
     }()
     
+    // MARK:放置"拍摄时长Label"のView
+    lazy var timeBackView: UIView = {
+        let timeBackView = UIView()
+        return timeBackView
+    }()
+    
+    private lazy var timeDotView: UIView = {
+        let timeDotView = UIView()
+        timeDotView.backgroundColor = kFF5E5EColor
+        timeDotView.cornerRadius = 4
+        timeDotView.masksToBounds = true
+        return timeDotView
+    }()
+    
+    private lazy var timeLabel: UILabel = {
+        let timeLabel = UILabel()
+        timeLabel.textColor = kffffffColor
+        timeLabel.font = kRegularFont14
+        timeLabel.textAlignment = .left
+        timeLabel.numberOfLines = 1
+        return timeLabel
+    }()
+    
     // MARK:放置"回删、确定"のView
     lazy var selBackView: UIView = {
         let selBackView = UIView()
@@ -258,6 +347,17 @@ class PublishVideoView: BaseView {
         return confirmButton
     }()
     
+    // MARK:progressView
+    lazy var progressView: QUProgressView = {
+        let progressView = QUProgressView()
+        progressView.showBlink = false
+        progressView.showNoticePoint = true
+        progressView.backgroundColor = UIColor.black.withAlphaComponent(0.01)
+        progressView.cornerRadius = 2
+        progressView.masksToBounds = true
+        return progressView
+    }()
+    
     // MARK:录制のButton
     private lazy var recordButton: UIButton = {
         let recordButton = UIButton(type: UIButton.ButtonType.custom)
@@ -266,8 +366,8 @@ class PublishVideoView: BaseView {
         recordButton.rx.tap.subscribe(onNext: { [weak self] (data) in
             recordButton.isSelected = !recordButton.isSelected
             if let videoClosure = self?.videoClosure {
-                let isRecording: Int = recordButton.isSelected == true ? 1 : 0
-                videoClosure(isRecording)
+                let isRecord: Int = recordButton.isSelected == true ? 1 : 0
+                videoClosure(isRecord)
             }
         }).disposed(by: disposeBag)