Procházet zdrojové kódy

播放器自动放时的判断

harry před 3 roky
rodič
revize
e631b0bc1c

+ 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()
+                    }
+                }
             }
         }
     }