Browse Source

暂停时添加蒙层

jsonwang 3 years ago
parent
commit
82c7cf29ba
1 changed files with 27 additions and 9 deletions
  1. 27 9
      BFFramework/Classes/Stuckpoint/ViewModel/PQGPUImagePlayerView.swift

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

@@ -162,16 +162,27 @@ public class PQGPUImagePlayerView: UIView {
 
     // 暂停播放view
     lazy var playView: UIImageView = {
-        let view = UIImageView(frame: CGRect(x: (self.frame.size.width - 52) / 2, y: (self.frame.size.height - 52) / 2, width: 52, height: 52))
-        view.image =  UIImage().BF_Image(named: "gpuplayBtn")
+        let view = UIImageView(frame: CGRect(x: (self.frame.size.width - self.frame.size.height / 3.6) / 2, y: (self.frame.size.height - self.frame.size.height / 3.6) / 2, width: self.frame.size.height / 3.6, height: self.frame.size.height / 3.6))
+        view.image =  UIImage().BF_Image(named: "gpuplayBtn").withRenderingMode(.alwaysTemplate)
+        view.tintColor = UIColor.hexColor(hexadecimal: PQBFConfig.shared.styleColor.rawValue)
         view.isHidden = true
         return view
 
     }()
+    
+    // 暂停播放view
+    lazy var playMaskView: UIView = {
+        let playMaskView = UIView.init()
+        playMaskView.backgroundColor = UIColor.init(red: 1, green: 1, blue: 1, alpha: 0.5)
+        playMaskView.isUserInteractionEnabled = false
+        playMaskView.isHidden = true
+        return playMaskView
+
+    }()
 
     // 播放进度/总时长
     lazy var progressLab: UILabel = {
-        let titleLab = UILabel(frame: CGRect(x: (self.frame.size.width - 140) / 2, y: 10, width: 140, height: 14))
+        let titleLab = UILabel(frame: CGRect(x: (self.frame.size.width - 140) / 2, y: self.frame.size.height - 10 - 14, width: 140, height: 14))
         titleLab.font = UIFont.systemFont(ofSize: 14, weight: .medium)
         titleLab.textColor = UIColor.white
         titleLab.textAlignment = .center
@@ -180,6 +191,8 @@ public class PQGPUImagePlayerView: UIView {
         titleLab.layer.shadowOpacity = 0.3
         titleLab.layer.shadowOffset = .zero
         titleLab.layer.shadowRadius = 1
+//        titleLab.backgroundColor = UIColor.hexColor(hexadecimal: "#FFFFFF",alpha: 0.3)
+//        titleLab.addCorner(corner:7)
 
         return titleLab
 
@@ -208,8 +221,10 @@ public class PQGPUImagePlayerView: UIView {
         super.init(frame: frame)
 
         addSubview(renderView)
-        addSubview(playView)
         addSubview(progressLab)
+        addSubview(playMaskView)
+        addSubview(playView)
+     
         backgroundColor = PQBFConfig.shared.styleBackGroundColor
         playerEmptyView = UIImageView(frame: bounds)
         playerEmptyView.backgroundColor = .black
@@ -289,9 +304,10 @@ public class PQGPUImagePlayerView: UIView {
         renderView.resatSize()
 
         playerEmptyView.frame = CGRect(x: 0, y: 0, width: self.frame.size.width, height: self.frame.size.height)
+        playMaskView.frame = CGRect.init(x: 0, y: 0, width: self.frame.width, height: self.frame.height)
         tipLab.frame = CGRect(x: (self.frame.size.width - 100) / 2, y: (self.frame.size.height - 14) / 2, width: 100, height: 14)
-        progressLab.frame = CGRect(x: (self.frame.size.width - 140) / 2, y: 10, width: 140, height: 14)
-        playView.frame = CGRect(x: (self.frame.size.width - 52) / 2, y: (self.frame.size.height - 52) / 2, width: 52, height: 52)
+        progressLab.frame = CGRect(x: (self.frame.size.width - 140) / 2, y: self.frame.size.height - 10 - 14, width: 140, height: 14)
+        playView.frame = CGRect(x: (self.frame.size.width - self.frame.size.height / 3.6) / 2, y: (self.frame.size.height - self.frame.size.height / 3.6) / 2, width: self.frame.size.height / 3.6, height: self.frame.size.height / 3.6)
     }
 
     override public func layoutSubviews() {
@@ -301,11 +317,12 @@ public class PQGPUImagePlayerView: UIView {
     @objc func RenderViewOnclick() {
         if status == .playing {
             playView.isHidden = false
+            playMaskView.isHidden = false
             pause()
 
         } else if status == .stop || status == .pause {
             playView.isHidden = true
-
+            playMaskView.isHidden = true
             movie?.resume()
             speaker?.start()
             status = .playing
@@ -317,6 +334,7 @@ public class PQGPUImagePlayerView: UIView {
 
     func showPlayBtn(isHidden: Bool) {
         playView.isHidden = isHidden
+        playMaskView.isHidden = isHidden
     }
 
     deinit {
@@ -336,7 +354,7 @@ public class PQGPUImagePlayerView: UIView {
         self.asset = asset
         if (audioMixModel != nil && audioMixModel?.localPath != nil) || (videoStickers != nil && (videoStickers?.count ?? 0) > 0 || originMusicDuration != 0) {
             FilterLog(message: "有参加混音的数据。")
-            (audioMix, composition) = PQPlayerViewModel.setupAudioMix(originAsset: asset, bgmData: audioMixModel, videoStickers: videoStickers,clipAudioRange: clipAudioRange)
+            (audioMix, composition) = PQPlayerViewModel.setupAudioMix(originAsset: asset, bgmData: audioMixModel, videoStickers: videoStickers,originMusicDuration:originMusicDuration,clipAudioRange: clipAudioRange)
         } else {
             audioMix = nil
         }
@@ -395,7 +413,7 @@ public class PQGPUImagePlayerView: UIView {
                 strongSelf.animationLayer?.timeOffset = strongSelf.playbackTime
                 if strongSelf.showProgressLab {
                     if duration < 1 {
-                        strongSelf.progressLab.text = "\(currTime.formatDurationToHMS()) / 00:01"
+                        strongSelf.progressLab.text =  "\(currTime.formatDurationToHMS()) / 00:01"
                     } else {
                         strongSelf.progressLab.text = "\(currTime.formatDurationToHMS()) / \(duration.formatDurationToHMS())"
                     }