检测并拦截SFSafariViewController中的视频播放

问题描述:

我在我的应用程序中使用SFSafariViewController。当用户播放视频时,我不得不弹出一个询问用户是否想要下载视频的提示。我已经使用UIWebView和AVPlayerItemBecameCurrentNotification完成了此操作。但是这在SFSafariViewController中不起作用。有人可以给我一个解决方案吗?检测并拦截SFSafariViewController中的视频播放

这里是增加观察员的代码SFSafariViewController

NotificationCenter.default.addObserver(self.safariViewController!, selector: #selector(self.playerItemBecameCurrent), name: NSNotification.Name(rawValue: "AVPlayerItemBecameCurrentNotification"), object: nil) 

感谢

说实话,这不会在SFSafariViewController是不可能的。

SFSafariViewController不可用于检查/拦截,如UIWebViewWKWebView。鉴于与KeyChain设备的控制接口,从安全的角度来看也是有意义的。

你非常可以只给它一个URL和一组2个可自定义的选项。

恢复为WKWebView或最坏的情况下,UIWebView

感谢我的回答迟到,希望你发现它有用