检测 webview 视频何时在 ios8 上变为全屏 [英] Detect when a webview video becomes fullscreen on ios8

查看:30
本文介绍了检测 webview 视频何时在 ios8 上变为全屏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序,用户可以在其中打开 UIWebview 的视频,包括 Youtube 视频.在 iOS7 中,我能够在开始播放或全屏播放时收到通知,这对我向用户显示某些选项和修改界面至关重要.

I have an app where users can open videos from UIWebview, including Youtube ones. In iOS7, I was able to get a notification when it started playing, or when it became full screen, which is vital for me to show certain options to the user and modify the interface.

我以前用这个:

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(VideoExitFullScreen:) name:@"UIMoviePlayerControllerDidExitFullscreenNotification" object:nil];

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(VideoEnterFullScreen:) name:@"UIMoviePlayerControllerDidEnterFullscreenNotification" object:nil];

但是,从 iOS8 开始,我无法做到这一点.就像 UIWebview 视频不再触发通知一样.但是,正如我测试过的,它仍然是由普通视频、非 Webview 触发的.

However, since iOS8, I can't achieve this. It is like the notification is no longer triggered from UIWebview videos. However, it is still triggered from normal videos, non-Webview, as I've tested.

知道发生了什么变化吗?

Any idea of what have changed?

推荐答案

这是我找到的解决方法..

This is the work around I found for this..

[[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(VideoExitFullScreen:)
                                                 name:UIWindowDidBecomeVisibleNotification
                                               object:self.view.window];

[[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(VideoEnterFullScreen:)
                                                 name:UIWindowDidBecomeHiddenNotification
                                               object:self.view.window];

这篇关于检测 webview 视频何时在 ios8 上变为全屏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆