ソースを参照

时间显示时长问题

jsonwang 3 年 前
コミット
e60f8e555e

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

@@ -216,6 +216,9 @@ public class PQGPUImagePlayerView: UIView {
     required public init?(coder _: NSCoder) {
         fatalError("init(coder:) has not been implemented")
     }
+    
+    //进度的开始时间
+    var showProgressStartTime:Float = 0.0
 
     override public init(frame: CGRect) {
         super.init(frame: frame)
@@ -412,11 +415,16 @@ public class PQGPUImagePlayerView: UIView {
                 // Non-main thread change this property is not valid
                 strongSelf.animationLayer?.timeOffset = strongSelf.playbackTime
                 if strongSelf.showProgressLab {
+                    
+                    if(strongSelf.showProgressStartTime == 0 ){
+                        strongSelf.showProgressStartTime = Float(CMTimeGetSeconds(movie.startTime ?? .zero))
+                    }
                     if duration < 1 {
                        
                         strongSelf.progressLab.text =  "\((currTime - Double(CMTimeGetSeconds(movie.startTime ?? .zero))).formatDurationToHMS()) / 00:01"
                     } else {
-                        strongSelf.progressLab.text = "\((currTime - Double(CMTimeGetSeconds(movie.startTime ?? .zero))).formatDurationToHMS()) / \( (duration - Double(CMTimeGetSeconds(movie.startTime ?? .zero))).formatDurationToHMS())"
+ 
+                        strongSelf.progressLab.text = "\((currTime -  Double(strongSelf.showProgressStartTime)).formatDurationToHMS()) / \( (duration - Double(strongSelf.showProgressStartTime)).formatDurationToHMS())"
                     }
                 }
             }