媒体播放器从UIWebView打开时通知? [英] Notified when media player opens from UIWebView?

查看:145
本文介绍了媒体播放器从UIWebView打开时通知?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用中有一个 UIViewController ,其中包含 UIWebView UIWebView 是固定大小的,并配置为打开新的 UIViewController (浏览器)中的任何链接。这有效,但是当我尝试在网络视图中点击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打开时通知?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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