Detect when a webview video becomes fullscreen on ios8

后端 未结 5 1802
生来不讨喜
生来不讨喜 2020-12-05 11:48

I have an app where users can open videos from UIWebview, including Youtube ones. In iOS7, I was able to get a notification when it started playing, or when it became full s

5条回答
  •  情话喂你
    2020-12-05 12:20

    Swift 5.1:

    NotificationCenter.default.addObserver(
        forName: UIWindow.didResignKeyNotification,
        object: self.view.window,
        queue: nil
    ) { notification in
        print("Video is now fullscreen")
    }
    
    NotificationCenter.default.addObserver(
        forName: UIWindow.didBecomeKeyNotification,
        object: self.view.window,
        queue: nil
    ) { notification in
        print("Video stopped")
    }
    

提交回复
热议问题