2014-10-17 132 views
4

我嵌入了一個iframe視頻,並且希望檢測用戶何時退出(點按「完成」)移動Safari上的全屏功能,點擊「播放」。我想下面的代碼:在iPhone上檢測「完成」YouTube/Vimeo視頻(退出全屏)

HTML

<iframe id="video-iframe" src="//player.vimeo.com/video/105953491?title=0&amp;byline=0&amp;portrait=0&amp;api=1" width="100%" height="100%" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe> 

的JavaScript

演示:http://jsfiddle.net/p3bLohfk/

但它不工作(的iOS 8.0.2)。有任何想法嗎?

回答

0

在iOS 8上,當系統視頻播放器從iOS上的UIWebView接管時,應用程序的主窗口將被隱藏。收聽視頻控制器上的UIWindowDidBecomeHiddenNotificationUIWindowDidBecomeVisibleNotification通知,以檢測用戶何時進入和退出全屏播放器:

[[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];