Browse Source

fix(iOS): 修复暂停时CPU上涨的问题

StyxS 4 years ago
parent
commit
d1016f4073

+ 1 - 1
QGVAPlayer.podspec

@@ -16,7 +16,7 @@ Pod::Spec.new do |spec|
   #
   #
 
 
   spec.name         = "QGVAPlayer"
   spec.name         = "QGVAPlayer"
-  spec.version      = "1.0.11"
+  spec.version      = "1.0.12"
   spec.summary      = "video animation player."
   spec.summary      = "video animation player."
   spec.platform     = :ios, "8.0"
   spec.platform     = :ios, "8.0"
 
 

+ 9 - 1
iOS/CHANGELOG.md

@@ -1,3 +1,11 @@
+## iOS 1.0.12
+
+**bugfix**
+
+- 修复暂停时CPU上升的问题(在退后台的场景下会导致CPU上涨约1s然后下降,形成一个尖刺)
+
+
+
 ## iOS 1.0.11
 ## iOS 1.0.11
 
 
 **feature**
 **feature**
@@ -20,4 +28,4 @@
 **feature**
 **feature**
 
 
 - 添加VTSession失效时的重建逻辑(Seek关键帧,解码并丢弃,直到当前帧)
 - 添加VTSession失效时的重建逻辑(Seek关键帧,解码并丢弃,直到当前帧)
-- 将VAP默认行为由退后台时结束播放改为退后台时暂停,进入前台时恢复
+- 将VAP默认行为由退后台时结束播放改为退后台时暂停,进入前台时恢复

+ 1 - 0
iOS/QGVAPlayer/QGVAPlayer/Classes/UIView+VAP.m

@@ -385,6 +385,7 @@ NSInteger const VapMaxCompatibleVersion = 2;
                 }
                 }
                 if (self.hwd_onPause || self.hwd_onSeek) {
                 if (self.hwd_onPause || self.hwd_onSeek) {
                     lastRenderingInterval = NSDate.timeIntervalSinceReferenceDate;
                     lastRenderingInterval = NSDate.timeIntervalSinceReferenceDate;
+                    [NSThread sleepForTimeInterval:durationForWaitingFrame];
                     continue;
                     continue;
                 }
                 }
                 __block QGMP4AnimatedImageFrame *nextFrame = nil;
                 __block QGMP4AnimatedImageFrame *nextFrame = nil;

+ 7 - 0
iOS/QGVAPlayerDemo/QGVAPlayerDemo/ViewController.m

@@ -104,6 +104,13 @@ void qg_VAP_Logger_handler(VAPLogLevel level, const char* file, int line, const
     UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onImageviewTap:)];
     UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onImageviewTap:)];
     [mp4View addGestureRecognizer:tap];
     [mp4View addGestureRecognizer:tap];
     [mp4View playHWDMP4:mp4Path repeatCount:-1 delegate:self];
     [mp4View playHWDMP4:mp4Path repeatCount:-1 delegate:self];
+    
+    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
+        [mp4View pauseHWDMP4];
+        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
+            [mp4View resumeHWDMP4];
+        });
+    });
 }
 }
 
 
 /// 使用WrapView,支持ContentMode
 /// 使用WrapView,支持ContentMode