【问题标题】:Detect “Done” on iPhone for YouTube/Vimeo videos (exit fullscreen)在 iPhone 上检测 YouTube/Vimeo 视频的“完成”(退出全屏)
【发布时间】:2014-12-12 16:33:16
【问题描述】:

我嵌入了一个 iframe 视频,我想检测用户何时退出(点击“完成”)移动 Safari 上的全屏功能,该功能在您点击“播放”时发生。我尝试了以下代码:

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

document.getElementById("video-iframe").addEventListener("webkitendfullscreen", function(){
  alert("Hello World!");
});

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

但它不起作用(iOS 8.0.2)。有什么想法吗?

【问题讨论】:

    标签: javascript ios youtube youtube-api youtube-iframe-api


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-03-05
      • 1970-01-01
      • 2013-07-28
      • 1970-01-01
      • 2016-02-14
      • 2018-05-16
      • 2012-03-16
      • 1970-01-01
      相关资源
      最近更新 更多