用透明背景加载MPMoviePlayerViewController? [英] Loading MPMoviePlayerViewController with transparent background?

查看:145
本文介绍了用透明背景加载MPMoviePlayerViewController?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我添加了一个MPMoviePlayerViewController实例,并且播放电影效果很好。
我有3个按钮,想要在UIView容器中加载不同的视频。这也有效。
但是,如果我点击按钮加载其他视频,每次背景闪烁黑色。
我将颜色设置为clearColor:

i´ve added a MPMoviePlayerViewController instance and playing of a movie works great. I´ve 3 buttons and want to load different videos in a UIView-container. That works, too. But if i click on a button to load an other video, everytime the background is flickering black. I´ve set the color to "clearColor":

    player.moviePlayer.backgroundView.backgroundColor = [UIColor  clearColor];

但这没有用。有没有办法加载没有背景的视频 - 只有视频内容?

But that doesn´t help. Is there a way to load a video without a background - only the video-content?

感谢您的时间。

推荐答案


  1. 不确定闪烁问题。你说当你加载另一个视频时它会闪烁 - 你是否无意中将多个视频叠加在一起?确保你删除旧版本!

  2. 黑色背景可能是因为你的
    MPMoviePlayerController的
    scalingMode 属性设置为 MPMovieScalingModeAspectFit (Apple的文档:
    MPMoviePlayerController
    scalingMode

  1. Not sure about the flickering issue. You said it flickers when you load another video -- Are you unintentionally layering multiple videos on top of each other? Make sure you remove the old one!
  2. The black background likely is because your MPMoviePlayerController's scalingMode property is set to MPMovieScalingModeAspectFit (Apple's Documentation: MPMoviePlayerController scalingMode)

对于问题#2,和你一样,我原本期望设置backgroundView的颜色来处理这个问题,但是看起来后面还有另一个视图,你还需要设置backgroundColor清除颜色。我对此的破解是简单地遍历电影播放器​​的子视图并将其backgroundColor设置为清除。

For issue #2, like you, I had expected setting the backgroundView's color to handle this, however it seems there is another view behind that which you also need to set the backgroundColor to clearColor. My hack for this was to simply iterate through the movie player's subviews and set their backgroundColor to clear.

使用变量名称的Hack /Solution示例:

for(UIView* subV in player.moviePlayer.view.subviews) {
    subV.backgroundColor = [UIColor clearColor];
}

您必须在进入/退出时重新将clearColor应用于子视图全屏模式。我希望其他人有更好的解决方案,因为这种方法看起来非常糟糕。

You have to re-apply clearColor to the subviews any time you enter/exit fullscreen mode as well. I hope someone else has a better solution because this method seems pretty kludgy.

这篇关于用透明背景加载MPMoviePlayerViewController?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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