在UIWebView中的MPMoviePlayerController全屏电影 [英] MPMoviePlayerController fullscreen movie inside a UIWebView
问题描述
我遇到了UIWebView和MPMoviePlayerController的问题:
我的UIWebView在html中有一部电影(它是一个本地的html文件),我正在使用html5和视频的视频标签。
问题是:用户可以将视频设置为直接在html上播放,也可以点击全屏按钮,但我需要知道视频是否正在全屏播放。
I'm having a problem with the UIWebView and MPMoviePlayerController: My UIWebView have a movie inside the html (it's a local html file), I'm using html5 and a video tag for the video. The problem is: the user can set the video to play inline, directly on the html or he can tap the fullscreen button, but I need to know if the video is playing fullscreen.
我试过使用MPMoviePlayerDidEnterFullscreenNotification但没有成功。
I've tried to use MPMoviePlayerDidEnterFullscreenNotification but with no success.
有人知道如何从网络视图获取此通知吗?
Does anybody know how to get this notification from the webview?
提前致谢
推荐答案
没有发送通知(另见这篇文章:视图上的事件显示更改(Youtube MPMoviePlayerViewController)),但是Web视图会做一些hackish:它会向root添加一个子视图 UIViewController的
视图,全屏显示并在那里播放电影。
There is no notification being sent (also see this post: Event on view displayed change (Youtube MPMoviePlayerViewController)), but the web view will do something hackish: it will add a subview to the root UIViewController's
view, make it full screen and play the movie there.
制作主 UIViewController的
查看你自己的视图,拦截 -didAddSubview:
和 -willRemoveSubview:
。通过这种方式,您可以检测播放器何时全屏显示。
Make your main UIViewController's
view a view of your own, and intercept -didAddSubview:
and -willRemoveSubview:
. This way you'll be able to detect when the player is brought fullscreen.
这篇关于在UIWebView中的MPMoviePlayerController全屏电影的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!