Detect player of iframe inside WKWebKit

Hello.
If I am load web site with movies using WKWebView and then press on player in website content will be open in some player above WKWebView, It is possible detect when this player is open or close?

Or if it's impossible I can detect when user press on player and then catch iframe of web element like that
Code Block
<iframe src="URL of player" width="560" height="315" frameborder="0" allowfullscreen></iframe>


and then open inside UIView or something else above WKWebView.

For clarity I am attach url with image of this player
Code Block
https://ibb.co/y69tQ6c


Regards, Ihor.
Answered by IlLoganlI in 648310022
I am solved this problem using NotificationCenter using UIWindowDidBecomeVisibleNotification & UIWindowDidBecomeHiddenNotification.

Example of my code.
Code Block
override func viewDidLoad() {
super.viewDidLoad()
NotificationCenter.default.addObserver(self, selector: #selector(onDidEnterFullscreen(_:)), name: UIWindow.didBecomeVisibleNotification, object: view.window)
NotificationCenter.default.addObserver(self, selector: #selector(onDidLeaveFullscreen(_:)), name: UIWindow.didBecomeHiddenNotification, object: view.window)
}
@objc func onDidEnterFullscreen(_ notification: Notification) {
print("Enter Fullscreen")
}
@objc func onDidLeaveFullscreen(_ notification: Notification) {
print("Leave Fullscreen")
}


If somebody know another way glad to hear your answer.
Accepted Answer
I am solved this problem using NotificationCenter using UIWindowDidBecomeVisibleNotification & UIWindowDidBecomeHiddenNotification.

Example of my code.
Code Block
override func viewDidLoad() {
super.viewDidLoad()
NotificationCenter.default.addObserver(self, selector: #selector(onDidEnterFullscreen(_:)), name: UIWindow.didBecomeVisibleNotification, object: view.window)
NotificationCenter.default.addObserver(self, selector: #selector(onDidLeaveFullscreen(_:)), name: UIWindow.didBecomeHiddenNotification, object: view.window)
}
@objc func onDidEnterFullscreen(_ notification: Notification) {
print("Enter Fullscreen")
}
@objc func onDidLeaveFullscreen(_ notification: Notification) {
print("Leave Fullscreen")
}


If somebody know another way glad to hear your answer.
Detect player of iframe inside WKWebKit
 
 
Q