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 打开媒体播放器时通知?
基础教程推荐
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01