我嵌入了iframe视频,我想检测用户何时退出(点击“完成”)移动Safari上的全屏功能,当您点按“播放”时。我尝试了下面的代码:
HTML
<iframe id="video-iframe" src="//player.vimeo.com/video/105953491?title=0&byline=0&portrait=0&api=1" width="100%" height="100%" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
的JavaScript
document.getElementById("video-iframe").addEventListener("webkitendfullscreen", function(){
alert("Hello World!");
});
演示:http://jsfiddle.net/p3bLohfk/
但它不起作用(iOS 8.0.2)。有什么想法吗?
答案 0 :(得分:-1)
在iOS 8上,当系统视频播放器从iOS上的UIWebView
接管时,应用程序的主窗口将被隐藏。在视图控制器上收听UIWindowDidBecomeHiddenNotification
和UIWindowDidBecomeVisibleNotification
通知,以检测用户何时进入和退出全屏播放器:
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(videoDidExitFullScreen:)
name:UIWindowDidBecomeVisibleNotification
object:self.view.window];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(videoDidEnterFullScreen:)
name:UIWindowDidBecomeHiddenNotification
object:self.view.window];