浏览代码

播放器自动放时的判断

harry 3 年之前
父节点
当前提交
e631b0bc1c
共有 1 个文件被更改,包括 11 次插入4 次删除
  1. 11 4
      BFFramework/Classes/BFModules/BFUtility/PQSingletoVideoPlayer.swift

+ 11 - 4
BFFramework/Classes/BFModules/BFUtility/PQSingletoVideoPlayer.swift

@@ -126,7 +126,11 @@ public class PQSingletoVideoPlayer: NSObject {
             }
             playId = getUniqueId(desc: "playId")
             // 开始播放
-            startPlayr()
+            if let vc = bf_getCurrentViewController(), let playview = self.playControllerView{
+                if playview.isDescendant(of: vc.view){
+                    startPlayr()
+                }
+            }
         }
     }
 
@@ -222,9 +226,12 @@ public class PQSingletoVideoPlayer: NSObject {
         NotificationCenter.default.addObserver(forName: UIApplication.willEnterForegroundNotification, object: nil, queue: nil) { _ in
 
             if self.autoResumePlayWhenEnterForeground, self.shouldResumePlayWhenEnterForeground {
-                self.shouldResumePlayWhenEnterForeground = false
-
-                self.resumePlayer()
+                if let vc = bf_getCurrentViewController(), let playview = self.playControllerView{
+                    if playview.isDescendant(of: vc.view){
+                        self.shouldResumePlayWhenEnterForeground = false
+                        self.resumePlayer()
+                    }
+                }
             }
         }
     }