Notified when media player opens from UIWebView?(从 UIWebView 打开媒体播放器时通知?)
问题描述
我的应用中有一个 UIViewController,其中有一个 UIWebView.UIWebView 是固定大小的,并配置为在新的 UIViewController(浏览器)中打开任何链接.这可行,但是当我尝试从 Web 视图中单击 YouTube 或 Vimeo 等视频时,它会在视图控制器顶部打开.这通常不会成为问题,但我有一个重叠的视图,需要在发生这种情况时收到一条消息才能让开.
I have got a UIViewController in my app with a UIWebView in it. The UIWebView is fixed-size and configured to open any links in a new UIViewController (browser). This works, but when I try clicking a video like YouTube or Vimeo from within the web view, it opens on top of the view controller. This would normally not be a problem, but I have an overlapping view that needs to get a message to move out of the way when this happens.
当媒体播放器从 UIWebView 中弹出时,是否有通知或任何其他方式可以通知我的视图控制器?我真的需要这个更好地工作,因为它现在的样子真的很丑.
Is there a notification or any other way my view controller can get notified when a media player pops out of the UIWebView? I really need this to work better, because it's really ugly the way it currently is.
谢谢!
推荐答案
来自:http://www.alexcurylo.com/blog/2009/08/24/snippet-playing-youtube-videos/
不幸的是,没有直接控制或加载、进度、退出等通知.但是,您可以根据应用程序的窗口状态获得一些间接通知:添加到您的视图控制器中
Unfortunately, there’s no kind of direct control or notifications of loading, progress, quitting, etc. However, you can get some indirect notifications based on your application’s window state: add in your view controller
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(windowNowVisible:)
name:UIWindowDidBecomeVisibleNotification
object:self.view.window
];
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(windowNowHidden:)
name:UIWindowDidBecomeHiddenNotification
object:self.view.window
];
在 YouTube 窗口显示和消失时分别调用它们.
to get these called when the YouTube window is shown and goes away respectively.
- (void)windowNowVisible:(NSNotification *)notification
{
NSLog(@"Youtube/ Media window appears");
}
- (void)windowNowHidden:(NSNotification *)notification
{
NSLog(@"Youtube/ Media window disappears.");
}
嘿,如果这就是你所需要的通知方式,那就太好了!
and hey, if that’s all you require by way of notification you’re good!
这篇关于从 UIWebView 打开媒体播放器时通知?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:从 UIWebView 打开媒体播放器时通知?
基础教程推荐
- iOS4 创建后台定时器 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
