4

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)。何か案は?

4

1 に答える 1

-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];
于 2016-02-11T04:02:07.240 に答える