在Streaming MPMoviePlayerController上叠加 [英] Overlay on top of Streaming MPMoviePlayerController

查看:155
本文介绍了在Streaming MPMoviePlayerController上叠加的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从苹果iPhone上的MoviePlayer中看到了这个例子。

I went through the example from apple "MoviePlayer on iPhone"

我试图覆盖在mpmovieplayercontroller之上,

Im trying to overlay on top of the mpmovieplayercontroller,

它与捆绑的视频剪辑完美配合,

it works perfectly with video clip that is in bundle,

但如果我从网址流式传输视频,它将无法正常工作。

but it wont work if i stream the video from the url.

叠加视图将隐藏在播放器后面。

the overlay view will just get hide behind the player.

有没有办法将叠加视图放到前面?

is there a way to bring the overlay view up to front?

推荐答案

MPMoviePlayerController创建自己的窗口并将其设置为关键窗口 - 您可能已经从MoviePlayer示例应用程序中了解到这一点。

MPMoviePlayerController creates its own window and sets that as the key window - you probably know this already from the MoviePlayer sample app.

我不知道为什么,但是当玩家使用流时会有延迟 - 所以你在初始化玩家后得到的keyWindow可能不是玩家的窗口,因为那样似乎稍后会添加。

I don't know why, but there's a delay when the player uses a stream - so the keyWindow you get right after you initialize the player is likely not the player's window, since that seems to get added later.

您可以欺骗并使用计时器在几秒钟后获取播放器窗口,并添加叠加层:

You can "cheat" and use a timer to get the player window a few seconds later, and add your overlay:

[NSTimer scheduledTimerWithTimeInterval:5 target:self selector:@selector(addMyOverlay:) userInfo:nil repeats:FALSE]

或者您可以监听UIWindowDidBecomeKeyNotification事件,并执行相同的操作:

Or you can listen for the UIWindowDidBecomeKeyNotification event, and do the same:

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyWindowChanged:) name:UIWindowDidBecomeKeyNotification object:nil];

两种选择都不是很好(我想知道一种更清洁的方法),但它完成工作。

Neither option is great (I'd love to know a cleaner way to do this), but it gets the job done.

这篇关于在Streaming MPMoviePlayerController上叠加的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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